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 6667 for branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domwri.F90 – NEMO

Ignore:
Timestamp:
2016-06-06T07:57:00+02:00 (8 years ago)
Author:
gm
Message:

#1692 - branch SIMPLIF_2_usrdef: reduced domain_cfg.nc file: GYRE OK using usrdef or reading file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domwri.F90

    r6624 r6667  
    1313   !!   dom_wri        : create and write mesh and mask file(s) 
    1414   !!   dom_uniq       : identify unique point of a grid (TUVF) 
     15   !!   dom_stiff      : diagnose maximum grid stiffness/hydrostatic consistency (s-coordinate) 
    1516   !!---------------------------------------------------------------------- 
    1617   USE dom_oce         ! ocean space and time domain 
     
    2728   PUBLIC   dom_wri              ! routine called by inidom.F90 
    2829   PUBLIC   dom_wri_coordinate   ! routine called by domhgr.F90 
    29     
     30   PUBLIC   dom_stiff            ! routine called by inidom.F90 
     31 
    3032   !! * Substitutions 
    3133#  include "vectopt_loop_substitute.h90" 
     
    114116      !!      domhgr, domzgr, and dommsk. Note: the file contain depends on 
    115117      !!      the vertical coord. used (z-coord, partial steps, s-coord) 
    116       !!            MOD(nmsh, 3) = 1  :   'mesh_mask.nc' file 
     118      !!            MOD(nn_msh, 3) = 1  :   'mesh_mask.nc' file 
    117119      !!                         = 2  :   'mesh.nc' and mask.nc' files 
    118120      !!                         = 0  :   'mesh_hgr.nc', 'mesh_zgr.nc' and 
     
    121123      !!      vertical coordinate. 
    122124      !! 
    123       !!      if     nmsh <= 3: write full 3D arrays for e3[tuvw] and gdep[tuvw] 
    124       !!      if 3 < nmsh <= 6: write full 3D arrays for e3[tuvw] and 2D arrays  
     125      !!      if     nn_msh <= 3: write full 3D arrays for e3[tuvw] and gdep[tuvw] 
     126      !!      if 3 < nn_msh <= 6: write full 3D arrays for e3[tuvw] and 2D arrays  
    125127      !!                        corresponding to the depth of the bottom t- and w-points 
    126       !!      if 6 < nmsh <= 9: write 2D arrays corresponding to the depth and the 
     128      !!      if 6 < nn_msh <= 9: write 2D arrays corresponding to the depth and the 
    127129      !!                        thickness (e3[tw]_ps) of the bottom points  
    128130      !! 
     
    149151      IF( nn_timing == 1 )  CALL timing_start('dom_wri') 
    150152      ! 
    151       CALL wrk_alloc( jpi, jpj, zprt, zprw ) 
    152       CALL wrk_alloc( jpi, jpj, jpk, zdepu, zdepv ) 
     153      CALL wrk_alloc( jpi,jpj,       zprt , zprw ) 
     154      CALL wrk_alloc( jpi,jpj,jpk,  zdepu, zdepv ) 
    153155      ! 
    154156      IF(lwp) WRITE(numout,*) 
     
    162164      clnam4 = 'mesh_zgr'   ! filename (vertical   mesh informations) 
    163165       
    164       SELECT CASE ( MOD(nmsh, 3) ) 
     166      SELECT CASE ( MOD(nn_msh, 3) ) 
    165167         !                                  ! ============================ 
    166168      CASE ( 1 )                            !  create 'mesh_mask.nc' file 
     
    201203      IF( ln_zps    ) THEN   ;   izps = 1   ;   ELSE   ;   izps = 0   ;   ENDIF 
    202204      IF( ln_sco    ) THEN   ;   isco = 1   ;   ELSE   ;   isco = 0   ;   ENDIF 
    203       CALL iom_rstput( 0, 0, inum, 'ln_zco'   , REAL( izco, wp), ktype = jp_i4 ) 
    204       CALL iom_rstput( 0, 0, inum, 'ln_zps'   , REAL( izps, wp), ktype = jp_i4 ) 
    205       CALL iom_rstput( 0, 0, inum, 'ln_sco'   , REAL( isco, wp), ktype = jp_i4 ) 
     205      CALL iom_rstput( 0, 0, inum2, 'ln_zco'   , REAL( izco, wp), ktype = jp_i4 ) 
     206      CALL iom_rstput( 0, 0, inum2, 'ln_zps'   , REAL( izps, wp), ktype = jp_i4 ) 
     207      CALL iom_rstput( 0, 0, inum2, 'ln_sco'   , REAL( isco, wp), ktype = jp_i4 ) 
    206208      !                                                         ! ocean cavities under iceshelves 
    207209      IF( ln_isfcav ) THEN   ;   icav = 1   ;   ELSE   ;   icav = 0   ;   ENDIF 
    208       CALL iom_rstput( 0, 0, inum, 'ln_isfcav', REAL( icav, wp), ktype = jp_i4 ) 
     210      CALL iom_rstput( 0, 0, inum2, 'ln_isfcav', REAL( icav, wp), ktype = jp_i4 ) 
    209211   
    210212      !                                                         ! masks (inum2)  
     
    280282             
    281283      IF( ln_sco ) THEN                                         ! s-coordinate 
    282          CALL iom_rstput( 0, 0, inum4, 'hbatt', hbatt ) 
    283          CALL iom_rstput( 0, 0, inum4, 'hbatu', hbatu ) 
    284          CALL iom_rstput( 0, 0, inum4, 'hbatv', hbatv ) 
    285          CALL iom_rstput( 0, 0, inum4, 'hbatf', hbatf ) 
    286          ! 
    287          CALL iom_rstput( 0, 0, inum4, 'gsigt', gsigt )         !    ! scaling coef. 
    288          CALL iom_rstput( 0, 0, inum4, 'gsigw', gsigw )   
    289          CALL iom_rstput( 0, 0, inum4, 'gsi3w', gsi3w ) 
    290          CALL iom_rstput( 0, 0, inum4, 'esigt', esigt ) 
    291          CALL iom_rstput( 0, 0, inum4, 'esigw', esigw ) 
    292          ! 
    293284         CALL iom_rstput( 0, 0, inum4, 'e3t_0', e3t_0 )         !    ! scale factors 
    294285         CALL iom_rstput( 0, 0, inum4, 'e3u_0', e3u_0 ) 
    295286         CALL iom_rstput( 0, 0, inum4, 'e3v_0', e3v_0 ) 
    296287         CALL iom_rstput( 0, 0, inum4, 'e3w_0', e3w_0 ) 
    297          CALL iom_rstput( 0, 0, inum4, 'rx1', rx1 )             !    ! Max. grid stiffness ratio 
     288         ! 
     289         CALL dom_stiff( zprt ) 
     290         CALL iom_rstput( 0, 0, inum4, 'stiffness', zprt )      !    ! Max. grid stiffness ratio 
    298291         ! 
    299292         CALL iom_rstput( 0, 0, inum4, 'gdept_1d' , gdept_1d )  !    ! stretched system 
     
    305298      IF( ln_zps ) THEN                                         ! z-coordinate - partial steps 
    306299         ! 
    307          IF( nmsh <= 6 ) THEN                                   !    ! 3D vertical scale factors 
     300         IF( nn_msh <= 6 ) THEN                                   !    ! 3D vertical scale factors 
    308301            CALL iom_rstput( 0, 0, inum4, 'e3t_0', e3t_0 )          
    309302            CALL iom_rstput( 0, 0, inum4, 'e3u_0', e3u_0 ) 
     
    321314         END IF 
    322315         ! 
    323          IF( nmsh <= 3 ) THEN                                   !    ! 3D depth 
     316         IF( nn_msh <= 3 ) THEN                                   !    ! 3D depth 
    324317            CALL iom_rstput( 0, 0, inum4, 'gdept_0', gdept_0, ktype = jp_r8 ) 
    325318            DO jk = 1,jpk    
     
    362355      !                                     !        close the files  
    363356      !                                     ! ============================ 
    364       SELECT CASE ( MOD(nmsh, 3) ) 
     357      SELECT CASE ( MOD(nn_msh, 3) ) 
    365358      CASE ( 1 )                 
    366359         CALL iom_close( inum0 ) 
     
    425418   END SUBROUTINE dom_uniq 
    426419 
     420 
     421   SUBROUTINE dom_stiff( px1 ) 
     422      !!---------------------------------------------------------------------- 
     423      !!                  ***  ROUTINE dom_stiff  *** 
     424      !!                      
     425      !! ** Purpose :   Diagnose maximum grid stiffness/hydrostatic consistency 
     426      !! 
     427      !! ** Method  :   Compute Haney (1991) hydrostatic condition ratio 
     428      !!                Save the maximum in the vertical direction 
     429      !!                (this number is only relevant in s-coordinates) 
     430      !! 
     431      !!                Haney, 1991, J. Phys. Oceanogr., 21, 610-619. 
     432      !!---------------------------------------------------------------------- 
     433      REAL(wp), DIMENSION(:,:), INTENT(out), OPTIONAL ::   px1   ! stiffness 
     434      ! 
     435      INTEGER  ::   ji, jj, jk  
     436      REAL(wp) ::   zrxmax 
     437      REAL(wp), DIMENSION(4) ::   zr1 
     438      REAL(wp), DIMENSION(jpi,jpj) ::   zx1 
     439      !!---------------------------------------------------------------------- 
     440      zx1(:,:) = 0._wp 
     441      zrxmax   = 0._wp 
     442      zr1(:)   = 0._wp 
     443      ! 
     444      DO ji = 2, jpim1 
     445         DO jj = 2, jpjm1 
     446            DO jk = 1, jpkm1 
     447!!gm   remark: dk(gdepw) = e3t   ===>>>  possible simplification of the following calculation.... 
     448!!             especially since it is gde3w which is used to compute the pressure gradient 
     449!!             furthermore, I think gdept_0 should be used below instead of w point in the numerator 
     450!!             so that the ratio is computed at the same point (i.e. uw and vw) .... 
     451               zr1(1) = ABS(  ( gdepw_0(ji  ,jj,jk  )-gdepw_0(ji-1,jj,jk  )               &  
     452                    &          +gdepw_0(ji  ,jj,jk+1)-gdepw_0(ji-1,jj,jk+1) )             & 
     453                    &       / ( gdepw_0(ji  ,jj,jk  )+gdepw_0(ji-1,jj,jk  )               & 
     454                    &          -gdepw_0(ji  ,jj,jk+1)-gdepw_0(ji-1,jj,jk+1) + rsmall )  ) * umask(ji-1,jj,jk) 
     455               zr1(2) = ABS(  ( gdepw_0(ji+1,jj,jk  )-gdepw_0(ji  ,jj,jk  )               & 
     456                    &          +gdepw_0(ji+1,jj,jk+1)-gdepw_0(ji  ,jj,jk+1) )             & 
     457                    &       / ( gdepw_0(ji+1,jj,jk  )+gdepw_0(ji  ,jj,jk  )               & 
     458                    &          -gdepw_0(ji+1,jj,jk+1)-gdepw_0(ji  ,jj,jk+1) + rsmall )  ) * umask(ji  ,jj,jk) 
     459               zr1(3) = ABS(  ( gdepw_0(ji,jj+1,jk  )-gdepw_0(ji,jj  ,jk  )               & 
     460                    &          +gdepw_0(ji,jj+1,jk+1)-gdepw_0(ji,jj  ,jk+1) )             & 
     461                    &       / ( gdepw_0(ji,jj+1,jk  )+gdepw_0(ji,jj  ,jk  )               & 
     462                    &          -gdepw_0(ji,jj+1,jk+1)-gdepw_0(ji,jj  ,jk+1) + rsmall )  ) * vmask(ji,jj  ,jk) 
     463               zr1(4) = ABS(  ( gdepw_0(ji,jj  ,jk  )-gdepw_0(ji,jj-1,jk  )               & 
     464                    &          +gdepw_0(ji,jj  ,jk+1)-gdepw_0(ji,jj-1,jk+1) )             & 
     465                    &       / ( gdepw_0(ji,jj  ,jk  )+gdepw_0(ji,jj-1,jk  )               & 
     466                    &          -gdepw_0(ji,jj  ,jk+1)-gdepw_0(ji,jj-1,jk+1) + rsmall )  ) * vmask(ji,jj-1,jk) 
     467               zrxmax = MAXVAL( zr1(1:4) ) 
     468               zx1(ji,jj) = MAX( zx1(ji,jj) , zrxmax ) 
     469            END DO 
     470         END DO 
     471      END DO 
     472      CALL lbc_lnk( zx1, 'T', 1. ) 
     473      ! 
     474      IF( PRESENT( px1 ) )    px1 = zx1 
     475      ! 
     476      zrxmax = MAXVAL( zx1 ) 
     477      ! 
     478      IF( lk_mpp )   CALL mpp_max( zrxmax ) ! max over the global domain 
     479      ! 
     480      IF(lwp) THEN 
     481         WRITE(numout,*) 
     482         WRITE(numout,*) 'dom_stiff : maximum grid stiffness ratio: ', zrxmax 
     483         WRITE(numout,*) '~~~~~~~~~' 
     484      ENDIF 
     485      ! 
     486   END SUBROUTINE dom_stiff 
     487 
    427488   !!====================================================================== 
    428489END MODULE domwri 
Note: See TracChangeset for help on using the changeset viewer.