New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
cpl_oasis3.F90 in NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/SBC – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/SBC/cpl_oasis3.F90 @ 10386

Last change on this file since 10386 was 10386, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: safer use of l_full_nf_update (2 lines north fold exchange), see #2133

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