1 |
!======================================================================= |
2 |
subroutine MITCOUPLER_register( compName, nnx, nny ) |
3 |
implicit none |
4 |
|
5 |
! Arguments |
6 |
character*(*) compName |
7 |
integer nnx, nny |
8 |
|
9 |
! MPI variables |
10 |
#include "mpif.h" |
11 |
|
12 |
! Predefined constants/arrays |
13 |
#include "CPLR_SIG.h" |
14 |
|
15 |
! Functions |
16 |
integer mitcplr_match_comp |
17 |
integer generate_tag |
18 |
|
19 |
! Local |
20 |
integer n,numprocs |
21 |
integer comm |
22 |
integer compind,count,dtype,tag,rank |
23 |
integer ierr, rc |
24 |
integer stat(MPI_STATUS_SIZE) |
25 |
integer j,numtiles,nx,ny,i0,j0 |
26 |
|
27 |
! ------------------------------------------------------------------ |
28 |
|
29 |
! Establish who I am communicating with |
30 |
compind=mitcplr_match_comp( compName ) |
31 |
if (compind.le.0) stop 'MITCOUPLER_register: Bad component' |
32 |
comm=MPI_COMM_compcplr( compind ) |
33 |
numprocs=num_component_procs(compind) |
34 |
if (numprocs.lt.1) then |
35 |
write(LogUnit,*) 'MITCOUPLER_register: compind = ',compind |
36 |
stop 'MITCOUPLER_register: numprocs < 1' |
37 |
endif |
38 |
|
39 |
! Foreach component process |
40 |
do n=1,numprocs |
41 |
|
42 |
! Receive message |
43 |
count=MAX_IBUF |
44 |
dtype=MPI_INTEGER |
45 |
tag=generate_tag(115,n,'Register') |
46 |
rank=rank_component_procs(n,compind) |
47 |
|
48 |
call MPI_Recv(ibuf, count, dtype, rank, tag, comm, stat, ierr) |
49 |
|
50 |
if (ierr.ne.0) then |
51 |
write(LogUnit,*) 'MITCOUPLER_register: rank(W,G)=', |
52 |
& my_rank_in_world,my_rank_in_global, |
53 |
& ' ierr=',ierr |
54 |
stop 'MITCOUPLER_register: MPI_Recv failed' |
55 |
endif |
56 |
|
57 |
! Extract data |
58 |
numtiles=ibuf(1) |
59 |
nx=ibuf(2) |
60 |
ny=ibuf(3) |
61 |
i0=ibuf(4) |
62 |
j0=ibuf(5) |
63 |
|
64 |
if (numtiles.ne.1) then |
65 |
write(LogUnit,*) 'MITCOUPLER_tile_register: #tiles = ',numtiles |
66 |
stop 'MITCOUPLER_tile_register: invalid value for numtiles' |
67 |
endif |
68 |
if (nx.lt.1) then |
69 |
write(LogUnit,*) 'MITCOUPLER_register: nx = ',nx |
70 |
stop 'MITCOUPLER_register: invalid value for nx' |
71 |
endif |
72 |
if (ny.lt.1) then |
73 |
write(LogUnit,*) 'MITCOUPLER_register: ny = ',ny |
74 |
stop 'MITCOUPLER_register: invalid value for ny' |
75 |
endif |
76 |
if (i0.lt.1) then |
77 |
write(LogUnit,*) 'MITCOUPLER_register: i0 = ',i0 |
78 |
stop 'MITCOUPLER_register: invalid value for i0' |
79 |
endif |
80 |
if (j0.lt.1) then |
81 |
write(LogUnit,*) 'MITCOUPLER_register: j0 = ',j0 |
82 |
stop 'MITCOUPLER_register: invalid value for j0' |
83 |
endif |
84 |
if (i0+nx-1.gt.nnx) then |
85 |
write(LogUnit,*) 'MITCOUPLER_register: i0 = ',i0 |
86 |
stop 'MITCOUPLER_register: i0 + nx -1 > nnx' |
87 |
endif |
88 |
if (j0+ny-1.gt.nny) then |
89 |
write(LogUnit,*) 'MITCOUPLER_register: j0 = ',j0 |
90 |
stop 'MITCOUPLER_register: j0 + ny -1 > nny' |
91 |
endif |
92 |
|
93 |
component_num_tiles(n,compind)=1 |
94 |
component_tile_nx(1,n,compind)=nx |
95 |
component_tile_ny(1,n,compind)=ny |
96 |
component_tile_i0(1,n,compind)=i0 |
97 |
component_tile_j0(1,n,compind)=j0 |
98 |
|
99 |
enddo ! n |
100 |
|
101 |
do n=1,numprocs |
102 |
write(LogUnit,*) 'MITCOUPLER_register: proc,nx,ny = ',n, |
103 |
& component_tile_nx(1,n,compind),component_tile_ny(1,n,compind) |
104 |
enddo ! n |
105 |
|
106 |
! ------------------------------------------------------------------ |
107 |
call flush(LogUnit) |
108 |
return |
109 |
end |
110 |
!======================================================================= |