|
1 |
| -! Unit test for register procedure. Testing static coarrays. |
| 1 | +! Unit test for initializion of MPI by LIBCAF_MPI. |
2 | 2 | !
|
3 | 3 | ! Copyright (c) 2012-2014, Sourcery, Inc.
|
4 | 4 | ! All rights reserved.
|
|
24 | 24 | ! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25 | 25 | ! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26 | 26 | ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 |
| - |
28 |
| -program register1 |
| 27 | +! |
| 28 | +program initialize_mpi |
| 29 | + use mpi, only : MPI_COMM_SIZE,MPI_COMM_WORLD |
29 | 30 | implicit none
|
30 |
| - include 'mpif.h' |
31 |
| - integer :: np,ierr,me_next |
32 |
| - |
33 |
| - np = -2 |
34 |
| - np = num_images() |
35 | 31 |
|
36 |
| - call image() |
37 |
| - |
38 |
| - if(this_image() == 1) then |
39 |
| - call image(me_next) |
40 |
| - if(me_next == 2) then |
41 |
| - write(*,*) 'Test passed.' |
42 |
| - else |
43 |
| - write(*,*) 'Test failed.' |
44 |
| - end if |
45 |
| - endif |
| 32 | + ! Set invalid default image number and number of ranks |
| 33 | + integer :: me=-1,np=-1,ierr |
46 | 34 |
|
47 |
| -contains |
| 35 | + ! Get image number |
| 36 | + me = this_image() |
48 | 37 |
|
49 |
| -subroutine image(me_next) |
50 |
| - implicit none |
51 |
| - integer,intent(out),optional :: me_next |
52 |
| - integer,save :: me[*] = -1 |
53 |
| - if(me == -1) then |
54 |
| - me = this_image() |
55 |
| - end if |
56 |
| - if(present(me_next) .and. me == 1) then |
57 |
| - me_next = me[2] |
58 |
| - end if |
59 |
| -end subroutine image |
| 38 | + ! Get number of ranks (np) |
| 39 | + call MPI_COMM_SIZE(MPI_COMM_WORLD,np,ierr) |
60 | 40 |
|
61 |
| -end program register1 |
| 41 | + ! Everybody verifies that they have a valid image number and rank |
| 42 | + if(me < 1 .or. np < 1) error stop "Test failed." |
| 43 | + |
| 44 | + ! Image 1 reports test success |
| 45 | + if(me==1) print *,"Test passed." |
| 46 | +end program |
0 commit comments