10 implicit none ;
private
19 real,
allocatable,
dimension(:) :: coordinateresolution
22 real,
allocatable,
dimension(:) :: target_density
28 real,
allocatable,
dimension(:) :: max_interface_depths
31 real,
allocatable,
dimension(:) :: max_layer_thickness
42 subroutine init_coord_hycom(CS, nk, coordinateResolution, target_density, interp_CS, rho_scale)
44 integer,
intent(in) :: nk
45 real,
dimension(nk),
intent(in) :: coordinateresolution
46 real,
dimension(nk+1),
intent(in) :: target_density
48 real,
optional,
intent(in) :: rho_scale
50 if (
associated(cs))
call mom_error(fatal,
"init_coord_hycom: CS already associated!")
52 allocate(cs%coordinateResolution(nk))
53 allocate(cs%target_density(nk+1))
56 cs%coordinateResolution(:) = coordinateresolution(:)
57 cs%target_density(:) = target_density(:)
58 cs%interp_CS = interp_cs
59 cs%kg_m3_to_R = 1.0 ;
if (
present(rho_scale)) cs%kg_m3_to_R = rho_scale
68 if (.not.
associated(cs))
return
69 deallocate(cs%coordinateResolution)
70 deallocate(cs%target_density)
71 if (
allocated(cs%max_interface_depths))
deallocate(cs%max_interface_depths)
72 if (
allocated(cs%max_layer_thickness))
deallocate(cs%max_layer_thickness)
77 subroutine set_hycom_params(CS, max_interface_depths, max_layer_thickness, interp_CS)
79 real,
dimension(:),
optional,
intent(in) :: max_interface_depths
80 real,
dimension(:),
optional,
intent(in) :: max_layer_thickness
83 if (.not.
associated(cs))
call mom_error(fatal,
"set_hycom_params: CS not associated")
85 if (
present(max_interface_depths))
then
86 if (
size(max_interface_depths) /= cs%nk+1) &
87 call mom_error(fatal,
"set_hycom_params: max_interface_depths inconsistent size")
88 allocate(cs%max_interface_depths(cs%nk+1))
89 cs%max_interface_depths(:) = max_interface_depths(:)
92 if (
present(max_layer_thickness))
then
93 if (
size(max_layer_thickness) /= cs%nk) &
94 call mom_error(fatal,
"set_hycom_params: max_layer_thickness inconsistent size")
95 allocate(cs%max_layer_thickness(cs%nk))
96 cs%max_layer_thickness(:) = max_layer_thickness(:)
99 if (
present(interp_cs)) cs%interp_CS = interp_cs
104 z_col, z_col_new, zScale, h_neglect, h_neglect_edge)
106 type(
eos_type),
pointer :: eqn_of_state
107 integer,
intent(in) :: nz
108 real,
intent(in) :: depth
109 real,
dimension(nz),
intent(in) :: t
110 real,
dimension(nz),
intent(in) :: s
111 real,
dimension(nz),
intent(in) :: h
112 real,
dimension(nz),
intent(in) :: p_col
113 real,
dimension(nz+1),
intent(in) :: z_col
114 real,
dimension(CS%nk+1),
intent(inout) :: z_col_new
115 real,
optional,
intent(in) :: zscale
117 real,
optional,
intent(in) :: h_neglect
120 real,
optional,
intent(in) :: h_neglect_edge
126 real,
dimension(nz) :: rho_col
127 real,
dimension(CS%nk) :: h_col_new
132 logical :: maximum_depths_set
133 logical :: maximum_h_set
135 maximum_depths_set =
allocated(cs%max_interface_depths)
136 maximum_h_set =
allocated(cs%max_layer_thickness)
138 z_scale = 1.0 ;
if (
present(zscale)) z_scale = zscale
141 call calculate_density(t, s, p_col, rho_col, 1, nz, eqn_of_state, scale=cs%kg_m3_to_R)
145 rho_col(k) = min( rho_col(k), rho_col(k+1) )
151 cs%target_density, cs%nk, h_col_new, z_col_new, h_neglect, h_neglect_edge)
156 stretching = z_col(nz+1) / depth
158 nominal_z = nominal_z + (z_scale * cs%coordinateResolution(k-1)) * stretching
159 z_col_new(k) = max( z_col_new(k), nominal_z )
160 z_col_new(k) = min( z_col_new(k), z_col(nz+1) )
163 if (maximum_depths_set .and. maximum_h_set)
then ;
do k=2,cs%nk
166 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k), &
167 z_col_new(k-1) + cs%max_layer_thickness(k-1))
168 enddo ;
elseif (maximum_depths_set)
then ;
do k=2,cs%nk
169 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k))
170 enddo ;
elseif (maximum_h_set)
then ;
do k=2,cs%nk
171 z_col_new(k) = min(z_col_new(k), z_col_new(k-1) + cs%max_layer_thickness(k-1))