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

source: branches/UKMO/dev_r5518_MO_couple_package/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 6546

Last change on this file since 6546 was 6546, checked in by frrh, 8 years ago

Commit final changes relating to manual addition of relevant code
from fcm:NEMO.xm/branches/UKMO/dev_r5107_hadgem3_mct@6355.

Note this is a subset of the total changnes... I have ecluded those which
have become or appear redundant or unnecessary.

This version bit compares with the original.

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