source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/config/IPSLCM6/SOURCES/NEMO/cpl_oasis3.F90 @ 5901

Last change on this file since 5901 was 5866, checked in by ymipsl, 3 years ago

Adapt NEMO to ensemble management.

Yann

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