1 |
!======================================================================= |
2 |
subroutine compsend_r8tiles( dataname,Ni,Oi,Nj,Oj,Nk,Ti,Tj, arr ) |
3 |
implicit none |
4 |
! Arguments |
5 |
character*(*) dataname |
6 |
integer Ni,Oi,Nj,Oj,Nk,Ti,Tj |
7 |
real*8 arr(1-Oi:Ni+Oi,1-Oj:Nj+Oj,Nk,Ti,Tj) |
8 |
! Predefined constants/arrays |
9 |
#include "CPLR_SIG.h" |
10 |
! MPI variables |
11 |
#include "mpif.h" |
12 |
integer count,datatype,dest,tag,comm,ierr |
13 |
! Functions |
14 |
integer generate_tag |
15 |
! Local |
16 |
integer i,j,ij,bi,bj,k,bibj |
17 |
! ------------------------------------------------------------------ |
18 |
|
19 |
if (HEADER_SIZE+Ni*Nj.gt.MAX_R8_BUFLEN) |
20 |
& stop 'compsend_r8tiles: Nx*Ny too big' |
21 |
|
22 |
! Foreach tile which is non-blank |
23 |
do bibj=1,my_num_tiles |
24 |
|
25 |
bi=my_tile_bi(bibj) |
26 |
bj=my_tile_bj(bibj) |
27 |
|
28 |
if (Ni.ne.my_tile_nx(bibj)) |
29 |
& stop 'compsend_r8tiles: ni != my_tile_nx' |
30 |
if (Nj.ne.my_tile_ny(bibj)) |
31 |
& stop 'compsend_r8tiles: nj != my_tile_ny' |
32 |
|
33 |
! Set up buffer |
34 |
r8buf(1)=float( my_tile_i0(bibj) ) |
35 |
r8buf(2)=float( my_tile_nx(bibj) ) |
36 |
r8buf(3)=float( my_tile_j0(bibj) ) |
37 |
r8buf(4)=float( my_tile_ny(bibj) ) |
38 |
call mitcplr_char2real( dataname, r8buf(9) ) |
39 |
|
40 |
! Copy interior of tile to buffer |
41 |
k=1 |
42 |
do j=1,Nj |
43 |
do i=1,Ni |
44 |
ij=HEADER_SIZE+i+Ni*(j-1) |
45 |
r8buf(ij)=arr(i,j,k,bi,bj) |
46 |
enddo |
47 |
enddo |
48 |
|
49 |
! Send message |
50 |
count=HEADER_SIZE+Ni*Nj |
51 |
datatype=MPI_DOUBLE_PRECISION |
52 |
dest=my_coupler_rank |
53 |
tag=generate_tag(103,bibj,dataname) |
54 |
comm=MPI_COMM_myglobal |
55 |
|
56 |
if (VERB) then |
57 |
write(LogUnit,*) |
58 |
& 'compsend_r8tiles: calling MPI_Send dest=',dest,' tile=',bibj |
59 |
write(LogUnit,*) 'compsend_r8tiles: dataname=',dataname |
60 |
call flush(LogUnit) |
61 |
endif |
62 |
call MPI_Send( r8buf, count, datatype, dest, tag, comm, ierr ) |
63 |
if (VERB) then |
64 |
write(LogUnit,*) 'compsend_r8tiles: returned ierr=',ierr |
65 |
call flush(LogUnit) |
66 |
endif |
67 |
|
68 |
if (ierr.ne.0) then |
69 |
write(LogUnit,*) 'compsend_r8tiles: rank(W,G,L)=', |
70 |
& my_rank_in_world,my_rank_in_global,my_rank_in_local, |
71 |
& ' ierr=',ierr |
72 |
stop 'compsend_r8tiles: MPI_Send failed' |
73 |
endif |
74 |
|
75 |
enddo ! bibj |
76 |
|
77 |
! ------------------------------------------------------------------ |
78 |
return |
79 |
end |
80 |
!======================================================================= |