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.
Changeset 5989 for branches/2014/dev_r4650_UKMO10_Tidally_Meaned_Diagnostics/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90 – NEMO

Ignore:
Timestamp:
2015-12-03T09:10:32+01:00 (8 years ago)
Author:
deazer
Message:

Merging TMB and 25h diagnostics to head of trunk
added brief documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4650_UKMO10_Tidally_Meaned_Diagnostics/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90

    r5260 r5989  
    44   !! Coupled O/A : coupled ocean-atmosphere case using OASIS3-MCT 
    55   !!===================================================================== 
    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 
     6   !! History :  1.0  !  2004-06  (R. Redler, NEC Laboratories Europe, Germany) Original code 
     7   !!             -   !  2004-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision 
     8   !!             -   !  2004-11  (V. Gayler, MPI M&D) Grid writing 
     9   !!            2.0  !  2005-08  (R. Redler, W. Park) frld initialization, paral(2) revision 
     10   !!             -   !  2005-09  (R. Redler) extended to allow for communication over root only 
     11   !!             -   !  2006-01  (W. Park) modification of physical part 
     12   !!             -   !  2006-02  (R. Redler, W. Park) buffer array fix for root exchange 
     13   !!            3.4  !  2011-11  (C. Harris) Changes to allow mutiple category fields 
     14   !!            3.6  !  2014-11  (S. Masson) OASIS3-MCT 
     15   !!---------------------------------------------------------------------- 
     16    
     17   !!---------------------------------------------------------------------- 
     18   !!   'key_oasis3'                    coupled Ocean/Atmosphere via OASIS3-MCT 
     19   !!   'key_oa3mct_v3'                 to be added for OASIS3-MCT version 3 
    1820   !!---------------------------------------------------------------------- 
    1921   !!   cpl_init     : initialization of coupled mode communication 
    2022   !!   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_snd      : snd out fields in coupled mode 
     24   !!   cpl_rcv      : receive fields in coupled mode 
    2325   !!   cpl_finalize : finalize the coupled mode communication 
    2426   !!---------------------------------------------------------------------- 
     
    6163#endif 
    6264 
    63    INTEGER, PUBLIC, PARAMETER ::   nmaxfld=40        ! Maximum number of coupling fields 
     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 
    6469   INTEGER, PUBLIC, PARAMETER ::   nmaxcat=5    ! Maximum number of coupling fields 
    6570   INTEGER, PUBLIC, PARAMETER ::   nmaxcpl=5    ! Maximum number of coupling fields 
     
    8691CONTAINS 
    8792 
    88    SUBROUTINE cpl_init( kl_comm ) 
     93   SUBROUTINE cpl_init( cd_modname, kl_comm ) 
    8994      !!------------------------------------------------------------------- 
    9095      !!             ***  ROUTINE cpl_init  *** 
     
    95100      !! ** Method  :   OASIS3 MPI communication  
    96101      !!-------------------------------------------------------------------- 
    97       INTEGER, INTENT(out) ::   kl_comm   ! local communicator of the model 
     102      CHARACTER(len = *), INTENT(in   ) ::   cd_modname   ! model name as set in namcouple file 
     103      INTEGER           , INTENT(  out) ::   kl_comm      ! local communicator of the model 
    98104      !!-------------------------------------------------------------------- 
    99105 
     
    104110      ! 1st Initialize the OASIS system for the application 
    105111      !------------------------------------------------------------------ 
    106       CALL oasis_init_comp ( ncomp_id, 'oceanx', nerror ) 
     112      CALL oasis_init_comp ( ncomp_id, TRIM(cd_modname), nerror ) 
    107113      IF ( nerror /= OASIS_Ok ) & 
    108114         CALL oasis_abort (ncomp_id, 'cpl_init', 'Failure in oasis_init_comp') 
     
    144150      IF(lwp) WRITE(numout,*) 
    145151 
     152      ncplmodel = kcplmodel 
    146153      IF( kcplmodel > nmaxcpl ) THEN 
    147          CALL oasis_abort ( ncomp_id, 'cpl_define', 'kcplmodel is larger than nmaxcpl, increase nmaxcpl')   ;   RETURN 
     154         CALL oasis_abort ( ncomp_id, 'cpl_define', 'ncplmodel is larger than nmaxcpl, increase nmaxcpl')   ;   RETURN 
     155      ENDIF 
     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 
    148165      ENDIF 
    149166      ! 
     
    400417 
    401418 
    402    INTEGER FUNCTION cpl_freq( kid 
     419   INTEGER FUNCTION cpl_freq( cdfieldname 
    403420      !!--------------------------------------------------------------------- 
    404421      !!              ***  ROUTINE cpl_freq  *** 
     
    406423      !! ** Purpose : - send back the coupling frequency for a particular field 
    407424      !!---------------------------------------------------------------------- 
    408       INTEGER,INTENT(in) ::   kid   ! variable index 
    409       !! 
     425      CHARACTER(len = *), INTENT(in) ::   cdfieldname    ! field name as set in namcouple file 
     426      !! 
     427      INTEGER               :: id 
    410428      INTEGER               :: info 
    411429      INTEGER, DIMENSION(1) :: itmp 
     430      INTEGER               :: ji,jm     ! local loop index 
     431      INTEGER               :: mop 
    412432      !!---------------------------------------------------------------------- 
    413       CALL oasis_get_freqs(kid, 1, itmp, info) 
    414       cpl_freq = itmp(1) 
     433      cpl_freq = 0   ! defaut definition 
     434      id = -1        ! defaut definition 
     435      ! 
     436      DO ji = 1, nsnd 
     437         IF (ssnd(ji)%laction ) THEN 
     438            DO jm = 1, ncplmodel 
     439               IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN 
     440                  IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN 
     441                     id = ssnd(ji)%nid(1,jm) 
     442                     mop = OASIS_Out 
     443                  ENDIF 
     444               ENDIF 
     445            ENDDO 
     446         ENDIF 
     447      ENDDO 
     448      DO ji = 1, nrcv 
     449         IF (srcv(ji)%laction ) THEN 
     450            DO jm = 1, ncplmodel 
     451               IF( srcv(ji)%nid(1,jm) /= -1 ) THEN 
     452                  IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN 
     453                     id = srcv(ji)%nid(1,jm) 
     454                     mop = OASIS_In 
     455                  ENDIF 
     456               ENDIF 
     457            ENDDO 
     458         ENDIF 
     459      ENDDO 
     460      ! 
     461      IF( id /= -1 ) THEN 
     462#if defined key_oa3mct_v3 
     463         CALL oasis_get_freqs(id, mop, 1, itmp, info) 
     464#else 
     465         CALL oasis_get_freqs(id,      1, itmp, info) 
     466#endif 
     467         cpl_freq = itmp(1) 
     468      ENDIF 
    415469      ! 
    416470   END FUNCTION cpl_freq 
Note: See TracChangeset for help on using the changeset viewer.