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/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/SBC – NEMO

source: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/SBC/cpl_oasis3.F90 @ 11105

Last change on this file since 11105 was 11105, checked in by dancopsey, 5 years ago

Merged in changes from dev_merge_2017_GC_couple_pkg branch except for zotx1 and zoty1 changes in sbccpl.F90.

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