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 @ 9918

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

Fix for wraparound points in coupling (to be added to trunk as well).

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