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.
usrdef_zgr.F90 in NEMO/branches/2019/dev_r11943_MERGE_2019/tests/LOCK_EXCHANGE/MY_SRC – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90 @ 12353

Last change on this file since 12353 was 12353, checked in by acc, 4 years ago

Branch 2019/dev_r11943_MERGE_2019. Additions to the do loop macro implementation: converted a few loops previously missed because they used jpi-1 instead of jpim1 etc.; changed internal macro names in do_loop_substitute.h90 to strings that are much more unlikely to appear in any future code elsewhere and removed the key_vectopt_loop option (and all related code) since the do loop macros have suppressed this option. These changes have been fully SETTE-tested and this branch should now be ready to go back to the trunk.

  • Property svn:keywords set to Id
File size: 8.2 KB
Line 
1MODULE usrdef_zgr
2   !!======================================================================
3   !!                   ***  MODULE  usrdef_zgr  ***
4   !!
5   !!                   ===  LOCK_EXCHANGE case  ===
6   !!
7   !! Ocean domain : user defined vertical coordinate system
8   !!======================================================================
9   !! History :  4.0  ! 2016-08  (G. Madec, S. Flavoni)  Original code
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_zgr   : user defined vertical coordinate system (required)
14   !!       zgr_z1d   : reference 1D z-coordinate
15   !!---------------------------------------------------------------------
16   USE oce            ! ocean variables
17   USE usrdef_nam     ! User defined : namelist variables
18   !
19   USE in_out_manager ! I/O manager
20   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
21   USE lib_mpp        ! distributed memory computing library
22   USE timing         ! Timing
23
24   IMPLICIT NONE
25   PRIVATE
26
27   PUBLIC   usr_def_zgr   ! called by domzgr.F90
28
29   !!----------------------------------------------------------------------
30   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
31   !! $Id$
32   !! Software governed by the CeCILL license (see ./LICENSE)
33   !!----------------------------------------------------------------------
34CONTAINS             
35
36   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
37      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
38      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
39      &                    pe3t  , pe3u  , pe3v , pe3f ,               &   ! vertical scale factors
40      &                    pe3w  , pe3uw , pe3vw,                      &   !     -      -      -
41      &                    k_top  , k_bot    )                             ! top & bottom ocean level
42      !!---------------------------------------------------------------------
43      !!              ***  ROUTINE usr_def_zgr  ***
44      !!
45      !! ** Purpose :   User defined the vertical coordinates
46      !!
47      !!----------------------------------------------------------------------
48      LOGICAL                   , INTENT(out) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags
49      LOGICAL                   , INTENT(out) ::   ld_isfcav                   ! under iceshelf cavity flag
50      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
51      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
52      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pdept, pdepw                ! grid-point depth        [m]
53      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
54      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors
55      INTEGER , DIMENSION(:,:)  , INTENT(out) ::   k_top, k_bot                ! first & last ocean level
56      !
57      INTEGER  ::   jk   ! dummy indices
58      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
59      !!----------------------------------------------------------------------
60      !
61      IF(lwp) WRITE(numout,*)
62      IF(lwp) WRITE(numout,*) 'usr_def_zgr : LOCK_EXCHANGE configuration (z-coordinate closed box ocean without cavities)'
63      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
64      !
65      !
66      ! type of vertical coordinate   ==>>>   here LOCK EXCHANGE : flat bottom always
67      ! ---------------------------
68      ld_zco    = .TRUE.       ! z-partial-step coordinate
69      ld_zps    = .FALSE.      ! z-partial-step coordinate
70      ld_sco    = .FALSE.      ! s-coordinate
71      ld_isfcav = .FALSE.      ! ISF Ice Shelves Flag
72      !
73      !
74      ! Build the vertical coordinate system
75      ! ------------------------------------
76      !
77      !                       !==  UNmasked meter bathymetry  ==!
78      !
79      ! flat bassin (20m deep and 64000m wide, set through the jpk and jpi (see userdef_nam.F90))
80      CALL zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
81      !
82      !
83      !                       !==  top masked level bathymetry  ==!  (all coordinates)
84      !
85      ! no ocean cavities : top ocean level is ONE, except over land
86      ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0
87      z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
88      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
89      k_top(:,:) = NINT( z2d(:,:) )
90      !
91      !                             
92      !                       !==  z-coordinate  ==!   (step-like topography)
93      !
94      !                                !* bottom ocean compute from the depth of grid-points
95      k_bot(:,:) = jpkm1 * k_top(:,:)     ! here use k_top as a land mask
96      !                                !* horizontally uniform coordinate (reference z-co everywhere)
97      DO jk = 1, jpk
98         pdept(:,:,jk) = pdept_1d(jk)
99         pdepw(:,:,jk) = pdepw_1d(jk)
100         pe3t (:,:,jk) = pe3t_1d (jk)
101         pe3u (:,:,jk) = pe3t_1d (jk)
102         pe3v (:,:,jk) = pe3t_1d (jk)
103         pe3f (:,:,jk) = pe3t_1d (jk)
104         pe3w (:,:,jk) = pe3w_1d (jk)
105         pe3uw(:,:,jk) = pe3w_1d (jk)
106         pe3vw(:,:,jk) = pe3w_1d (jk)
107      END DO
108      !
109   END SUBROUTINE usr_def_zgr
110
111
112   SUBROUTINE zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
113      !!----------------------------------------------------------------------
114      !!                   ***  ROUTINE zgr_z1d  ***
115      !!
116      !! ** Purpose :   set the depth of model levels and the resulting
117      !!      vertical scale factors.
118      !!
119      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
120      !!       The depth of model levels is set from dep(k), an analytical function:
121      !!                   w-level: depw_1d  = dep(k)
122      !!                   t-level: dept_1d  = dep(k+0.5)
123      !!       The scale factors are the discrete derivative of the depth:
124      !!                   e3w_1d(jk) = dk[ dept_1d ]
125      !!                   e3t_1d(jk) = dk[ depw_1d ]
126      !!
127      !!            ===    Here constant vertical resolution   ===
128      !!
129      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
130      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
131      !!----------------------------------------------------------------------
132      REAL(wp), DIMENSION(:), INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
133      REAL(wp), DIMENSION(:), INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
134      !
135      INTEGER  ::   jk       ! dummy loop indices
136      REAL(wp) ::   zt, zw   ! local scalar
137      !!----------------------------------------------------------------------
138      !
139      IF(lwp) THEN                         ! Parameter print
140         WRITE(numout,*)
141         WRITE(numout,*) '    zgr_z1d : Reference vertical z-coordinates: uniform dz = ', rn_dz
142         WRITE(numout,*) '    ~~~~~~~'
143      ENDIF
144      !
145      ! Reference z-coordinate (depth - scale factor at T- and W-points)   ! Madec & Imbard 1996 function
146      ! ----------------------
147      DO jk = 1, jpk
148         zw = REAL( jk , wp )
149         zt = REAL( jk , wp ) + 0.5_wp
150         pdepw_1d(jk) =    rn_dz *   REAL( jk-1 , wp )
151         pdept_1d(jk) =    rn_dz * ( REAL( jk-1 , wp ) + 0.5_wp )
152         pe3w_1d (jk) =    rn_dz
153         pe3t_1d (jk) =    rn_dz
154      END DO
155      !
156      IF(lwp) THEN                        ! control print
157         WRITE(numout,*)
158         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
159         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
160         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
161      ENDIF
162      !
163   END SUBROUTINE zgr_z1d
164   
165   !!======================================================================
166END MODULE usrdef_zgr
Note: See TracBrowser for help on using the repository browser.