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

    r2528 r2715  
    2525   USE in_out_manager  ! I/O manager 
    2626   USE lbclnk          ! ocean lateral boundary condition (or mpp link) 
     27   USE lib_mpp         ! MPP library 
    2728 
    2829   IMPLICIT NONE 
     
    3940   REAL(wp) ::   rn_alp   =   5._wp      ! coefficient of the parameterization 
    4041 
    41    REAL(wp), DIMENSION(jpi,jpj,jpk) ::   tmric                    ! coef. for the horizontal mean at t-point 
     42   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tmric   !: coef. for the horizontal mean at t-point 
    4243 
    4344   !! * Substitutions 
    4445#  include "domzgr_substitute.h90" 
    4546   !!---------------------------------------------------------------------- 
    46    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     47   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
    4748   !! $Id$ 
    48    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    4950   !!---------------------------------------------------------------------- 
    5051CONTAINS 
     52 
     53   INTEGER FUNCTION zdf_ric_alloc() 
     54      !!---------------------------------------------------------------------- 
     55      !!                 ***  FUNCTION zdf_ric_alloc  *** 
     56      !!---------------------------------------------------------------------- 
     57      ALLOCATE( tmric(jpi,jpj,jpk)   , STAT= zdf_ric_alloc ) 
     58      ! 
     59      IF( lk_mpp             )   CALL mpp_sum ( zdf_ric_alloc ) 
     60      IF( zdf_ric_alloc /= 0 )   CALL ctl_warn('zdf_ric_alloc: failed to allocate arrays') 
     61   END FUNCTION zdf_ric_alloc 
     62 
    5163 
    5264   SUBROUTINE zdf_ric( kt ) 
     
    7789      !! References : Pacanowski & Philander 1981, JPO, 1441-1451. 
    7890      !!---------------------------------------------------------------------- 
     91      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released 
     92      USE wrk_nemo, ONLY:   zwx => wrk_2d_1     ! 2D workspace 
     93      !! 
    7994      INTEGER, INTENT( in ) ::   kt         ! ocean time-step indexocean time step 
    8095      !! 
    8196      INTEGER  ::   ji, jj, jk               ! dummy loop indices 
    8297      REAL(wp) ::   zcoef, zdku, zdkv, zri, z05alp     ! temporary scalars 
    83       REAL(wp), DIMENSION(jpi,jpj) ::   zwx ! temporary workspace 
    84       !!---------------------------------------------------------------------- 
    85  
     98      !!---------------------------------------------------------------------- 
     99 
     100      IF( wrk_in_use(2, 1) ) THEN 
     101         CALL ctl_stop('zdf_ric : requested workspace array unavailable')   ;   RETURN 
     102      ENDIF 
    86103      !                                                ! =============== 
    87104      DO jk = 2, jpkm1                                 ! Horizontal slab 
     
    104121         CALL lbc_lnk( zwx, 'W', 1. )                       ! Boundary condition   (sign unchanged) 
    105122 
    106  
    107123         ! Vertical eddy viscosity and diffusivity coefficients 
    108124         ! ------------------------------------------------------- 
    109          z05alp = 0.5 * rn_alp 
     125         z05alp = 0.5_wp * rn_alp 
    110126         DO jj = 1, jpjm1                                   ! Eddy viscosity coefficients (avm) 
    111127            DO ji = 1, jpim1 
    112                avmu(ji,jj,jk) = umask(ji,jj,jk)   & 
    113                   &           * rn_avmri / ( 1. + z05alp*( zwx(ji+1,jj)+zwx(ji,jj) ) )**nn_ric 
    114                avmv(ji,jj,jk) = vmask(ji,jj,jk)   & 
    115                   &           * rn_avmri / ( 1. + z05alp*( zwx(ji,jj+1)+zwx(ji,jj) ) )**nn_ric 
     128               avmu(ji,jj,jk) = umask(ji,jj,jk) * rn_avmri / ( 1. + z05alp*( zwx(ji+1,jj)+zwx(ji,jj) ) )**nn_ric 
     129               avmv(ji,jj,jk) = vmask(ji,jj,jk) * rn_avmri / ( 1. + z05alp*( zwx(ji,jj+1)+zwx(ji,jj) ) )**nn_ric 
    116130            END DO 
    117131         END DO 
    118132         DO jj = 2, jpjm1                                   ! Eddy diffusivity coefficients (avt) 
    119133            DO ji = 2, jpim1 
    120                avt(ji,jj,jk) = tmric(ji,jj,jk) / ( 1. + rn_alp * zwx(ji,jj) )   & 
    121                   &          * (  avmu(ji,jj,jk) + avmu(ji-1, jj ,jk)        & 
    122                   &             + avmv(ji,jj,jk) + avmv( ji ,jj-1,jk)  )     & 
     134               avt(ji,jj,jk) = tmric(ji,jj,jk) / ( 1._wp + rn_alp * zwx(ji,jj) )           & 
     135                  &                            * (  avmu(ji,jj,jk) + avmu(ji-1,jj,jk)      & 
     136                  &                               + avmv(ji,jj,jk) + avmv(ji,jj-1,jk)  )   & 
    123137                  &          + avtb(jk) * tmask(ji,jj,jk) 
    124138               !                                            ! Add the background coefficient on eddy viscosity 
     
    134148      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. ) 
    135149      ! 
     150      IF( wrk_not_released(2, 1) )   CALL ctl_stop('zdf_ric: failed to release workspace array') 
     151      ! 
    136152   END SUBROUTINE zdf_ric 
    137153 
     
    150166      !! ** Action  :   increase by 1 the nstop flag is setting problem encounter 
    151167      !!---------------------------------------------------------------------- 
    152       INTEGER :: ji, jj, jk        ! dummy loop indices 
     168      INTEGER :: ji, jj, jk   ! dummy loop indices 
    153169      !! 
    154170      NAMELIST/namzdf_ric/ rn_avmri, rn_alp, nn_ric 
     
    168184      ENDIF 
    169185      ! 
    170       DO jk = 1, jpk                 ! weighting mean array tmric for 4 T-points which accounts for coastal boundary conditions. 
    171          DO jj = 2, jpj               
     186      !                              ! allocate zdfric arrays 
     187      IF( zdf_ric_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_ric_init : unable to allocate arrays' ) 
     188      ! 
     189      DO jk = 1, jpk                 ! weighting mean array tmric for 4 T-points 
     190         DO jj = 2, jpj              ! which accounts for coastal boundary conditions             
    172191            DO ji = 2, jpi 
    173192               tmric(ji,jj,jk) =  tmask(ji,jj,jk)                                  & 
     
    177196         END DO 
    178197      END DO 
    179       tmric(:,1,:) = 0.e0 
     198      tmric(:,1,:) = 0._wp 
    180199      ! 
    181200      DO jk = 1, jpk                 ! Initialization of vertical eddy coef. to the background value 
Note: See TracChangeset for help on using the changeset viewer.