9 use fckit_configuration_module,
only: fckit_configuration
13 use oops_variables_mod
14 use missing_values_mod
16 use fckit_log_module,
only : fckit_log
26 character(len=max_string) :: variable
27 character(len=max_string) :: errmodel
28 character(len=max_string) :: rmatrix_filename
29 character(len=max_string) :: err_variable
30 type(oops_variables),
public :: obsvar
41 use oops_variables_mod
44 type(c_ptr),
value,
intent(in) :: obspace
45 type(fckit_configuration),
intent(in) :: f_conf
46 character(len=:),
allocatable :: str
48 self%errmodel =
"NBAM"
49 if (f_conf%has(
"errmodel"))
then
50 call f_conf%get_or_die(
"errmodel",str)
54 self % rmatrix_filename =
""
55 if (f_conf % has(
"rmatrix_filename"))
then
56 call f_conf % get_or_die(
"rmatrix_filename", str)
57 self % rmatrix_filename = str
60 self % err_variable =
""
61 if (f_conf % has(
"err_variable"))
then
62 call f_conf % get_or_die(
"err_variable", str)
63 self % err_variable = str
68 if (f_conf % has(
"n_horiz"))
then
69 call f_conf % get_or_die(
"n_horiz", self % n_horiz)
88 use fckit_log_module,
only : fckit_log
94 integer,
intent(in) :: model_nobs
95 integer,
intent(in) :: model_nlevs
96 real,
intent(in) :: air_temperature(:,:)
97 real,
intent(in) :: geopotential_height(:,:)
100 real(kind_real),
allocatable :: obsz(:), obslat(:)
101 integer,
allocatable :: obssatid(:)
102 integer,
allocatable :: obsorigc(:)
103 real(kind_real),
allocatable :: obsimpa(:)
104 real(kind_real),
allocatable :: obsimph(:)
105 real(kind_real),
allocatable :: obsimpp(:)
106 real(kind_real),
allocatable :: obsgeoid(:)
107 real(kind_real),
allocatable :: obslocr(:)
108 real(kind_real),
allocatable :: obsvalue(:)
109 real(kind_real),
allocatable :: obserr(:)
110 integer(c_int),
allocatable :: obssaid(:)
111 integer(c_int),
allocatable :: qcflags(:)
112 real(kind_real) :: missing
113 character(max_string) :: err_msg
115 missing = missing_value(missing)
116 nobs = obsspace_get_nlocs(self%obsdb)
117 allocate(qcflags(nobs))
118 allocate(obserr(nobs))
121 if (model_nobs /= nobs * self % n_horiz)
then
122 write(err_msg,
'(A,2I8)')
'nobs from model and observations must be equal', nobs, model_nobs
123 call abor1_ftn(err_msg)
127 call obsspace_get_db(self%obsdb,
"FortranQC", trim(self%variable),qcflags )
130 select case (trim(self%variable))
133 case (
"bending_angle")
135 allocate(obsimpp(nobs))
136 allocate(obsgeoid(nobs))
137 allocate(obslocr(nobs))
138 allocate(obsimph(nobs))
139 allocate(obsimpa(nobs))
140 call obsspace_get_db(self%obsdb,
"MetaData",
"impact_parameter", obsimpp)
141 call obsspace_get_db(self%obsdb,
"MetaData",
"geoid_height_above_reference_ellipsoid",obsgeoid)
142 call obsspace_get_db(self%obsdb,
"MetaData",
"earth_radius_of_curvature", obslocr)
143 obsimph(:) = obsimpp(:) - obslocr(:)
144 obsimpa(:) = obsimpp(:) - obsgeoid(:) - obslocr(:)
146 select case (trim(self%errmodel))
148 allocate(obssaid(nobs))
149 allocate(obslat(nobs))
150 call obsspace_get_db(self%obsdb,
"MetaData",
"occulting_sat_id", obssaid)
151 call obsspace_get_db(self%obsdb,
"MetaData",
"latitude", obslat)
153 write(err_msg,*)
"ufo_roobserror_mod: setting up bending_angle obs error with NBAM method"
154 call fckit_log%info(err_msg)
158 call obsspace_put_db(self%obsdb,
"FortranERR", trim(self%variable), obserr)
161 allocate(obsvalue(nobs))
162 call obsspace_get_db(self%obsdb,
"ObsValue",
"bending_angle", obsvalue)
164 write(err_msg,*)
"ufo_roobserror_mod: setting up bending_angle obs error with ECMWF method"
165 call fckit_log%info(err_msg)
168 call obsspace_put_db(self%obsdb,
"FortranERR", trim(self%variable), obserr)
170 allocate(obsvalue(nobs))
171 allocate(obslat(nobs))
172 call obsspace_get_db(self%obsdb,
"ObsValue",
"bending_angle", obsvalue)
173 call obsspace_get_db(self%obsdb,
"MetaData",
"latitude", obslat)
175 write(err_msg,*)
"ufo_roobserror_mod: setting up bending_angle obs error with NRL method"
176 call fckit_log%info(err_msg)
180 call obsspace_put_db(self%obsdb,
"FortranERR", trim(self%variable), obserr)
183 write(err_msg,*)
"ufo_roobserror_mod: setting up bending_angle obs error with the Met Office method"
184 call fckit_log%info(err_msg)
186 err_msg =
"If you choose the Met Office method, then you must specify rmatrix_filename"
187 call abor1_ftn(err_msg)
189 allocate(obssatid(nobs))
190 allocate(obsorigc(nobs))
191 allocate(obsvalue(nobs))
192 call obsspace_get_db(self%obsdb,
"MetaData",
"occulting_sat_id", obssatid)
193 call obsspace_get_db(self%obsdb,
"MetaData",
"originating_center", obsorigc)
194 call obsspace_get_db(self%obsdb,
"ObsValue",
"bending_angle", obsvalue)
195 call obsspace_get_db(self%obsdb,
"ObsError", trim(self%variable), obserr)
196 if (self % err_variable ==
"latitude")
then
197 allocate(obslat(nobs))
198 call obsspace_get_db(self%obsdb,
"MetaData",
"latitude", obslat)
200 obsvalue, obserr, qcflags, missing)
202 else if (self % err_variable ==
"average_temperature")
then
204 model_nlevs, air_temperature, geopotential_height, obsimph, obsvalue, &
205 obserr, qcflags, missing)
207 err_msg =
"The error variable should be either 'latitude' or 'average_temperature', but you gave " // &
208 trim(self % err_variable)
209 call fckit_log%info(err_msg)
215 call obsspace_put_db(self%obsdb,
"FortranERR", trim(self%variable), obserr)
218 write(err_msg,*)
"ufo_roobserror_mod: bending_angle error model must be NBAM, ECMWF, NRL or MetOffice"
219 call fckit_log%info(err_msg)
228 case (
"refractivity")
230 select case (trim(self%errmodel))
235 allocate(obslat(nobs))
236 call obsspace_get_db(self%obsdb,
"MetaData",
"altitude", obsz)
237 call obsspace_get_db(self%obsdb,
"MetaData",
"latitude", obslat)
239 write(err_msg,*)
"ufo_roobserror_mod: setting up refractivity obs error with NBAM method"
240 call fckit_log%info(err_msg)
244 call obsspace_put_db(self%obsdb,
"FortranERR", trim(self%variable), obserr)
247 write(err_msg,*)
"ufo_roobserror_mod: ECMWF refractivity error model is not available now"
248 call fckit_log%info(err_msg)
251 write(err_msg,*)
"ufo_roobserror_mod: only NBAM refractivity model is available now"
252 call fckit_log%info(err_msg)
256 call abor1_ftn(
"ufo_roobserror_prior: variable has to be bending_angle or refractivity")
subroutine bending_angle_obserr_nbam(obsLat, obsImpH, obsSaid, nobs, obsErr, QCflags, missing)
subroutine bending_angle_obserr_ecmwf(obsImpH, obsValue, nobs, obsErr, QCflags, missing)
subroutine gnssro_obserr_latitude(nobs, rmatrix_filename, obsSatid, obsOrigC, obsLat, obsZ, obsValue, obsErr, QCflags, missing)
subroutine refractivity_obserr_nbam(obsLat, obsZ, nobs, obsErr, QCflags, missing)
subroutine gnssro_obserr_avtemp(nobs, n_horiz, rmatrix_filename, obsSatid, obsOrigC, nlevs, air_temperature, geopotential_height, obsZ, obsValue, obsErr, QCflags, missing)
subroutine bending_angle_obserr_nrl(obsLat, obsImpH, obsValue, nobs, obsErr, QCflags, missing)
integer, parameter max_string
Fortran module to implement RO observational error.
subroutine, public ufo_roobserror_prior(self, model_nobs, model_nlevs, air_temperature, geopotential_height)
subroutine, public ufo_roobserror_create(self, obspace, f_conf)
subroutine, public ufo_roobserror_delete(self)
Fortran module with various useful routines.
logical function, public cmp_strings(str1, str2)