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/zdfmxl.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/zdfmxl.F90

    r2528 r2715  
    1414   USE in_out_manager  ! I/O manager 
    1515   USE prtctl          ! Print control 
    16    USE iom 
     16   USE iom             ! I/O library 
     17   USE lib_mpp         ! MPP library 
    1718 
    1819   IMPLICIT NONE 
    1920   PRIVATE 
    2021 
    21    PUBLIC   zdf_mxl    ! called by step.F90 
     22   PUBLIC   zdf_mxl       ! called by step.F90 
    2223 
    23    INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   nmln    !: number of level in the mixed layer (used by TOP) 
    24    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmld    !: mixing layer depth (turbocline)      [m] 
    25    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m] 
    26    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmlpt   !: mixed layer depth at t-points        [m] 
     24   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by TOP) 
     25   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld    !: mixing layer depth (turbocline)      [m] 
     26   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m] 
     27   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlpt   !: mixed layer depth at t-points        [m] 
    2728 
    2829   !! * Substitutions 
    2930#  include "domzgr_substitute.h90" 
    3031   !!---------------------------------------------------------------------- 
    31    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     32   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
    3233   !! $Id$  
    33    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     34   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    3435   !!---------------------------------------------------------------------- 
     36CONTAINS 
    3537 
    36 CONTAINS 
     38   INTEGER FUNCTION zdf_mxl_alloc() 
     39      !!---------------------------------------------------------------------- 
     40      !!               ***  FUNCTION zdf_mxl_alloc  *** 
     41      !!---------------------------------------------------------------------- 
     42      ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), STAT= zdf_mxl_alloc ) 
     43      ! 
     44      IF( lk_mpp             )   CALL mpp_sum ( zdf_mxl_alloc ) 
     45      IF( zdf_mxl_alloc /= 0 )   CALL ctl_warn('zdf_mxl_alloc: failed to allocate arrays.') 
     46   END FUNCTION zdf_mxl_alloc 
     47 
    3748 
    3849   SUBROUTINE zdf_mxl( kt ) 
     
    5364      !! ** Action  :   nmln, hmld, hmlp, hmlpt 
    5465      !!---------------------------------------------------------------------- 
    55       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index 
     66      USE wrk_nemo, ONLY:   iwrk_in_use, iwrk_not_released 
     67      USE wrk_nemo, ONLY:   imld => iwrk_2d_1    ! 2D integer workspace 
    5668      !! 
    57       INTEGER                     ::   ji, jj, jk          ! dummy loop indices 
    58       INTEGER                     ::   iikn, iiki          ! temporary integer within a do loop 
    59       INTEGER, DIMENSION(jpi,jpj) ::   imld                ! temporary workspace 
    60       REAL(wp)                    ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth 
    61       REAL(wp)                    ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth 
     69      INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
     70      !! 
     71      INTEGER  ::   ji, jj, jk          ! dummy loop indices 
     72      INTEGER  ::   iikn, iiki          ! temporary integer within a do loop 
     73      REAL(wp) ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth 
     74      REAL(wp) ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth 
    6275      !!---------------------------------------------------------------------- 
     76 
     77      IF( iwrk_in_use(2, 1) ) THEN 
     78         CALL ctl_stop('zdf_mxl : requested workspace array unavailable')   ;   RETURN 
     79      ENDIF 
    6380 
    6481      IF( kt == nit000 ) THEN 
     
    6683         IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth' 
    6784         IF(lwp) WRITE(numout,*) '~~~~~~~ ' 
     85         !                             ! allocate zdfmxl arrays 
     86         IF( zdf_mxl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl : unable to allocate arrays' ) 
    6887      ENDIF 
    6988 
     
    94113      IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 ) 
    95114      ! 
     115      IF( iwrk_not_released(2, 1) )   CALL ctl_stop('zdf_mxl: failed to release workspace array') 
     116      ! 
    96117   END SUBROUTINE zdf_mxl 
    97118 
Note: See TracChangeset for help on using the changeset viewer.