MODULE lbclnk !!====================================================================== !! *** MODULE lbclnk *** !! Ocean : lateral boundary conditions !!===================================================================== !! NEMO/OPA 3.3 , NEMO Consortium (2010) !! $Id$ !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) !!---------------------------------------------------------------------- #if defined key_mpp_mpi || defined key_mpp_shmem !!---------------------------------------------------------------------- !! 'key_mpp_mpi' OR MPI massively parallel processing library !! 'key_mpp_shmem' SHMEM massively parallel processing library !!---------------------------------------------------------------------- !!---------------------------------------------------------------------- !! lbc_lnk : generic interface for mpp_lnk_3d and mpp_lnk_2d !! routines defined in lib_mpp !! lbc_lnk_e : generic interface for mpp_lnk_2d_e !! routinee defined in lib_mpp !!---------------------------------------------------------------------- !! * Modules used USE lib_mpp ! distributed memory computing library INTERFACE lbc_lnk MODULE PROCEDURE mpp_lnk_3d_gather, mpp_lnk_3d, mpp_lnk_2d END INTERFACE INTERFACE lbc_lnk_e MODULE PROCEDURE mpp_lnk_2d_e END INTERFACE PUBLIC lbc_lnk ! ocean lateral boundary conditions PUBLIC lbc_lnk_e !!---------------------------------------------------------------------- #else !!---------------------------------------------------------------------- !! Default option shared memory computing !!---------------------------------------------------------------------- !! lbc_lnk : generic interface for lbc_lnk_3d and lbc_lnk_2d !! lbc_lnk_3d : set the lateral boundary condition on a 3D variable !! on OPA ocean mesh !! lbc_lnk_2d : set the lateral boundary condition on a 2D variable !! on OPA ocean mesh !!---------------------------------------------------------------------- !! * Modules used USE oce ! ocean dynamics and tracers USE dom_oce ! ocean space and time domain USE in_out_manager ! I/O manager USE lbcnfd ! north fold IMPLICIT NONE PRIVATE INTERFACE lbc_lnk MODULE PROCEDURE lbc_lnk_3d_gather, lbc_lnk_3d, lbc_lnk_2d END INTERFACE INTERFACE lbc_lnk_e MODULE PROCEDURE lbc_lnk_2d END INTERFACE PUBLIC lbc_lnk ! ocean/ice lateral boundary conditions PUBLIC lbc_lnk_e !!---------------------------------------------------------------------- CONTAINS SUBROUTINE lbc_lnk_3d_gather( pt3d1, cd_type1, pt3d2, cd_type2, psgn ) !!--------------------------------------------------------------------- !! *** ROUTINE lbc_lnk_3d_gather *** !! !! ** Purpose : set lateral boundary conditions (non mpp case) !! !! ** Method : !! !! History : !! ! 97-06 (G. Madec) Original code !! 8.5 ! 02-09 (G. Madec) F90: Free form and module !! ! 09-03 (R. Benshila) External north fold treatment !!---------------------------------------------------------------------- !! * Arguments CHARACTER(len=1), INTENT( in ) :: & cd_type1, cd_type2 ! nature of pt3d grid-points ! ! = T , U , V , F or W gridpoints REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) :: & pt3d1, pt3d2 ! 3D array on which the boundary condition is applied REAL(wp), INTENT( in ) :: & psgn ! control of the sign change ! ! =-1 , the sign is changed if north fold boundary ! ! = 1 , no sign change ! ! = 0 , no sign change and > 0 required (use the inner ! ! row/column if closed boundary) CALL lbc_lnk_3d( pt3d1, cd_type1, psgn) CALL lbc_lnk_3d( pt3d2, cd_type2, psgn) END SUBROUTINE lbc_lnk_3d_gather SUBROUTINE lbc_lnk_3d( pt3d, cd_type, psgn, cd_mpp, pval ) !!--------------------------------------------------------------------- !! *** ROUTINE lbc_lnk_3d *** !! !! ** Purpose : set lateral boundary conditions (non mpp case) !! !! ** Method : !! !! History : !! ! 97-06 (G. Madec) Original code !! 8.5 ! 02-09 (G. Madec) F90: Free form and module !! ! 09-03 (R. Benshila) External north fold treatment !!---------------------------------------------------------------------- !! * Arguments CHARACTER(len=1), INTENT( in ) :: & cd_type ! nature of pt3d grid-points ! ! = T , U , V , F or W gridpoints REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) :: & pt3d ! 3D array on which the boundary condition is applied REAL(wp), INTENT( in ) :: & psgn ! control of the sign change ! ! =-1 , the sign is changed if north fold boundary ! ! = 1 , no sign change ! ! = 0 , no sign change and > 0 required (use the inner ! ! row/column if closed boundary) CHARACTER(len=3), INTENT( in ), OPTIONAL :: & cd_mpp ! fill the overlap area only (here do nothing) REAL(wp) , INTENT(in ), OPTIONAL :: pval ! background value (used at closed boundaries) !! * Local declarations REAL(wp) :: zland IF( PRESENT( pval ) ) THEN ! set land value (zero by default) zland = pval ELSE zland = 0.e0 ENDIF IF( PRESENT( cd_mpp ) ) THEN ! only fill the overlap area and extra allows ! this is in mpp case. In this module, just do nothing ELSE ! ! East-West boundaries ! ! ====================== SELECT CASE ( nperio ) ! CASE ( 1 , 4 , 6 ) !** cyclic east-west pt3d( 1 ,:,:) = pt3d(jpim1,:,:) ! all points pt3d(jpi,:,:) = pt3d( 2 ,:,:) ! CASE DEFAULT !** East closed -- West closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'V' , 'W' ) ! T-, U-, V-, W-points pt3d( 1 ,:,:) = zland pt3d(jpi,:,:) = zland CASE ( 'F' ) ! F-point pt3d(jpi,:,:) = zland END SELECT ! END SELECT ! ! North-South boundaries ! ! ====================== SELECT CASE ( nperio ) ! CASE ( 2 ) !** South symmetric -- North closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'W' ) ! T-, U-, W-points pt3d(:, 1 ,:) = pt3d(:,3,:) pt3d(:,jpj,:) = zland CASE ( 'V' , 'F' ) ! V-, F-points pt3d(:, 1 ,:) = psgn * pt3d(:,2,:) pt3d(:,jpj,:) = zland END SELECT ! CASE ( 3 , 4 , 5 , 6 ) !** North fold T or F-point pivot -- South closed SELECT CASE ( cd_type ) ! South : closed CASE ( 'T' , 'U' , 'V' , 'W' , 'I' ) ! all points except F-point pt3d(:, 1 ,:) = zland END SELECT ! ! North fold pt3d( 1 ,jpj,:) = zland pt3d(jpi,jpj,:) = zland CALL lbc_nfd( pt3d(:,:,:), cd_type, psgn ) ! CASE DEFAULT !** North closed -- South closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'V' , 'W' ) ! T-, U-, V-, W-points pt3d(:, 1 ,:) = zland pt3d(:,jpj,:) = zland CASE ( 'F' ) ! F-point pt3d(:,jpj,:) = zland END SELECT ! END SELECT ENDIF END SUBROUTINE lbc_lnk_3d SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval ) !!--------------------------------------------------------------------- !! *** ROUTINE lbc_lnk_2d *** !! !! ** Purpose : set lateral boundary conditions (non mpp case) !! !! ** Method : !! !! History : !! ! 97-06 (G. Madec) Original code !! ! 01-05 (E. Durand) correction !! 8.5 ! 02-09 (G. Madec) F90: Free form and module !! ! 09-03 (R. Benshila) External north fold treatment !!---------------------------------------------------------------------- !! * Arguments CHARACTER(len=1), INTENT( in ) :: & cd_type ! nature of pt2d grid-point ! ! = T , U , V , F or W gridpoints ! ! = I sea-ice U-V gridpoint (= F ocean grid point with indice shift) REAL(wp), INTENT( in ) :: & psgn ! control of the sign change ! ! =-1 , the sign is modified following the type of b.c. used ! ! = 1 , no sign change REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) :: & pt2d ! 2D array on which the boundary condition is applied CHARACTER(len=3), INTENT( in ), OPTIONAL :: & cd_mpp ! fill the overlap area only (here do nothing) REAL(wp) , INTENT(in ), OPTIONAL :: pval ! background value (used at closed boundaries) !! * Local declarations REAL(wp) :: zland IF( PRESENT( pval ) ) THEN ! set land value (zero by default) zland = pval ELSE zland = 0.e0 ENDIF IF (PRESENT(cd_mpp)) THEN ! only fill the overlap area and extra allows ! this is in mpp case. In this module, just do nothing ELSE ! ! East-West boundaries ! ! ==================== SELECT CASE ( nperio ) ! CASE ( 1 , 4 , 6 ) !** cyclic east-west pt2d( 1 ,:) = pt2d(jpim1,:) ! all points pt2d(jpi,:) = pt2d( 2 ,:) ! CASE DEFAULT !** East closed -- West closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'V' , 'W' ) ! T-, U-, V-, W-points pt2d( 1 ,:) = zland pt2d(jpi,:) = zland CASE ( 'F' ) ! F-point pt2d(jpi,:) = zland END SELECT ! END SELECT ! ! North-South boundaries ! ! ====================== SELECT CASE ( nperio ) ! CASE ( 2 ) !** South symmetric -- North closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'W' ) ! T-, U-, W-points pt2d(:, 1 ) = pt2d(:,3) pt2d(:,jpj) = zland CASE ( 'V' , 'F' ) ! V-, F-points pt2d(:, 1 ) = psgn * pt2d(:,2) pt2d(:,jpj) = zland END SELECT ! CASE ( 3 , 4 , 5 , 6 ) !** North fold T or F-point pivot -- South closed SELECT CASE ( cd_type ) ! South : closed CASE ( 'T' , 'U' , 'V' , 'W' , 'I' ) ! all points except F-point pt2d(:, 1 ) = zland END SELECT ! ! North fold pt2d( 1 ,1 ) = zland pt2d( 1 ,jpj) = zland pt2d(jpi,jpj) = zland CALL lbc_nfd( pt2d(:,:), cd_type, psgn ) ! CASE DEFAULT !** North closed -- South closed SELECT CASE ( cd_type ) CASE ( 'T' , 'U' , 'V' , 'W' ) ! T-, U-, V-, W-points pt2d(:, 1 ) = zland pt2d(:,jpj) = zland CASE ( 'F' ) ! F-point pt2d(:,jpj) = zland END SELECT ! END SELECT ENDIF END SUBROUTINE lbc_lnk_2d #endif !!====================================================================== END MODULE lbclnk