8 implicit none ;
private
21 real,
allocatable,
dimension(:) :: coordinateresolution
31 integer,
intent(in) :: nk
32 real,
dimension(:),
intent(in) :: coordinateresolution
34 if (
associated(cs))
call mom_error(fatal,
"init_coord_zlike: CS already associated!")
36 allocate(cs%coordinateResolution(nk))
39 cs%coordinateResolution = coordinateresolution
47 if (.not.
associated(cs))
return
48 deallocate(cs%coordinateResolution)
55 real,
optional,
intent(in) :: min_thickness
57 if (.not.
associated(cs))
call mom_error(fatal,
"set_zlike_params: CS not associated")
59 if (
present(min_thickness)) cs%min_thickness = min_thickness
64 z_rigid_top, eta_orig, zScale)
66 real,
intent(in) :: depth
67 real,
intent(in) :: total_thickness
68 real,
dimension(CS%nk+1),
intent(inout) :: zinterface
69 real,
optional,
intent(in) :: z_rigid_top
71 real,
optional,
intent(in) :: eta_orig
73 real,
optional,
intent(in) :: zscale
76 real :: eta, stretching, dh, min_thickness, z0_top, z_star, z_scale
78 logical :: new_zstar_def
80 z_scale = 1.0 ;
if (
present(zscale)) z_scale = zscale
82 new_zstar_def = .false.
83 min_thickness = min( cs%min_thickness, total_thickness/real(cs%nk) )
85 if (
present(z_rigid_top))
then
87 new_zstar_def = .true.
91 eta = total_thickness - depth
92 if (
present(eta_orig)) eta = eta_orig
101 stretching = total_thickness / ( depth + z0_top )
103 if (new_zstar_def)
then
108 z_star = z_star - cs%coordinateResolution(k-1)*z_scale
110 zinterface(k) = min( eta + stretching * ( z_star - z0_top ), z0_top )
112 zinterface(k) = min( zinterface(k), zinterface(k-1) - min_thickness )
114 zinterface(k) = max( zinterface(k), -depth + real(cs%nk+1-k) * min_thickness )
116 zinterface(cs%nk+1) = -depth
124 dh = stretching * cs%coordinateResolution(k)*z_scale
125 zinterface(k+1) = zinterface(k) - dh
130 zinterface(cs%nk+1) = -depth
132 if ( zinterface(k) < (zinterface(k+1) + min_thickness) )
then
133 zinterface(k) = zinterface(k+1) + min_thickness