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_r8183_GC_couple_pkg/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_r8183_GC_couple_pkg/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 8731

Last change on this file since 8731 was 8731, checked in by dancopsey, 6 years ago

Merged in NEMO3.6 version of this branch (dev_r5518_GC3_couple_pkg)

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