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/DIA/diahth.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/DIA/diahth.F90

    r2561 r2715  
    2121   USE phycst          ! physical constants 
    2222   USE in_out_manager  ! I/O manager 
     23   USE lib_mpp         ! MPP library 
    2324   USE iom             ! I/O library 
    2425 
     
    2627   PRIVATE 
    2728 
    28    PUBLIC   dia_hth    ! routine called by step.F90 
    29  
    30    LOGICAL , PUBLIC, PARAMETER          ::   lk_diahth = .TRUE.   !: thermocline-20d depths flag 
     29   PUBLIC   dia_hth       ! routine called by step.F90 
     30   PUBLIC   dia_hth_alloc ! routine called by nemogcm.F90 
     31 
     32   LOGICAL , PUBLIC, PARAMETER          ::   lk_diahth = .TRUE.    !: thermocline-20d depths flag 
    3133   ! note: following variables should move to local variables once iom_put is always used  
    32    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hth                  !: depth of the max vertical temperature gradient [m] 
    33    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hd20                 !: depth of 20 C isotherm                         [m] 
    34    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hd28                 !: depth of 28 C isotherm                         [m] 
    35    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   htc3                 !: heat content of first 300 m                    [W] 
     34   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hth    !: depth of the max vertical temperature gradient [m] 
     35   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hd20   !: depth of 20 C isotherm                         [m] 
     36   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hd28   !: depth of 28 C isotherm                         [m] 
     37   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   htc3   !: heat content of first 300 m                    [W] 
    3638 
    3739   !! * Substitutions 
    3840#  include "domzgr_substitute.h90" 
    3941   !!---------------------------------------------------------------------- 
    40    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     42   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
    4143   !! $Id$  
    4244   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    4345   !!---------------------------------------------------------------------- 
    4446CONTAINS 
     47 
     48   FUNCTION dia_hth_alloc() 
     49      !!--------------------------------------------------------------------- 
     50      INTEGER :: dia_hth_alloc 
     51      !!--------------------------------------------------------------------- 
     52      ! 
     53      ALLOCATE(hth(jpi,jpj), hd20(jpi,jpj), hd28(jpi,jpj), htc3(jpi,jpj), STAT=dia_hth_alloc) 
     54      ! 
     55      IF( lk_mpp           )   CALL mpp_sum ( dia_hth_alloc ) 
     56      IF(dia_hth_alloc /= 0)   CALL ctl_warn('dia_hth_alloc: failed to allocate arrays.') 
     57      ! 
     58   END FUNCTION dia_hth_alloc 
     59 
    4560 
    4661   SUBROUTINE dia_hth( kt ) 
     
    6883      INTEGER                          ::   ji, jj, jk            ! dummy loop arguments 
    6984      INTEGER                          ::   iid, ilevel           ! temporary integers 
    70       INTEGER, DIMENSION(jpi,jpj)      ::   ik20, ik28            ! levels 
     85      INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ik20, ik28  ! levels 
    7186      REAL(wp)                         ::   zavt5 = 5.e-4_wp      ! Kz criterion for the turbocline depth 
    7287      REAL(wp)                         ::   zrho3 = 0.03_wp       ! density     criterion for mixed layer depth 
     
    7691      REAL(wp)                         ::   zztmp, zzdep          ! temporary scalars inside do loop 
    7792      REAL(wp)                         ::   zu, zv, zw, zut, zvt  ! temporary workspace 
    78       REAL(wp), DIMENSION(jpi,jpj)     ::   zabs2                 ! MLD: abs( tn - tn(10m) ) = ztem2  
    79       REAL(wp), DIMENSION(jpi,jpj)     ::   ztm2                  ! Top of thermocline: tn = tn(10m) - ztem2      
    80       REAL(wp), DIMENSION(jpi,jpj)     ::   zrho10_3              ! MLD: rho = rho10m + zrho3       
    81       REAL(wp), DIMENSION(jpi,jpj)     ::   zpycn                 ! pycnocline: rho = rho10m + (dr/dT)(T,S,10m)*(-0.2 degC) 
    82       REAL(wp), DIMENSION(jpi,jpj)     ::   ztinv                 ! max of temperature inversion 
    83       REAL(wp), DIMENSION(jpi,jpj)     ::   zdepinv               ! depth of temperature inversion 
    84       REAL(wp), DIMENSION(jpi,jpj)     ::   zrho0_3               ! MLD rho = rho(surf) = 0.03 
    85       REAL(wp), DIMENSION(jpi,jpj)     ::   zrho0_1               ! MLD rho = rho(surf) = 0.01 
    86       REAL(wp), DIMENSION(jpi,jpj)     ::   zmaxdzT               ! max of dT/dz 
    87       REAL(wp), DIMENSION(jpi,jpj)     ::   zthick                ! vertical integration thickness  
    88       REAL(wp), DIMENSION(jpi,jpj)     ::   zdelr                 ! delta rho equivalent to deltaT = 0.2 
     93      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zabs2      ! MLD: abs( tn - tn(10m) ) = ztem2  
     94      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ztm2       ! Top of thermocline: tn = tn(10m) - ztem2      
     95      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zrho10_3   ! MLD: rho = rho10m + zrho3       
     96      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zpycn      ! pycnocline: rho = rho10m + (dr/dT)(T,S,10m)*(-0.2 degC) 
     97      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ztinv      ! max of temperature inversion 
     98      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zdepinv    ! depth of temperature inversion 
     99      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zrho0_3    ! MLD rho = rho(surf) = 0.03 
     100      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zrho0_1    ! MLD rho = rho(surf) = 0.01 
     101      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zmaxdzT    ! max of dT/dz 
     102      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zthick     ! vertical integration thickness  
     103      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zdelr      ! delta rho equivalent to deltaT = 0.2 
    89104      !!---------------------------------------------------------------------- 
    90105 
    91106      IF( kt == nit000 ) THEN 
     107         !                                      ! allocate dia_hth array 
     108         IF( dia_hth_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'lim_sbc_init : unable to allocate standard arrays' ) 
     109 
     110         IF(.not. ALLOCATED(ik20))THEN 
     111            ALLOCATE(ik20(jpi,jpj), ik28(jpi,jpj), & 
     112               &      zabs2(jpi,jpj),   & 
     113               &      ztm2(jpi,jpj),    & 
     114               &      zrho10_3(jpi,jpj),& 
     115               &      zpycn(jpi,jpj),   & 
     116               &      ztinv(jpi,jpj),   & 
     117               &      zdepinv(jpi,jpj), & 
     118               &      zrho0_3(jpi,jpj), & 
     119               &      zrho0_1(jpi,jpj), & 
     120               &      zmaxdzT(jpi,jpj), & 
     121               &      zthick(jpi,jpj),  & 
     122               &      zdelr(jpi,jpj), STAT=ji) 
     123            IF( lk_mpp  )   CALL mpp_sum(ji) 
     124            IF( ji /= 0 )   CALL ctl_stop( 'STOP', 'dia_hth : unable to allocate standard ocean arrays' ) 
     125         END IF 
     126 
    92127         IF(lwp) WRITE(numout,*) 
    93128         IF(lwp) WRITE(numout,*) 'dia_hth : diagnostics of the thermocline depth' 
Note: See TracChangeset for help on using the changeset viewer.