1 | SUBROUTINE CLIM_Export(id_port_id,kstep,pfield,kinfo) |
---|
2 | c |
---|
3 | c* *** Export *** |
---|
4 | c |
---|
5 | c purpose: |
---|
6 | c -------- |
---|
7 | c give pfield to models connected to port id_port_id at the time kstep |
---|
8 | c |
---|
9 | c interface: |
---|
10 | c ---------- |
---|
11 | c id_port_id : port number of the field |
---|
12 | c kstep : current time in seconds |
---|
13 | c pfield : buffer of reals |
---|
14 | c kinfo : output status |
---|
15 | c |
---|
16 | c lib mp: |
---|
17 | c ------- |
---|
18 | c mpi-1 |
---|
19 | c |
---|
20 | c author: |
---|
21 | c ------- |
---|
22 | c Eric Sevault - METEO FRANCE |
---|
23 | c Laurent Terray - CERFACS |
---|
24 | c Jean Latour - F.S.E. |
---|
25 | c Arnaud Caubel - Fecit |
---|
26 | c |
---|
27 | c ---------------------------------------------------------------- |
---|
28 | #if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE |
---|
29 | USE mod_kinds_oasis |
---|
30 | USE mod_clim |
---|
31 | USE mod_comclim |
---|
32 | #include <mpif.h> |
---|
33 | c ---------------------------------------------------------------- |
---|
34 | INTEGER (kind=ip_intwp_p) kstep, kinfo |
---|
35 | CHARACTER(len=1), DIMENSION(*) :: pfield |
---|
36 | c ---------------------------------------------------------------- |
---|
37 | INTEGER (kind=ip_intwp_p) info |
---|
38 | INTEGER (kind=ip_intwp_p) isend, ip, iport, ilk, iseg, is, |
---|
39 | $ ilgb, imod, itid, itag, ilen, ioff, ityp, ibyt |
---|
40 | INTEGER (kind=ip_intwp_p) iposbuf |
---|
41 | c ---------------------------------------------------------------- |
---|
42 | c |
---|
43 | c* 0. First Check |
---|
44 | c -------------- |
---|
45 | c |
---|
46 | WRITE(nulprt, *)'entering CLIM_Export' |
---|
47 | IF (nexit.ne.1) THEN |
---|
48 | kinfo = CLIM_FastExit |
---|
49 | WRITE(nulprt,FMT='(A)') 'Export - should not be called' |
---|
50 | GO TO 1010 |
---|
51 | ENDIF |
---|
52 | kinfo = CLIM_Ok |
---|
53 | c |
---|
54 | c* 1. check for this port in my list |
---|
55 | c --------------------------------- |
---|
56 | c |
---|
57 | isend = 0 |
---|
58 | iport = -1 |
---|
59 | c |
---|
60 | IF (myport(1,id_port_id).eq.CLIM_Out) iport=id_port_id |
---|
61 | |
---|
62 | IF (iport.lt.0) THEN |
---|
63 | kinfo = CLIM_BadPort |
---|
64 | WRITE(nulprt,FMT='(A,A)') |
---|
65 | * 'Export - WARNING - Invalid port out: ', |
---|
66 | $ cports(id_port_id) |
---|
67 | GO TO 1010 |
---|
68 | ENDIF |
---|
69 | c |
---|
70 | c* 2. check for connected ports (in) |
---|
71 | c --------------------------------- |
---|
72 | c |
---|
73 | WRITE(nulprt,FMT='(A,A)') 'Export - ', cports(iport) |
---|
74 | c |
---|
75 | ityp = myport(2,iport) |
---|
76 | ibyt = myport(3,iport) |
---|
77 | c |
---|
78 | DO 290 ip=1,myport(5,iport) |
---|
79 | c |
---|
80 | ilk = myport(5+ip,iport) |
---|
81 | imod = mylink(1,ilk) |
---|
82 | itid = mylink(2,ilk) |
---|
83 | itag = mylink(3,ilk) - kstep / ig_frqmin |
---|
84 | iseg = mylink(4,ilk) |
---|
85 | c |
---|
86 | ilgb = 0 |
---|
87 | iposbuf = 0 |
---|
88 | DO 240 is=1,iseg |
---|
89 | ioff = mylink(4+2*is-1,ilk) * ibyt + 1 |
---|
90 | ilen = mylink(4+2*is,ilk) |
---|
91 | c |
---|
92 | c IF ( ityp .EQ. CLIM_Integer ) THEN |
---|
93 | c CALL MPI_Pack ( pfield(ioff), ilen, MPI_INTEGER, |
---|
94 | c * pkwork, ig_maxtype, iposbuf, mpi_comm, info ) |
---|
95 | c ELSEIF ( ityp .EQ. CLIM_Real ) THEN |
---|
96 | IF ( ityp .EQ. CLIM_Real ) THEN |
---|
97 | C IF ( kind(rl_testvar) .eq. 4 ) THEN |
---|
98 | IF ( ip_realwp_p .eq. ip_single_p ) THEN |
---|
99 | CALL MPI_Pack ( pfield(ioff), ilen, |
---|
100 | * MPI_REAL,pkwork, ig_maxtype, iposbuf, |
---|
101 | * mpi_comm, info ) |
---|
102 | C ELSE IF ( kind(rl_testvar) .eq. 8 ) THEN |
---|
103 | ELSE IF ( ip_realwp_p .eq. ip_double_p ) THEN |
---|
104 | CALL MPI_Pack ( pfield(ioff), ilen, |
---|
105 | * MPI_DOUBLE_PRECISION,pkwork, ig_maxtype, |
---|
106 | * iposbuf, mpi_comm, info ) |
---|
107 | ENDIF |
---|
108 | c ELSEIF ( ityp .EQ. CLIM_Double ) THEN |
---|
109 | c CALL MPI_Pack ( pfield(ioff), ilen, |
---|
110 | c * MPI_DOUBLE_PRECISION, |
---|
111 | c * pkwork, ig_maxtype, iposbuf, mpi_comm, info ) |
---|
112 | ELSE |
---|
113 | WRITE(nulprt,*)'Export - pb type incorrect ',ityp |
---|
114 | kinfo = CLIM_BadType |
---|
115 | GO TO 1010 |
---|
116 | ENDIF |
---|
117 | ilgb = ilgb + ilen |
---|
118 | 240 CONTINUE |
---|
119 | IF (info.ne.0 .or. ilgb*ibyt .gt. ig_maxtype) THEN |
---|
120 | kinfo = CLIM_Pack |
---|
121 | WRITE(nulprt,FMT='(A,I3,I8,A)') |
---|
122 | * 'Export - pb pack<mpi ',info,ilgb*ibyt,'>' |
---|
123 | ELSE |
---|
124 | c |
---|
125 | IF (lg_bsend) then |
---|
126 | c* |
---|
127 | c* Buffered send |
---|
128 | c* -> if fields are not sent and received in the same order, and |
---|
129 | c* and on architectures on which MPI_Send is not implemented with a |
---|
130 | c* mailbox (e.g. NEC SX5) |
---|
131 | c* |
---|
132 | CALL MPI_BSend ( pkwork, iposbuf, MPI_PACKED, itid, |
---|
133 | * itag, mpi_comm, info ) |
---|
134 | ELSE |
---|
135 | c |
---|
136 | c* Standard blocking send: To be used |
---|
137 | c* -> if fields are necessarily sent and received in the same order, |
---|
138 | c* -> or on architectures on which MPI_Send is implemented with a |
---|
139 | c* mailbox (e.g. VPPs); in this case, make sure that your mailbox |
---|
140 | c* size is large enough. |
---|
141 | c |
---|
142 | CALL MPI_Send ( pkwork, iposbuf, MPI_PACKED, itid, |
---|
143 | * itag, mpi_comm, info ) |
---|
144 | c |
---|
145 | ENDIF |
---|
146 | c |
---|
147 | IF (info.eq.CLIM_ok) THEN |
---|
148 | isend = isend + 1 |
---|
149 | nbsend = nbsend + ilgb * ibyt |
---|
150 | WRITE(nulprt,FMT='(A,I2,A,I9,A,I7,A,I2,A,I10,A)') |
---|
151 | * 'Export - <dest:',imod, |
---|
152 | * '> <step:',kstep, |
---|
153 | * '> <len:',ilgb, |
---|
154 | * '> <type:',ibyt, |
---|
155 | * '> <tag:',itag,'>' |
---|
156 | ELSE |
---|
157 | kinfo = CLIM_Pvm |
---|
158 | WRITE(nulprt,FMT='(A,I3,A)') |
---|
159 | * 'Export - pb send <mpi ',info,'>' |
---|
160 | ENDIF |
---|
161 | ENDIF |
---|
162 | c |
---|
163 | c |
---|
164 | 290 CONTINUE |
---|
165 | c |
---|
166 | WRITE(nulprt,FMT='(A,I3,A)') |
---|
167 | * 'Export - ',isend,' fields exported' |
---|
168 | c |
---|
169 | c ---------------------------------------------------------------- |
---|
170 | c |
---|
171 | 1010 CONTINUE |
---|
172 | CALL FLUSH(nulprt) |
---|
173 | #endif |
---|
174 | RETURN |
---|
175 | END |
---|