10 implicit none ;
private 19 real,
allocatable,
dimension(:) :: coordinateresolution
22 real,
allocatable,
dimension(:) :: target_density
25 real,
allocatable,
dimension(:) :: max_interface_depths
28 real,
allocatable,
dimension(:) :: max_layer_thickness
34 public init_coord_hycom, set_hycom_params, build_hycom1_column, end_coord_hycom
39 subroutine init_coord_hycom(CS, nk, coordinateResolution, target_density, interp_CS)
41 integer,
intent(in) :: nk
42 real,
dimension(nk),
intent(in) :: coordinateResolution
43 real,
dimension(nk+1),
intent(in) :: target_density
46 if (
associated(cs))
call mom_error(fatal,
"init_coord_hycom: CS already associated!")
48 allocate(cs%coordinateResolution(nk))
49 allocate(cs%target_density(nk+1))
52 cs%coordinateResolution(:) = coordinateresolution(:)
53 cs%target_density(:) = target_density(:)
54 cs%interp_CS = interp_cs
56 end subroutine init_coord_hycom
59 subroutine end_coord_hycom(CS)
63 if (.not.
associated(cs))
return 64 deallocate(cs%coordinateResolution)
65 deallocate(cs%target_density)
66 if (
allocated(cs%max_interface_depths))
deallocate(cs%max_interface_depths)
67 if (
allocated(cs%max_layer_thickness))
deallocate(cs%max_layer_thickness)
69 end subroutine end_coord_hycom
72 subroutine set_hycom_params(CS, max_interface_depths, max_layer_thickness, interp_CS)
74 real,
dimension(:),
optional,
intent(in) :: max_interface_depths
75 real,
dimension(:),
optional,
intent(in) :: max_layer_thickness
78 if (.not.
associated(cs))
call mom_error(fatal,
"set_hycom_params: CS not associated")
80 if (
present(max_interface_depths))
then 81 if (
size(max_interface_depths) /= cs%nk+1) &
82 call mom_error(fatal,
"set_hycom_params: max_interface_depths inconsistent size")
83 allocate(cs%max_interface_depths(cs%nk+1))
84 cs%max_interface_depths(:) = max_interface_depths(:)
87 if (
present(max_layer_thickness))
then 88 if (
size(max_layer_thickness) /= cs%nk) &
89 call mom_error(fatal,
"set_hycom_params: max_layer_thickness inconsistent size")
90 allocate(cs%max_layer_thickness(cs%nk))
91 cs%max_layer_thickness(:) = max_layer_thickness(:)
94 if (
present(interp_cs)) cs%interp_CS = interp_cs
95 end subroutine set_hycom_params
98 subroutine build_hycom1_column(CS, eqn_of_state, nz, depth, h, T, S, p_col, &
99 z_col, z_col_new, zScale, h_neglect, h_neglect_edge)
101 type(
eos_type),
pointer :: eqn_of_state
102 integer,
intent(in) :: nz
103 real,
intent(in) :: depth
104 real,
dimension(nz),
intent(in) :: T
105 real,
dimension(nz),
intent(in) :: S
106 real,
dimension(nz),
intent(in) :: h
107 real,
dimension(nz),
intent(in) :: p_col
108 real,
dimension(nz+1),
intent(in) :: z_col
109 real,
dimension(CS%nk+1),
intent(inout) :: z_col_new
110 real,
optional,
intent(in) :: zScale
112 real,
optional,
intent(in) :: h_neglect
114 real,
optional,
intent(in) :: h_neglect_edge
119 real,
dimension(nz) :: rho_col
120 real,
dimension(CS%nk) :: h_col_new
125 logical :: maximum_depths_set
126 logical :: maximum_h_set
128 maximum_depths_set =
allocated(cs%max_interface_depths)
129 maximum_h_set =
allocated(cs%max_layer_thickness)
131 z_scale = 1.0 ;
if (
present(zscale)) z_scale = zscale
138 rho_col(k) = min( rho_col(k), rho_col(k+1) )
143 call build_and_interpolate_grid(cs%interp_CS, rho_col, nz, h(:), z_col, &
144 cs%target_density, cs%nk, h_col_new, z_col_new, h_neglect, h_neglect_edge)
149 stretching = z_col(nz+1) / depth
151 nominal_z = nominal_z + (z_scale * cs%coordinateResolution(k-1)) * stretching
152 z_col_new(k) = max( z_col_new(k), nominal_z )
153 z_col_new(k) = min( z_col_new(k), z_col(nz+1) )
156 if (maximum_depths_set .and. maximum_h_set)
then ;
do k=2,cs%nk
159 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k), &
160 z_col_new(k-1) + cs%max_layer_thickness(k-1))
161 enddo ;
elseif (maximum_depths_set)
then ;
do k=2,cs%nk
162 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k))
163 enddo ;
elseif (maximum_h_set)
then ;
do k=2,cs%nk
164 z_col_new(k) = min(z_col_new(k), z_col_new(k-1) + cs%max_layer_thickness(k-1))
166 end subroutine build_hycom1_column
Calculates density of sea water from T, S and P.
Regrid columns for the HyCOM coordinate.
Routines for error handling and I/O management.
Provides subroutines for quantities specific to the equation of state.
Control structure for regrid_interp module.
Control structure containing required parameters for the HyCOM coordinate.
Vertical interpolation for regridding.
A control structure for the equation of state.