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

source: branches/UKMO/dev_r5107_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 @ 5284

Last change on this file since 5284 was 5284, checked in by dancopsey, 9 years ago

First attempt to convert OASIS3-MCT branch from NEMO3.5 to NEMO3.6. Original branch was dev/frrh/vn3.5_beta_hadgem3_mct

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