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

source: branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 11883

Last change on this file since 11883 was 11883, checked in by timgraham, 4 years ago

Mergerd in changes from Chris' working copy (except for symlink changes)

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