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/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/SBC – NEMO

source: NEMO/branches/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/SBC/cpl_oasis3.F90 @ 15540

Last change on this file since 15540 was 15540, checked in by sparonuz, 3 years ago

Mixed precision version, tested up to 30 years on ORCA2.

  • Property svn:keywords set to Id
File size: 25.6 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   INTEGER, PUBLIC            ::   OASIS_Rcv  = 1    !: return code if received field
46   INTEGER, PUBLIC            ::   OASIS_idle = 0    !: return code if nothing done by oasis
47   INTEGER                    ::   ncomp_id          ! id returned by oasis_init_comp
48   INTEGER                    ::   nerror            ! return error code
49#if ! defined key_oasis3
50   ! OASIS Variables not used. defined only for compilation purpose
51   INTEGER                    ::   OASIS_Out         = -1
52   INTEGER                    ::   OASIS_REAL        = -1
53   INTEGER                    ::   OASIS_Ok          = -1
54   INTEGER                    ::   OASIS_In          = -1
55   INTEGER                    ::   OASIS_Sent        = -1
56   INTEGER                    ::   OASIS_SentOut     = -1
57   INTEGER                    ::   OASIS_ToRest      = -1
58   INTEGER                    ::   OASIS_ToRestOut   = -1
59   INTEGER                    ::   OASIS_Recvd       = -1
60   INTEGER                    ::   OASIS_RecvOut     = -1
61   INTEGER                    ::   OASIS_FromRest    = -1
62   INTEGER                    ::   OASIS_FromRestOut = -1
63#endif
64
65   INTEGER                    ::   nrcv         ! total number of fields received
66   INTEGER                    ::   nsnd         ! total number of fields sent
67   INTEGER                    ::   ncplmodel    ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
68   INTEGER, PUBLIC, PARAMETER ::   nmaxfld=62   ! Maximum number of coupling fields
69   INTEGER, PUBLIC, PARAMETER ::   nmaxcat=5    ! Maximum number of coupling fields
70   INTEGER, PUBLIC, PARAMETER ::   nmaxcpl=5    ! Maximum number of coupling fields
71
72   TYPE, PUBLIC ::   FLD_CPL               !: Type for coupling field information
73      LOGICAL               ::   laction   ! To be coupled or not
74      CHARACTER(len = 8)    ::   clname    ! Name of the coupling field
75      CHARACTER(len = 1)    ::   clgrid    ! Grid type
76      REAL(dp)              ::   nsgn      ! Control of the sign change
77      INTEGER, DIMENSION(nmaxcat,nmaxcpl) ::   nid   ! Id of the field (no more than 9 categories and 9 extrena models)
78      INTEGER               ::   nct       ! Number of categories in field
79      INTEGER               ::   ncplmodel ! Maximum number of models to/from which this variable may be sent/received
80   END TYPE FLD_CPL
81
82   TYPE(FLD_CPL), DIMENSION(nmaxfld), PUBLIC ::   srcv, ssnd   !: Coupling fields
83
84   REAL(dp), DIMENSION(:,:), ALLOCATABLE ::   exfld   ! Temporary buffer for receiving
85
86   !!----------------------------------------------------------------------
87   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
88   !! $Id$
89   !! Software governed by the CeCILL license (see ./LICENSE)
90   !!----------------------------------------------------------------------
91#  include "single_precision_substitute.h90"
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 oasis_enddef(nerror)
301      IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
302#if defined key_agrif
303      ENDIF
304#endif
305      !
306   END SUBROUTINE cpl_define
307
308
309   SUBROUTINE cpl_snd( kid, kstep, pdata, kinfo )
310      !!---------------------------------------------------------------------
311      !!              ***  ROUTINE cpl_snd  ***
312      !!
313      !! ** Purpose : - At each coupling time-step,this routine sends fields
314      !!      like sst or ice cover to the coupler or remote application.
315      !!----------------------------------------------------------------------
316      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
317      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
318      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
319      REAL(dp), DIMENSION(:,:,:), INTENT(in   ) ::   pdata
320      !!
321      INTEGER                                   ::   jc,jm     ! local loop index
322      !!--------------------------------------------------------------------
323      !
324      ! snd data to OASIS3
325      !
326      DO jc = 1, ssnd(kid)%nct
327         DO jm = 1, ssnd(kid)%ncplmodel
328
329            IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN   ! exclude halos from data sent to oasis
330               CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(Nis0:Nie0, Njs0:Nje0,jc), kinfo )
331
332               IF ( sn_cfctl%l_oasout ) THEN
333                  IF ( kinfo == OASIS_Sent     .OR. kinfo == OASIS_ToRest .OR.   &
334                     & kinfo == OASIS_SentOut  .OR. kinfo == OASIS_ToRestOut ) THEN
335                     WRITE(numout,*) '****************'
336                     WRITE(numout,*) 'oasis_put: Outgoing ', ssnd(kid)%clname
337                     WRITE(numout,*) 'oasis_put: ivarid ', ssnd(kid)%nid(jc,jm)
338                     WRITE(numout,*) 'oasis_put:  kstep ', kstep
339                     WRITE(numout,*) 'oasis_put:   info ', kinfo
340                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc))
341                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc))
342                     WRITE(numout,*) '     -     Sum value is ',    SUM(pdata(Nis0:Nie0,Njs0:Nje0,jc))
343                     WRITE(numout,*) '****************'
344                  ENDIF
345               ENDIF
346
347            ENDIF
348
349         ENDDO
350      ENDDO
351      !
352    END SUBROUTINE cpl_snd
353
354
355   SUBROUTINE cpl_rcv( kid, kstep, pdata, pmask, kinfo )
356      !!---------------------------------------------------------------------
357      !!              ***  ROUTINE cpl_rcv  ***
358      !!
359      !! ** Purpose : - At each coupling time-step,this routine receives fields
360      !!      like stresses and fluxes from the coupler or remote application.
361      !!----------------------------------------------------------------------
362      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
363      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
364      REAL(dp), DIMENSION(:,:,:), INTENT(inout) ::   pdata     ! IN to keep the value if nothing is done
365      REAL(dp), DIMENSION(:,:,:), INTENT(in   ) ::   pmask     ! coupling mask
366      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
367      !!
368      INTEGER                                   ::   jc,jm     ! local loop index
369      LOGICAL                                   ::   llaction, ll_1st
370      !!--------------------------------------------------------------------
371      !
372      ! receive local data from OASIS3 on every process
373      !
374      kinfo = OASIS_idle
375      !
376      DO jc = 1, srcv(kid)%nct
377         ll_1st = .TRUE.
378
379         DO jm = 1, srcv(kid)%ncplmodel
380
381            IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN
382
383               CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )
384
385               llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   &
386                  &        kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut
387
388               IF ( sn_cfctl%l_oasout )   &
389                  &  WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid(jc,jm)
390
391               IF( llaction ) THEN   ! data received from oasis do not include halos
392
393                  kinfo = OASIS_Rcv
394                  IF( ll_1st ) THEN
395                     pdata(Nis0:Nie0,Njs0:Nje0,jc) =   exfld(:,:) * pmask(Nis0:Nie0,Njs0:Nje0,jm)
396                     ll_1st = .FALSE.
397                  ELSE
398                     pdata(Nis0:Nie0,Njs0:Nje0,jc) = pdata(Nis0:Nie0,Njs0:Nje0,jc)   &
399                        &                                + exfld(:,:) * pmask(Nis0:Nie0,Njs0:Nje0,jm)
400                  ENDIF
401
402                  IF ( sn_cfctl%l_oasout ) THEN
403                     WRITE(numout,*) '****************'
404                     WRITE(numout,*) 'oasis_get: Incoming ', srcv(kid)%clname
405                     WRITE(numout,*) 'oasis_get: ivarid '  , srcv(kid)%nid(jc,jm)
406                     WRITE(numout,*) 'oasis_get:   kstep', kstep
407                     WRITE(numout,*) 'oasis_get:   info ', kinfo
408                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc))
409                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc))
410                     WRITE(numout,*) '     -     Sum value is ',    SUM(pdata(Nis0:Nie0,Njs0:Nje0,jc))
411                     WRITE(numout,*) '****************'
412                  ENDIF
413
414               ENDIF
415
416            ENDIF
417
418         ENDDO
419
420         !--- we must call lbc_lnk to fill the halos that where not received.
421         IF( .NOT. ll_1st ) THEN
422            CALL lbc_lnk( 'cpl_oasis3', pdata(:,:,jc), srcv(kid)%clgrid, CASTSP(srcv(kid)%nsgn) )
423         ENDIF
424
425      ENDDO
426      !
427   END SUBROUTINE cpl_rcv
428
429
430   INTEGER FUNCTION cpl_freq( cdfieldname )
431      !!---------------------------------------------------------------------
432      !!              ***  ROUTINE cpl_freq  ***
433      !!
434      !! ** Purpose : - send back the coupling frequency for a particular field
435      !!----------------------------------------------------------------------
436      CHARACTER(len = *), INTENT(in) ::   cdfieldname    ! field name as set in namcouple file
437      !!
438      INTEGER               :: id
439      INTEGER               :: info
440      INTEGER, DIMENSION(1) :: itmp
441      INTEGER               :: ji,jm     ! local loop index
442      INTEGER               :: mop
443      !!----------------------------------------------------------------------
444      cpl_freq = 0   ! defaut definition
445      id = -1        ! defaut definition
446      !
447      DO ji = 1, nsnd
448         IF(ssnd(ji)%laction ) THEN
449            DO jm = 1, ncplmodel
450               IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN
451                  IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN
452                     id = ssnd(ji)%nid(1,jm)
453                     mop = OASIS_Out
454                  ENDIF
455               ENDIF
456            ENDDO
457         ENDIF
458      ENDDO
459      DO ji = 1, nrcv
460         IF(srcv(ji)%laction ) THEN
461            DO jm = 1, ncplmodel
462               IF( srcv(ji)%nid(1,jm) /= -1 ) THEN
463                  IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN
464                     id = srcv(ji)%nid(1,jm)
465                     mop = OASIS_In
466                  ENDIF
467               ENDIF
468            ENDDO
469         ENDIF
470      ENDDO
471      !
472      IF( id /= -1 ) THEN
473#if ! defined key_oa3mct_v1v2
474         CALL oasis_get_freqs(id, mop, 1, itmp, info)
475#else
476         CALL oasis_get_freqs(id,      1, itmp, info)
477#endif
478         cpl_freq = itmp(1)
479      ENDIF
480      !
481   END FUNCTION cpl_freq
482
483
484   SUBROUTINE cpl_finalize
485      !!---------------------------------------------------------------------
486      !!              ***  ROUTINE cpl_finalize  ***
487      !!
488      !! ** Purpose : - Finalizes the coupling. If MPI_init has not been
489      !!      called explicitly before cpl_init it will also close
490      !!      MPI communication.
491      !!----------------------------------------------------------------------
492      !
493      DEALLOCATE( exfld )
494      IF(nstop == 0) THEN
495         CALL oasis_terminate( nerror )
496      ELSE
497         CALL oasis_abort( ncomp_id, "cpl_finalize", "NEMO ABORT STOP" )
498      ENDIF
499      !
500   END SUBROUTINE cpl_finalize
501
502#if ! defined key_oasis3
503
504   !!----------------------------------------------------------------------
505   !!   No OASIS Library          OASIS3 Dummy module...
506   !!----------------------------------------------------------------------
507
508   SUBROUTINE oasis_init_comp(k1,cd1,k2)
509      CHARACTER(*), INTENT(in   ) ::  cd1
510      INTEGER     , INTENT(  out) ::  k1,k2
511      k1 = -1 ; k2 = -1
512      WRITE(numout,*) 'oasis_init_comp: Error you sould not be there...', cd1
513   END SUBROUTINE oasis_init_comp
514
515   SUBROUTINE oasis_abort(k1,cd1,cd2)
516      INTEGER     , INTENT(in   ) ::  k1
517      CHARACTER(*), INTENT(in   ) ::  cd1,cd2
518      WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2
519   END SUBROUTINE oasis_abort
520
521   SUBROUTINE oasis_get_localcomm(k1,k2)
522      INTEGER     , INTENT(  out) ::  k1,k2
523      k1 = -1 ; k2 = -1
524      WRITE(numout,*) 'oasis_get_localcomm: Error you sould not be there...'
525   END SUBROUTINE oasis_get_localcomm
526
527   SUBROUTINE oasis_def_partition(k1,k2,k3,k4)
528      INTEGER     , INTENT(  out) ::  k1,k3
529      INTEGER     , INTENT(in   ) ::  k2(5)
530      INTEGER     , INTENT(in   ) ::  k4
531      k1 = k2(1) ; k3 = k2(5)+k4
532      WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...'
533   END SUBROUTINE oasis_def_partition
534
535   SUBROUTINE oasis_def_var(k1,cd1,k2,k3,k4,k5,k6,k7)
536      CHARACTER(*), INTENT(in   ) ::  cd1
537      INTEGER     , INTENT(in   ) ::  k2,k3(2),k4,k5(2,2),k6
538      INTEGER     , INTENT(  out) ::  k1,k7
539      k1 = -1 ; k7 = -1
540      WRITE(numout,*) 'oasis_def_var: Error you sould not be there...', cd1
541   END SUBROUTINE oasis_def_var
542
543   SUBROUTINE oasis_enddef(k1)
544      INTEGER     , INTENT(  out) ::  k1
545      k1 = -1
546      WRITE(numout,*) 'oasis_enddef: Error you sould not be there...'
547   END SUBROUTINE oasis_enddef
548
549   SUBROUTINE oasis_put(k1,k2,p1,k3)
550      REAL(dp), DIMENSION(:,:), INTENT(in   ) ::  p1
551      INTEGER                 , INTENT(in   ) ::  k1,k2
552      INTEGER                 , INTENT(  out) ::  k3
553      k3 = -1
554      WRITE(numout,*) 'oasis_put: Error you sould not be there...'
555   END SUBROUTINE oasis_put
556
557   SUBROUTINE oasis_get(k1,k2,p1,k3)
558      REAL(dp), DIMENSION(:,:), INTENT(  out) ::  p1
559      INTEGER                 , INTENT(in   ) ::  k1,k2
560      INTEGER                 , INTENT(  out) ::  k3
561      p1(1,1) = -1. ; k3 = -1
562      WRITE(numout,*) 'oasis_get: Error you sould not be there...'
563   END SUBROUTINE oasis_get
564
565   SUBROUTINE oasis_get_freqs(k1,k5,k2,k3,k4)
566      INTEGER              , INTENT(in   ) ::  k1,k2
567      INTEGER, DIMENSION(1), INTENT(  out) ::  k3
568      INTEGER              , INTENT(  out) ::  k4,k5
569      k3(1) = k1 ; k4 = k2 ; k5 = k2
570      WRITE(numout,*) 'oasis_get_freqs: Error you sould not be there...'
571   END SUBROUTINE oasis_get_freqs
572
573   SUBROUTINE oasis_terminate(k1)
574      INTEGER     , INTENT(  out) ::  k1
575      k1 = -1
576      WRITE(numout,*) 'oasis_terminate: Error you sould not be there...'
577   END SUBROUTINE oasis_terminate
578
579#endif
580
581   !!=====================================================================
582END MODULE cpl_oasis3
Note: See TracBrowser for help on using the repository browser.