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 2715 for trunk/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90 – NEMO

Ignore:
Timestamp:
2011-03-30T17:58:35+02:00 (13 years ago)
Author:
rblod
Message:

First attempt to put dynamic allocation on the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90

    r2528 r2715  
    2525   USE restart        ! only for lrst_oce 
    2626   USE lbclnk         ! ocean lateral boundary conditions (or mpp link) 
     27   USE lib_mpp        ! MPP manager 
    2728   USE prtctl         ! Print control 
    2829   USE in_out_manager ! I/O manager 
     
    3637   PUBLIC   gls_rst        ! routine called in step module 
    3738 
    38    LOGICAL , PUBLIC, PARAMETER              ::   lk_zdfgls = .TRUE.  !: TKE vertical mixing flag 
    39    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   en                  !: now turbulent kinetic energy 
    40    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   mxln                !: now mixing length 
    41    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   zwall               !: wall function 
    42    REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ustars2             !: Squared surface velocity scale at T-points 
    43    REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ustarb2             !: Squared bottom  velocity scale at T-points 
     39   LOGICAL , PUBLIC, PARAMETER ::   lk_zdfgls = .TRUE.   !: TKE vertical mixing flag 
     40   ! 
     41   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   en      !: now turbulent kinetic energy 
     42   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   mxln    !: now mixing length 
     43   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   zwall   !: wall function 
     44   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ustars2 !: Squared surface velocity scale at T-points 
     45   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ustarb2 !: Squared bottom  velocity scale at T-points 
    4446 
    4547   !                                         !!! ** Namelist  namzdf_gls  ** 
     
    105107   !!---------------------------------------------------------------------- 
    106108   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
    107    !! $Id $ 
     109   !! $Id$ 
    108110   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    109111   !!---------------------------------------------------------------------- 
    110112CONTAINS 
     113 
     114   INTEGER FUNCTION zdf_gls_alloc() 
     115      !!---------------------------------------------------------------------- 
     116      !!                ***  FUNCTION zdf_gls_alloc  *** 
     117      !!---------------------------------------------------------------------- 
     118      ALLOCATE( en(jpi,jpj,jpk),  mxln(jpi,jpj,jpk), zwall(jpi,jpj,jpk) ,     & 
     119         &      ustars2(jpi,jpj), ustarb2(jpi,jpj)                      , STAT= zdf_gls_alloc ) 
     120         ! 
     121      IF( lk_mpp             )   CALL mpp_sum ( zdf_gls_alloc ) 
     122      IF( zdf_gls_alloc /= 0 )   CALL ctl_warn('zdf_gls_alloc: failed to allocate arrays') 
     123   END FUNCTION zdf_gls_alloc 
     124 
    111125 
    112126   SUBROUTINE zdf_gls( kt ) 
     
    121135      USE oce,     z_elem_c  =>   ta   ! use ta as workspace 
    122136      USE oce,     psi       =>   sa   ! use sa as workspace 
     137      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released 
     138      USE wrk_nemo, ONLY: zdep  => wrk_2d_1 
     139      USE wrk_nemo, ONLY: zflxs => wrk_2d_2     ! Turbulence fluxed induced by internal waves  
     140      USE wrk_nemo, ONLY: zhsro => wrk_2d_3     ! Surface roughness (surface waves) 
     141      USE wrk_nemo, ONLY: eb        => wrk_3d_1   ! tke at time before 
     142      USE wrk_nemo, ONLY: mxlb      => wrk_3d_2   ! mixing length at time before 
     143      USE wrk_nemo, ONLY: shear     => wrk_3d_3   ! vertical shear 
     144      USE wrk_nemo, ONLY: eps       => wrk_3d_4   ! dissipation rate 
     145      USE wrk_nemo, ONLY: zwall_psi => wrk_3d_5   ! Wall function use in the wb case (ln_sigpsi.AND.ln_crban=T) 
    123146      ! 
    124147      INTEGER, INTENT(in) ::   kt ! ocean time step 
     
    129152      REAL(wp) ::   prod, buoy, diss, zdiss, sm         !   -      - 
    130153      REAL(wp) ::   gh, gm, shr, dif, zsqen, zav        !   -      - 
    131       REAL(wp), DIMENSION(jpi,jpj)     ::   zdep        ! 
    132       REAL(wp), DIMENSION(jpi,jpj)     ::   zflxs       ! Turbulence fluxed induced by internal waves  
    133       REAL(wp), DIMENSION(jpi,jpj)     ::   zhsro       ! Surface roughness (surface waves) 
    134       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   eb          ! tke at time before 
    135       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   mxlb        ! mixing length at time before 
    136       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   shear       ! vertical shear 
    137       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   eps         ! dissipation rate 
    138       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwall_psi   ! Wall function use in the wb case (ln_sigpsi.AND.ln_crban=T) 
    139154      !!-------------------------------------------------------------------- 
     155 
     156      IF(  wrk_in_use(2, 1,2,3)  .OR.  wrk_in_use(3, 1,2,3,4,5)  ) THEN 
     157         CALL ctl_stop('zdf_gls: requested workspace arrays unavailable.')   ;   RETURN 
     158      END IF 
    140159 
    141160      ! Preliminary computing 
     
    864883      ENDIF 
    865884      ! 
     885      IF( wrk_not_released(2, 1,2,3)     .OR. & 
     886          wrk_not_released(3, 1,2,3,4,5)  )   CALL ctl_stop('zdf_gls: failed to release workspace arrays') 
     887      ! 
    866888   END SUBROUTINE zdf_gls 
    867889 
     
    896918      !!---------------------------------------------------------- 
    897919 
    898       REWIND ( numnam )                !* Read Namelist namzdf_gls 
    899       READ   ( numnam, namzdf_gls ) 
     920      REWIND( numnam )                 !* Read Namelist namzdf_gls 
     921      READ  ( numnam, namzdf_gls ) 
    900922 
    901923      IF(lwp) THEN                     !* Control print 
     
    923945      ENDIF 
    924946 
     947      !                                !* allocate gls arrays 
     948      IF( zdf_gls_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_gls_init : unable to allocate arrays' ) 
     949 
    925950      !                                !* Check of some namelist values 
    926951      IF( nn_tkebc_surf < 0 .OR. nn_tkebc_surf > 1 ) CALL ctl_stop( 'bad flag: nn_tkebc_surf is 0 or 1' ) 
     
    931956      IF( nn_clos       < 0 .OR. nn_clos       > 3 ) CALL ctl_stop( 'bad flag: nn_clos is 0, 1, 2 or 3' ) 
    932957 
    933       ! Initialisation of the parameters for the choosen closure 
    934       ! -------------------------------------------------------- 
    935       ! 
    936       SELECT CASE ( nn_clos ) 
    937       ! 
    938       CASE( 0 )               ! k-kl  (Mellor-Yamada) 
     958      SELECT CASE ( nn_clos )          !* set the parameters for the chosen closure 
     959      ! 
     960      CASE( 0 )                              ! k-kl  (Mellor-Yamada) 
    939961         ! 
    940962         IF(lwp) WRITE(numout,*) 'The choosen closure is k-kl closed to the classical Mellor-Yamada' 
     
    954976         END SELECT 
    955977         ! 
    956       CASE( 1 )               ! k-eps 
     978      CASE( 1 )                              ! k-eps 
    957979         ! 
    958980         IF(lwp) WRITE(numout,*) 'The choosen closure is k-eps' 
     
    972994         END SELECT 
    973995         ! 
    974       CASE( 2 )               ! k-omega 
     996      CASE( 2 )                              ! k-omega 
    975997         ! 
    976998         IF(lwp) WRITE(numout,*) 'The choosen closure is k-omega' 
     
    9901012         END SELECT 
    9911013         ! 
    992       CASE( 3 )               ! generic 
     1014      CASE( 3 )                              ! generic 
    9931015         ! 
    9941016         IF(lwp) WRITE(numout,*) 'The choosen closure is generic' 
     
    10101032      END SELECT 
    10111033 
    1012       ! Initialisation of the parameters of the stability functions 
    1013       ! ----------------------------------------------------------- 
    1014       ! 
    1015       SELECT CASE ( nn_stab_func ) 
    1016       ! 
    1017       CASE ( 0 )             ! Galperin stability functions 
     1034      ! 
     1035      SELECT CASE ( nn_stab_func )     !* set the parameters of the stability functions 
     1036      ! 
     1037      CASE ( 0 )                             ! Galperin stability functions 
    10181038         ! 
    10191039         IF(lwp) WRITE(numout,*) 'Stability functions from Galperin' 
     
    10271047         rghcri  =  0.02_wp 
    10281048         ! 
    1029       CASE ( 1 )             ! Kantha-Clayson stability functions 
     1049      CASE ( 1 )                             ! Kantha-Clayson stability functions 
    10301050         ! 
    10311051         IF(lwp) WRITE(numout,*) 'Stability functions from Kantha-Clayson' 
     
    10391059         rghcri  =  0.02_wp 
    10401060         ! 
    1041       CASE ( 2 )             ! Canuto A stability functions 
     1061      CASE ( 2 )                             ! Canuto A stability functions 
    10421062         ! 
    10431063         IF(lwp) WRITE(numout,*) 'Stability functions from Canuto A' 
     
    10631083         rghcri  =  0.03_wp 
    10641084         ! 
    1065       CASE ( 3 )             ! Canuto B stability functions 
     1085      CASE ( 3 )                             ! Canuto B stability functions 
    10661086         ! 
    10671087         IF(lwp) WRITE(numout,*) 'Stability functions from Canuto B' 
     
    10881108      END SELECT 
    10891109     
    1090       ! Set Schmidt number for psi diffusion in the wave breaking case 
    1091       ! See equation 13 of Carniel et al, Ocean modelling, 30, 225-239, 2009 
    1092       ! or equation (17) of Burchard, JPO, 31, 3133-3145, 2001 
     1110      !                                !* Set Schmidt number for psi diffusion in the wave breaking case 
     1111      !                                     ! See Eq. (13) of Carniel et al, OM, 30, 225-239, 2009 
     1112      !                                     !  or Eq. (17) of Burchard, JPO, 31, 3133-3145, 2001 
    10931113      IF( ln_sigpsi .AND. ln_crban ) THEN 
    10941114         zcr = SQRT( 1.5_wp*rsc_tke ) * rcm_sf / vkarmn 
     
    11001120      ENDIF 
    11011121  
    1102       ! Shear free turbulence parameters: 
     1122      !                                !* Shear free turbulence parameters 
    11031123      ! 
    11041124      ra_sf  = -4._wp * rnn * SQRT( rsc_tke ) / ( (1._wp+4._wp*rmm) * SQRT( rsc_tke )   & 
     
    11111131 
    11121132      ! 
    1113       IF(lwp) THEN      ! Control print 
     1133      IF(lwp) THEN                     !* Control print 
    11141134         WRITE(numout,*) 
    11151135         WRITE(numout,*) 'Limit values' 
     
    11341154      ENDIF 
    11351155 
    1136       ! Constants initialization 
     1156      !                                !* Constants initialization 
    11371157      rc02  = rc0  * rc0   ;   rc02r = 1. / rc02 
    11381158      rc03  = rc02 * rc0 
     
    11611181         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk) 
    11621182      END DO 
    1163       !                                !* read or initialize all required files  
    1164       CALL gls_rst( nit000, 'READ' ) 
     1183      !                               
     1184      CALL gls_rst( nit000, 'READ' )   !* read or initialize all required files 
    11651185      ! 
    11661186   END SUBROUTINE zdf_gls_init 
Note: See TracChangeset for help on using the changeset viewer.