1 |
jmc |
1.1 |
!======================================================================= |
2 |
|
|
subroutine coupsend_r4( component, dataname, Nx, Ny, arr ) |
3 |
|
|
implicit none |
4 |
|
|
! Arguments |
5 |
|
|
character*(*) component |
6 |
|
|
character*(*) dataname |
7 |
|
|
integer Nx,Ny |
8 |
|
|
real*4 arr(Nx,Ny) |
9 |
|
|
! Predefined constants/arrays |
10 |
|
|
#include "CPLR_SIG.h" |
11 |
|
|
! MPI variables |
12 |
|
|
#include "mpif.h" |
13 |
|
|
integer count,dtype,dest,tag,comm,ierr |
14 |
|
|
! Functions |
15 |
|
|
integer mitcplr_match_comp |
16 |
|
|
integer generate_tag |
17 |
|
|
! Local |
18 |
|
|
integer compind,numprocs |
19 |
|
|
integer i,j,ij,n |
20 |
|
|
integer Ni,Io,Nj,Jo |
21 |
|
|
! ------------------------------------------------------------------ |
22 |
|
|
|
23 |
|
|
! Establish who I am communicating with |
24 |
|
|
compind=mitcplr_match_comp( component ) |
25 |
|
|
if (compind.le.0) stop 'coupsend_r4: Bad component id' |
26 |
|
|
comm=MPI_COMM_compcplr( compind ) |
27 |
|
|
numprocs=num_component_procs(compind) |
28 |
|
|
if (numprocs.lt.1) then |
29 |
|
|
write(LogUnit,*) 'coupsend_r4: compind = ',compind |
30 |
|
|
stop 'coupsend_r4: numprocs < 1' |
31 |
|
|
endif |
32 |
|
|
if (VERB) |
33 |
|
|
& write(LogUnit,*) 'coupsend_r4: ',component_Name(compind) |
34 |
|
|
if (VERB) |
35 |
|
|
& write(LogUnit,*) 'coupsend_r4: dataname=',dataname |
36 |
|
|
|
37 |
|
|
! Foreach component process |
38 |
|
|
do n=1,numprocs |
39 |
|
|
|
40 |
|
|
! Create header |
41 |
|
|
Io=component_tile_i0(1,n,compind) |
42 |
|
|
Jo=component_tile_j0(1,n,compind) |
43 |
|
|
Ni=component_tile_nx(1,n,compind) |
44 |
|
|
Nj=component_tile_ny(1,n,compind) |
45 |
|
|
r4buf(1)=float( Io ) |
46 |
|
|
r4buf(2)=float( Jo ) |
47 |
|
|
r4buf(3)=float( Ni ) |
48 |
|
|
r4buf(4)=float( Nj ) |
49 |
|
|
call mitcplr_char2real( dataname, r4buf(9) ) |
50 |
|
|
|
51 |
|
|
! Pack data |
52 |
|
|
do j=1,Nj |
53 |
|
|
do i=1,Ni |
54 |
|
|
ij=HEADER_SIZE+i+Ni*(j-1) |
55 |
|
|
r4buf(ij)=arr(Io+i-1,Jo+j-1) |
56 |
|
|
enddo |
57 |
|
|
enddo |
58 |
|
|
|
59 |
|
|
! Send message |
60 |
|
|
count=HEADER_SIZE+Ni*Nj |
61 |
|
|
dtype=MPI_REAL |
62 |
|
|
tag=generate_tag(121,n,dataname) |
63 |
|
|
dest=rank_component_procs(n,compind) |
64 |
|
|
|
65 |
|
|
if (VERB) then |
66 |
|
|
write(LogUnit,*) 'coupsend_r4: calling MPI_Send dest=',dest, |
67 |
|
|
& ' proc=',n,'/',numprocs |
68 |
|
|
call flush(LogUnit) |
69 |
|
|
endif |
70 |
|
|
call MPI_Send( r4buf, count, dtype, dest, tag, comm, ierr ) |
71 |
|
|
if (VERB) then |
72 |
|
|
write(LogUnit,*) 'coupsend_r4: returned ierr=',ierr |
73 |
|
|
call flush(LogUnit) |
74 |
|
|
endif |
75 |
|
|
|
76 |
|
|
if (ierr.ne.0) then |
77 |
|
|
write(LogUnit,*) 'coupsend_r4tiles: rank(W,G)=', |
78 |
|
|
& my_rank_in_world,my_rank_in_global, |
79 |
|
|
& ' ierr=',ierr |
80 |
|
|
stop 'coupsend_r4: MPI_Recv failed' |
81 |
|
|
endif |
82 |
|
|
|
83 |
|
|
enddo ! n |
84 |
|
|
|
85 |
|
|
! ------------------------------------------------------------------ |
86 |
|
|
return |
87 |
|
|
end |
88 |
|
|
!======================================================================= |