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