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 6140 for trunk/NEMOGCM/NEMO/OPA_SRC/LBC – NEMO

Ignore:
Timestamp:
2015-12-21T12:35:23+01:00 (8 years ago)
Author:
timgraham
Message:

Merge of branches/2015/dev_merge_2015 back into trunk. Merge excludes NEMOGCM/TOOLS/OBSTOOLS/ for now due to issues with the change of file type. Will sort these manually with further commits.

Branch merged as follows:
In the working copy of branch ran:
svn merge svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk@HEAD
Small conflicts due to bug fixes applied to trunk since the dev_merge_2015 was copied. Bug fixes were applied to the branch as well so these were easy to resolve.
Branch committed at this stage

In working copy run:
svn switch svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk
to switch working copy

Run:
svn merge --reintegrate svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2015/dev_merge_2015
to merge the branch into the trunk and then commit - no conflicts at this stage.

Location:
trunk/NEMOGCM/NEMO/OPA_SRC/LBC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90

    r5429 r6140  
    44   !! Ocean        : lateral boundary conditions 
    55   !!===================================================================== 
    6    !! History :  OPA  ! 1997-06  (G. Madec)     Original code 
    7    !!   NEMO     1.0  ! 2002-09  (G. Madec)     F90: Free form and module 
     6   !! History :  OPA  ! 1997-06  (G. Madec)  Original code 
     7   !!   NEMO     1.0  ! 2002-09  (G. Madec)  F90: Free form and module 
    88   !!            3.2  ! 2009-03  (R. Benshila)  External north fold treatment   
    9    !!            3.5  ! 2012     (S.Mocavero, I. Epicoco) Add 'lbc_bdy_lnk'  
    10    !!                            and lbc_obc_lnk' routine to optimize   
    11    !!                            the BDY/OBC communications 
    12    !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add a C1D case   
     9   !!            3.5  ! 2012     (S.Mocavero, I. Epicoco) optimization of BDY comm. via lbc_bdy_lnk and lbc_obc_lnk 
     10   !!            3.4  ! 2012-12  (R. Bourdalle-Badie, G. Reffray)  add a C1D case   
    1311   !!---------------------------------------------------------------------- 
    1412#if defined key_mpp_mpi 
     
    1715   !!---------------------------------------------------------------------- 
    1816   !!   lbc_lnk      : generic interface for mpp_lnk_3d and mpp_lnk_2d routines defined in lib_mpp 
     17   !!   lbc_sum      : generic interface for mpp_lnk_sum_3d and mpp_lnk_sum_2d routines defined in lib_mpp 
    1918   !!   lbc_lnk_e    : generic interface for mpp_lnk_2d_e routine defined in lib_mpp 
    2019   !!   lbc_bdy_lnk  : generic interface for mpp_lnk_bdy_2d and mpp_lnk_bdy_3d routines defined in lib_mpp 
    2120   !!---------------------------------------------------------------------- 
    22    USE lib_mpp          ! distributed memory computing library 
    23  
     21   USE lib_mpp        ! distributed memory computing library 
    2422 
    2523   INTERFACE lbc_lnk_multi 
    2624      MODULE PROCEDURE mpp_lnk_2d_9 
    2725   END INTERFACE 
    28  
     26   ! 
    2927   INTERFACE lbc_lnk 
    3028      MODULE PROCEDURE mpp_lnk_3d_gather, mpp_lnk_3d, mpp_lnk_2d 
    3129   END INTERFACE 
     30   ! 
     31!JMM interface not defined if not key_mpp_mpi : likely do not compile without this CPP key !!!! 
     32   INTERFACE lbc_sum 
     33      MODULE PROCEDURE mpp_lnk_sum_3d, mpp_lnk_sum_2d 
     34   END INTERFACE 
    3235 
    3336   INTERFACE lbc_bdy_lnk 
    3437      MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d 
    3538   END INTERFACE 
    36  
     39   ! 
    3740   INTERFACE lbc_lnk_e 
    3841      MODULE PROCEDURE mpp_lnk_2d_e 
    3942   END INTERFACE 
    40  
     43   ! 
    4144   INTERFACE lbc_lnk_icb 
    4245      MODULE PROCEDURE mpp_lnk_2d_icb 
    4346   END INTERFACE 
    4447 
    45    PUBLIC lbc_lnk       ! ocean lateral boundary conditions 
    46    PUBLIC lbc_lnk_multi ! modified ocean lateral boundary conditions 
    47    PUBLIC lbc_lnk_e 
    48    PUBLIC lbc_bdy_lnk   ! ocean lateral BDY boundary conditions 
    49    PUBLIC lbc_lnk_icb 
     48   PUBLIC   lbc_lnk       ! ocean lateral boundary conditions 
     49   PUBLIC   lbc_lnk_multi ! modified ocean lateral boundary conditions 
     50   PUBLIC   lbc_sum 
     51   PUBLIC   lbc_lnk_e     ! 
     52   PUBLIC   lbc_bdy_lnk   ! ocean lateral BDY boundary conditions 
     53   PUBLIC   lbc_lnk_icb   ! 
    5054 
    5155   !!---------------------------------------------------------------------- 
     
    5458   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    5559   !!---------------------------------------------------------------------- 
    56  
    5760#else 
    5861   !!---------------------------------------------------------------------- 
    5962   !!   Default option                              shared memory computing 
    6063   !!---------------------------------------------------------------------- 
    61    !!   lbc_lnk      : generic interface for lbc_lnk_3d and lbc_lnk_2d 
    62    !!   lbc_lnk_3d   : set the lateral boundary condition on a 3D variable on ocean mesh 
    63    !!   lbc_lnk_2d   : set the lateral boundary condition on a 2D variable on ocean mesh 
    64    !!   lbc_bdy_lnk  : set the lateral BDY boundary condition 
     64   !!   lbc_sum       : generic interface for mpp_lnk_sum_3d and mpp_lnk_sum_2d  
     65   !!   lbc_lnk_sum_3d: compute sum over the halos on a 3D variable on ocean mesh 
     66   !!   lbc_lnk_sum_3d: compute sum over the halos on a 2D variable on ocean mesh 
     67   !!   lbc_lnk       : generic interface for lbc_lnk_3d and lbc_lnk_2d 
     68   !!   lbc_lnk_3d    : set the lateral boundary condition on a 3D variable on ocean mesh 
     69   !!   lbc_lnk_2d    : set the lateral boundary condition on a 2D variable on ocean mesh 
     70   !!   lbc_bdy_lnk   : set the lateral BDY boundary condition 
    6571   !!---------------------------------------------------------------------- 
    6672   USE oce             ! ocean dynamics and tracers    
     
    7581      MODULE PROCEDURE lbc_lnk_3d_gather, lbc_lnk_3d, lbc_lnk_2d 
    7682   END INTERFACE 
     83   ! 
     84   INTERFACE lbc_sum 
     85      MODULE PROCEDURE mpp_lnk_sum_3d, mpp_lnk_sum_2d 
     86   END INTERFACE 
    7787 
    7888   INTERFACE lbc_lnk_e 
    7989      MODULE PROCEDURE lbc_lnk_2d_e 
    8090   END INTERFACE 
    81  
     91   ! 
    8292   INTERFACE lbc_bdy_lnk 
    8393      MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d 
    8494   END INTERFACE 
    85  
     95   ! 
    8696   INTERFACE lbc_lnk_icb 
    8797      MODULE PROCEDURE lbc_lnk_2d_e 
     
    8999 
    90100   PUBLIC   lbc_lnk       ! ocean/ice  lateral boundary conditions 
    91    PUBLIC   lbc_lnk_e  
     101   PUBLIC   lbc_lnk_e     ! 
    92102   PUBLIC   lbc_bdy_lnk   ! ocean lateral BDY boundary conditions 
    93    PUBLIC   lbc_lnk_icb 
     103   PUBLIC   lbc_lnk_icb   ! 
    94104    
    95105   !!---------------------------------------------------------------------- 
    96    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     106   !! NEMO/OPA 3.7 , NEMO Consortium (2015) 
    97107   !! $Id$ 
    98108   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    230240         ! this is in mpp case. In this module, just do nothing 
    231241      ELSE 
    232          ! 
    233242         !                                     !  East-West boundaries 
    234243         !                                     ! ====================== 
     
    249258            ! 
    250259         END SELECT 
    251          ! 
    252260         !                                     ! North-South boundaries 
    253261         !                                     ! ====================== 
     
    287295   END SUBROUTINE lbc_lnk_3d 
    288296 
     297 
    289298   SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval ) 
    290299      !!--------------------------------------------------------------------- 
     
    316325         ! this is in mpp case. In this module, just do nothing 
    317326      ELSE       
    318          ! 
    319327         !                                     ! East-West boundaries 
    320328         !                                     ! ==================== 
     
    335343            ! 
    336344         END SELECT 
    337          ! 
    338345         !                                     ! North-South boundaries 
    339346         !                                     ! ====================== 
     
    375382#endif 
    376383 
    377  
    378384   SUBROUTINE lbc_bdy_lnk_3d( pt3d, cd_type, psgn, ib_bdy ) 
    379385      !!--------------------------------------------------------------------- 
     
    381387      !! 
    382388      !! ** Purpose :   wrapper rountine to 'lbc_lnk_3d'. This wrapper is used 
    383       !!                to maintain the same interface with regards to the mpp 
    384       !case 
    385       !! 
    386       !!---------------------------------------------------------------------- 
    387       CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points 
    388       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied 
    389       REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign  
    390       INTEGER                                                   ::   ib_bdy    ! BDY boundary set 
    391       !! 
     389      !!              to maintain the same interface with regards to the mpp case 
     390      !! 
     391      !!---------------------------------------------------------------------- 
     392      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points 
     393      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d      ! 3D array on which the lbc is applied 
     394      REAL(wp)                        , INTENT(in   ) ::   psgn      ! control of the sign  
     395      INTEGER                         , INTENT(in   ) ::   ib_bdy    ! BDY boundary set 
     396      !!---------------------------------------------------------------------- 
     397      ! 
    392398      CALL lbc_lnk_3d( pt3d, cd_type, psgn) 
    393  
     399      ! 
    394400   END SUBROUTINE lbc_bdy_lnk_3d 
    395401 
     402 
    396403   SUBROUTINE lbc_bdy_lnk_2d( pt2d, cd_type, psgn, ib_bdy ) 
    397404      !!--------------------------------------------------------------------- 
     
    399406      !! 
    400407      !! ** Purpose :   wrapper rountine to 'lbc_lnk_3d'. This wrapper is used 
    401       !!                to maintain the same interface with regards to the mpp 
    402       !case 
    403       !! 
    404       !!---------------------------------------------------------------------- 
    405       CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points 
    406       REAL(wp), DIMENSION(jpi,jpj),     INTENT(inout)           ::   pt2d      ! 3D array on which the lbc is applied 
    407       REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign  
    408       INTEGER                                                   ::   ib_bdy    ! BDY boundary set 
    409       !! 
     408      !!              to maintain the same interface with regards to the mpp case 
     409      !! 
     410      !!---------------------------------------------------------------------- 
     411      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points 
     412      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d      ! 3D array on which the lbc is applied 
     413      REAL(wp)                    , INTENT(in   ) ::   psgn      ! control of the sign  
     414      INTEGER                     , INTENT(in   ) ::   ib_bdy    ! BDY boundary set 
     415      !!---------------------------------------------------------------------- 
     416      ! 
    410417      CALL lbc_lnk_2d( pt2d, cd_type, psgn) 
    411  
     418      ! 
    412419   END SUBROUTINE lbc_bdy_lnk_2d 
    413420 
     
    426433      !!                             for closed boundaries. 
    427434      !!---------------------------------------------------------------------- 
    428       CHARACTER(len=1)            , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points 
    429       REAL(wp), DIMENSION(jpi,jpj), INTENT(inout)           ::   pt2d      ! 2D array on which the lbc is applied 
    430       REAL(wp)                    , INTENT(in   )           ::   psgn      ! control of the sign  
    431       INTEGER                     , INTENT(in   )           ::   jpri      ! size of extra halo (not needed in non-mpp) 
    432       INTEGER                     , INTENT(in   )           ::   jprj      ! size of extra halo (not needed in non-mpp) 
    433       !!---------------------------------------------------------------------- 
    434  
     435      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points 
     436      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d      ! 2D array on which the lbc is applied 
     437      REAL(wp)                    , INTENT(in   ) ::   psgn      ! control of the sign  
     438      INTEGER                     , INTENT(in   ) ::   jpri      ! size of extra halo (not needed in non-mpp) 
     439      INTEGER                     , INTENT(in   ) ::   jprj      ! size of extra halo (not needed in non-mpp) 
     440      !!---------------------------------------------------------------------- 
     441      ! 
    435442      CALL lbc_lnk_2d( pt2d, cd_type, psgn ) 
    436443      !     
  • trunk/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90

    r4686 r6140  
    2424      MODULE PROCEDURE   lbc_nfd_3d, lbc_nfd_2d 
    2525   END INTERFACE 
    26  
    27    PUBLIC   lbc_nfd   ! north fold conditions 
     26   ! 
    2827   INTERFACE mpp_lbc_nfd 
    2928      MODULE PROCEDURE   mpp_lbc_nfd_3d, mpp_lbc_nfd_2d 
    3029   END INTERFACE 
    3130 
    32    PUBLIC   mpp_lbc_nfd   ! north fold conditions in parallel case 
    33  
    34    INTEGER, PUBLIC,  PARAMETER :: jpmaxngh = 3 
    35    INTEGER, PUBLIC                                  ::   nsndto, nfsloop, nfeloop 
    36    INTEGER, PUBLIC,  DIMENSION (jpmaxngh)           ::   isendto ! processes to which communicate 
    37  
    38  
     31   PUBLIC   lbc_nfd       ! north fold conditions 
     32   PUBLIC   mpp_lbc_nfd   ! north fold conditions (parallel case) 
     33 
     34   INTEGER, PUBLIC, PARAMETER            ::   jpmaxngh = 3               !: 
     35   INTEGER, PUBLIC                       ::   nsndto, nfsloop, nfeloop   !: 
     36   INTEGER, PUBLIC, DIMENSION (jpmaxngh) ::   isendto                    !: processes to which communicate 
    3937 
    4038   !!---------------------------------------------------------------------- 
     
    391389      REAL(wp)                  , INTENT(in   ) ::   psgn      ! control of the sign change 
    392390      !                                                        !   = -1. , the sign is changed if north fold boundary 
    393       !                                                        !   =  1. , the sign is kept  if north fold boundary 
    394       REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pt3dl      ! 3D array on which the boundary condition is applied 
    395       REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   pt3dr      ! 3D array on which the boundary condition is applied 
     391      !                                                        !   =  1. , the sign is kept    if north fold boundary 
     392      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pt3dl     ! 3D array on which the boundary condition is applied 
     393      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt3dr     ! 3D array on which the boundary condition is applied 
    396394      ! 
    397395      INTEGER  ::   ji, jk 
    398396      INTEGER  ::   ijt, iju, ijpj, ijpjm1, ijta, ijua, jia, startloop, endloop 
    399397      !!---------------------------------------------------------------------- 
    400  
     398      ! 
    401399      SELECT CASE ( jpni ) 
    402400      CASE ( 1 )     ;   ijpj = nlcj      ! 1 proc only  along the i-direction 
     
    657655      !                                                      !   = -1. , the sign is changed if north fold boundary 
    658656      !                                                      !   =  1. , the sign is kept  if north fold boundary 
    659       REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2dl      ! 2D array on which the boundary condition is applied 
    660       REAL(wp), DIMENSION(:,:), INTENT(in) ::   pt2dr      ! 2D array on which the boundary condition is applied 
     657      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2dl     ! 2D array on which the boundary condition is applied 
     658      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   pt2dr     ! 2D array on which the boundary condition is applied 
    661659      ! 
    662660      INTEGER  ::   ji 
     
    970968   END SUBROUTINE mpp_lbc_nfd_2d 
    971969 
     970   !!====================================================================== 
    972971END MODULE lbcnfd 
  • trunk/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90

    r5836 r6140  
    2323   !!                          the mppobc routine to optimize the BDY and OBC communications 
    2424   !!            3.5  !  2013  ( C. Ethe, G. Madec ) message passing arrays as local variables  
    25    !!            3.5  !  2013 (S.Mocavero, I.Epicoco - CMCC) north fold optimizations 
     25   !!            3.5  !  2013  (S.Mocavero, I.Epicoco - CMCC) north fold optimizations 
    2626   !!---------------------------------------------------------------------- 
    2727 
    2828   !!---------------------------------------------------------------------- 
    29    !!   ctl_stop   : update momentum and tracer Kz from a tke scheme 
    30    !!   ctl_warn   : initialization, namelist read, and parameters control 
    31    !!   ctl_opn    : Open file and check if required file is available. 
    32    !!   ctl_nam    : Prints informations when an error occurs while reading a namelist 
    33    !!   get_unit   : give the index of an unused logical unit 
     29   !!   ctl_stop      : update momentum and tracer Kz from a tke scheme 
     30   !!   ctl_warn      : initialization, namelist read, and parameters control 
     31   !!   ctl_opn       : Open file and check if required file is available. 
     32   !!   ctl_nam       : Prints informations when an error occurs while reading a namelist 
     33   !!   get_unit      : give the index of an unused logical unit 
    3434   !!---------------------------------------------------------------------- 
    3535#if   defined key_mpp_mpi 
     
    4343   !!   mpp_lnk_e     : interface (defined in lbclnk) for message passing of 2d array with extra halo (mpp_lnk_2d_e) 
    4444   !!   mpp_lnk_icb   : interface for message passing of 2d arrays with extra halo for icebergs (mpp_lnk_2d_icb) 
    45    !!   mpprecv         : 
     45   !!   mpprecv       : 
    4646   !!   mppsend       :   SUBROUTINE mpp_ini_znl 
    4747   !!   mppscatter    : 
     
    7272   PUBLIC   mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e 
    7373   PUBLIC   mpp_lnk_2d_9  
     74   PUBLIC   mpp_lnk_sum_3d, mpp_lnk_sum_2d 
    7475   PUBLIC   mppscatter, mppgather 
    7576   PUBLIC   mpp_ini_ice, mpp_ini_znl 
     
    9495   END INTERFACE 
    9596   INTERFACE mpp_sum 
    96       MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real, & 
     97      MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real,   & 
    9798                       mppsum_realdd, mppsum_a_realdd 
    9899   END INTERFACE 
     
    175176      !! ** Purpose :   Find processor unit 
    176177      !!---------------------------------------------------------------------- 
    177       CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt 
    178       CHARACTER(len=*)             , INTENT(in   ) ::   ldname 
    179       INTEGER                      , INTENT(in   ) ::   kumnam_ref     ! logical unit for reference namelist 
    180       INTEGER                      , INTENT(in   ) ::   kumnam_cfg     ! logical unit for configuration namelist 
    181       INTEGER                      , INTENT(inout) ::   kumond         ! logical unit for namelist output 
    182       INTEGER                      , INTENT(inout) ::   kstop          ! stop indicator 
    183       INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm 
     178      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt        ! 
     179      CHARACTER(len=*)             , INTENT(in   ) ::   ldname       ! 
     180      INTEGER                      , INTENT(in   ) ::   kumnam_ref   ! logical unit for reference namelist 
     181      INTEGER                      , INTENT(in   ) ::   kumnam_cfg   ! logical unit for configuration namelist 
     182      INTEGER                      , INTENT(inout) ::   kumond       ! logical unit for namelist output 
     183      INTEGER                      , INTENT(inout) ::   kstop        ! stop indicator 
     184      INTEGER         , OPTIONAL   , INTENT(in   ) ::   localComm    ! 
    184185      ! 
    185186      INTEGER ::   mynode, ierr, code, ji, ii, ios 
     
    190191      ! 
    191192      ii = 1 
    192       WRITE(ldtxt(ii),*)                                                                          ;   ii = ii + 1 
    193       WRITE(ldtxt(ii),*) 'mynode : mpi initialisation'                                            ;   ii = ii + 1 
    194       WRITE(ldtxt(ii),*) '~~~~~~ '                                                                ;   ii = ii + 1 
     193      WRITE(ldtxt(ii),*)                                                                  ;   ii = ii + 1 
     194      WRITE(ldtxt(ii),*) 'mynode : mpi initialisation'                                    ;   ii = ii + 1 
     195      WRITE(ldtxt(ii),*) '~~~~~~ '                                                        ;   ii = ii + 1 
    195196      ! 
    196197 
     
    204205 
    205206      !                              ! control print 
    206       WRITE(ldtxt(ii),*) '   Namelist nammpp'                                                     ;   ii = ii + 1 
    207       WRITE(ldtxt(ii),*) '      mpi send type                      cn_mpi_send = ', cn_mpi_send   ;   ii = ii + 1 
    208       WRITE(ldtxt(ii),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer     ;   ii = ii + 1 
     207      WRITE(ldtxt(ii),*) '   Namelist nammpp'                                             ;   ii = ii + 1 
     208      WRITE(ldtxt(ii),*) '      mpi send type          cn_mpi_send = ', cn_mpi_send       ;   ii = ii + 1 
     209      WRITE(ldtxt(ii),*) '      size exported buffer   nn_buffer   = ', nn_buffer,' bytes';   ii = ii + 1 
    209210 
    210211#if defined key_agrif 
     
    223224 
    224225      IF( (jpni < 1) .OR. (jpnj < 1) )THEN 
    225          WRITE(ldtxt(ii),*) '      jpni, jpnj and jpnij will be calculated automatically'; ii = ii + 1 
     226         WRITE(ldtxt(ii),*) '      jpni, jpnj and jpnij will be calculated automatically' ;  ii = ii + 1 
    226227      ELSE 
    227          WRITE(ldtxt(ii),*) '      processor grid extent in i         jpni = ',jpni; ii = ii + 1 
    228          WRITE(ldtxt(ii),*) '      processor grid extent in j         jpnj = ',jpnj; ii = ii + 1 
    229          WRITE(ldtxt(ii),*) '      number of local domains           jpnij = ',jpnij; ii = ii +1 
     228         WRITE(ldtxt(ii),*) '      processor grid extent in i         jpni = ',jpni       ;  ii = ii + 1 
     229         WRITE(ldtxt(ii),*) '      processor grid extent in j         jpnj = ',jpnj       ;  ii = ii + 1 
     230         WRITE(ldtxt(ii),*) '      number of local domains           jpnij = ',jpnij      ;   ii = ii + 1 
    230231      END IF 
    231232 
     
    246247         SELECT CASE ( cn_mpi_send ) 
    247248         CASE ( 'S' )                ! Standard mpi send (blocking) 
    248             WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'                     ;   ii = ii + 1 
     249            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'             ;   ii = ii + 1 
    249250         CASE ( 'B' )                ! Buffer mpi send (blocking) 
    250             WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'                      ;   ii = ii + 1 
     251            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'              ;   ii = ii + 1 
    251252            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr ) 
    252253         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    253             WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'                   ;   ii = ii + 1 
     254            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'           ;   ii = ii + 1 
    254255            l_isend = .TRUE. 
    255256         CASE DEFAULT 
    256             WRITE(ldtxt(ii),cform_err)                                                            ;   ii = ii + 1 
    257             WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send             ;   ii = ii + 1 
     257            WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1 
     258            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1 
    258259            kstop = kstop + 1 
    259260         END SELECT 
    260261      ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN 
    261          WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '                  ;   ii = ii + 1 
    262          WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                        ;   ii = ii + 1 
     262         WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1 
     263         WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1 
    263264         kstop = kstop + 1 
    264265      ELSE 
    265266         SELECT CASE ( cn_mpi_send ) 
    266267         CASE ( 'S' )                ! Standard mpi send (blocking) 
    267             WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'                     ;   ii = ii + 1 
     268            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'             ;   ii = ii + 1 
    268269            CALL mpi_init( ierr ) 
    269270         CASE ( 'B' )                ! Buffer mpi send (blocking) 
    270             WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'                      ;   ii = ii + 1 
     271            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'              ;   ii = ii + 1 
    271272            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr ) 
    272273         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    273             WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'                   ;   ii = ii + 1 
     274            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'           ;   ii = ii + 1 
    274275            l_isend = .TRUE. 
    275276            CALL mpi_init( ierr ) 
    276277         CASE DEFAULT 
    277             WRITE(ldtxt(ii),cform_err)                                                            ;   ii = ii + 1 
    278             WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send             ;   ii = ii + 1 
     278            WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1 
     279            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1 
    279280            kstop = kstop + 1 
    280281         END SELECT 
     
    319320   END FUNCTION mynode 
    320321 
     322 
    321323   SUBROUTINE mpp_lnk_3d( ptab, cd_type, psgn, cd_mpp, pval ) 
    322324      !!---------------------------------------------------------------------- 
     
    347349      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
    348350      REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries) 
    349       !! 
     351      ! 
    350352      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices 
    351353      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
    352354      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    353355      REAL(wp) ::   zland 
    354       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    355       ! 
     356      INTEGER , DIMENSION(MPI_STATUS_SIZE)      ::   ml_stat        ! for key_mpi_isend 
    356357      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! 3d for north-south & south-north 
    357358      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east 
    358  
    359359      !!---------------------------------------------------------------------- 
    360360       
     
    364364      ! 
    365365      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
    366       ELSE                         ;   zland = 0.e0      ! zero by default 
     366      ELSE                         ;   zland = 0._wp     ! zero by default 
    367367      ENDIF 
    368368 
     
    455455      END SELECT 
    456456 
    457  
    458457      ! 3. North and south directions 
    459458      ! ----------------------------- 
     
    508507      END SELECT 
    509508 
    510  
    511509      ! 4. north fold treatment 
    512510      ! ----------------------- 
     
    524522      ! 
    525523   END SUBROUTINE mpp_lnk_3d 
     524 
    526525 
    527526   SUBROUTINE mpp_lnk_2d_multiple( pt2d_array , type_array , psgn_array , num_fields , cd_mpp, pval ) 
     
    542541      !!                    noso   : number for local neighboring processors 
    543542      !!                    nono   : number for local neighboring processors 
    544       !! 
    545       !!---------------------------------------------------------------------- 
    546  
    547       INTEGER :: num_fields 
    548       TYPE( arrayptr ), DIMENSION(:) :: pt2d_array 
     543      !!---------------------------------------------------------------------- 
    549544      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   type_array   ! define the nature of ptab array grid-points 
    550545      !                                                               ! = T , U , V , F , W and I points 
     
    558553      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
    559554      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    560  
     555      INTEGER :: num_fields 
     556      TYPE( arrayptr ), DIMENSION(:) :: pt2d_array 
    561557      REAL(wp) ::   zland 
    562       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    563       ! 
     558      INTEGER , DIMENSION(MPI_STATUS_SIZE)    ::   ml_stat       ! for key_mpi_isend 
    564559      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ns, zt2sn   ! 2d for north-south & south-north 
    565560      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ew, zt2we   ! 2d for east-west & west-east 
    566561 
    567562      !!---------------------------------------------------------------------- 
    568  
     563      ! 
    569564      ALLOCATE( zt2ns(jpi,jprecj,2*num_fields), zt2sn(jpi,jprecj,2*num_fields),  & 
    570565         &      zt2ew(jpj,jpreci,2*num_fields), zt2we(jpj,jpreci,2*num_fields)   ) 
    571  
    572566      ! 
    573567      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
    574       ELSE                         ;   zland = 0.e0      ! zero by default 
     568      ELSE                         ;   zland = 0._wp     ! zero by default 
    575569      ENDIF 
    576570 
     
    744738         ! 
    745739      END DO 
    746        
     740      ! 
    747741      DEALLOCATE( zt2ns, zt2sn, zt2ew, zt2we ) 
    748742      ! 
     
    750744 
    751745    
    752    SUBROUTINE load_array(pt2d,cd_type,psgn,pt2d_array, type_array, psgn_array,num_fields) 
     746   SUBROUTINE load_array( pt2d, cd_type, psgn, pt2d_array, type_array, psgn_array, num_fields ) 
    753747      !!--------------------------------------------------------------------- 
    754       REAL(wp), DIMENSION(jpi,jpj), TARGET   ,  INTENT(inout) ::   pt2d    ! Second 2D array on which the boundary condition is applied 
    755       CHARACTER(len=1)            , INTENT(in   ) ::   cd_type ! define the nature of ptab array grid-points 
    756       REAL(wp)                    , INTENT(in   ) ::   psgn    ! =-1 the sign change across the north fold boundary 
     748      REAL(wp), DIMENSION(jpi,jpj), TARGET, INTENT(inout) ::   pt2d    ! Second 2D array on which the boundary condition is applied 
     749      CHARACTER(len=1)                    , INTENT(in   ) ::   cd_type ! define the nature of ptab array grid-points 
     750      REAL(wp)                            , INTENT(in   ) ::   psgn    ! =-1 the sign change across the north fold boundary 
    757751      TYPE(arrayptr)   , DIMENSION(9) ::   pt2d_array 
    758752      CHARACTER(len=1) , DIMENSION(9) ::   type_array    ! define the nature of ptab array grid-points 
    759753      REAL(wp)         , DIMENSION(9) ::   psgn_array    ! =-1 the sign change across the north fold boundary 
    760       INTEGER                      , INTENT (inout):: num_fields  
     754      INTEGER                            , INTENT (inout) :: num_fields  
    761755      !!--------------------------------------------------------------------- 
    762       num_fields=num_fields+1 
    763       pt2d_array(num_fields)%pt2d=>pt2d 
    764       type_array(num_fields)=cd_type 
    765       psgn_array(num_fields)=psgn 
     756      num_fields = num_fields + 1 
     757      pt2d_array(num_fields)%pt2d => pt2d 
     758      type_array(num_fields)      =  cd_type 
     759      psgn_array(num_fields)      =  psgn 
    766760   END SUBROUTINE load_array 
    767761    
     
    792786      INTEGER :: num_fields 
    793787      !!--------------------------------------------------------------------- 
    794  
     788      ! 
    795789      num_fields = 0 
    796  
    797       !! Load the first array 
    798       CALL load_array(pt2dA,cd_typeA,psgnA,pt2d_array, type_array, psgn_array,num_fields) 
    799  
    800       !! Look if more arrays are added 
    801       IF(PRESENT (psgnB) )CALL load_array(pt2dB,cd_typeB,psgnB,pt2d_array, type_array, psgn_array,num_fields) 
    802       IF(PRESENT (psgnC) )CALL load_array(pt2dC,cd_typeC,psgnC,pt2d_array, type_array, psgn_array,num_fields) 
    803       IF(PRESENT (psgnD) )CALL load_array(pt2dD,cd_typeD,psgnD,pt2d_array, type_array, psgn_array,num_fields) 
    804       IF(PRESENT (psgnE) )CALL load_array(pt2dE,cd_typeE,psgnE,pt2d_array, type_array, psgn_array,num_fields) 
    805       IF(PRESENT (psgnF) )CALL load_array(pt2dF,cd_typeF,psgnF,pt2d_array, type_array, psgn_array,num_fields) 
    806       IF(PRESENT (psgnG) )CALL load_array(pt2dG,cd_typeG,psgnG,pt2d_array, type_array, psgn_array,num_fields) 
    807       IF(PRESENT (psgnH) )CALL load_array(pt2dH,cd_typeH,psgnH,pt2d_array, type_array, psgn_array,num_fields) 
    808       IF(PRESENT (psgnI) )CALL load_array(pt2dI,cd_typeI,psgnI,pt2d_array, type_array, psgn_array,num_fields) 
    809        
    810       CALL mpp_lnk_2d_multiple(pt2d_array,type_array,psgn_array,num_fields,cd_mpp,pval) 
     790      ! 
     791      ! Load the first array 
     792      CALL load_array( pt2dA, cd_typeA, psgnA, pt2d_array, type_array, psgn_array, num_fields ) 
     793      ! 
     794      ! Look if more arrays are added 
     795      IF( PRESENT(psgnB) )   CALL load_array(pt2dB,cd_typeB,psgnB,pt2d_array, type_array, psgn_array,num_fields) 
     796      IF( PRESENT(psgnC) )   CALL load_array(pt2dC,cd_typeC,psgnC,pt2d_array, type_array, psgn_array,num_fields) 
     797      IF( PRESENT(psgnD) )   CALL load_array(pt2dD,cd_typeD,psgnD,pt2d_array, type_array, psgn_array,num_fields) 
     798      IF( PRESENT(psgnE) )   CALL load_array(pt2dE,cd_typeE,psgnE,pt2d_array, type_array, psgn_array,num_fields) 
     799      IF( PRESENT(psgnF) )   CALL load_array(pt2dF,cd_typeF,psgnF,pt2d_array, type_array, psgn_array,num_fields) 
     800      IF( PRESENT(psgnG) )   CALL load_array(pt2dG,cd_typeG,psgnG,pt2d_array, type_array, psgn_array,num_fields) 
     801      IF( PRESENT(psgnH) )   CALL load_array(pt2dH,cd_typeH,psgnH,pt2d_array, type_array, psgn_array,num_fields) 
     802      IF( PRESENT(psgnI) )   CALL load_array(pt2dI,cd_typeI,psgnI,pt2d_array, type_array, psgn_array,num_fields) 
     803      ! 
     804      CALL mpp_lnk_2d_multiple( pt2d_array, type_array, psgn_array, num_fields, cd_mpp,pval ) 
     805      ! 
    811806   END SUBROUTINE mpp_lnk_2d_9 
    812807 
     
    843838      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    844839      REAL(wp) ::   zland 
    845       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    846       ! 
     840      INTEGER, DIMENSION(MPI_STATUS_SIZE)     ::   ml_stat       ! for key_mpi_isend 
    847841      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ns, zt2sn   ! 2d for north-south & south-north 
    848842      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ew, zt2we   ! 2d for east-west & west-east 
    849  
    850       !!---------------------------------------------------------------------- 
    851  
     843      !!---------------------------------------------------------------------- 
     844      ! 
    852845      ALLOCATE( zt2ns(jpi,jprecj,2), zt2sn(jpi,jprecj,2),  & 
    853846         &      zt2ew(jpj,jpreci,2), zt2we(jpj,jpreci,2)   ) 
    854  
    855847      ! 
    856848      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
    857       ELSE                         ;   zland = 0.e0      ! zero by default 
     849      ELSE                         ;   zland = 0._wp     ! zero by default 
    858850      ENDIF 
    859851 
     
    10461038      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
    10471039      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    1048       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    1049       ! 
     1040      INTEGER , DIMENSION(MPI_STATUS_SIZE)        ::   ml_stat   ! for key_mpi_isend 
    10501041      REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zt4ns, zt4sn   ! 2 x 3d for north-south & south-north 
    10511042      REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zt4ew, zt4we   ! 2 x 3d for east-west & west-east 
    1052  
    1053       !!---------------------------------------------------------------------- 
     1043      !!---------------------------------------------------------------------- 
     1044      ! 
    10541045      ALLOCATE( zt4ns(jpi,jprecj,jpk,2,2), zt4sn(jpi,jprecj,jpk,2,2) ,    & 
    10551046         &      zt4ew(jpj,jpreci,jpk,2,2), zt4we(jpj,jpreci,jpk,2,2) ) 
    1056  
    1057  
     1047      ! 
    10581048      ! 1. standard boundary treatment 
    10591049      ! ------------------------------ 
     
    13991389         END DO 
    14001390      END SELECT 
    1401  
     1391      ! 
    14021392   END SUBROUTINE mpp_lnk_2d_e 
    14031393 
     1394   SUBROUTINE mpp_lnk_sum_3d( ptab, cd_type, psgn, cd_mpp, pval ) 
     1395      !!---------------------------------------------------------------------- 
     1396      !!                  ***  routine mpp_lnk_sum_3d  *** 
     1397      !! 
     1398      !! ** Purpose :   Message passing manadgement (sum the overlap region) 
     1399      !! 
     1400      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
     1401      !!      between processors following neighboring subdomains. 
     1402      !!            domain parameters 
     1403      !!                    nlci   : first dimension of the local subdomain 
     1404      !!                    nlcj   : second dimension of the local subdomain 
     1405      !!                    nbondi : mark for "east-west local boundary" 
     1406      !!                    nbondj : mark for "north-south local boundary" 
     1407      !!                    noea   : number for local neighboring processors 
     1408      !!                    nowe   : number for local neighboring processors 
     1409      !!                    noso   : number for local neighboring processors 
     1410      !!                    nono   : number for local neighboring processors 
     1411      !! 
     1412      !! ** Action  :   ptab with update value at its periphery 
     1413      !! 
     1414      !!---------------------------------------------------------------------- 
     1415      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied 
     1416      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points 
     1417      !                                                             ! = T , U , V , F , W points 
     1418      REAL(wp)                        , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary 
     1419      !                                                             ! =  1. , the sign is kept 
     1420      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
     1421      REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries) 
     1422      !! 
     1423      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices 
     1424      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
     1425      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
     1426      REAL(wp) ::   zland 
     1427      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
     1428      ! 
     1429      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! 3d for north-south & south-north 
     1430      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east 
     1431 
     1432      !!---------------------------------------------------------------------- 
     1433       
     1434      ALLOCATE( zt3ns(jpi,jprecj,jpk,2), zt3sn(jpi,jprecj,jpk,2),   & 
     1435         &      zt3ew(jpj,jpreci,jpk,2), zt3we(jpj,jpreci,jpk,2)  ) 
     1436 
     1437      ! 
     1438      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
     1439      ELSE                         ;   zland = 0.e0      ! zero by default 
     1440      ENDIF 
     1441 
     1442      ! 1. standard boundary treatment 
     1443      ! ------------------------------ 
     1444      ! 2. East and west directions exchange 
     1445      ! ------------------------------------ 
     1446      ! we play with the neigbours AND the row number because of the periodicity 
     1447      ! 
     1448      SELECT CASE ( nbondi )      ! Read lateral conditions 
     1449      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case) 
     1450      iihom = nlci-jpreci 
     1451         DO jl = 1, jpreci 
     1452            zt3ew(:,jl,:,1) = ptab(jl      ,:,:) ; ptab(jl      ,:,:) = 0.0_wp 
     1453            zt3we(:,jl,:,1) = ptab(iihom+jl,:,:) ; ptab(iihom+jl,:,:) = 0.0_wp  
     1454         END DO 
     1455      END SELECT 
     1456      ! 
     1457      !                           ! Migrations 
     1458      imigr = jpreci * jpj * jpk 
     1459      ! 
     1460      SELECT CASE ( nbondi ) 
     1461      CASE ( -1 ) 
     1462         CALL mppsend( 2, zt3we(1,1,1,1), imigr, noea, ml_req1 ) 
     1463         CALL mpprecv( 1, zt3ew(1,1,1,2), imigr, noea ) 
     1464         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1465      CASE ( 0 ) 
     1466         CALL mppsend( 1, zt3ew(1,1,1,1), imigr, nowe, ml_req1 ) 
     1467         CALL mppsend( 2, zt3we(1,1,1,1), imigr, noea, ml_req2 ) 
     1468         CALL mpprecv( 1, zt3ew(1,1,1,2), imigr, noea ) 
     1469         CALL mpprecv( 2, zt3we(1,1,1,2), imigr, nowe ) 
     1470         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1471         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err) 
     1472      CASE ( 1 ) 
     1473         CALL mppsend( 1, zt3ew(1,1,1,1), imigr, nowe, ml_req1 ) 
     1474         CALL mpprecv( 2, zt3we(1,1,1,2), imigr, nowe ) 
     1475         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1476      END SELECT 
     1477      ! 
     1478      !                           ! Write lateral conditions 
     1479      iihom = nlci-nreci 
     1480      ! 
     1481      SELECT CASE ( nbondi ) 
     1482      CASE ( -1 ) 
     1483         DO jl = 1, jpreci 
     1484            ptab(iihom+jl,:,:) = ptab(iihom+jl,:,:) + zt3ew(:,jl,:,2) 
     1485         END DO 
     1486      CASE ( 0 ) 
     1487         DO jl = 1, jpreci 
     1488            ptab(jpreci+jl,:,:) = ptab(jpreci+jl,:,:) + zt3we(:,jl,:,2) 
     1489            ptab(iihom +jl,:,:) = ptab(iihom +jl,:,:) + zt3ew(:,jl,:,2) 
     1490         END DO 
     1491      CASE ( 1 ) 
     1492         DO jl = 1, jpreci 
     1493            ptab(jpreci+jl,:,:) = ptab(jpreci+jl,:,:) + zt3we(:,jl,:,2) 
     1494         END DO 
     1495      END SELECT 
     1496 
     1497 
     1498      ! 3. North and south directions 
     1499      ! ----------------------------- 
     1500      ! always closed : we play only with the neigbours 
     1501      ! 
     1502      IF( nbondj /= 2 ) THEN      ! Read lateral conditions 
     1503         ijhom = nlcj-jprecj 
     1504         DO jl = 1, jprecj 
     1505            zt3sn(:,jl,:,1) = ptab(:,ijhom+jl,:) ; ptab(:,ijhom+jl,:) = 0.0_wp 
     1506            zt3ns(:,jl,:,1) = ptab(:,jl      ,:) ; ptab(:,jl      ,:) = 0.0_wp 
     1507         END DO 
     1508      ENDIF 
     1509      ! 
     1510      !                           ! Migrations 
     1511      imigr = jprecj * jpi * jpk 
     1512      ! 
     1513      SELECT CASE ( nbondj ) 
     1514      CASE ( -1 ) 
     1515         CALL mppsend( 4, zt3sn(1,1,1,1), imigr, nono, ml_req1 ) 
     1516         CALL mpprecv( 3, zt3ns(1,1,1,2), imigr, nono ) 
     1517         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1518      CASE ( 0 ) 
     1519         CALL mppsend( 3, zt3ns(1,1,1,1), imigr, noso, ml_req1 ) 
     1520         CALL mppsend( 4, zt3sn(1,1,1,1), imigr, nono, ml_req2 ) 
     1521         CALL mpprecv( 3, zt3ns(1,1,1,2), imigr, nono ) 
     1522         CALL mpprecv( 4, zt3sn(1,1,1,2), imigr, noso ) 
     1523         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1524         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err) 
     1525      CASE ( 1 ) 
     1526         CALL mppsend( 3, zt3ns(1,1,1,1), imigr, noso, ml_req1 ) 
     1527         CALL mpprecv( 4, zt3sn(1,1,1,2), imigr, noso ) 
     1528         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err) 
     1529      END SELECT 
     1530      ! 
     1531      !                           ! Write lateral conditions 
     1532      ijhom = nlcj-nrecj 
     1533      ! 
     1534      SELECT CASE ( nbondj ) 
     1535      CASE ( -1 ) 
     1536         DO jl = 1, jprecj 
     1537            ptab(:,ijhom+jl,:) = ptab(:,ijhom+jl,:) + zt3ns(:,jl,:,2) 
     1538         END DO 
     1539      CASE ( 0 ) 
     1540         DO jl = 1, jprecj 
     1541            ptab(:,jprecj+jl,:) = ptab(:,jprecj+jl,:) + zt3sn(:,jl,:,2) 
     1542            ptab(:,ijhom +jl,:) = ptab(:,ijhom +jl,:) + zt3ns(:,jl,:,2) 
     1543         END DO 
     1544      CASE ( 1 ) 
     1545         DO jl = 1, jprecj 
     1546            ptab(:,jprecj+jl,:) = ptab(:,jprecj+jl,:) + zt3sn(:,jl   ,:,2) 
     1547         END DO 
     1548      END SELECT 
     1549 
     1550 
     1551      ! 4. north fold treatment 
     1552      ! ----------------------- 
     1553      ! 
     1554      IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN 
     1555         ! 
     1556         SELECT CASE ( jpni ) 
     1557         CASE ( 1 )     ;   CALL lbc_nfd      ( ptab, cd_type, psgn )   ! only 1 northern proc, no mpp 
     1558         CASE DEFAULT   ;   CALL mpp_lbc_north( ptab, cd_type, psgn )   ! for all northern procs. 
     1559         END SELECT 
     1560         ! 
     1561      ENDIF 
     1562      ! 
     1563      DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we ) 
     1564      ! 
     1565   END SUBROUTINE mpp_lnk_sum_3d 
     1566 
     1567   SUBROUTINE mpp_lnk_sum_2d( pt2d, cd_type, psgn, cd_mpp, pval ) 
     1568      !!---------------------------------------------------------------------- 
     1569      !!                  ***  routine mpp_lnk_sum_2d  *** 
     1570      !! 
     1571      !! ** Purpose :   Message passing manadgement for 2d array (sum the overlap region) 
     1572      !! 
     1573      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
     1574      !!      between processors following neighboring subdomains. 
     1575      !!            domain parameters 
     1576      !!                    nlci   : first dimension of the local subdomain 
     1577      !!                    nlcj   : second dimension of the local subdomain 
     1578      !!                    nbondi : mark for "east-west local boundary" 
     1579      !!                    nbondj : mark for "north-south local boundary" 
     1580      !!                    noea   : number for local neighboring processors 
     1581      !!                    nowe   : number for local neighboring processors 
     1582      !!                    noso   : number for local neighboring processors 
     1583      !!                    nono   : number for local neighboring processors 
     1584      !! 
     1585      !!---------------------------------------------------------------------- 
     1586      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d     ! 2D array on which the boundary condition is applied 
     1587      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points 
     1588      !                                                         ! = T , U , V , F , W and I points 
     1589      REAL(wp)                    , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary 
     1590      !                                                         ! =  1. , the sign is kept 
     1591      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
     1592      REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval     ! background value (used at closed boundaries) 
     1593      !! 
     1594      INTEGER  ::   ji, jj, jl   ! dummy loop indices 
     1595      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
     1596      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
     1597      REAL(wp) ::   zland 
     1598      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
     1599      ! 
     1600      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ns, zt2sn   ! 2d for north-south & south-north 
     1601      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ew, zt2we   ! 2d for east-west & west-east 
     1602 
     1603      !!---------------------------------------------------------------------- 
     1604 
     1605      ALLOCATE( zt2ns(jpi,jprecj,2), zt2sn(jpi,jprecj,2),  & 
     1606         &      zt2ew(jpj,jpreci,2), zt2we(jpj,jpreci,2)   ) 
     1607 
     1608      ! 
     1609      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
     1610      ELSE                         ;   zland = 0.e0      ! zero by default 
     1611      ENDIF 
     1612 
     1613      ! 1. standard boundary treatment 
     1614      ! ------------------------------ 
     1615      ! 2. East and west directions exchange 
     1616      ! ------------------------------------ 
     1617      ! we play with the neigbours AND the row number because of the periodicity 
     1618      ! 
     1619      SELECT CASE ( nbondi )      ! Read lateral conditions 
     1620      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case) 
     1621         iihom = nlci - jpreci 
     1622         DO jl = 1, jpreci 
     1623            zt2ew(:,jl,1) = pt2d(jl       ,:) ; pt2d(jl       ,:) = 0.0_wp 
     1624            zt2we(:,jl,1) = pt2d(iihom +jl,:) ; pt2d(iihom +jl,:) = 0.0_wp 
     1625         END DO 
     1626      END SELECT 
     1627      ! 
     1628      !                           ! Migrations 
     1629      imigr = jpreci * jpj 
     1630      ! 
     1631      SELECT CASE ( nbondi ) 
     1632      CASE ( -1 ) 
     1633         CALL mppsend( 2, zt2we(1,1,1), imigr, noea, ml_req1 ) 
     1634         CALL mpprecv( 1, zt2ew(1,1,2), imigr, noea ) 
     1635         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1636      CASE ( 0 ) 
     1637         CALL mppsend( 1, zt2ew(1,1,1), imigr, nowe, ml_req1 ) 
     1638         CALL mppsend( 2, zt2we(1,1,1), imigr, noea, ml_req2 ) 
     1639         CALL mpprecv( 1, zt2ew(1,1,2), imigr, noea ) 
     1640         CALL mpprecv( 2, zt2we(1,1,2), imigr, nowe ) 
     1641         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1642         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err) 
     1643      CASE ( 1 ) 
     1644         CALL mppsend( 1, zt2ew(1,1,1), imigr, nowe, ml_req1 ) 
     1645         CALL mpprecv( 2, zt2we(1,1,2), imigr, nowe ) 
     1646         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1647      END SELECT 
     1648      ! 
     1649      !                           ! Write lateral conditions 
     1650      iihom = nlci-nreci 
     1651      ! 
     1652      SELECT CASE ( nbondi ) 
     1653      CASE ( -1 ) 
     1654         DO jl = 1, jpreci 
     1655            pt2d(iihom+jl,:) = pt2d(iihom+jl,:) + zt2ew(:,jl,2) 
     1656         END DO 
     1657      CASE ( 0 ) 
     1658         DO jl = 1, jpreci 
     1659            pt2d(jpreci+jl,:) = pt2d(jpreci+jl,:) + zt2we(:,jl,2) 
     1660            pt2d(iihom +jl,:) = pt2d(iihom +jl,:) + zt2ew(:,jl,2) 
     1661         END DO 
     1662      CASE ( 1 ) 
     1663         DO jl = 1, jpreci 
     1664            pt2d(jpreci+jl,:) = pt2d(jpreci+jl,:) + zt2we(:,jl,2) 
     1665         END DO 
     1666      END SELECT 
     1667 
     1668 
     1669      ! 3. North and south directions 
     1670      ! ----------------------------- 
     1671      ! always closed : we play only with the neigbours 
     1672      ! 
     1673      IF( nbondj /= 2 ) THEN      ! Read lateral conditions 
     1674         ijhom = nlcj - jprecj 
     1675         DO jl = 1, jprecj 
     1676            zt2sn(:,jl,1) = pt2d(:,ijhom +jl) ; pt2d(:,ijhom +jl) = 0.0_wp 
     1677            zt2ns(:,jl,1) = pt2d(:,jl       ) ; pt2d(:,jl       ) = 0.0_wp 
     1678         END DO 
     1679      ENDIF 
     1680      ! 
     1681      !                           ! Migrations 
     1682      imigr = jprecj * jpi 
     1683      ! 
     1684      SELECT CASE ( nbondj ) 
     1685      CASE ( -1 ) 
     1686         CALL mppsend( 4, zt2sn(1,1,1), imigr, nono, ml_req1 ) 
     1687         CALL mpprecv( 3, zt2ns(1,1,2), imigr, nono ) 
     1688         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1689      CASE ( 0 ) 
     1690         CALL mppsend( 3, zt2ns(1,1,1), imigr, noso, ml_req1 ) 
     1691         CALL mppsend( 4, zt2sn(1,1,1), imigr, nono, ml_req2 ) 
     1692         CALL mpprecv( 3, zt2ns(1,1,2), imigr, nono ) 
     1693         CALL mpprecv( 4, zt2sn(1,1,2), imigr, noso ) 
     1694         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1695         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err) 
     1696      CASE ( 1 ) 
     1697         CALL mppsend( 3, zt2ns(1,1,1), imigr, noso, ml_req1 ) 
     1698         CALL mpprecv( 4, zt2sn(1,1,2), imigr, noso ) 
     1699         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err) 
     1700      END SELECT 
     1701      ! 
     1702      !                           ! Write lateral conditions 
     1703      ijhom = nlcj-nrecj 
     1704      ! 
     1705      SELECT CASE ( nbondj ) 
     1706      CASE ( -1 ) 
     1707         DO jl = 1, jprecj 
     1708            pt2d(:,ijhom+jl) = pt2d(:,ijhom+jl) + zt2ns(:,jl,2) 
     1709         END DO 
     1710      CASE ( 0 ) 
     1711         DO jl = 1, jprecj 
     1712            pt2d(:,jprecj+jl) = pt2d(:,jprecj+jl) + zt2sn(:,jl,2) 
     1713            pt2d(:,ijhom +jl) = pt2d(:,ijhom +jl) + zt2ns(:,jl,2) 
     1714         END DO 
     1715      CASE ( 1 ) 
     1716         DO jl = 1, jprecj 
     1717            pt2d(:,jprecj+jl) = pt2d(:,jprecj+jl) + zt2sn(:,jl,2) 
     1718         END DO 
     1719      END SELECT 
     1720 
     1721 
     1722      ! 4. north fold treatment 
     1723      ! ----------------------- 
     1724      ! 
     1725      IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN 
     1726         ! 
     1727         SELECT CASE ( jpni ) 
     1728         CASE ( 1 )     ;   CALL lbc_nfd      ( pt2d, cd_type, psgn )   ! only 1 northern proc, no mpp 
     1729         CASE DEFAULT   ;   CALL mpp_lbc_north( pt2d, cd_type, psgn )   ! for all northern procs. 
     1730         END SELECT 
     1731         ! 
     1732      ENDIF 
     1733      ! 
     1734      DEALLOCATE( zt2ns, zt2sn, zt2ew, zt2we ) 
     1735      ! 
     1736   END SUBROUTINE mpp_lnk_sum_2d 
    14041737 
    14051738   SUBROUTINE mppsend( ktyp, pmess, kbytes, kdest, md_req ) 
     
    14491782      !!---------------------------------------------------------------------- 
    14501783      ! 
    1451  
    14521784      ! If a specific process number has been passed to the receive call, 
    14531785      ! use that one. Default is to use mpi_any_source 
    1454       use_source=mpi_any_source 
    1455       if(present(ksource)) then 
    1456          use_source=ksource 
    1457       end if 
    1458  
     1786      use_source = mpi_any_source 
     1787      IF( PRESENT(ksource) )   use_source = ksource 
     1788      ! 
    14591789      CALL mpi_recv( pmess, kbytes, mpi_double_precision, use_source, ktyp, mpi_comm_opa, istatus, iflag ) 
    14601790      ! 
     
    14701800      !! 
    14711801      !!---------------------------------------------------------------------- 
    1472       REAL(wp), DIMENSION(jpi,jpj),      INTENT(in   ) ::   ptab   ! subdomain input array 
    1473       INTEGER ,                          INTENT(in   ) ::   kp     ! record length 
     1802      REAL(wp), DIMENSION(jpi,jpj)      , INTENT(in   ) ::   ptab   ! subdomain input array 
     1803      INTEGER                           , INTENT(in   ) ::   kp     ! record length 
    14741804      REAL(wp), DIMENSION(jpi,jpj,jpnij), INTENT(  out) ::   pio    ! subdomain input array 
    14751805      !! 
     
    14921822      !! 
    14931823      !!---------------------------------------------------------------------- 
    1494       REAL(wp), DIMENSION(jpi,jpj,jpnij)  ::  pio        ! output array 
    1495       INTEGER                             ::   kp        ! Tag (not used with MPI 
    1496       REAL(wp), DIMENSION(jpi,jpj)        ::  ptab       ! subdomain array input 
     1824      REAL(wp), DIMENSION(jpi,jpj,jpnij)  ::   pio    ! output array 
     1825      INTEGER                             ::   kp     ! Tag (not used with MPI 
     1826      REAL(wp), DIMENSION(jpi,jpj)        ::   ptab   ! subdomain array input 
    14971827      !! 
    14981828      INTEGER :: itaille, ierror   ! temporary integer 
    14991829      !!--------------------------------------------------------------------- 
    15001830      ! 
    1501       itaille=jpi*jpj 
     1831      itaille = jpi * jpj 
    15021832      ! 
    15031833      CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille     ,   & 
     
    15171847      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array 
    15181848      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom   ! 
    1519       !! 
     1849      ! 
    15201850      INTEGER :: ierror, localcomm   ! temporary integer 
    15211851      INTEGER, DIMENSION(kdim) ::   iwork 
     
    15391869      !! 
    15401870      !!---------------------------------------------------------------------- 
    1541       INTEGER, INTENT(inout)           ::   ktab      ! ??? 
    1542       INTEGER, INTENT(in   ), OPTIONAL ::   kcom      ! ??? 
    1543       !! 
     1871      INTEGER, INTENT(inout)           ::   ktab   ! ??? 
     1872      INTEGER, INTENT(in   ), OPTIONAL ::   kcom   ! ??? 
     1873      ! 
    15441874      INTEGER ::   ierror, iwork, localcomm   ! temporary integer 
    15451875      !!---------------------------------------------------------------------- 
     
    15481878      IF( PRESENT(kcom) )   localcomm = kcom 
    15491879      ! 
    1550       CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_max, localcomm, ierror) 
     1880      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_max, localcomm, ierror ) 
    15511881      ! 
    15521882      ktab = iwork 
     
    15621892      !! 
    15631893      !!---------------------------------------------------------------------- 
    1564       INTEGER , INTENT( in  )                  ::   kdim        ! size of array 
    1565       INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab        ! input array 
    1566       INTEGER , INTENT( in  ), OPTIONAL        ::   kcom        ! input array 
     1894      INTEGER , INTENT( in  )                  ::   kdim   ! size of array 
     1895      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array 
     1896      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom   ! input array 
    15671897      !! 
    15681898      INTEGER ::   ierror, localcomm   ! temporary integer 
     
    15961926      IF( PRESENT(kcom) )   localcomm = kcom 
    15971927      ! 
    1598      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_min, localcomm, ierror ) 
     1928      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_min, localcomm, ierror ) 
    15991929      ! 
    16001930      ktab = iwork 
     
    16101940      !! 
    16111941      !!---------------------------------------------------------------------- 
    1612       INTEGER, INTENT(in   )                   ::   kdim      ! ??? 
    1613       INTEGER, INTENT(inout), DIMENSION (kdim) ::   ktab      ! ??? 
    1614       !! 
     1942      INTEGER, INTENT(in   )                   ::   kdim   ! ??? 
     1943      INTEGER, INTENT(inout), DIMENSION (kdim) ::   ktab   ! ??? 
     1944      ! 
    16151945      INTEGER :: ierror 
    16161946      INTEGER, DIMENSION (kdim) ::  iwork 
     
    16531983      REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab 
    16541984      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom 
    1655       !! 
     1985      ! 
    16561986      INTEGER :: ierror, localcomm 
    16571987      REAL(wp), DIMENSION(kdim) ::  zwork 
     
    17852115   END SUBROUTINE mppsum_real 
    17862116 
     2117 
    17872118   SUBROUTINE mppsum_realdd( ytab, kcom ) 
    17882119      !!---------------------------------------------------------------------- 
     
    17932124      !! 
    17942125      !!----------------------------------------------------------------------- 
    1795       COMPLEX(wp), INTENT(inout)         :: ytab    ! input scalar 
    1796       INTEGER , INTENT( in  ), OPTIONAL :: kcom 
    1797  
    1798       !! * Local variables   (MPI version) 
    1799       INTEGER  ::    ierror 
    1800       INTEGER  ::   localcomm 
    1801       COMPLEX(wp) :: zwork 
    1802  
     2126      COMPLEX(wp), INTENT(inout)           ::  ytab    ! input scalar 
     2127      INTEGER    , INTENT(in   ), OPTIONAL ::  kcom 
     2128      ! 
     2129      INTEGER     ::   ierror 
     2130      INTEGER     ::   localcomm 
     2131      COMPLEX(wp) ::   zwork 
     2132      !!----------------------------------------------------------------------- 
     2133      ! 
    18032134      localcomm = mpi_comm_opa 
    1804       IF( PRESENT(kcom) ) localcomm = kcom 
    1805  
     2135      IF( PRESENT(kcom) )   localcomm = kcom 
     2136      ! 
    18062137      ! reduce local sums into global sum 
    1807       CALL MPI_ALLREDUCE (ytab, zwork, 1, MPI_DOUBLE_COMPLEX, & 
    1808                        MPI_SUMDD,localcomm,ierror) 
     2138      CALL MPI_ALLREDUCE (ytab, zwork, 1, MPI_DOUBLE_COMPLEX, MPI_SUMDD, localcomm, ierror ) 
    18092139      ytab = zwork 
    1810  
     2140      ! 
    18112141   END SUBROUTINE mppsum_realdd 
    18122142 
     
    18202150      !! 
    18212151      !!----------------------------------------------------------------------- 
    1822       INTEGER , INTENT( in )                        ::   kdim      ! size of ytab 
    1823       COMPLEX(wp), DIMENSION(kdim), INTENT( inout ) ::   ytab      ! input array 
    1824       INTEGER , INTENT( in  ), OPTIONAL :: kcom 
    1825  
    1826       !! * Local variables   (MPI version) 
    1827       INTEGER                      :: ierror    ! temporary integer 
    1828       INTEGER                      ::   localcomm 
     2152      INTEGER                     , INTENT(in   ) ::   kdim   ! size of ytab 
     2153      COMPLEX(wp), DIMENSION(kdim), INTENT(inout) ::   ytab   ! input array 
     2154      INTEGER    , OPTIONAL       , INTENT(in   ) ::   kcom 
     2155      ! 
     2156      INTEGER:: ierror, localcomm    ! local integer 
    18292157      COMPLEX(wp), DIMENSION(kdim) :: zwork     ! temporary workspace 
    1830  
     2158      !!----------------------------------------------------------------------- 
     2159      ! 
    18312160      localcomm = mpi_comm_opa 
    1832       IF( PRESENT(kcom) ) localcomm = kcom 
    1833  
    1834       CALL MPI_ALLREDUCE (ytab, zwork, kdim, MPI_DOUBLE_COMPLEX, & 
    1835                        MPI_SUMDD,localcomm,ierror) 
     2161      IF( PRESENT(kcom) )   localcomm = kcom 
     2162      ! 
     2163      CALL MPI_ALLREDUCE( ytab, zwork, kdim, MPI_DOUBLE_COMPLEX, MPI_SUMDD, localcomm, ierror ) 
    18362164      ytab(:) = zwork(:) 
    1837  
     2165      ! 
    18382166   END SUBROUTINE mppsum_a_realdd 
     2167 
    18392168 
    18402169   SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki,kj ) 
     
    18522181      REAL(wp)                     , INTENT(  out) ::   pmin    ! Global minimum of ptab 
    18532182      INTEGER                      , INTENT(  out) ::   ki, kj   ! index of minimum in global frame 
    1854       !! 
     2183      ! 
     2184      INTEGER :: ierror 
    18552185      INTEGER , DIMENSION(2)   ::   ilocs 
    1856       INTEGER :: ierror 
    18572186      REAL(wp) ::   zmin   ! local minimum 
    18582187      REAL(wp), DIMENSION(2,1) ::   zain, zaout 
     
    26622991   END SUBROUTINE mpp_lbc_north_e 
    26632992 
    2664       SUBROUTINE mpp_lnk_bdy_3d( ptab, cd_type, psgn, ib_bdy ) 
     2993 
     2994   SUBROUTINE mpp_lnk_bdy_3d( ptab, cd_type, psgn, ib_bdy ) 
    26652995      !!---------------------------------------------------------------------- 
    26662996      !!                  ***  routine mpp_lnk_bdy_3d  *** 
     
    26833013      !! 
    26843014      !!---------------------------------------------------------------------- 
    2685  
    2686       USE lbcnfd          ! north fold 
    2687  
    2688       INCLUDE 'mpif.h' 
    2689  
    26903015      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied 
    26913016      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points 
     
    26943019      !                                                             ! =  1. , the sign is kept 
    26953020      INTEGER                         , INTENT(in   ) ::   ib_bdy   ! BDY boundary set 
     3021      ! 
    26963022      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices 
    2697       INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
     3023      INTEGER  ::   imigr, iihom, ijhom        ! local integers 
    26983024      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    2699       REAL(wp) ::   zland 
     3025      REAL(wp) ::   zland                      ! local scalar 
    27003026      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    27013027      ! 
    27023028      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! 3d for north-south & south-north 
    27033029      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east 
    2704  
    2705       !!---------------------------------------------------------------------- 
    2706        
     3030      !!---------------------------------------------------------------------- 
     3031      ! 
    27073032      ALLOCATE( zt3ns(jpi,jprecj,jpk,2), zt3sn(jpi,jprecj,jpk,2),   & 
    27083033         &      zt3ew(jpj,jpreci,jpk,2), zt3we(jpj,jpreci,jpk,2)  ) 
    27093034 
    2710       zland = 0.e0 
     3035      zland = 0._wp 
    27113036 
    27123037      ! 1. standard boundary treatment 
    27133038      ! ------------------------------ 
    2714        
    27153039      !                                   ! East-West boundaries 
    27163040      !                                        !* Cyclic east-west 
    2717  
    27183041      IF( nbondi == 2) THEN 
    2719         IF (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN 
    2720           ptab( 1 ,:,:) = ptab(jpim1,:,:) 
    2721           ptab(jpi,:,:) = ptab(  2  ,:,:) 
    2722         ELSE 
    2723           IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:,:) = zland    ! south except F-point 
    2724           ptab(nlci-jpreci+1:jpi   ,:,:) = zland    ! north 
    2725         ENDIF 
     3042         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN 
     3043            ptab( 1 ,:,:) = ptab(jpim1,:,:) 
     3044            ptab(jpi,:,:) = ptab(  2  ,:,:) 
     3045         ELSE 
     3046            IF( .NOT. cd_type == 'F' )   ptab(1:jpreci,:,:) = zland    ! south except F-point 
     3047            ptab(nlci-jpreci+1:jpi,:,:) = zland    ! north 
     3048         ENDIF 
    27263049      ELSEIF(nbondi == -1) THEN 
    2727         IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:,:) = zland    ! south except F-point 
     3050         IF( .NOT. cd_type == 'F' )   ptab(1:jpreci,:,:) = zland    ! south except F-point 
    27283051      ELSEIF(nbondi == 1) THEN 
    2729         ptab(nlci-jpreci+1:jpi   ,:,:) = zland    ! north 
     3052         ptab(nlci-jpreci+1:jpi,:,:) = zland    ! north 
    27303053      ENDIF                                     !* closed 
    27313054 
    27323055      IF (nbondj == 2 .OR. nbondj == -1) THEN 
    2733         IF( .NOT. cd_type == 'F' )   ptab(:,     1       :jprecj,:) = zland       ! south except F-point 
     3056        IF( .NOT. cd_type == 'F' )   ptab(:,1:jprecj,:) = zland       ! south except F-point 
    27343057      ELSEIF (nbondj == 2 .OR. nbondj == 1) THEN 
    2735         ptab(:,nlcj-jprecj+1:jpj   ,:) = zland       ! north 
    2736       ENDIF 
    2737        
    2738       ! 
    2739  
     3058        ptab(:,nlcj-jprecj+1:jpj,:) = zland       ! north 
     3059      ENDIF 
     3060      ! 
    27403061      ! 2. East and west directions exchange 
    27413062      ! ------------------------------------ 
     
    27943115      CASE ( 0 ) 
    27953116         DO jl = 1, jpreci 
    2796             ptab(jl      ,:,:) = zt3we(:,jl,:,2) 
     3117            ptab(      jl,:,:) = zt3we(:,jl,:,2) 
    27973118            ptab(iihom+jl,:,:) = zt3ew(:,jl,:,2) 
    27983119         END DO 
    27993120      CASE ( 1 ) 
    28003121         DO jl = 1, jpreci 
    2801             ptab(jl      ,:,:) = zt3we(:,jl,:,2) 
     3122            ptab(      jl,:,:) = zt3we(:,jl,:,2) 
    28023123         END DO 
    28033124      END SELECT 
     
    28853206   END SUBROUTINE mpp_lnk_bdy_3d 
    28863207 
    2887       SUBROUTINE mpp_lnk_bdy_2d( ptab, cd_type, psgn, ib_bdy ) 
     3208 
     3209   SUBROUTINE mpp_lnk_bdy_2d( ptab, cd_type, psgn, ib_bdy ) 
    28883210      !!---------------------------------------------------------------------- 
    28893211      !!                  ***  routine mpp_lnk_bdy_2d  *** 
     
    29063228      !! 
    29073229      !!---------------------------------------------------------------------- 
    2908  
    2909       USE lbcnfd          ! north fold 
    2910  
    2911       INCLUDE 'mpif.h' 
    2912  
    2913       REAL(wp), DIMENSION(jpi,jpj)    , INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied 
    2914       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points 
    2915       !                                                             ! = T , U , V , F , W points 
    2916       REAL(wp)                        , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary 
    2917       !                                                             ! =  1. , the sign is kept 
    2918       INTEGER                         , INTENT(in   ) ::   ib_bdy   ! BDY boundary set 
     3230      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied 
     3231      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points 
     3232      !                                                         ! = T , U , V , F , W points 
     3233      REAL(wp)                    , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary 
     3234      !                                                         ! =  1. , the sign is kept 
     3235      INTEGER                     , INTENT(in   ) ::   ib_bdy   ! BDY boundary set 
     3236      ! 
    29193237      INTEGER  ::   ji, jj, jl             ! dummy loop indices 
    2920       INTEGER  ::   imigr, iihom, ijhom        ! temporary integers 
     3238      INTEGER  ::   imigr, iihom, ijhom        ! local integers 
    29213239      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend 
    29223240      REAL(wp) ::   zland 
     
    29253243      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ns, zt2sn   ! 2d for north-south & south-north 
    29263244      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  zt2ew, zt2we   ! 2d for east-west & west-east 
    2927  
    29283245      !!---------------------------------------------------------------------- 
    29293246 
     
    29313248         &      zt2ew(jpj,jpreci,2), zt2we(jpj,jpreci,2)   ) 
    29323249 
    2933       zland = 0.e0 
     3250      zland = 0._wp 
    29343251 
    29353252      ! 1. standard boundary treatment 
    29363253      ! ------------------------------ 
    2937        
    29383254      !                                   ! East-West boundaries 
    2939       !                                        !* Cyclic east-west 
    2940  
    2941       IF( nbondi == 2) THEN 
    2942         IF (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN 
    2943           ptab( 1 ,:) = ptab(jpim1,:) 
    2944           ptab(jpi,:) = ptab(  2  ,:) 
    2945         ELSE 
    2946           IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:) = zland    ! south except F-point 
    2947           ptab(nlci-jpreci+1:jpi   ,:) = zland    ! north 
    2948         ENDIF 
     3255      !                                      !* Cyclic east-west 
     3256      IF( nbondi == 2 ) THEN 
     3257         IF (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN 
     3258            ptab( 1 ,:) = ptab(jpim1,:) 
     3259            ptab(jpi,:) = ptab(  2  ,:) 
     3260         ELSE 
     3261            IF(.NOT.cd_type == 'F' )  ptab(     1       :jpreci,:) = zland    ! south except F-point 
     3262                                      ptab(nlci-jpreci+1:jpi   ,:) = zland    ! north 
     3263         ENDIF 
    29493264      ELSEIF(nbondi == -1) THEN 
    2950         IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:) = zland    ! south except F-point 
     3265         IF( .NOT.cd_type == 'F' )    ptab(     1       :jpreci,:) = zland    ! south except F-point 
    29513266      ELSEIF(nbondi == 1) THEN 
    2952         ptab(nlci-jpreci+1:jpi   ,:) = zland    ! north 
    2953       ENDIF                                     !* closed 
    2954  
    2955       IF (nbondj == 2 .OR. nbondj == -1) THEN 
    2956         IF( .NOT. cd_type == 'F' )   ptab(:,     1       :jprecj) = zland       ! south except F-point 
     3267                                      ptab(nlci-jpreci+1:jpi   ,:) = zland    ! north 
     3268      ENDIF 
     3269      !                                      !* closed 
     3270      IF( nbondj == 2 .OR. nbondj == -1 ) THEN 
     3271         IF( .NOT.cd_type == 'F' )    ptab(:,     1       :jprecj) = zland    ! south except F-point 
    29573272      ELSEIF (nbondj == 2 .OR. nbondj == 1) THEN 
    2958         ptab(:,nlcj-jprecj+1:jpj) = zland       ! north 
    2959       ENDIF 
    2960        
    2961       ! 
    2962  
     3273                                      ptab(:,nlcj-jprecj+1:jpj   ) = zland    ! north 
     3274      ENDIF 
     3275      ! 
    29633276      ! 2. East and west directions exchange 
    29643277      ! ------------------------------------ 
     
    31073420      ! 
    31083421   END SUBROUTINE mpp_lnk_bdy_2d 
     3422 
    31093423 
    31103424   SUBROUTINE mpi_init_opa( ldtxt, ksft, code ) 
     
    31963510   END SUBROUTINE DDPDD_MPI 
    31973511 
     3512 
    31983513   SUBROUTINE mpp_lbc_north_icb( pt2d, cd_type, psgn, pr2dj) 
    31993514      !!--------------------------------------------------------------------- 
     
    32183533      !!                                                    ! north fold, =  1. otherwise 
    32193534      INTEGER, OPTIONAL       , INTENT(in   ) ::   pr2dj 
     3535      ! 
    32203536      INTEGER ::   ji, jj, jr 
    32213537      INTEGER ::   ierr, itaille, ildi, ilei, iilb 
     
    32243540      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE  ::  ztab_e, znorthloc_e 
    32253541      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE  ::  znorthgloio_e 
    3226  
    32273542      !!---------------------------------------------------------------------- 
    32283543      ! 
     
    32343549      ENDIF 
    32353550      ALLOCATE( ztab_e(jpiglo,4+2*ipr2dj), znorthloc_e(jpi,4+2*ipr2dj), znorthgloio_e(jpi,4+2*ipr2dj,jpni) ) 
    3236  
    3237       ! 
    3238       ztab_e(:,:) = 0.e0 
    3239  
    3240       ij=0 
     3551      ! 
     3552      ztab_e(:,:) = 0._wp 
     3553      ! 
     3554      ij = 0 
    32413555      ! put in znorthloc_e the last 4 jlines of pt2d 
    32423556      DO jj = nlcj - ijpj + 1 - ipr2dj, nlcj +ipr2dj 
     
    32803594      ! 
    32813595   END SUBROUTINE mpp_lbc_north_icb 
     3596 
    32823597 
    32833598   SUBROUTINE mpp_lnk_2d_icb( pt2d, cd_type, psgn, jpri, jprj ) 
     
    33003615      !!                    noso   : number for local neighboring processors 
    33013616      !!                    nono   : number for local neighboring processors 
    3302       !! 
    33033617      !!---------------------------------------------------------------------- 
    33043618      INTEGER                                             , INTENT(in   ) ::   jpri 
     
    34593773 
    34603774   END SUBROUTINE mpp_lnk_2d_icb 
     3775    
    34613776#else 
    34623777   !!---------------------------------------------------------------------- 
  • trunk/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90

    r4679 r6140  
    1111   !!   mpp_init_ioispl: IOIPSL initialization in mpp 
    1212   !!---------------------------------------------------------------------- 
    13    !! * Modules used 
    1413   USE dom_oce         ! ocean space and time domain  
    1514   USE in_out_manager  ! I/O Manager 
     
    2322   PUBLIC mpp_init2      ! called by opa.F90 
    2423 
    25    !! * Substitutions 
    26 #  include "domzgr_substitute.h90" 
    2724   !!---------------------------------------------------------------------- 
    2825   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     
    457454#  include "mppini_2.h90" 
    458455 
    459 # if defined key_dimgout 
    460    !!---------------------------------------------------------------------- 
    461    !!   'key_dimgout'                  NO use of NetCDF files 
    462    !!---------------------------------------------------------------------- 
    463    SUBROUTINE mpp_init_ioipsl       ! Dummy routine 
    464    END SUBROUTINE mpp_init_ioipsl   
    465 # else 
    466456   SUBROUTINE mpp_init_ioipsl 
    467457      !!---------------------------------------------------------------------- 
     
    509499   END SUBROUTINE mpp_init_ioipsl   
    510500 
    511 # endif 
    512501#endif 
    513502 
  • trunk/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90

    r5130 r6140  
    136136 
    137137      imask(:,:)=1 
    138       WHERE ( zdta(:,:) - zdtaisf(:,:) <= 0. ) imask = 0 
     138      WHERE ( zdta(:,:) - zdtaisf(:,:) <= rn_isfhmin ) imask = 0 
    139139 
    140140      !  1. Dimension arrays for subdomains 
Note: See TracChangeset for help on using the changeset viewer.