source: CONFIG/UNIFORM/v6/IPSLCM6.5.1/SOURCES/NEMO/cpl_oasis3.F90 @ 6152

Last change on this file since 6152 was 6152, checked in by cetlod, 2 years ago

CM65_work : minor improvments

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