8 implicit none ;
private 18 real,
allocatable,
dimension(:) :: coordinateresolution
21 real,
allocatable,
dimension(:) :: target_density
24 real,
allocatable,
dimension(:) :: max_interface_depths
27 real,
allocatable,
dimension(:) :: max_layer_thickness
38 subroutine init_coord_hycom(CS, nk, coordinateResolution, target_density, interp_CS)
40 integer,
intent(in) :: nk
41 real,
dimension(:),
intent(in) :: coordinateResolution
42 real,
dimension(:),
intent(in) :: target_density
45 if (
associated(cs))
call mom_error(fatal,
"init_coord_hycom: CS already associated!")
47 allocate(cs%coordinateResolution(nk))
48 allocate(cs%target_density(nk+1))
51 cs%coordinateResolution(:) = coordinateresolution(:)
52 cs%target_density(:) = target_density(:)
53 cs%interp_CS = interp_cs
60 if (.not.
associated(cs))
return 61 deallocate(cs%coordinateResolution)
62 deallocate(cs%target_density)
63 if (
allocated(cs%max_interface_depths))
deallocate(cs%max_interface_depths)
64 if (
allocated(cs%max_layer_thickness))
deallocate(cs%max_layer_thickness)
68 subroutine set_hycom_params(CS, max_interface_depths, max_layer_thickness, interp_CS)
70 real,
optional,
dimension(:),
intent(in) :: max_interface_depths
71 real,
optional,
dimension(:),
intent(in) :: max_layer_thickness
74 if (.not.
associated(cs))
call mom_error(fatal,
"set_hycom_params: CS not associated")
76 if (
present(max_interface_depths))
then 77 if (
size(max_interface_depths) /= cs%nk+1) &
78 call mom_error(fatal,
"set_hycom_params: max_interface_depths inconsistent size")
79 allocate(cs%max_interface_depths(cs%nk+1))
80 cs%max_interface_depths(:) = max_interface_depths(:)
83 if (
present(max_layer_thickness))
then 84 if (
size(max_layer_thickness) /= cs%nk) &
85 call mom_error(fatal,
"set_hycom_params: max_layer_thickness inconsistent size")
86 allocate(cs%max_layer_thickness(cs%nk))
87 cs%max_layer_thickness(:) = max_layer_thickness(:)
90 if (
present(interp_cs)) cs%interp_CS = interp_cs
94 subroutine build_hycom1_column(CS, eqn_of_state, nz, depth, h, T, S, p_col, z_col, z_col_new)
96 type(
eos_type),
pointer :: eqn_of_state
97 integer,
intent(in) :: nz
98 real,
intent(in) :: depth
99 real,
dimension(nz),
intent(in) :: T, S
100 real,
dimension(nz),
intent(in) :: h
101 real,
dimension(nz),
intent(in) :: p_col
102 real,
dimension(nz+1),
intent(in) :: z_col
103 real,
dimension(nz+1),
intent(inout) :: z_col_new
107 real,
dimension(nz) :: rho_col, h_col_new
111 logical :: maximum_depths_set
112 logical :: maximum_h_set
114 maximum_depths_set =
allocated(cs%max_interface_depths)
115 maximum_h_set =
allocated(cs%max_layer_thickness)
122 rho_col(k) = min( rho_col(k), rho_col(k+1) )
128 cs%target_density, nz, h_col_new, z_col_new)
133 stretching = z_col(nz+1) / depth
135 nominal_z = nominal_z + cs%coordinateResolution(k-1) * stretching
136 z_col_new(k) = max( z_col_new(k), nominal_z )
137 z_col_new(k) = min( z_col_new(k), z_col(nz+1) )
140 if (maximum_depths_set .and. maximum_h_set)
then ;
do k=2,nz
143 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k), &
144 z_col_new(k-1) + cs%max_layer_thickness(k-1))
145 enddo ;
elseif (maximum_depths_set)
then ;
do k=2,nz
146 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k))
147 enddo ;
elseif (maximum_h_set)
then ;
do k=2,nz
148 z_col_new(k) = min(z_col_new(k), z_col_new(k-1) + cs%max_layer_thickness(k-1))
subroutine, public build_hycom1_column(CS, eqn_of_state, nz, depth, h, T, S, p_col, z_col, z_col_new)
Build a HyCOM coordinate column.
Calculates density of sea water from T, S and P.
subroutine, public set_hycom_params(CS, max_interface_depths, max_layer_thickness, interp_CS)
subroutine, public build_and_interpolate_grid(CS, densities, n0, h0, x0, target_values, n1, h1, x1)
Regrid columns for the HyCOM coordinate.
Provides subroutines for quantities specific to the equation of state.
Control structure containing required parameters for the HyCOM coordinate.
subroutine, public init_coord_hycom(CS, nk, coordinateResolution, target_density, interp_CS)
Initialise a hycom_CS with pointers to parameters.
subroutine, public end_coord_hycom(CS)
subroutine, public mom_error(level, message, all_print)
A control structure for the equation of state.