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 branches/UKMO/dev_merge_2017_GC_couple_pkg/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_merge_2017_GC_couple_pkg/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 9968

Last change on this file since 9968 was 9968, checked in by timgraham, 6 years ago

Correction to fix in cpl_oasis3.F90

File size: 27.3 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
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/OPA 3.3 , NEMO Consortium (2010)
103   !! $Id$
104   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
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(2,2)    ! 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      INTEGER          ::   nldi_save, nlei_save
162      INTEGER          ::   nldj_save, nlej_save
163      !!--------------------------------------------------------------------
164
165      IF(lwp) WRITE(numout,*)
166      IF(lwp) WRITE(numout,*) 'cpl_define : initialization in coupled ocean/atmosphere case'
167      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
168      IF(lwp) WRITE(numout,*)
169
170      ncplmodel = kcplmodel
171      IF( kcplmodel > nmaxcpl ) THEN
172         CALL oasis_abort ( ncomp_id, 'cpl_define', 'ncplmodel is larger than nmaxcpl, increase nmaxcpl')   ;   RETURN
173      ENDIF
174
175      nrcv = krcv
176      IF( nrcv > nmaxfld ) THEN
177         CALL oasis_abort ( ncomp_id, 'cpl_define', 'nrcv is larger than nmaxfld, increase nmaxfld')   ;   RETURN
178      ENDIF
179
180      nsnd = ksnd
181      IF( nsnd > nmaxfld ) THEN
182         CALL oasis_abort ( ncomp_id, 'cpl_define', 'nsnd is larger than nmaxfld, increase nmaxfld')   ;   RETURN
183      ENDIF
184
185      nldi_save = nldi   ;   nlei_save = nlei
186      nldj_save = nldj   ;   nlej_save = nlej
187      IF( nimpp           ==      1 ) nldi = 1
188      IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
189      IF( njmpp           ==      1 ) nldj = 1
190      IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
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, nlei-nldi+1 /)
197      ishape(:,2) = (/ 1, nlej-nldj+1 /)
198      !
199      ! ... Allocate memory for data exchange
200      !
201      ALLOCATE(exfld(nlei-nldi+1, nlej-nldj+1), stat = nerror)
202      IF( nerror > 0 ) THEN
203         CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld')   ;   RETURN
204      ENDIF
205      !
206      ! -----------------------------------------------------------------
207      ! ... Define the partition
208      ! -----------------------------------------------------------------
209     
210      paral(1) = 2                                              ! box partitioning
211      paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset   
212      paral(3) = nlei-nldi+1                                    ! local extent in i
213      paral(4) = nlej-nldj+1                                    ! local extent in j
214      paral(5) = jpiglo                                         ! global extent in x
215     
216      IF( ln_ctl ) THEN
217         WRITE(numout,*) ' multiexchg: paral (1:5)', paral
218         WRITE(numout,*) ' multiexchg: jpi, jpj =', jpi, jpj
219         WRITE(numout,*) ' multiexchg: nldi, nlei, nimpp =', nldi, nlei, nimpp
220         WRITE(numout,*) ' multiexchg: nldj, nlej, njmpp =', nldj, nlej, njmpp
221      ENDIF
222   
223      CALL oasis_def_partition ( id_part, paral, nerror, jpiglo*jpjglo )
224      !
225      ! ... Announce send variables.
226      !
227      ssnd(:)%ncplmodel = kcplmodel
228      !
229      DO ji = 1, ksnd
230         IF ( ssnd(ji)%laction ) THEN
231
232            IF( ssnd(ji)%nct > nmaxcat ) THEN
233               CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '//   &
234                  &              TRIM(ssnd(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' )
235               RETURN
236            ENDIF
237           
238            DO jc = 1, ssnd(ji)%nct
239               DO jm = 1, kcplmodel
240
241                  IF ( ssnd(ji)%nct .GT. 1 ) THEN
242                     WRITE(cli2,'(i2.2)') jc
243                     zclname = TRIM(ssnd(ji)%clname)//'_cat'//cli2
244                  ELSE
245                     zclname = ssnd(ji)%clname
246                  ENDIF
247                  IF ( kcplmodel  > 1 ) THEN
248                     WRITE(cli2,'(i2.2)') jm
249                     zclname = 'model'//cli2//'_'//TRIM(zclname)
250                  ENDIF
251#if defined key_agrif
252                  IF( agrif_fixed() /= 0 ) THEN
253                     zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname)
254                  END IF
255#endif
256                  IF( ln_ctl ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_Out
257                  CALL oasis_def_var (ssnd(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
258                     &                OASIS_Out          , ishape , OASIS_REAL, nerror )
259                  IF ( nerror /= OASIS_Ok ) THEN
260                     WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname)
261                     CALL oasis_abort ( ssnd(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' )
262                  ENDIF
263                  IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple"
264                  IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple"
265               END DO
266            END DO
267         ENDIF
268      END DO
269      !
270      ! ... Announce received variables.
271      !
272      srcv(:)%ncplmodel = kcplmodel
273      !
274      DO ji = 1, krcv
275         IF ( srcv(ji)%laction ) THEN
276           
277            IF( srcv(ji)%nct > nmaxcat ) THEN
278               CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '//   &
279                  &              TRIM(srcv(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' )
280               RETURN
281            ENDIF
282           
283            DO jc = 1, srcv(ji)%nct
284               DO jm = 1, kcplmodel
285                 
286                  IF ( srcv(ji)%nct .GT. 1 ) THEN
287                     WRITE(cli2,'(i2.2)') jc
288                     zclname = TRIM(srcv(ji)%clname)//'_cat'//cli2
289                  ELSE
290                     zclname = srcv(ji)%clname
291                  ENDIF
292                  IF ( kcplmodel  > 1 ) THEN
293                     WRITE(cli2,'(i2.2)') jm
294                     zclname = 'model'//cli2//'_'//TRIM(zclname)
295                  ENDIF
296#if defined key_agrif
297                  IF( agrif_fixed() /= 0 ) THEN
298                     zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname)
299                  END IF
300#endif
301                  IF( ln_ctl ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_In
302                  CALL oasis_def_var (srcv(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
303                     &                OASIS_In           , ishape , OASIS_REAL, nerror )
304                  IF ( nerror /= OASIS_Ok ) THEN
305                     WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname)
306                     CALL oasis_abort ( srcv(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' )
307                  ENDIF
308                  IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple"
309                  IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple"
310
311               END DO
312            END DO
313         ENDIF
314      END DO
315     
316      !------------------------------------------------------------------
317      ! End of definition phase
318      !------------------------------------------------------------------
319     
320      CALL oasis_enddef(nerror)
321      IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
322
323      nldi = nldi_save   ;   nlei = nlei_save
324      nldj = nldj_save   ;   nlej = nlej_save
325
326      !
327   END SUBROUTINE cpl_define
328   
329   
330   SUBROUTINE cpl_snd( kid, kstep, pdata, kinfo )
331      !!---------------------------------------------------------------------
332      !!              ***  ROUTINE cpl_snd  ***
333      !!
334      !! ** Purpose : - At each coupling time-step,this routine sends fields
335      !!      like sst or ice cover to the coupler or remote application.
336      !!----------------------------------------------------------------------
337      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
338      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
339      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
340      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdata
341      !!
342      INTEGER                                   ::   jc,jm     ! local loop index
343      INTEGER                                   ::   nldi_save, nlei_save
344      INTEGER                                   ::   nldj_save, nlej_save
345      !!--------------------------------------------------------------------
346      !
347      ! snd data to OASIS3
348     
349
350      nldi_save = nldi   ;   nlei_save = nlei
351      nldj_save = nldj   ;   nlej_save = nlej
352      IF( nimpp           ==      1 ) nldi = 1
353      IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
354      IF( njmpp           ==      1 ) nldj = 1
355      IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
356      DO jc = 1, ssnd(kid)%nct
357         DO jm = 1, ssnd(kid)%ncplmodel
358       
359            IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN
360               CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(nldi:nlei, nldj:nlej,jc), kinfo )
361               
362               IF ( ln_ctl ) THEN       
363                  IF ( kinfo == OASIS_Sent     .OR. kinfo == OASIS_ToRest .OR.   &
364                     & kinfo == OASIS_SentOut  .OR. kinfo == OASIS_ToRestOut ) THEN
365                     WRITE(numout,*) '****************'
366                     WRITE(numout,*) 'oasis_put: Outgoing ', ssnd(kid)%clname
367                     WRITE(numout,*) 'oasis_put: ivarid ', ssnd(kid)%nid(jc,jm)
368                     WRITE(numout,*) 'oasis_put:  kstep ', kstep
369                     WRITE(numout,*) 'oasis_put:   info ', kinfo
370                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(:,:,jc))
371                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(:,:,jc))
372                     WRITE(numout,*) '     -     Sum value is ', SUM(pdata(:,:,jc))
373                     WRITE(numout,*) '****************'
374                  ENDIF
375               ENDIF
376               
377            ENDIF
378           
379         ENDDO
380      ENDDO
381      nldi = nldi_save   ;   nlei = nlei_save
382      nldj = nldj_save   ;   nlej = nlej_save
383      !
384    END SUBROUTINE cpl_snd
385
386
387   SUBROUTINE cpl_rcv( kid, kstep, pdata, pmask, kinfo )
388      !!---------------------------------------------------------------------
389      !!              ***  ROUTINE cpl_rcv  ***
390      !!
391      !! ** Purpose : - At each coupling time-step,this routine receives fields
392      !!      like stresses and fluxes from the coupler or remote application.
393      !!----------------------------------------------------------------------
394      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
395      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
396      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdata     ! IN to keep the value if nothing is done
397      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pmask     ! coupling mask
398      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
399      !!
400      INTEGER                                   ::   jc,jm     ! local loop index
401      LOGICAL                                   ::   llaction, llfisrt
402      INTEGER                                   ::   nldi_save, nlei_save
403      INTEGER                                   ::   nldj_save, nlej_save
404      !!--------------------------------------------------------------------
405      !
406      ! receive local data from OASIS3 on every process
407      !
408      kinfo = OASIS_idle
409      !
410      nldi_save = nldi   ;   nlei_save = nlei
411      nldj_save = nldj   ;   nlej_save = nlej
412     
413      DO jc = 1, srcv(kid)%nct
414
415         IF( nimpp           ==      1 ) nldi = 1
416         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
417         IF( njmpp           ==      1 ) nldj = 1
418         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
419         llfisrt = .TRUE.
420
421         DO jm = 1, srcv(kid)%ncplmodel
422
423            IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN
424
425               CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )   
426               
427               llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   &
428                  &        kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut
429               
430               IF ( ln_ctl )   WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid(jc,jm)
431               
432               IF ( llaction ) THEN
433                 
434                  kinfo = OASIS_Rcv
435                  IF( llfisrt ) THEN
436                     pdata(nldi:nlei,nldj:nlej,jc) =                                 exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)
437                     llfisrt = .FALSE.
438                  ELSE
439                     pdata(nldi:nlei,nldj:nlej,jc) = pdata(nldi:nlei,nldj:nlej,jc) + exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)
440                  ENDIF
441                 
442                  IF ( ln_ctl ) THEN       
443                     WRITE(numout,*) '****************'
444                     WRITE(numout,*) 'oasis_get: Incoming ', srcv(kid)%clname
445                     WRITE(numout,*) 'oasis_get: ivarid '  , srcv(kid)%nid(jc,jm)
446                     WRITE(numout,*) 'oasis_get:   kstep', kstep
447                     WRITE(numout,*) 'oasis_get:   info ', kinfo
448                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(:,:,jc))
449                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(:,:,jc))
450                     WRITE(numout,*) '     -     Sum value is ', SUM(pdata(:,:,jc))
451                     WRITE(numout,*) '****************'
452                     CALL FLUSH(numout)
453                  ENDIF
454                 
455               ENDIF
456               
457            ENDIF
458           
459         ENDDO
460         nldi = nldi_save   ;   nlei = nlei_save
461         nldj = nldj_save   ;   nlej = nlej_save
462
463         !--- Fill the overlap areas and extra hallows (mpp)
464         !--- check periodicity conditions (all cases)
465         IF( .not. llfisrt )   CALL lbc_lnk( pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn )   
466 
467      ENDDO
468      !
469   END SUBROUTINE cpl_rcv
470
471
472   INTEGER FUNCTION cpl_freq( cdfieldname ) 
473      !!---------------------------------------------------------------------
474      !!              ***  ROUTINE cpl_freq  ***
475      !!
476      !! ** Purpose : - send back the coupling frequency for a particular field
477      !!----------------------------------------------------------------------
478      CHARACTER(len = *), INTENT(in) ::   cdfieldname    ! field name as set in namcouple file
479      !!
480      INTEGER               :: id
481      INTEGER               :: info
482      INTEGER, DIMENSION(1) :: itmp
483      INTEGER               :: ji,jm     ! local loop index
484      INTEGER               :: mop
485      !!----------------------------------------------------------------------
486      cpl_freq = 0   ! defaut definition
487      id = -1        ! defaut definition
488      !
489      DO ji = 1, nsnd
490         IF (ssnd(ji)%laction ) THEN
491            DO jm = 1, ncplmodel
492               IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN
493                  IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN
494                     id = ssnd(ji)%nid(1,jm)
495                     mop = OASIS_Out
496                  ENDIF
497               ENDIF
498            ENDDO
499         ENDIF
500      ENDDO
501      DO ji = 1, nrcv
502         IF (srcv(ji)%laction ) THEN
503            DO jm = 1, ncplmodel
504               IF( srcv(ji)%nid(1,jm) /= -1 ) THEN
505                  IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN
506                     id = srcv(ji)%nid(1,jm)
507                     mop = OASIS_In
508                  ENDIF
509               ENDIF
510            ENDDO
511         ENDIF
512      ENDDO
513      !
514      IF( id /= -1 ) THEN
515#if defined key_oa3mct_v3
516         CALL oasis_get_freqs(id, mop, 1, itmp, info)
517#else
518!         CALL oasis_get_freqs(id,      1, itmp, info)
519         cpl_freq = namflddti( id )
520#endif
521      ENDIF
522      !
523   END FUNCTION cpl_freq
524
525
526   SUBROUTINE cpl_finalize
527      !!---------------------------------------------------------------------
528      !!              ***  ROUTINE cpl_finalize  ***
529      !!
530      !! ** Purpose : - Finalizes the coupling. If MPI_init has not been
531      !!      called explicitly before cpl_init it will also close
532      !!      MPI communication.
533      !!----------------------------------------------------------------------
534      !
535      DEALLOCATE( exfld )
536      IF (nstop == 0) THEN
537         CALL oasis_terminate( nerror )         
538      ELSE
539         CALL oasis_abort( ncomp_id, "cpl_finalize", "NEMO ABORT STOP" )
540      ENDIF       
541      !
542   END SUBROUTINE cpl_finalize
543
544#if ! defined key_oasis3
545
546   !!----------------------------------------------------------------------
547   !!   No OASIS Library          OASIS3 Dummy module...
548   !!----------------------------------------------------------------------
549
550   SUBROUTINE oasis_init_comp(k1,cd1,k2)
551      CHARACTER(*), INTENT(in   ) ::  cd1
552      INTEGER     , INTENT(  out) ::  k1,k2
553      k1 = -1 ; k2 = -1
554      WRITE(numout,*) 'oasis_init_comp: Error you sould not be there...', cd1
555   END SUBROUTINE oasis_init_comp
556
557   SUBROUTINE oasis_abort(k1,cd1,cd2)
558      INTEGER     , INTENT(in   ) ::  k1
559      CHARACTER(*), INTENT(in   ) ::  cd1,cd2
560      WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2
561   END SUBROUTINE oasis_abort
562
563   SUBROUTINE oasis_get_localcomm(k1,k2)
564      INTEGER     , INTENT(  out) ::  k1,k2
565      k1 = -1 ; k2 = -1
566      WRITE(numout,*) 'oasis_get_localcomm: Error you sould not be there...'
567   END SUBROUTINE oasis_get_localcomm
568
569   SUBROUTINE oasis_def_partition(k1,k2,k3,k4)
570      INTEGER     , INTENT(  out) ::  k1,k3
571      INTEGER     , INTENT(in   ) ::  k2(5)
572      INTEGER     , INTENT(in   ) ::  k4
573      k1 = k2(1) ; k3 = k2(5)+k4
574      WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...'
575   END SUBROUTINE oasis_def_partition
576
577   SUBROUTINE oasis_def_var(k1,cd1,k2,k3,k4,k5,k6,k7)
578      CHARACTER(*), INTENT(in   ) ::  cd1
579      INTEGER     , INTENT(in   ) ::  k2,k3(2),k4,k5(2,2),k6
580      INTEGER     , INTENT(  out) ::  k1,k7
581      k1 = -1 ; k7 = -1
582      WRITE(numout,*) 'oasis_def_var: Error you sould not be there...', cd1
583   END SUBROUTINE oasis_def_var
584
585   SUBROUTINE oasis_enddef(k1)
586      INTEGER     , INTENT(  out) ::  k1
587      k1 = -1
588      WRITE(numout,*) 'oasis_enddef: Error you sould not be there...'
589   END SUBROUTINE oasis_enddef
590 
591   SUBROUTINE oasis_put(k1,k2,p1,k3)
592      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::  p1
593      INTEGER                 , INTENT(in   ) ::  k1,k2
594      INTEGER                 , INTENT(  out) ::  k3
595      k3 = -1
596      WRITE(numout,*) 'oasis_put: Error you sould not be there...'
597   END SUBROUTINE oasis_put
598
599   SUBROUTINE oasis_get(k1,k2,p1,k3)
600      REAL(wp), DIMENSION(:,:), INTENT(  out) ::  p1
601      INTEGER                 , INTENT(in   ) ::  k1,k2
602      INTEGER                 , INTENT(  out) ::  k3
603      p1(1,1) = -1. ; k3 = -1
604      WRITE(numout,*) 'oasis_get: Error you sould not be there...'
605   END SUBROUTINE oasis_get
606
607   SUBROUTINE oasis_get_freqs(k1,k2,k3,k4)
608      INTEGER              , INTENT(in   ) ::  k1,k2
609      INTEGER, DIMENSION(1), INTENT(  out) ::  k3
610      INTEGER              , INTENT(  out) ::  k4
611      k3(1) = k1 ; k4 = k2
612      WRITE(numout,*) 'oasis_get_freqs: Error you sould not be there...'
613   END SUBROUTINE oasis_get_freqs
614
615   SUBROUTINE oasis_terminate(k1)
616      INTEGER     , INTENT(  out) ::  k1
617      k1 = -1
618      WRITE(numout,*) 'oasis_terminate: Error you sould not be there...'
619   END SUBROUTINE oasis_terminate
620   
621#endif
622
623   !!=====================================================================
624END MODULE cpl_oasis3
Note: See TracBrowser for help on using the repository browser.