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

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

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