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

Last change on this file since 8820 was 8820, checked in by dancopsey, 6 years ago

Output information for every processor.

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