[5725] | 1 | program receiver |
---|
| 2 | use mod_oasis |
---|
| 3 | use mpi |
---|
| 4 | implicit none |
---|
| 5 | integer :: i, kinfo, il_x, root |
---|
| 6 | integer :: comp_id |
---|
| 7 | integer :: local_comm, comm_size, comm_rank |
---|
| 8 | character(len=8) :: comp_name = "receiver" |
---|
| 9 | character(len=10), dimension(3) :: cnames |
---|
| 10 | integer, dimension(3) :: root_ranks |
---|
| 11 | integer :: intra_comm, intra_rank, intra_size |
---|
| 12 | |
---|
| 13 | print '(2A)', "Component name: ", comp_name |
---|
| 14 | |
---|
| 15 | call oasis_init_comp(comp_id, comp_name, kinfo) |
---|
| 16 | if(kinfo<0) call oasis_abort(comp_id, comp_name, & |
---|
| 17 | & "Error in oasis_init_comp: ", rcode=kinfo) |
---|
| 18 | print '(A,I0)', "Receiver: Component ID: ", comp_id |
---|
| 19 | |
---|
| 20 | call oasis_get_localcomm(local_comm, kinfo) |
---|
| 21 | if(kinfo<0) call oasis_abort(comp_id, comp_name, & |
---|
| 22 | & "Error in oasis_get_localcomm: ", rcode=kinfo) |
---|
| 23 | |
---|
| 24 | call mpi_comm_size(local_comm, comm_size, kinfo) |
---|
| 25 | call mpi_comm_rank(local_comm, comm_rank, kinfo) |
---|
| 26 | print '(A,I0,A,I0)', "Receiver: rank = ",comm_rank, " of ",comm_size |
---|
| 27 | |
---|
| 28 | call oasis_enddef(kinfo) |
---|
| 29 | if(kinfo<0) call oasis_abort(comp_id, comp_name, & |
---|
| 30 | & "Error in oasis_enddef: ", rcode=kinfo) |
---|
| 31 | |
---|
| 32 | cnames(:) = '' |
---|
| 33 | cnames(1) = 'xios' |
---|
| 34 | cnames(2) = comp_name |
---|
| 35 | cnames(3) = 'sender-box' |
---|
| 36 | |
---|
| 37 | call oasis_get_multi_intracomm(intra_comm,cnames,root_ranks,kinfo) |
---|
| 38 | if(kinfo<0) call oasis_abort(comp_id, comp_name, & |
---|
| 39 | &"Error in oasis_get_intracomm: ", rcode=kinfo) |
---|
| 40 | |
---|
| 41 | call mpi_comm_size(intra_comm, intra_size, kinfo) |
---|
| 42 | call mpi_comm_rank(intra_comm, intra_rank, kinfo) |
---|
| 43 | print '(A,I0,A,I0,A,I0)', "Receiver rank(",comm_rank,") intra_comm: rank = ",intra_rank, " of ",intra_size |
---|
| 44 | |
---|
| 45 | if ( comm_rank == 0 ) then |
---|
| 46 | do i = 1, size(cnames) |
---|
| 47 | print '(3A,I0)', "Receiver: component ",trim(cnames(i))," starts at rank ",root_ranks(i) |
---|
| 48 | end do |
---|
| 49 | end if |
---|
| 50 | |
---|
| 51 | if ( comm_rank == 0 ) then |
---|
| 52 | do i = 1, size(cnames) |
---|
| 53 | if (trim(cnames(i)) == 'xios') then |
---|
| 54 | root = root_ranks(i) |
---|
| 55 | exit |
---|
| 56 | end if |
---|
| 57 | end do |
---|
| 58 | end if |
---|
| 59 | call mpi_bcast(il_x, 1, MPI_INTEGER, root, intra_comm, kinfo) |
---|
| 60 | if (il_x == 222) then |
---|
| 61 | print '(A,I0,A,I0)', "Receiver rank(",comm_rank,") successfully got broadcasted il_x = ",il_x |
---|
| 62 | else |
---|
| 63 | print '(A,I0,A,I0)', "Receiver rank(",comm_rank,") got broadcasted il_x = ",il_x |
---|
| 64 | end if |
---|
| 65 | |
---|
| 66 | call oasis_terminate(kinfo) |
---|
| 67 | if(kinfo<0) call oasis_abort(comp_id, comp_name, & |
---|
| 68 | & "Error in oasis_terminate: ", rcode=kinfo) |
---|
| 69 | |
---|
| 70 | end program receiver |
---|