source: CONFIG_DEVT/IPSLCM6.2.2_ENSEMBLES/config/IPSLCM6/SOURCES/NEMO/cpl_oasis3.F90 @ 6205

Last change on this file since 6205 was 6205, checked in by aclsce, 2 years ago

Forgot some modifications.

File size: 25.9 KB
Line 
1
2MODULE cpl_oasis3
3   !!======================================================================
4   !!                    ***  MODULE cpl_oasis  ***
5   !! Coupled O/A : coupled ocean-atmosphere case using OASIS3-MCT
6   !!=====================================================================
7   !! History :   
8   !!   9.0  !  04-06  (R. Redler, NEC Laboratories Europe, Germany) Original code
9   !!   " "  !  04-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision
10   !!   " "  !  04-11  (V. Gayler, MPI M&D) Grid writing
11   !!   " "  !  05-08  (R. Redler, W. Park) frld initialization, paral(2) revision
12   !!   " "  !  05-09  (R. Redler) extended to allow for communication over root only
13   !!   " "  !  06-01  (W. Park) modification of physical part
14   !!   " "  !  06-02  (R. Redler, W. Park) buffer array fix for root exchange
15   !!   3.4  !  11-11  (C. Harris) Changes to allow mutiple category fields
16   !!----------------------------------------------------------------------
17   !!----------------------------------------------------------------------
18   !!   'key_oasis3'                    coupled Ocean/Atmosphere via OASIS3-MCT
19   !!   'key_oa3mct_v3'                 to be added for OASIS3-MCT version 3
20   !!----------------------------------------------------------------------
21   !!   cpl_init     : initialization of coupled mode communication
22   !!   cpl_define   : definition of grid and fields
23   !!   cpl_snd     : snd out fields in coupled mode
24   !!   cpl_rcv     : receive fields in coupled mode
25   !!   cpl_finalize : finalize the coupled mode communication
26   !!----------------------------------------------------------------------
27#if defined key_oasis3
28   USE mod_oasis                    ! OASIS3-MCT module
29#endif
30   USE par_oce                      ! ocean parameters
31   USE dom_oce                      ! ocean space and time domain
32   USE in_out_manager               ! I/O manager
33   USE lbclnk                       ! ocean lateral boundary conditions (or mpp link)
34   USE xios
35
36   IMPLICIT NONE
37   PRIVATE
38
39   PUBLIC   cpl_init
40   PUBLIC   cpl_define
41   PUBLIC   cpl_snd
42   PUBLIC   cpl_rcv
43   PUBLIC   cpl_freq
44   PUBLIC   cpl_finalize
45
46   INTEGER, PUBLIC            ::   OASIS_Rcv  = 1    !: return code if received field
47   INTEGER, PUBLIC            ::   OASIS_idle = 0    !: return code if nothing done by oasis
48   INTEGER                    ::   ncomp_id          ! id returned by oasis_init_comp
49   INTEGER                    ::   nerror            ! return error code
50#if ! defined key_oasis3
51   ! OASIS Variables not used. defined only for compilation purpose
52   INTEGER                    ::   OASIS_Out         = -1
53   INTEGER                    ::   OASIS_REAL        = -1
54   INTEGER                    ::   OASIS_Ok          = -1
55   INTEGER                    ::   OASIS_In          = -1
56   INTEGER                    ::   OASIS_Sent        = -1
57   INTEGER                    ::   OASIS_SentOut     = -1
58   INTEGER                    ::   OASIS_ToRest      = -1
59   INTEGER                    ::   OASIS_ToRestOut   = -1
60   INTEGER                    ::   OASIS_Recvd       = -1
61   INTEGER                    ::   OASIS_RecvOut     = -1
62   INTEGER                    ::   OASIS_FromRest    = -1
63   INTEGER                    ::   OASIS_FromRestOut = -1
64#endif
65
66   INTEGER                    ::   nrcv         ! total number of fields received
67   INTEGER                    ::   nsnd         ! total number of fields sent
68   INTEGER                    ::   ncplmodel    ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
69   INTEGER, PUBLIC, PARAMETER ::   nmaxfld=50   ! Maximum number of coupling fields
70   INTEGER, PUBLIC, PARAMETER ::   nmaxcat=5    ! Maximum number of coupling fields
71   INTEGER, PUBLIC, PARAMETER ::   nmaxcpl=5    ! Maximum number of coupling fields
72   
73   TYPE, PUBLIC ::   FLD_CPL               !: Type for coupling field information
74      LOGICAL               ::   laction   ! To be coupled or not
75      CHARACTER(len = 8)    ::   clname    ! Name of the coupling field   
76      CHARACTER(len = 1)    ::   clgrid    ! Grid type 
77      REAL(wp)              ::   nsgn      ! Control of the sign change
78      INTEGER, DIMENSION(nmaxcat,nmaxcpl) ::   nid   ! Id of the field (no more than 9 categories and 9 extrena models)
79      INTEGER               ::   nct       ! Number of categories in field
80      INTEGER               ::   ncplmodel ! Maximum number of models to/from which this variable may be sent/received
81   END TYPE FLD_CPL
82
83   TYPE(FLD_CPL), DIMENSION(nmaxfld), PUBLIC ::   srcv, ssnd   !: Coupling fields
84
85   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   exfld   ! Temporary buffer for receiving
86
87   !!----------------------------------------------------------------------
88   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
89   !! $Id: cpl_oasis3.F90 7846 2017-03-30 13:25:01Z cetlod $
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      USE ensemble_oce
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, jpiglo*jpjglo )
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                  IF (ensemble_management) zclname=TRIM(ADJUSTL(zclname))//"__"//TRIM(ADJUSTL(str_ensemble_pool_member_rank)) 
236!                  PRINT*,"oasis_def_var sent ",zclname
237!                  CALL oasis_def_var (ssnd(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
238!                     &                OASIS_Out          , ishape , OASIS_REAL, nerror )
239                  CALL oasis_def_var (ssnd(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
240                     &                OASIS_Out          , OASIS_REAL, nerror )
241                  IF ( nerror /= OASIS_Ok ) THEN
242                     WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname)
243                     CALL oasis_abort ( ssnd(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' )
244                  ENDIF
245                  IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple"
246                  IF( ln_ctl .AND. ssnd(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple"
247               END DO
248            END DO
249         ENDIF
250      END DO
251      !
252      ! ... Announce received variables.
253      !
254      srcv(:)%ncplmodel = kcplmodel
255      !
256      DO ji = 1, krcv
257         IF ( srcv(ji)%laction ) THEN
258           
259            IF( srcv(ji)%nct > nmaxcat ) THEN
260               CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '//   &
261                  &              TRIM(srcv(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' )
262               RETURN
263            ENDIF
264           
265            DO jc = 1, srcv(ji)%nct
266               DO jm = 1, kcplmodel
267                 
268                  IF ( srcv(ji)%nct .GT. 1 ) THEN
269                     WRITE(cli2,'(i2.2)') jc
270                     zclname = TRIM(srcv(ji)%clname)//'_cat'//cli2
271                  ELSE
272                     zclname = srcv(ji)%clname
273                  ENDIF
274                  IF ( kcplmodel  > 1 ) THEN
275                     WRITE(cli2,'(i2.2)') jm
276                     zclname = 'model'//cli2//'_'//TRIM(zclname)
277                  ENDIF
278#if defined key_agrif
279                  IF( agrif_fixed() /= 0 ) THEN
280                     zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname)
281                  END IF
282#endif
283                  IF( ln_ctl ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_In
284                  IF (ensemble_management) zclname=TRIM(ADJUSTL(zclname))//"__"//TRIM(ADJUSTL(str_ensemble_pool_member_rank)) 
285!                  PRINT*,"oasis_def_var recv ",zclname
286!                  CALL oasis_def_var (srcv(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
287!                     &                OASIS_In           , ishape , OASIS_REAL, nerror )
288                  CALL oasis_def_var (srcv(ji)%nid(jc,jm), zclname, id_part   , (/ 2, 0 /),   &
289                     &                OASIS_In           , OASIS_REAL, nerror )
290                  IF ( nerror /= OASIS_Ok ) THEN
291                     WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname)
292                     CALL oasis_abort ( srcv(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' )
293                  ENDIF
294                  IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple"
295                  IF( ln_ctl .AND. srcv(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple"
296
297               END DO
298            END DO
299         ENDIF
300      END DO
301     
302      !------------------------------------------------------------------
303      ! End of definition phase
304      !------------------------------------------------------------------
305     
306      CALL xios_oasis_enddef()
307      CALL oasis_enddef(nerror)
308      IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
309      !
310   END SUBROUTINE cpl_define
311   
312   
313   SUBROUTINE cpl_snd( kid, kstep, pdata, kinfo )
314      !!---------------------------------------------------------------------
315      !!              ***  ROUTINE cpl_snd  ***
316      !!
317      !! ** Purpose : - At each coupling time-step,this routine sends fields
318      !!      like sst or ice cover to the coupler or remote application.
319      !!----------------------------------------------------------------------
320      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
321      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
322      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
323      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdata
324      !!
325      INTEGER                                   ::   jc,jm     ! local loop index
326      !!--------------------------------------------------------------------
327      !
328      ! snd data to OASIS3
329      !
330      DO jc = 1, ssnd(kid)%nct
331         DO jm = 1, ssnd(kid)%ncplmodel
332       
333            IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN
334               CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(nldi:nlei, nldj:nlej,jc), kinfo )
335               
336               IF ( ln_ctl ) THEN       
337                  IF ( kinfo == OASIS_Sent     .OR. kinfo == OASIS_ToRest .OR.   &
338                     & kinfo == OASIS_SentOut  .OR. kinfo == OASIS_ToRestOut ) THEN
339                     WRITE(numout,*) '****************'
340                     WRITE(numout,*) 'oasis_put: Outgoing ', ssnd(kid)%clname
341                     WRITE(numout,*) 'oasis_put: ivarid ', ssnd(kid)%nid(jc,jm)
342                     WRITE(numout,*) 'oasis_put:  kstep ', kstep
343                     WRITE(numout,*) 'oasis_put:   info ', kinfo
344                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(:,:,jc))
345                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(:,:,jc))
346                     WRITE(numout,*) '     -     Sum value is ', SUM(pdata(:,:,jc))
347                     WRITE(numout,*) '****************'
348                  ENDIF
349               ENDIF
350               
351            ENDIF
352           
353         ENDDO
354      ENDDO
355      !
356    END SUBROUTINE cpl_snd
357
358
359   SUBROUTINE cpl_rcv( kid, kstep, pdata, pmask, kinfo )
360      !!---------------------------------------------------------------------
361      !!              ***  ROUTINE cpl_rcv  ***
362      !!
363      !! ** Purpose : - At each coupling time-step,this routine receives fields
364      !!      like stresses and fluxes from the coupler or remote application.
365      !!----------------------------------------------------------------------
366      INTEGER                   , INTENT(in   ) ::   kid       ! variable index in the array
367      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
368      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdata     ! IN to keep the value if nothing is done
369      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pmask     ! coupling mask
370      INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
371      !!
372      INTEGER                                   ::   jc,jm     ! local loop index
373      LOGICAL                                   ::   llaction, llfisrt
374      !!--------------------------------------------------------------------
375      !
376      ! receive local data from OASIS3 on every process
377      !
378      kinfo = OASIS_idle
379      !
380      DO jc = 1, srcv(kid)%nct
381         llfisrt = .TRUE.
382
383         DO jm = 1, srcv(kid)%ncplmodel
384
385            IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN
386
387               CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )         
388               
389               llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   &
390                  &        kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut
391               
392               IF ( ln_ctl )   WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid(jc,jm)
393               
394               IF ( llaction ) THEN
395                 
396                  kinfo = OASIS_Rcv
397                  IF( llfisrt ) THEN
398                     pdata(nldi:nlei,nldj:nlej,jc) =                                 exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)
399                     llfisrt = .FALSE.
400                  ELSE
401                     pdata(nldi:nlei,nldj:nlej,jc) = pdata(nldi:nlei,nldj:nlej,jc) + exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)
402                  ENDIF
403                 
404                  IF ( ln_ctl ) THEN       
405                     WRITE(numout,*) '****************'
406                     WRITE(numout,*) 'oasis_get: Incoming ', srcv(kid)%clname
407                     WRITE(numout,*) 'oasis_get: ivarid '  , srcv(kid)%nid(jc,jm)
408                     WRITE(numout,*) 'oasis_get:   kstep', kstep
409                     WRITE(numout,*) 'oasis_get:   info ', kinfo
410                     WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata(:,:,jc))
411                     WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata(:,:,jc))
412                     WRITE(numout,*) '     -     Sum value is ', SUM(pdata(:,:,jc))
413                     WRITE(numout,*) '****************'
414                  ENDIF
415                 
416               ENDIF
417               
418            ENDIF
419           
420         ENDDO
421
422         !--- Fill the overlap areas and extra hallows (mpp)
423         !--- check periodicity conditions (all cases)
424         IF( .not. llfisrt )   CALL lbc_lnk( pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn )   
425 
426      ENDDO
427      !
428   END SUBROUTINE cpl_rcv
429
430
431   INTEGER FUNCTION cpl_freq( cdfieldname ) 
432      !!---------------------------------------------------------------------
433      !!              ***  ROUTINE cpl_freq  ***
434      !!
435      !! ** Purpose : - send back the coupling frequency for a particular field
436      !!----------------------------------------------------------------------
437      CHARACTER(len = *), INTENT(in) ::   cdfieldname    ! field name as set in namcouple file
438      !!
439      INTEGER               :: id
440      INTEGER               :: info
441      INTEGER, DIMENSION(1) :: itmp
442      INTEGER               :: ji,jm     ! local loop index
443      INTEGER               :: mop
444      !!----------------------------------------------------------------------
445      cpl_freq = 0   ! defaut definition
446      id = -1        ! defaut definition
447      !
448      DO ji = 1, nsnd
449         IF (ssnd(ji)%laction ) THEN
450            DO jm = 1, ncplmodel
451               IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN
452                  IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN
453                     id = ssnd(ji)%nid(1,jm)
454                     mop = OASIS_Out
455                  ENDIF
456               ENDIF
457            ENDDO
458         ENDIF
459      ENDDO
460      DO ji = 1, nrcv
461         IF (srcv(ji)%laction ) THEN
462            DO jm = 1, ncplmodel
463               IF( srcv(ji)%nid(1,jm) /= -1 ) THEN
464                  IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN
465                     id = srcv(ji)%nid(1,jm)
466                     mop = OASIS_In
467                  ENDIF
468               ENDIF
469            ENDDO
470         ENDIF
471      ENDDO
472      !
473      IF( id /= -1 ) THEN
474#if defined key_oa3mct_v3
475         CALL oasis_get_freqs(id, mop, 1, itmp, info)
476#else
477         CALL oasis_get_freqs(id,      1, itmp, info)
478#endif
479         cpl_freq = itmp(1)
480      ENDIF
481      !
482   END FUNCTION cpl_freq
483
484
485   SUBROUTINE cpl_finalize
486      !!---------------------------------------------------------------------
487      !!              ***  ROUTINE cpl_finalize  ***
488      !!
489      !! ** Purpose : - Finalizes the coupling. If MPI_init has not been
490      !!      called explicitly before cpl_init it will also close
491      !!      MPI communication.
492      !!----------------------------------------------------------------------
493      !
494      DEALLOCATE( exfld )
495      IF (nstop == 0) THEN
496         CALL oasis_terminate( nerror )         
497      ELSE
498         CALL oasis_abort( ncomp_id, "cpl_finalize", "NEMO ABORT STOP" )
499      ENDIF       
500      !
501   END SUBROUTINE cpl_finalize
502
503#if ! defined key_oasis3
504
505   !!----------------------------------------------------------------------
506   !!   No OASIS Library          OASIS3 Dummy module...
507   !!----------------------------------------------------------------------
508
509   SUBROUTINE oasis_init_comp(k1,cd1,k2)
510      CHARACTER(*), INTENT(in   ) ::  cd1
511      INTEGER     , INTENT(  out) ::  k1,k2
512      k1 = -1 ; k2 = -1
513      WRITE(numout,*) 'oasis_init_comp: Error you sould not be there...', cd1
514   END SUBROUTINE oasis_init_comp
515
516   SUBROUTINE oasis_abort(k1,cd1,cd2)
517      INTEGER     , INTENT(in   ) ::  k1
518      CHARACTER(*), INTENT(in   ) ::  cd1,cd2
519      WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2
520   END SUBROUTINE oasis_abort
521
522   SUBROUTINE oasis_get_localcomm(k1,k2)
523      INTEGER     , INTENT(  out) ::  k1,k2
524      k1 = -1 ; k2 = -1
525      WRITE(numout,*) 'oasis_get_localcomm: Error you sould not be there...'
526   END SUBROUTINE oasis_get_localcomm
527
528   SUBROUTINE oasis_def_partition(k1,k2,k3,k4)
529      INTEGER     , INTENT(  out) ::  k1,k3
530      INTEGER     , INTENT(in   ) ::  k2(5)
531      INTEGER     , INTENT(in   ) ::  k4
532      k1 = k2(1) ; k3 = k2(5)+k4
533      WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...'
534   END SUBROUTINE oasis_def_partition
535
536   SUBROUTINE oasis_def_var(k1,cd1,k2,k3,k4,k5,k6,k7)
537      CHARACTER(*), INTENT(in   ) ::  cd1
538      INTEGER     , INTENT(in   ) ::  k2,k3(2),k4,k5(2,2),k6
539      INTEGER     , INTENT(  out) ::  k1,k7
540      k1 = -1 ; k7 = -1
541      WRITE(numout,*) 'oasis_def_var: Error you sould not be there...', cd1
542   END SUBROUTINE oasis_def_var
543
544   SUBROUTINE oasis_enddef(k1)
545      INTEGER     , INTENT(  out) ::  k1
546      k1 = -1
547      WRITE(numout,*) 'oasis_enddef: Error you sould not be there...'
548   END SUBROUTINE oasis_enddef
549 
550   SUBROUTINE oasis_put(k1,k2,p1,k3)
551      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::  p1
552      INTEGER                 , INTENT(in   ) ::  k1,k2
553      INTEGER                 , INTENT(  out) ::  k3
554      k3 = -1
555      WRITE(numout,*) 'oasis_put: Error you sould not be there...'
556   END SUBROUTINE oasis_put
557
558   SUBROUTINE oasis_get(k1,k2,p1,k3)
559      REAL(wp), DIMENSION(:,:), INTENT(  out) ::  p1
560      INTEGER                 , INTENT(in   ) ::  k1,k2
561      INTEGER                 , INTENT(  out) ::  k3
562      p1(1,1) = -1. ; k3 = -1
563      WRITE(numout,*) 'oasis_get: Error you sould not be there...'
564   END SUBROUTINE oasis_get
565
566   SUBROUTINE oasis_get_freqs(k1,k2,k3,k4)
567      INTEGER              , INTENT(in   ) ::  k1,k2
568      INTEGER, DIMENSION(1), INTENT(  out) ::  k3
569      INTEGER              , INTENT(  out) ::  k4
570      k3(1) = k1 ; k4 = k2
571      WRITE(numout,*) 'oasis_get_freqs: Error you sould not be there...'
572   END SUBROUTINE oasis_get_freqs
573
574   SUBROUTINE oasis_terminate(k1)
575      INTEGER     , INTENT(  out) ::  k1
576      k1 = -1
577      WRITE(numout,*) 'oasis_terminate: Error you sould not be there...'
578   END SUBROUTINE oasis_terminate
579   
580#endif
581
582   !!=====================================================================
583END MODULE cpl_oasis3
Note: See TracBrowser for help on using the repository browser.