1 | MODULE cpl_oasis3 |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE cpl_oasis *** |
---|
4 | !! Coupled O/A : coupled ocean-atmosphere case using OASIS3-MCT |
---|
5 | !!===================================================================== |
---|
6 | !! History : |
---|
7 | !! 9.0 ! 04-06 (R. Redler, NEC Laboratories Europe, Germany) Original code |
---|
8 | !! " " ! 04-11 (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision |
---|
9 | !! " " ! 04-11 (V. Gayler, MPI M&D) Grid writing |
---|
10 | !! " " ! 05-08 (R. Redler, W. Park) frld initialization, paral(2) revision |
---|
11 | !! " " ! 05-09 (R. Redler) extended to allow for communication over root only |
---|
12 | !! " " ! 06-01 (W. Park) modification of physical part |
---|
13 | !! " " ! 06-02 (R. Redler, W. Park) buffer array fix for root exchange |
---|
14 | !! 3.4 ! 11-11 (C. Harris) Changes to allow mutiple category fields |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | !!---------------------------------------------------------------------- |
---|
17 | !! 'key_oasis3' coupled Ocean/Atmosphere via OASIS3-MCT |
---|
18 | !! 'key_oa3mct_v3' to be added for OASIS3-MCT version 3 |
---|
19 | !!---------------------------------------------------------------------- |
---|
20 | !! cpl_init : initialization of coupled mode communication |
---|
21 | !! cpl_define : definition of grid and fields |
---|
22 | !! cpl_snd : snd out fields in coupled mode |
---|
23 | !! cpl_rcv : receive fields in coupled mode |
---|
24 | !! cpl_finalize : finalize the coupled mode communication |
---|
25 | !!---------------------------------------------------------------------- |
---|
26 | #if defined key_oasis3 || defined key_oasis3mct |
---|
27 | USE mod_oasis ! OASIS3-MCT module |
---|
28 | #endif |
---|
29 | USE par_oce ! ocean parameters |
---|
30 | USE dom_oce ! ocean space and time domain |
---|
31 | USE in_out_manager ! I/O manager |
---|
32 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
33 | |
---|
34 | IMPLICIT NONE |
---|
35 | PRIVATE |
---|
36 | |
---|
37 | PUBLIC cpl_init |
---|
38 | PUBLIC cpl_define |
---|
39 | PUBLIC cpl_snd |
---|
40 | PUBLIC cpl_rcv |
---|
41 | PUBLIC cpl_freq |
---|
42 | PUBLIC cpl_finalize |
---|
43 | |
---|
44 | INTEGER, PUBLIC :: OASIS_Rcv = 1 !: return code if received field |
---|
45 | INTEGER, PUBLIC :: OASIS_idle = 0 !: return code if nothing done by oasis |
---|
46 | INTEGER :: ncomp_id ! id returned by oasis_init_comp |
---|
47 | INTEGER :: nerror ! return error code |
---|
48 | #if ! defined key_oasis3 && ! defined key_oasis3mct |
---|
49 | ! OASIS Variables not used. defined only for compilation purpose |
---|
50 | INTEGER :: OASIS_Out = -1 |
---|
51 | INTEGER :: OASIS_REAL = -1 |
---|
52 | INTEGER :: OASIS_Ok = -1 |
---|
53 | INTEGER :: OASIS_In = -1 |
---|
54 | INTEGER :: OASIS_Sent = -1 |
---|
55 | INTEGER :: OASIS_SentOut = -1 |
---|
56 | INTEGER :: OASIS_ToRest = -1 |
---|
57 | INTEGER :: OASIS_ToRestOut = -1 |
---|
58 | INTEGER :: OASIS_Recvd = -1 |
---|
59 | INTEGER :: OASIS_RecvOut = -1 |
---|
60 | INTEGER :: OASIS_FromRest = -1 |
---|
61 | INTEGER :: OASIS_FromRestOut = -1 |
---|
62 | #endif |
---|
63 | |
---|
64 | INTEGER :: nrcv ! total number of fields received |
---|
65 | INTEGER :: nsnd ! total number of fields sent |
---|
66 | INTEGER :: ncplmodel ! Maximum number of models to/from which NEMO is potentialy sending/receiving data |
---|
67 | INTEGER, PUBLIC, PARAMETER :: nmaxfld=50 ! Maximum number of coupling fields |
---|
68 | INTEGER, PUBLIC, PARAMETER :: nmaxcat=5 ! Maximum number of coupling fields |
---|
69 | INTEGER, PUBLIC, PARAMETER :: nmaxcpl=5 ! Maximum number of coupling fields |
---|
70 | |
---|
71 | INTEGER, PUBLIC :: nn_cpl_river=0 ! Maximum number of rivers being passed through the coupler |
---|
72 | INTEGER, PUBLIC :: runoff_id ! OASIS coupling id used in oasis_get command |
---|
73 | |
---|
74 | TYPE, PUBLIC :: FLD_CPL !: Type for coupling field information |
---|
75 | LOGICAL :: laction ! To be coupled or not |
---|
76 | CHARACTER(len = 8) :: clname ! Name of the coupling field |
---|
77 | CHARACTER(len = 1) :: clgrid ! Grid type |
---|
78 | REAL(wp) :: nsgn ! Control of the sign change |
---|
79 | INTEGER, DIMENSION(nmaxcat,nmaxcpl) :: nid ! Id of the field (no more than 9 categories and 9 extrena models) |
---|
80 | INTEGER :: nct ! Number of categories in field |
---|
81 | INTEGER :: ncplmodel ! Maximum number of models to/from which this variable may be sent/received |
---|
82 | END TYPE FLD_CPL |
---|
83 | |
---|
84 | TYPE(FLD_CPL), DIMENSION(nmaxfld), PUBLIC :: srcv, ssnd !: Coupling fields |
---|
85 | |
---|
86 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: exfld ! Temporary buffer for receiving |
---|
87 | |
---|
88 | !!---------------------------------------------------------------------- |
---|
89 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
90 | !! $Id$ |
---|
91 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
92 | !!---------------------------------------------------------------------- |
---|
93 | CONTAINS |
---|
94 | |
---|
95 | SUBROUTINE cpl_init( cd_modname, kl_comm ) |
---|
96 | !!------------------------------------------------------------------- |
---|
97 | !! *** ROUTINE cpl_init *** |
---|
98 | !! |
---|
99 | !! ** Purpose : Initialize coupled mode communication for ocean |
---|
100 | !! exchange between AGCM, OGCM and COUPLER. (OASIS3 software) |
---|
101 | !! |
---|
102 | !! ** Method : OASIS3 MPI communication |
---|
103 | !!-------------------------------------------------------------------- |
---|
104 | CHARACTER(len = *), INTENT(in) :: cd_modname ! model name as set in namcouple file |
---|
105 | INTEGER , INTENT(out) :: kl_comm ! local communicator of the model |
---|
106 | !!-------------------------------------------------------------------- |
---|
107 | |
---|
108 | ! WARNING: No write in numout in this routine |
---|
109 | !============================================ |
---|
110 | |
---|
111 | !------------------------------------------------------------------ |
---|
112 | ! 1st Initialize the OASIS system for the application |
---|
113 | !------------------------------------------------------------------ |
---|
114 | CALL oasis_init_comp ( ncomp_id, TRIM(cd_modname), nerror ) |
---|
115 | IF ( nerror /= OASIS_Ok ) & |
---|
116 | CALL oasis_abort (ncomp_id, 'cpl_init', 'Failure in oasis_init_comp') |
---|
117 | |
---|
118 | !------------------------------------------------------------------ |
---|
119 | ! 3rd Get an MPI communicator for OPA local communication |
---|
120 | !------------------------------------------------------------------ |
---|
121 | |
---|
122 | CALL oasis_get_localcomm ( kl_comm, nerror ) |
---|
123 | IF ( nerror /= OASIS_Ok ) & |
---|
124 | CALL oasis_abort (ncomp_id, 'cpl_init','Failure in oasis_get_localcomm' ) |
---|
125 | ! |
---|
126 | END SUBROUTINE cpl_init |
---|
127 | |
---|
128 | |
---|
129 | SUBROUTINE cpl_define( krcv, ksnd, kcplmodel ) |
---|
130 | !!------------------------------------------------------------------- |
---|
131 | !! *** ROUTINE cpl_define *** |
---|
132 | !! |
---|
133 | !! ** Purpose : Define grid and field information for ocean |
---|
134 | !! exchange between AGCM, OGCM and COUPLER. (OASIS3 software) |
---|
135 | !! |
---|
136 | !! ** Method : OASIS3 MPI communication |
---|
137 | !!-------------------------------------------------------------------- |
---|
138 | INTEGER, INTENT(in) :: krcv, ksnd ! Number of received and sent coupling fields |
---|
139 | INTEGER, INTENT(in) :: kcplmodel ! Maximum number of models to/from which NEMO is potentialy sending/receiving data |
---|
140 | ! |
---|
141 | INTEGER :: id_part ! Partition for all 2D model fields to be coupled |
---|
142 | INTEGER :: id_part_rnf_1d ! Partition for river runoff using 1D array |
---|
143 | INTEGER :: paral(5) ! OASIS3 box partition |
---|
144 | INTEGER :: ishape(2,2) ! shape of arrays passed to PSMILe |
---|
145 | INTEGER :: ji,jc,jm ! local loop indicees |
---|
146 | CHARACTER(LEN=64) :: zclname |
---|
147 | CHARACTER(LEN=2) :: cli2 |
---|
148 | !!-------------------------------------------------------------------- |
---|
149 | |
---|
150 | IF(lwp) WRITE(numout,*) |
---|
151 | IF(lwp) WRITE(numout,*) 'cpl_define : initialization in coupled ocean/atmosphere case' |
---|
152 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~' |
---|
153 | IF(lwp) WRITE(numout,*) |
---|
154 | |
---|
155 | ncplmodel = kcplmodel |
---|
156 | IF( kcplmodel > nmaxcpl ) THEN |
---|
157 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'ncplmodel is larger than nmaxcpl, increase nmaxcpl') ; RETURN |
---|
158 | ENDIF |
---|
159 | |
---|
160 | nrcv = krcv |
---|
161 | IF( nrcv > nmaxfld ) THEN |
---|
162 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'nrcv is larger than nmaxfld, increase nmaxfld') ; RETURN |
---|
163 | ENDIF |
---|
164 | |
---|
165 | nsnd = ksnd |
---|
166 | IF( nsnd > nmaxfld ) THEN |
---|
167 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'nsnd is larger than nmaxfld, increase nmaxfld') ; RETURN |
---|
168 | ENDIF |
---|
169 | |
---|
170 | ! |
---|
171 | ! ... Define the shape for the area that excludes the halo |
---|
172 | ! For serial configuration (key_mpp_mpi not being active) |
---|
173 | ! nl* is set to the global values 1 and jp*glo. |
---|
174 | ! |
---|
175 | ishape(:,1) = (/ 1, nlei-nldi+1 /) |
---|
176 | ishape(:,2) = (/ 1, nlej-nldj+1 /) |
---|
177 | ! |
---|
178 | ! ... Allocate memory for data exchange |
---|
179 | ! |
---|
180 | ALLOCATE(exfld(nlei-nldi+1, nlej-nldj+1), stat = nerror) |
---|
181 | IF( nerror > 0 ) THEN |
---|
182 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld') ; RETURN |
---|
183 | ENDIF |
---|
184 | ! |
---|
185 | ! ----------------------------------------------------------------- |
---|
186 | ! ... Define the partition |
---|
187 | ! ----------------------------------------------------------------- |
---|
188 | |
---|
189 | paral(1) = 2 ! box partitioning |
---|
190 | paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1) ! NEMO lower left corner global offset |
---|
191 | paral(3) = nlei-nldi+1 ! local extent in i |
---|
192 | paral(4) = nlej-nldj+1 ! local extent in j |
---|
193 | paral(5) = jpiglo ! global extent in x |
---|
194 | |
---|
195 | IF( ln_ctl ) THEN |
---|
196 | WRITE(numout,*) ' multiexchg: paral (1:5)', paral |
---|
197 | WRITE(numout,*) ' multiexchg: jpi, jpj =', jpi, jpj |
---|
198 | WRITE(numout,*) ' multiexchg: nldi, nlei, nimpp =', nldi, nlei, nimpp |
---|
199 | WRITE(numout,*) ' multiexchg: nldj, nlej, njmpp =', nldj, nlej, njmpp |
---|
200 | ENDIF |
---|
201 | |
---|
202 | CALL oasis_def_partition ( id_part, paral, nerror ) |
---|
203 | ! |
---|
204 | ! Another partition is needed for river runoff when using 1D array |
---|
205 | paral(1) = 0 ! serial partitioning |
---|
206 | paral(2) = 0 |
---|
207 | paral(3) = nn_cpl_river ! size of array to couple |
---|
208 | paral(4) = 0 |
---|
209 | paral(5) = 0 |
---|
210 | |
---|
211 | CALL oasis_def_partition ( id_part_rnf_1d, paral, nerror, nn_cpl_river ) |
---|
212 | ! ... Announce send variables. |
---|
213 | ! |
---|
214 | ssnd(:)%ncplmodel = kcplmodel |
---|
215 | ! |
---|
216 | DO ji = 1, ksnd |
---|
217 | IF ( ssnd(ji)%laction ) THEN |
---|
218 | |
---|
219 | IF( ssnd(ji)%nct > nmaxcat ) THEN |
---|
220 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '// & |
---|
221 | & TRIM(ssnd(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' ) |
---|
222 | RETURN |
---|
223 | ENDIF |
---|
224 | |
---|
225 | DO jc = 1, ssnd(ji)%nct |
---|
226 | DO jm = 1, kcplmodel |
---|
227 | |
---|
228 | IF ( ssnd(ji)%nct .GT. 1 ) THEN |
---|
229 | WRITE(cli2,'(i2.2)') jc |
---|
230 | zclname = TRIM(ssnd(ji)%clname)//'_cat'//cli2 |
---|
231 | ELSE |
---|
232 | zclname = ssnd(ji)%clname |
---|
233 | ENDIF |
---|
234 | IF ( kcplmodel > 1 ) THEN |
---|
235 | WRITE(cli2,'(i2.2)') jm |
---|
236 | zclname = 'model'//cli2//'_'//TRIM(zclname) |
---|
237 | ENDIF |
---|
238 | #if defined key_agrif |
---|
239 | IF( agrif_fixed() /= 0 ) THEN |
---|
240 | zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname) |
---|
241 | END IF |
---|
242 | #endif |
---|
243 | IF( ln_ctl ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_Out |
---|
244 | CALL oasis_def_var (ssnd(ji)%nid(jc,jm), zclname, id_part , (/ 2, 0 /), & |
---|
245 | & OASIS_Out , ishape , OASIS_REAL, nerror ) |
---|
246 | IF ( nerror /= OASIS_Ok ) THEN |
---|
247 | WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname) |
---|
248 | CALL oasis_abort ( ssnd(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' ) |
---|
249 | ENDIF |
---|
250 | IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple" |
---|
251 | IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple" |
---|
252 | END DO |
---|
253 | END DO |
---|
254 | ENDIF |
---|
255 | END DO |
---|
256 | ! |
---|
257 | ! ... Announce received variables. |
---|
258 | ! |
---|
259 | srcv(:)%ncplmodel = kcplmodel |
---|
260 | ! |
---|
261 | DO ji = 1, krcv |
---|
262 | IF ( srcv(ji)%laction ) THEN |
---|
263 | |
---|
264 | IF( srcv(ji)%nct > nmaxcat ) THEN |
---|
265 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '// & |
---|
266 | & TRIM(srcv(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' ) |
---|
267 | RETURN |
---|
268 | ENDIF |
---|
269 | |
---|
270 | DO jc = 1, srcv(ji)%nct |
---|
271 | DO jm = 1, kcplmodel |
---|
272 | |
---|
273 | IF ( srcv(ji)%nct .GT. 1 ) THEN |
---|
274 | WRITE(cli2,'(i2.2)') jc |
---|
275 | zclname = TRIM(srcv(ji)%clname)//'_cat'//cli2 |
---|
276 | ELSE |
---|
277 | zclname = srcv(ji)%clname |
---|
278 | ENDIF |
---|
279 | IF ( kcplmodel > 1 ) THEN |
---|
280 | WRITE(cli2,'(i2.2)') jm |
---|
281 | zclname = 'model'//cli2//'_'//TRIM(zclname) |
---|
282 | ENDIF |
---|
283 | #if defined key_agrif |
---|
284 | IF( agrif_fixed() /= 0 ) THEN |
---|
285 | zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname) |
---|
286 | END IF |
---|
287 | #endif |
---|
288 | IF( ln_ctl ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_In |
---|
289 | CALL oasis_def_var (srcv(ji)%nid(jc,jm), zclname, id_part , (/ 2, 0 /), & |
---|
290 | & OASIS_In , ishape , OASIS_REAL, nerror ) |
---|
291 | IF ( nerror /= OASIS_Ok ) THEN |
---|
292 | WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname) |
---|
293 | CALL oasis_abort ( srcv(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' ) |
---|
294 | ENDIF |
---|
295 | IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple" |
---|
296 | IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple" |
---|
297 | |
---|
298 | END DO |
---|
299 | END DO |
---|
300 | ENDIF |
---|
301 | END DO |
---|
302 | |
---|
303 | ! Define coupled river runoff using 1D array |
---|
304 | CALL oasis_def_var (runoff_id, 'runoffo', id_part_rnf_1d, (/ 1, 0 /), & |
---|
305 | & OASIS_In , (/ 1, nn_cpl_river /) , OASIS_REAL, nerror ) |
---|
306 | IF ( nerror /= OASIS_Ok ) THEN |
---|
307 | WRITE(numout,*) 'Failed to define transient runoffo' |
---|
308 | CALL oasis_abort ( runoff_id, 'cpl_define', 'Failure in oasis_def_var' ) |
---|
309 | ENDIF |
---|
310 | |
---|
311 | !------------------------------------------------------------------ |
---|
312 | ! End of definition phase |
---|
313 | !------------------------------------------------------------------ |
---|
314 | |
---|
315 | CALL oasis_enddef(nerror) |
---|
316 | IF( nerror /= OASIS_Ok ) CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef') |
---|
317 | ! |
---|
318 | END SUBROUTINE cpl_define |
---|
319 | |
---|
320 | |
---|
321 | SUBROUTINE cpl_snd( kid, kstep, pdata, kinfo ) |
---|
322 | !!--------------------------------------------------------------------- |
---|
323 | !! *** ROUTINE cpl_snd *** |
---|
324 | !! |
---|
325 | !! ** Purpose : - At each coupling time-step,this routine sends fields |
---|
326 | !! like sst or ice cover to the coupler or remote application. |
---|
327 | !!---------------------------------------------------------------------- |
---|
328 | INTEGER , INTENT(in ) :: kid ! variable index in the array |
---|
329 | INTEGER , INTENT( out) :: kinfo ! OASIS3 info argument |
---|
330 | INTEGER , INTENT(in ) :: kstep ! ocean time-step in seconds |
---|
331 | REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pdata |
---|
332 | !! |
---|
333 | INTEGER :: jc,jm ! local loop index |
---|
334 | !!-------------------------------------------------------------------- |
---|
335 | ! |
---|
336 | ! snd data to OASIS3 |
---|
337 | ! |
---|
338 | DO jc = 1, ssnd(kid)%nct |
---|
339 | DO jm = 1, ssnd(kid)%ncplmodel |
---|
340 | |
---|
341 | IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN |
---|
342 | CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(nldi:nlei, nldj:nlej,jc), kinfo ) |
---|
343 | |
---|
344 | IF ( ln_ctl ) THEN |
---|
345 | IF ( kinfo == OASIS_Sent .OR. kinfo == OASIS_ToRest .OR. & |
---|
346 | & kinfo == OASIS_SentOut .OR. kinfo == OASIS_ToRestOut ) THEN |
---|
347 | WRITE(numout,*) '****************' |
---|
348 | WRITE(numout,*) 'oasis_put: Outgoing ', ssnd(kid)%clname |
---|
349 | WRITE(numout,*) 'oasis_put: ivarid ', ssnd(kid)%nid(jc,jm) |
---|
350 | WRITE(numout,*) 'oasis_put: kstep ', kstep |
---|
351 | WRITE(numout,*) 'oasis_put: info ', kinfo |
---|
352 | WRITE(numout,*) ' - Minimum value is ', MINVAL(pdata(:,:,jc)) |
---|
353 | WRITE(numout,*) ' - Maximum value is ', MAXVAL(pdata(:,:,jc)) |
---|
354 | WRITE(numout,*) ' - Sum value is ', SUM(pdata(:,:,jc)) |
---|
355 | WRITE(numout,*) '****************' |
---|
356 | ENDIF |
---|
357 | ENDIF |
---|
358 | |
---|
359 | ENDIF |
---|
360 | |
---|
361 | ENDDO |
---|
362 | ENDDO |
---|
363 | ! |
---|
364 | END SUBROUTINE cpl_snd |
---|
365 | |
---|
366 | |
---|
367 | SUBROUTINE cpl_rcv( kid, kstep, pdata, pmask, kinfo ) |
---|
368 | !!--------------------------------------------------------------------- |
---|
369 | !! *** ROUTINE cpl_rcv *** |
---|
370 | !! |
---|
371 | !! ** Purpose : - At each coupling time-step,this routine receives fields |
---|
372 | !! like stresses and fluxes from the coupler or remote application. |
---|
373 | !!---------------------------------------------------------------------- |
---|
374 | INTEGER , INTENT(in ) :: kid ! variable index in the array |
---|
375 | INTEGER , INTENT(in ) :: kstep ! ocean time-step in seconds |
---|
376 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pdata ! IN to keep the value if nothing is done |
---|
377 | REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pmask ! coupling mask |
---|
378 | INTEGER , INTENT( out) :: kinfo ! OASIS3 info argument |
---|
379 | !! |
---|
380 | INTEGER :: jc,jm ! local loop index |
---|
381 | LOGICAL :: llaction, llfisrt |
---|
382 | !!-------------------------------------------------------------------- |
---|
383 | ! |
---|
384 | ! receive local data from OASIS3 on every process |
---|
385 | ! |
---|
386 | kinfo = OASIS_idle |
---|
387 | ! |
---|
388 | DO jc = 1, srcv(kid)%nct |
---|
389 | llfisrt = .TRUE. |
---|
390 | |
---|
391 | DO jm = 1, srcv(kid)%ncplmodel |
---|
392 | |
---|
393 | IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN |
---|
394 | |
---|
395 | CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo ) |
---|
396 | |
---|
397 | llaction = kinfo == OASIS_Recvd .OR. kinfo == OASIS_FromRest .OR. & |
---|
398 | & kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut |
---|
399 | |
---|
400 | IF ( ln_ctl ) WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid(jc,jm) |
---|
401 | |
---|
402 | IF ( llaction ) THEN |
---|
403 | |
---|
404 | kinfo = OASIS_Rcv |
---|
405 | IF( llfisrt ) THEN |
---|
406 | pdata(nldi:nlei,nldj:nlej,jc) = exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm) |
---|
407 | llfisrt = .FALSE. |
---|
408 | ELSE |
---|
409 | pdata(nldi:nlei,nldj:nlej,jc) = pdata(nldi:nlei,nldj:nlej,jc) + exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm) |
---|
410 | ENDIF |
---|
411 | |
---|
412 | IF ( ln_ctl ) THEN |
---|
413 | WRITE(numout,*) '****************' |
---|
414 | WRITE(numout,*) 'oasis_get: Incoming ', srcv(kid)%clname |
---|
415 | WRITE(numout,*) 'oasis_get: ivarid ' , srcv(kid)%nid(jc,jm) |
---|
416 | WRITE(numout,*) 'oasis_get: kstep', kstep |
---|
417 | WRITE(numout,*) 'oasis_get: info ', kinfo |
---|
418 | WRITE(numout,*) ' - Minimum value is ', MINVAL(pdata(:,:,jc)) |
---|
419 | WRITE(numout,*) ' - Maximum value is ', MAXVAL(pdata(:,:,jc)) |
---|
420 | WRITE(numout,*) ' - Sum value is ', SUM(pdata(:,:,jc)) |
---|
421 | WRITE(numout,*) '****************' |
---|
422 | ENDIF |
---|
423 | |
---|
424 | ENDIF |
---|
425 | |
---|
426 | ENDIF |
---|
427 | |
---|
428 | ENDDO |
---|
429 | |
---|
430 | !--- Fill the overlap areas and extra hallows (mpp) |
---|
431 | !--- check periodicity conditions (all cases) |
---|
432 | IF( .not. llfisrt ) CALL lbc_lnk( pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn ) |
---|
433 | |
---|
434 | ENDDO |
---|
435 | ! |
---|
436 | END SUBROUTINE cpl_rcv |
---|
437 | |
---|
438 | |
---|
439 | INTEGER FUNCTION cpl_freq( cdfieldname ) |
---|
440 | !!--------------------------------------------------------------------- |
---|
441 | !! *** ROUTINE cpl_freq *** |
---|
442 | !! |
---|
443 | !! ** Purpose : - send back the coupling frequency for a particular field |
---|
444 | !!---------------------------------------------------------------------- |
---|
445 | CHARACTER(len = *), INTENT(in) :: cdfieldname ! field name as set in namcouple file |
---|
446 | !! |
---|
447 | INTEGER :: id |
---|
448 | INTEGER :: info |
---|
449 | INTEGER, DIMENSION(1) :: itmp |
---|
450 | INTEGER :: ji,jm ! local loop index |
---|
451 | INTEGER :: mop |
---|
452 | !!---------------------------------------------------------------------- |
---|
453 | cpl_freq = 0 ! defaut definition |
---|
454 | id = -1 ! defaut definition |
---|
455 | ! |
---|
456 | DO ji = 1, nsnd |
---|
457 | IF (ssnd(ji)%laction ) THEN |
---|
458 | DO jm = 1, ncplmodel |
---|
459 | IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN |
---|
460 | IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN |
---|
461 | id = ssnd(ji)%nid(1,jm) |
---|
462 | mop = OASIS_Out |
---|
463 | ENDIF |
---|
464 | ENDIF |
---|
465 | ENDDO |
---|
466 | ENDIF |
---|
467 | ENDDO |
---|
468 | DO ji = 1, nrcv |
---|
469 | IF (srcv(ji)%laction ) THEN |
---|
470 | DO jm = 1, ncplmodel |
---|
471 | IF( srcv(ji)%nid(1,jm) /= -1 ) THEN |
---|
472 | IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN |
---|
473 | id = srcv(ji)%nid(1,jm) |
---|
474 | mop = OASIS_In |
---|
475 | ENDIF |
---|
476 | ENDIF |
---|
477 | ENDDO |
---|
478 | ENDIF |
---|
479 | ENDDO |
---|
480 | ! |
---|
481 | IF( id /= -1 ) THEN |
---|
482 | #if defined key_oa3mct_v3 |
---|
483 | CALL oasis_get_freqs(id, mop, 1, itmp, info) |
---|
484 | #else |
---|
485 | CALL oasis_get_freqs(id, 1, itmp, info) |
---|
486 | #endif |
---|
487 | cpl_freq = itmp(1) |
---|
488 | ENDIF |
---|
489 | ! |
---|
490 | END FUNCTION cpl_freq |
---|
491 | |
---|
492 | |
---|
493 | SUBROUTINE cpl_finalize |
---|
494 | !!--------------------------------------------------------------------- |
---|
495 | !! *** ROUTINE cpl_finalize *** |
---|
496 | !! |
---|
497 | !! ** Purpose : - Finalizes the coupling. If MPI_init has not been |
---|
498 | !! called explicitly before cpl_init it will also close |
---|
499 | !! MPI communication. |
---|
500 | !!---------------------------------------------------------------------- |
---|
501 | ! |
---|
502 | DEALLOCATE( exfld ) |
---|
503 | IF (nstop == 0) THEN |
---|
504 | CALL oasis_terminate( nerror ) |
---|
505 | ELSE |
---|
506 | CALL oasis_abort( ncomp_id, "cpl_finalize", "NEMO ABORT STOP" ) |
---|
507 | ENDIF |
---|
508 | ! |
---|
509 | END SUBROUTINE cpl_finalize |
---|
510 | |
---|
511 | #if ! defined key_oasis3 |
---|
512 | |
---|
513 | !!---------------------------------------------------------------------- |
---|
514 | !! No OASIS Library OASIS3 Dummy module... |
---|
515 | !!---------------------------------------------------------------------- |
---|
516 | |
---|
517 | SUBROUTINE oasis_init_comp(k1,cd1,k2) |
---|
518 | CHARACTER(*), INTENT(in ) :: cd1 |
---|
519 | INTEGER , INTENT( out) :: k1,k2 |
---|
520 | k1 = -1 ; k2 = -1 |
---|
521 | WRITE(numout,*) 'oasis_init_comp: Error you sould not be there...', cd1 |
---|
522 | END SUBROUTINE oasis_init_comp |
---|
523 | |
---|
524 | SUBROUTINE oasis_abort(k1,cd1,cd2) |
---|
525 | INTEGER , INTENT(in ) :: k1 |
---|
526 | CHARACTER(*), INTENT(in ) :: cd1,cd2 |
---|
527 | WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2 |
---|
528 | END SUBROUTINE oasis_abort |
---|
529 | |
---|
530 | SUBROUTINE oasis_get_localcomm(k1,k2) |
---|
531 | INTEGER , INTENT( out) :: k1,k2 |
---|
532 | k1 = -1 ; k2 = -1 |
---|
533 | WRITE(numout,*) 'oasis_get_localcomm: Error you sould not be there...' |
---|
534 | END SUBROUTINE oasis_get_localcomm |
---|
535 | |
---|
536 | SUBROUTINE oasis_def_partition(k1,k2,k3,k4) |
---|
537 | INTEGER , INTENT( out) :: k1,k3 |
---|
538 | INTEGER , INTENT(in ) :: k2(5) |
---|
539 | INTEGER, OPTIONAL, INTENT(in ) :: k4 |
---|
540 | k1 = k2(1) ; k3 = k2(5) |
---|
541 | WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...' |
---|
542 | END SUBROUTINE oasis_def_partition |
---|
543 | |
---|
544 | SUBROUTINE oasis_def_var(k1,cd1,k2,k3,k4,k5,k6,k7) |
---|
545 | CHARACTER(*), INTENT(in ) :: cd1 |
---|
546 | INTEGER , INTENT(in ) :: k2,k3(2),k4,k5(2,2),k6 |
---|
547 | INTEGER , INTENT( out) :: k1,k7 |
---|
548 | k1 = -1 ; k7 = -1 |
---|
549 | WRITE(numout,*) 'oasis_def_var: Error you sould not be there...', cd1 |
---|
550 | END SUBROUTINE oasis_def_var |
---|
551 | |
---|
552 | SUBROUTINE oasis_enddef(k1) |
---|
553 | INTEGER , INTENT( out) :: k1 |
---|
554 | k1 = -1 |
---|
555 | WRITE(numout,*) 'oasis_enddef: Error you sould not be there...' |
---|
556 | END SUBROUTINE oasis_enddef |
---|
557 | |
---|
558 | SUBROUTINE oasis_put(k1,k2,p1,k3) |
---|
559 | REAL(wp), DIMENSION(:,:), INTENT(in ) :: p1 |
---|
560 | INTEGER , INTENT(in ) :: k1,k2 |
---|
561 | INTEGER , INTENT( out) :: k3 |
---|
562 | k3 = -1 |
---|
563 | WRITE(numout,*) 'oasis_put: Error you sould not be there...' |
---|
564 | END SUBROUTINE oasis_put |
---|
565 | |
---|
566 | SUBROUTINE oasis_get(k1,k2,p1,k3) |
---|
567 | REAL(wp), DIMENSION(:,:), INTENT( out) :: p1 |
---|
568 | INTEGER , INTENT(in ) :: k1,k2 |
---|
569 | INTEGER , INTENT( out) :: k3 |
---|
570 | p1(1,1) = -1. ; k3 = -1 |
---|
571 | WRITE(numout,*) 'oasis_get: Error you sould not be there...' |
---|
572 | END SUBROUTINE oasis_get |
---|
573 | |
---|
574 | SUBROUTINE oasis_get_freqs(k1,k2,k3,k4) |
---|
575 | INTEGER , INTENT(in ) :: k1,k2 |
---|
576 | INTEGER, DIMENSION(1), INTENT( out) :: k3 |
---|
577 | INTEGER , INTENT( out) :: k4 |
---|
578 | k3(1) = k1 ; k4 = k2 |
---|
579 | WRITE(numout,*) 'oasis_get_freqs: Error you sould not be there...' |
---|
580 | END SUBROUTINE oasis_get_freqs |
---|
581 | |
---|
582 | SUBROUTINE oasis_terminate(k1) |
---|
583 | INTEGER , INTENT( out) :: k1 |
---|
584 | k1 = -1 |
---|
585 | WRITE(numout,*) 'oasis_terminate: Error you sould not be there...' |
---|
586 | END SUBROUTINE oasis_terminate |
---|
587 | |
---|
588 | #endif |
---|
589 | |
---|
590 | !!===================================================================== |
---|
591 | END MODULE cpl_oasis3 |
---|