|
| 1 | +! BSD 3-Clause License |
| 2 | +! |
| 3 | +! Copyright (c) 2018-2025, Sourcery Institute |
| 4 | +! All rights reserved. |
| 5 | +! |
| 6 | +! Redistribution and use in source and binary forms, with or without |
| 7 | +! modification, are permitted provided that the following conditions are met: |
| 8 | +! |
| 9 | +! * Redistributions of source code must retain the above copyright notice, this |
| 10 | +! list of conditions and the following disclaimer. |
| 11 | +! |
| 12 | +! * Redistributions in binary form must reproduce the above copyright notice, |
| 13 | +! this list of conditions and the following disclaimer in the documentation |
| 14 | +! and/or other materials provided with the distribution. |
| 15 | +! |
| 16 | +! * Neither the name of the copyright holder nor the names of its |
| 17 | +! contributors may be used to endorse or promote products derived from |
| 18 | +! this software without specific prior written permission. |
| 19 | +! |
| 20 | +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 | +! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | +! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 | +! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 24 | +! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 | +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 26 | +! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 27 | +! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 28 | +! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | + |
| 31 | +program teams_coindexed |
| 32 | + use, intrinsic :: iso_fortran_env |
| 33 | + |
| 34 | + type(team_type) :: parentteam, team, formed_team |
| 35 | + integer :: t_num= 42, stat = 42, lhs |
| 36 | + integer(kind=2) :: st_num=42 |
| 37 | + integer :: caf(2)[*] |
| 38 | + |
| 39 | + parentteam = get_team() |
| 40 | + |
| 41 | + caf = [23, 32] |
| 42 | + form team(t_num, team) |
| 43 | + form team(t_num, formed_team) |
| 44 | + |
| 45 | + associate(me => this_image()) |
| 46 | + change team(team, cell[*] => caf(2)) |
| 47 | + ! for get_from_remote |
| 48 | + ! Checking against caf_single is very limitted. |
| 49 | + if (cell[me, team_number=t_num] /= 32) stop 1 |
| 50 | + if (cell[me, team_number=st_num] /= 32) stop 2 |
| 51 | + if (cell[me, team=parentteam] /= 32) stop 3 |
| 52 | + |
| 53 | + ! Check that team_number is validated |
| 54 | + lhs = cell[me, team_number=5, stat=stat] |
| 55 | + if (stat /= 1) stop 4 |
| 56 | + |
| 57 | + ! Check that only access to active teams is valid |
| 58 | + stat = 42 |
| 59 | + lhs = cell[me, team=formed_team, stat=stat] |
| 60 | + if (stat /= 1) stop 5 |
| 61 | + |
| 62 | + ! for send_to_remote |
| 63 | + ! Checking against caf_single is very limitted. |
| 64 | + cell[me, team_number=t_num] = 45 |
| 65 | + if (cell /= 45) stop 11 |
| 66 | + cell[me, team_number=st_num] = 46 |
| 67 | + if (cell /= 46) stop 12 |
| 68 | + cell[me, team=parentteam] = 47 |
| 69 | + if (cell /= 47) stop 13 |
| 70 | + |
| 71 | + ! Check that team_number is validated |
| 72 | + stat = -1 |
| 73 | + cell[me, team_number=5, stat=stat] = 0 |
| 74 | + if (stat /= 1) stop 14 |
| 75 | + |
| 76 | + ! Check that only access to active teams is valid |
| 77 | + stat = 42 |
| 78 | + cell[me, team=formed_team, stat=stat] = -1 |
| 79 | + if (stat /= 1) stop 15 |
| 80 | + |
| 81 | + ! for transfer_between_remotes |
| 82 | + ! Checking against caf_single is very limitted. |
| 83 | + cell[me, team_number=t_num] = caf(1)[me, team_number=-1] |
| 84 | + if (cell /= 23) stop 21 |
| 85 | + cell[me, team_number=st_num] = caf(2)[me, team_number=-1] |
| 86 | + ! cell is an alias for caf(2) and has been overwritten by caf(1)! |
| 87 | + if (cell /= 23) stop 22 |
| 88 | + cell[me, team=parentteam] = caf(1)[me, team= team] |
| 89 | + if (cell /= 23) stop 23 |
| 90 | + |
| 91 | + ! Check that team_number is validated |
| 92 | + stat = -1 |
| 93 | + cell[me, team_number=5, stat=stat] = caf(1)[me, team_number= -1] |
| 94 | + if (stat /= 1) stop 24 |
| 95 | + stat = -1 |
| 96 | + cell[me, team_number=t_num] = caf(1)[me, team_number= -2, stat=stat] |
| 97 | + if (stat /= 1) stop 25 |
| 98 | + |
| 99 | + ! Check that only access to active teams is valid |
| 100 | + stat = 42 |
| 101 | + cell[me, team=formed_team, stat=stat] = caf(1)[me] |
| 102 | + if (stat /= 1) stop 26 |
| 103 | + stat = 42 |
| 104 | + cell[me] = caf(1)[me, team=formed_team, stat=stat] |
| 105 | + if (stat /= 1) stop 27 |
| 106 | + end team |
| 107 | + |
| 108 | + sync all |
| 109 | + if (me == 1) print *, "Test passed." |
| 110 | + end associate |
| 111 | +end program teams_coindexed |
0 commit comments