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 use fckit_mpi_module,
only: fckit_mpi_comm
103 type(c_ptr),
value,
intent(in) :: obss
104 integer,
intent(in) :: nvars, nlocs
106 real(c_double),
intent(inout) :: hofx(nvars,nlocs)
109 real(c_double) :: missing
110 type(fckit_mpi_comm) :: f_comm
113 character(*),
parameter :: ROUTINE_NAME =
'ufo_radiancerttov_simobs'
117 integer(kind=jpim) :: errorstatus
119 integer :: i_inst, nlevels, nchan_total, ichan, iprof, prof
120 integer :: nprof_sim, nprof_max_sim
121 integer :: prof_start, prof_end
123 logical :: jacobian_needed
124 logical,
allocatable :: skip_profiles(:)
128 logical :: layer_quantities
130 include
'rttov_direct.interface'
131 include
'rttov_k.interface'
132 include
'rttov_print_profile.interface'
133 include
'rttov_user_profile_checkinput.interface'
136 call obsspace_get_comm(obss, f_comm)
141 nprofiles = geovals % nlocs
144 nlevels = temp % nval
145 layer_quantities = .false.
150 missing = missing_value(missing)
166 sensor_loop:
do i_inst = 1, self % conf % nSensors
169 call rttov_user_options_checkinput(errorstatus, self % conf % rttov_opts, &
170 self % conf % rttov_coef_array(i_inst))
172 if (errorstatus /= errorstatus_success)
then
173 write(
message,
'(A, I6)')
'after rttov_user_options_checkinput: error = ',&
179 allocate(skip_profiles(nprofiles))
180 skip_profiles(:) = .false.
187 nprof_max_sim = self % conf % nchan_max_sim /
nchan_inst
188 nprof_sim = min(nprof_max_sim, nprofiles)
194 nprof_sim = min(nprof_sim, prof_end - prof_start + 1)
195 nchan_sim = nprof_sim *
size(self%channels)
200 if (.not. jacobian_needed)
then
202 call self % RTprof % alloc(errorstatus, self % conf, nprof_sim,
nchan_sim, nlevels, init=.true., asw=1)
204 call self % RTprof % alloc(errorstatus, self % conf, nprof_sim,
nchan_sim, nlevels, init=.true., asw=2)
207 self % RTProf % profiles(:) % skin % surftype = -1_jpim
209 do while (prof_start <= prof_end)
210 self % RTprof % chanprof(:) % prof = 0
211 self % RTprof % chanprof(:) % chan = 0
214 nprof_sim = min(nprof_sim, prof_end - prof_start + 1)
220 do iprof = 1, min(nprof_sim, prof_end - prof_start + 1)
221 if(.not. skip_profiles(prof_start + iprof - 1))
then
225 self % RTprof % chanprof(
nchan_sim) % prof = iprof
226 self % RTprof % chanprof(
nchan_sim) % chan = self % channels(ichan)
229 if (
debug)
write(*,*)
'skipping ', iprof, prof_start + iprof - 1
238 call load_atm_data_rttov(geovals,obss,self % RTprof % profiles,prof_start,self % conf,layer_quantities,obs_info=obs_info)
241 call load_atm_data_rttov(geovals,obss,self % RTprof % profiles,prof_start,self%conf,layer_quantities)
249 call self % RTProf % init_emissivity(self % conf)
251 if(self % conf % RTTOV_profile_checkinput)
then
252 if (self % conf % inspect > 0)
then
253 call rttov_print_profile(self % RTprof % profiles(self % conf % inspect))
258 self % conf % rttov_opts, &
259 self % conf % rttov_coef_array(i_inst), &
260 self % RTprof % profiles(self % conf % inspect))
268 if (jacobian_needed)
then
272 self % RTProf % chanprof(nchan_total + 1:nchan_total +
nchan_sim), &
273 self % conf % rttov_opts, &
274 self % RTProf % profiles, &
275 self % RTProf % profiles_k(nchan_total + 1 : nchan_total +
nchan_sim), &
276 self % conf % rttov_coef_array(i_inst), &
277 self % RTProf % transmission, &
278 self % RTProf % transmission_k, &
279 self % RTProf % radiance, &
280 self % RTProf % radiance_k, &
281 calcemis = self % RTProf % calcemis, &
282 emissivity = self % RTProf % emissivity, &
283 emissivity_k = self % RTProf % emissivity_k)
285 if ( errorstatus /= errorstatus_success )
then
286 write(
message,
'(A, 2I6)')
'after rttov_k: error ', errorstatus, i_inst
294 self % conf % rttov_opts, &
295 self % RTProf % profiles(1:nprof_sim), &
296 self % conf % rttov_coef_array(i_inst), &
297 self % RTProf % transmission, &
298 self % RTProf % radiance, &
299 calcemis = self % RTProf % calcemis(1:
nchan_sim), &
300 emissivity = self % RTProf % emissivity(1:
nchan_sim))
302 if ( errorstatus /= errorstatus_success )
then
303 write(
message,
'(A, 2I6)')
'after rttov_direct: error ', errorstatus, i_inst
310 if (
debug)
write(*,
'(A1, i0, A, i0)',advance=
"NO") achar(13), prof_start+nprof_sim-1,
' locations processed out of ', geovals%nlocs
314 do ichan=1,
nchan_sim,
size(self%channels)
315 prof = self % RTProf % chanprof(ichan)%prof
316 hofx(1:
size(self%channels),prof_start + prof - 1) = self % RTprof % radiance % bt(ichan:ichan+
size(self%channels)-1)
321 if(hofxdiags%nvar > 0)
call populate_hofxdiags(self % RTProf, self % RTProf % chanprof, hofxdiags)
324 prof_start = prof_start + nprof_sim
330 call self % RTprof % alloc(errorstatus, self % conf, nprof_sim,
nchan_sim, nlevels, asw=0)
332 if (errorstatus /= errorstatus_success)
then
334 'after rttov_alloc_direct (deallocation): errorstatus, i_inst =', &