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

source: branches/UKMO/dev_r5518_new_runoff_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 8212

Last change on this file since 8212 was 8212, checked in by dancopsey, 7 years ago

Corrected array.

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