10 use fckit_configuration_module,
only: fckit_configuration
11 use fckit_log_module,
only : fckit_log
14 use missing_values_mod
23 use rttov_const,
only : errorstatus_success
32 character(len=MAXVARLEN),
public,
allocatable :: varin(:)
33 integer,
allocatable :: channels(:)
49 type(fckit_configuration),
intent(in) :: f_confOper
50 integer(c_int),
intent(in) :: channels(:)
52 type(fckit_configuration) :: f_confOpts
55 call f_confoper % get_or_die(
"obs options",f_confopts)
61 write(
message,*)
'ufo_radiancerttov_setup error: H2O must be included in RTTOV Absorbers'
72 do jspec = 1, self%conf%ngas
73 self%varin(ind) = self%conf%Absorbers(jspec)
78 allocate(self%channels(
size(channels)))
79 self%channels(:) = channels(:)
81 write(
message,
'(A, 2I6)')
'Finished setting up rttov'
97 hofx, hofxdiags, ob_info)
98 use fckit_mpi_module,
only: fckit_mpi_comm
105 type(c_ptr),
value,
intent(in) :: obss
106 integer,
intent(in) :: nvars, nlocs
108 real(c_double),
intent(inout) :: hofx(nvars,nlocs)
112 real(c_double) :: missing
113 type(fckit_mpi_comm) :: f_comm
116 character(*),
parameter :: routine_name =
'ufo_radiancerttov_simobs'
117 type(rttov_chanprof),
allocatable :: chanprof(:)
120 integer :: nprofiles, nlevels
121 integer(kind=jpim) :: errorstatus
123 integer :: i_inst, iprof_rttov, iprof, ichan, ichan_sim
124 integer :: nprof_sim, nprof_max_sim, nchan_total
125 integer :: prof_start, prof_end
127 logical :: jacobian_needed
129 include
'rttov_direct.interface'
130 include
'rttov_k.interface'
132 write(
message,
'(A, A, I0, A, I0, A)') trim(routine_name),
': Simulating observations'
136 missing = missing_value(missing)
140 call obsspace_get_comm(obss, f_comm)
149 nprofiles = geovals % nlocs
151 nlevels = geoval_temp % nval
155 write(
message,
'(A, A, I0, A, I0, A)') &
156 trim(routine_name),
': Allocating ', nprofiles,
' profiles with ', nlevels,
' levels'
159 call self % RTprof % alloc_profs(errorstatus, self % conf, nprofiles, nlevels, init=.true., asw=1)
162 write(
message,
'(A, A, I0, A, I0, A)') &
163 trim(routine_name),
': Creating RTTOV profiles from geovals'
165 if(
present(ob_info))
then
166 call self % RTprof % setup(geovals,obss,self % conf,ob_info=ob_info)
168 call self % RTprof % setup(geovals,obss,self % conf)
180 if(self % conf % prof_by_prof)
then
183 nprof_max_sim = max(1,self % conf % nchan_max_sim /
nchan_inst)
185 nprof_sim = min(nprof_max_sim, nprofiles)
188 nchan_sim = nprof_sim *
size(self%channels)
191 write(
message,
'(A,A,I0,A,I0,A)') &
192 trim(routine_name),
': Allocating resources for RTTOV direct code: ', nprof_sim,
' and ',
nchan_sim,
' channels'
194 call self % RTprof % alloc_direct(errorstatus, self % conf, nprof_sim,
nchan_sim, nlevels, init=.true., asw=1)
196 if (jacobian_needed)
then
197 write(
message,
'(A,A,I0,A,I0,A)') &
198 trim(routine_name),
': Allocating resources for RTTOV K code: ', nprof_sim,
' and ',
nchan_sim,
' channels'
201 call self % RTprof % alloc_profs_k(errorstatus, self % conf,
nchan_sim, nlevels, init=.true., asw=1)
202 call self % RTprof % alloc_k(errorstatus, self % conf, nprof_sim,
nchan_sim, nlevels, init=.true., asw=1)
206 allocate(self % RTprof % chanprof ( nprofiles *
nchan_inst ))
208 prof_start = 1; prof_end = nprofiles
211 rttov_loop :
do while (prof_start <= prof_end)
214 nprof_sim = min(nprof_sim, prof_end - prof_start + 1)
215 nchan_sim = nprof_sim *
size(self%channels)
219 chanprof(:) % prof = 0
220 chanprof(:) % chan = 0
226 do iprof_rttov = 1, nprof_sim
227 errorstatus = errorstatus_success
230 iprof = prof_start + iprof_rttov - 1
233 if(any(self % conf % inspect == iprof))
call self % RTprof % print(self % conf, iprof, i_inst)
236 if(self % conf % RTTOV_profile_checkinput)
call self % RTprof % check(self % conf, iprof, i_inst, errorstatus)
238 if (errorstatus == errorstatus_success)
then
240 ichan_sim = ichan_sim + 1_jpim
241 chanprof(ichan_sim) % prof = iprof_rttov
242 chanprof(ichan_sim) % chan = self % channels(ichan)
243 self % RTprof % chanprof(nchan_total + ichan_sim) % prof = iprof
244 self % RTprof % chanprof(nchan_total + ichan_sim) % chan = self % channels(ichan)
252 call self % RTProf % init_emissivity(self % conf, prof_start)
259 if (jacobian_needed)
then
263 self % conf % rttov_opts, &
264 self % RTProf % profiles(prof_start:prof_start + nprof_sim -1), &
265 self % RTProf % profiles_k(1:
nchan_sim), &
266 self % conf % rttov_coef_array(i_inst), &
267 self % RTProf % transmission, &
268 self % RTProf % transmission_k, &
269 self % RTProf % radiance, &
270 self % RTProf % radiance_k, &
271 calcemis = self % RTProf % calcemis(1:
nchan_sim), &
272 emissivity = self % RTProf % emissivity(1:
nchan_sim), &
273 emissivity_k = self % RTProf % emissivity_k(1:
nchan_sim))
275 if ( errorstatus /= errorstatus_success )
then
276 write(
message,
'(A, A, 2I6)') trim(routine_name),
'after rttov_k: error ', errorstatus, i_inst, &
277 ' skipping profiles ', prof_start,
' -- ', prof_start + nprof_sim - 1
285 self % conf % rttov_opts, &
286 self % RTProf % profiles(prof_start:prof_start + nprof_sim -1), &
287 self % conf % rttov_coef_array(i_inst), &
288 self % RTProf % transmission, &
289 self % RTProf % radiance, &
290 calcemis = self % RTProf % calcemis(1:
nchan_sim), &
291 emissivity = self % RTProf % emissivity(1:
nchan_sim))
293 if ( errorstatus /= errorstatus_success )
then
294 write(
message,
'(A, A, 2I6)') trim(routine_name),
'after rttov_direct: error ', errorstatus, i_inst, &
295 ' skipping profiles ', prof_start,
' -- ', prof_start + nprof_sim - 1
301 if ( errorstatus == errorstatus_success )
then
302 do ichan = 1,
nchan_sim,
size(self%channels)
303 iprof = self % RTProf % chanprof(nchan_total + ichan)%prof
304 hofx(1:
size(self%channels),iprof) = self % RTprof % radiance % bt(ichan:ichan+
size(self%channels)-1)
308 if(hofxdiags%nvar > 0)
call populate_hofxdiags(self % RTProf, chanprof, self % conf, prof_start, hofxdiags)
313 prof_start = prof_start + nprof_sim
317 if (jacobian_needed)
call self % RTprof % zero_k()
322 if(jacobian_needed)
then
323 call self % RTprof % alloc_k(errorstatus, self % conf, -1, -1, -1, asw=0)
324 call self % RTprof % alloc_profs_k(errorstatus, self % conf,
size(self % RTprof % profiles_k), -1, asw=0)
327 deallocate (self % RTprof % profiles_k)
329 call self % RTprof % alloc_direct(errorstatus, self % conf, -1, -1, -1, asw=0)
330 call self % RTprof % alloc_profs(errorstatus, self % conf,
size(self % RTprof % profiles), -1, asw=0)
332 deallocate(self % RTprof % chanprof)
334 if (errorstatus /= errorstatus_success)
then
336 'after rttov_alloc_direct (deallocation): errorstatus, i_inst =', errorstatus, i_inst
subroutine, public ufo_geovals_get_var(self, varname, geoval)
Fortran module for radiancerttov observation operator.
subroutine ufo_radiancerttov_setup(self, f_confOper, channels)
subroutine ufo_radiancerttov_simobs(self, geovals, obss, nvars, nlocs, hofx, hofxdiags, ob_info)
subroutine ufo_radiancerttov_delete(self)
Fortran module to provide code shared between nonlinear and tlm/adm radiance calculations.
subroutine, public parse_hofxdiags(hofxdiags, jacobian_needed)
integer, public nchan_inst
subroutine, public rttov_conf_setup(conf, f_confOpts, f_confOper)
character(len=max_string), public message
subroutine, public rttov_conf_delete(conf)
character(len=maxvarlen), dimension(:), pointer, public varin_default
subroutine, public populate_hofxdiags(RTProf, chanprof, conf, prof_start, hofxdiags)
integer, public nchan_sim
Fortran module which contains the observation metadata for a single observation.
integer function, public ufo_vars_getindex(vars, varname)
character(len=maxvarlen), parameter, public var_q
character(len=maxvarlen), parameter, public var_mixr
character(len=maxvarlen), parameter, public var_ts
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 observation type.