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