10 use fckit_configuration_module,
only: fckit_configuration
18 use missing_values_mod
33 real (kind=kind_real),
allocatable :: depth(:,:)
34 real (kind=kind_real),
allocatable :: lono(:)
35 real (kind=kind_real),
allocatable :: lato(:)
36 real (kind=kind_real),
allocatable :: deptho(:)
37 real (kind=kind_real),
allocatable :: tempo(:)
38 real (kind=kind_real),
allocatable :: salto(:)
39 real(kind_real),
allocatable :: wf(:)
40 integer,
allocatable :: wi(:)
41 real (kind=kind_real),
allocatable :: jac(:,:)
56 type(fckit_configuration),
intent(in) :: f_conf
65 if (
allocated(self%jac))
deallocate(self%jac)
66 if (
allocated(self%wi))
deallocate(self%wi)
67 if (
allocated(self%wf))
deallocate(self%wf)
68 if (
allocated(self%deptho))
deallocate(self%deptho)
69 if (
allocated(self%lato))
deallocate(self%lato)
70 if (
allocated(self%lono))
deallocate(self%lono)
71 if (
allocated(self%depth))
deallocate(self%depth)
72 if (
allocated(self%temp%vals))
deallocate(self%temp%vals)
73 if (
allocated(self%salt%vals))
deallocate(self%salt%vals)
74 if (
allocated(self%h%vals))
deallocate(self%h%vals)
75 if (
allocated(self%tempo))
deallocate(self%tempo)
76 if (
allocated(self%salto))
deallocate(self%salto)
89 type(c_ptr),
value,
intent(in) :: obss
91 character(len=*),
parameter :: myname_=
"ufo_insitutemperature_tlad_settraj"
92 character(max_string) :: err_msg
95 integer :: nlocs, nlev, iobs, ilev
97 real(kind_real),
allocatable :: obs_lat(:)
98 real(kind_real),
allocatable :: obs_lon(:)
99 real(kind_real),
allocatable :: obs_depth(:)
100 integer :: obss_nlocs
123 allocate(self%lono(nlocs))
124 allocate(self%lato(nlocs))
125 allocate(self%deptho(nlocs))
127 obss_nlocs = obsspace_get_nlocs(obss)
128 allocate(obs_lat(obss_nlocs))
129 allocate(obs_lon(obss_nlocs))
130 allocate(obs_depth(obss_nlocs))
132 call obsspace_get_db(obss,
"MetaData",
"longitude", obs_lon)
133 call obsspace_get_db(obss,
"MetaData",
"latitude", obs_lat)
134 call obsspace_get_db(obss,
"MetaData",
"depth", obs_depth)
138 self%deptho = obs_depth
141 allocate(self%depth(nlev,nlocs))
143 self%depth(1,iobs)=0.5*self%h%vals(1,iobs)
145 self%depth(ilev,iobs)=sum(self%h%vals(1:ilev-1,iobs))+0.5*self%h%vals(ilev,iobs)
150 allocate(self%wi(nlocs),self%wf(nlocs))
152 call vert_interp_weights(nlev,self%deptho(iobs),self%depth(:,iobs),self%wi(iobs),self%wf(iobs))
153 if (self%deptho(iobs).ge.maxval(self%depth(:,iobs)))
then
161 allocate(self%jac(2,nlocs),self%tempo(nlocs),self%salto(nlocs))
164 call vert_interp_apply(nlev, self%temp%vals(:,iobs), self%tempo(iobs), self%wi(iobs), self%wf(iobs))
165 call vert_interp_apply(nlev, self%salt%vals(:,iobs), self%salto(iobs), self%wi(iobs), self%wf(iobs))
168 call insitu_t_jac(self%jac(:,iobs), self%tempo(iobs), self%salto(iobs), self%lono(iobs), self%lato(iobs), self%deptho(iobs))
173 deallocate(obs_depth)
185 real(c_double),
intent(inout) :: hofx(:)
186 type(c_ptr),
value,
intent(in) :: obss
188 character(len=*),
parameter :: myname_=
"ufo_insitutemperature_simobs_tl"
189 character(max_string) :: err_msg
191 integer :: iobs, ilev, nlev, nlocs
193 type(
ufo_geoval),
pointer :: temp_d, salt_d, dlayerthick
194 real (kind=kind_real) :: lono, lato, deptho
197 real(kind_real) :: dtp, dsp
200 if (.not. self%ltraj)
then
201 write(err_msg,*) myname_,
' trajectory wasnt set!'
202 call abor1_ftn(err_msg)
206 if (geovals%nlocs /=
size(hofx,1))
then
207 write(err_msg,*) myname_,
' error: nlocs inconsistent!'
208 call abor1_ftn(err_msg)
229 lono = self%lono(iobs)
230 lato = self%lato(iobs)
231 deptho = self%deptho(iobs)
234 call vert_interp_apply(nlev, temp_d%vals(:,iobs), dtp, self%wi(iobs), self%wf(iobs))
235 call vert_interp_apply(nlev, salt_d%vals(:,iobs), dsp, self%wi(iobs), self%wf(iobs))
238 call insitu_t_tl(hofx(iobs),dtp,dsp,self%tempo(iobs),self%salto(iobs),lono,lato,deptho,self%jac(:,iobs))
252 real(c_double),
intent(in) :: hofx(:)
253 type(c_ptr),
value,
intent(in) :: obss
255 character(len=*),
parameter :: myname_=
"ufo_insitutemperature_simobs_ad"
256 character(max_string) :: err_msg
258 real (kind=kind_real) :: lono, lato, deptho
260 integer :: iobs, nlocs, ilev, nlev
261 type(
ufo_geoval),
pointer :: dtemp, dsalt, dlayerthick
262 real (kind_real) :: dtp, dsp
263 real(c_double) :: missing
266 missing = missing_value(missing)
269 if (.not. self%ltraj)
then
270 write(err_msg,*) myname_,
' trajectory wasnt set!'
271 call abor1_ftn(err_msg)
275 if (geovals%nlocs /=
size(hofx,1))
then
276 write(err_msg,*) myname_,
' error: nlocs inconsistent!'
277 call abor1_ftn(err_msg)
280 if (.not. geovals%linit ) geovals%linit=.true.
295 do iobs = 1,
size(hofx,1)
297 if (hofx(iobs) /= missing)
then
298 lono = self%lono(iobs)
299 lato = self%lato(iobs)
300 deptho = self%deptho(iobs)
305 call insitu_t_tlad(hofx(iobs),dtp,dsp,self%tempo(iobs),self%salto(iobs),lono,lato,deptho,self%jac(:,iobs))
subroutine, public ufo_geovals_get_var(self, varname, geoval)
Fortran insitutemperature module for tl/ad observation operator.
subroutine ufo_insitutemperature_simobs_tl(self, geovals, hofx, obss)
subroutine ufo_insitutemperature_simobs_ad(self, geovals, hofx, obss)
integer, parameter max_string
subroutine ufo_insitutemperature_tlad_settraj(self, geovals, obss)
subroutine ufo_insitutemperature_tlad_setup(self, f_conf)
subroutine ufo_insitutemperature_tlad_delete(self)
subroutine, public insitu_t_tlad(dtemp_i, dtemp_p, dsalt_p, temp_p, salt_p, lono, lato, deptho, Jacobian)
subroutine, public insitu_t_tl(dtemp_i, dtemp_p, dsalt_p, temp_p, salt_p, lono, lato, deptho, Jacobian)
subroutine, public insitu_t_jac(jac, temp_p, salt_p, lono, lato, deptho)
character(len=maxvarlen), public var_ocn_pot_temp
character(len=maxvarlen), public var_ocn_salt
character(len=maxvarlen), public var_ocn_lay_thick
Fortran module to perform linear interpolation.
subroutine vert_interp_apply_ad(nlev, fvec_ad, f_ad, wi, wf)
subroutine vert_interp_weights(nlev, obl, vec, wi, wf)
subroutine vert_interp_apply(nlev, fvec, f, wi, wf)
type to hold interpolated field for one variable, one observation
type to hold interpolated fields required by the obs operators
Fortran derived type for the tl/ad observation operator.