10 use fckit_configuration_module,
only: fckit_configuration
18 use missing_values_mod
19 use oops_variables_mod
29 type(oops_variables),
public :: obsvars
30 character(max_string) :: thickness_sim_option
34 real(kind=kind_real) :: rho_ice = 905.0
35 real(kind=kind_real) :: rho_snow = 330.0
36 real(kind=kind_real) :: rho_water= 1000.0
52 type(fckit_configuration),
intent(in) :: f_conf
53 real(kind=kind_real) :: rho_ice, rho_snow, rho_water
54 integer :: ivar, nvars
55 character(max_string) :: err_msg
57 nvars = self%obsvars%nvars()
59 write(err_msg,*)
'ufo_seaicethickness_tlad_setup error: only variables size 1 supported!'
60 call abor1_ftn(err_msg)
82 type(c_ptr),
value,
intent(in) :: obss
84 character(len=*),
parameter :: myname_=
"ufo_seaicethick_tlad_settraj"
86 type(
ufo_geoval),
pointer :: icethick, icefrac, snowthick
94 if (trim(self%obsvars%variable(1)) ==
"sea_ice_freeboard")
then
96 self%snowthick= snowthick
99 self%icethick = icethick
100 self%icefrac = icefrac
110 real(c_double),
intent(inout) :: hofx(:)
111 type(c_ptr),
value,
intent(in) :: obss
113 character(len=*),
parameter :: myname_=
"ufo_seaicethick_simobs_tl"
114 character(max_string) :: err_msg
116 integer :: iobs, icat, ncat
117 type(
ufo_geoval),
pointer :: icethick_d, icefrac_d, snowthick
118 real(kind=kind_real) :: rho_wiw, rho_wsw
121 if (.not. self%ltraj)
then
122 write(err_msg,*) myname_,
' trajectory wasnt set!'
123 call abor1_ftn(err_msg)
127 if (geovals%nlocs /=
size(hofx,1))
then
128 write(err_msg,*) myname_,
' error: nlocs inconsistent!'
129 call abor1_ftn(err_msg)
138 if (trim(self%obsvars%variable(1)) ==
"sea_ice_freeboard")
then
139 rho_wiw = (self%rho_water-self%rho_ice)/self%rho_water
140 rho_wsw = (self%rho_water-self%rho_snow)/self%rho_water
144 ncat = icefrac_d%nval
147 select case (trim(self%obsvars%variable(1)))
148 case (
"sea_ice_freeboard")
149 do iobs = 1,
size(hofx,1)
151 hofx(iobs) = hofx(iobs) + &
152 rho_wiw * self%icefrac%vals(icat,iobs) * icethick_d%vals(icat,iobs) + &
153 rho_wiw * icefrac_d%vals(icat,iobs) * self%icethick%vals(icat,iobs) + &
154 rho_wsw * icefrac_d%vals(icat,iobs) * self%snowthick%vals(icat,iobs)
157 case (
"sea_ice_thickness")
158 do iobs = 1,
size(hofx,1)
160 hofx(iobs) = hofx(iobs) + &
161 self%icefrac%vals(icat,iobs) * icethick_d%vals(icat,iobs) + &
162 icefrac_d%vals(icat,iobs) * self%icethick%vals(icat,iobs)
166 write(err_msg,*) myname_,
' error: no match seaice thickness_option!'
167 call abor1_ftn(err_msg)
177 real(c_double),
intent(in) :: hofx(:)
178 type(c_ptr),
value,
intent(in) :: obss
180 character(len=*),
parameter :: myname_=
"ufo_seaicethick_simobs_ad"
181 character(max_string) :: err_msg
183 integer :: iobs, icat, ncat
184 type(
ufo_geoval),
pointer :: icefrac_d, icethick_d
185 real(c_double) :: missing
186 real(kind=kind_real) :: rho_wiw, rho_wsw
189 missing = missing_value(missing)
192 if (.not. self%ltraj)
then
193 write(err_msg,*) myname_,
' trajectory wasnt set!'
194 call abor1_ftn(err_msg)
198 if (geovals%nlocs /=
size(hofx,1))
then
199 write(err_msg,*) myname_,
' error: nlocs inconsistent!'
200 call abor1_ftn(err_msg)
203 if (trim(self%obsvars%variable(1)) ==
"sea_ice_freeboard")
then
204 rho_wiw = (self%rho_water-self%rho_ice)/self%rho_water
205 rho_wsw = (self%rho_water-self%rho_snow)/self%rho_water
208 if (.not. geovals%linit ) geovals%linit=.true.
214 ncat = self%icethick%nval
215 if (.not.(
allocated(icefrac_d%vals) .or. .not.
allocated(icethick_d%vals)))
then
217 write(err_msg,*) myname_,
' unknown number of categories'
218 call abor1_ftn(err_msg)
220 if (.not.
allocated(icefrac_d%vals))
allocate(icefrac_d%vals(ncat,
size(hofx,1)))
221 if (.not.
allocated(icethick_d%vals))
allocate(icethick_d%vals(ncat,
size(hofx,1)))
226 if (.not.
allocated(icefrac_d%vals))
allocate(icefrac_d%vals(ncat,
size(hofx,1)))
227 if (.not.
allocated(icethick_d%vals))
allocate(icethick_d%vals(ncat,
size(hofx,1)))
229 icethick_d%vals = 0.0
232 select case (trim(self%obsvars%variable(1)))
233 case (
"sea_ice_freeboard")
234 do iobs = 1,
size(hofx,1)
235 if (hofx(iobs) /= missing)
then
237 icefrac_d%vals(icat,iobs) = icefrac_d%vals(icat,iobs)&
238 + rho_wiw*self%icethick%vals(icat,iobs) * hofx(iobs)&
239 + rho_wsw*self%snowthick%vals(icat,iobs) * hofx(iobs)
240 icethick_d%vals(icat,iobs) = icethick_d%vals(icat,iobs)&
241 + rho_wiw*self%icefrac%vals(icat,iobs) * hofx(iobs)
245 case (
"sea_ice_thickness")
246 do iobs = 1,
size(hofx,1)
247 if (hofx(iobs) /= missing)
then
249 icefrac_d%vals(icat,iobs) = icefrac_d%vals(icat,iobs) + self%icethick%vals(icat,iobs) * hofx(iobs)
250 icethick_d%vals(icat,iobs) = icethick_d%vals(icat,iobs) + self%icefrac%vals(icat,iobs) * hofx(iobs)
255 write(err_msg,*) myname_,
' error: no match seaice thickness_option!'
256 call abor1_ftn(err_msg)