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

Last change on this file since 11446 was 11446, checked in by timgraham, 5 years ago

Remove OASIS3 legacy code from cpl_oasis.F90. Tested to not change results.

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