10 use fckit_configuration_module,
only: fckit_configuration
13 use missing_values_mod
27 character(len=MAXVARLEN),
public,
allocatable :: varin(:)
28 integer,
allocatable :: channels(:)
47 type(fckit_configuration),
intent(in) :: f_confOper
48 integer(c_int),
intent(in) :: channels(:)
51 character(len=max_string) :: err_msg
52 type(fckit_configuration) :: f_confOpts
54 CHARACTER(len=MAXVARLEN),
ALLOCATABLE :: var_aerosols(:)
56 call f_confoper%get_or_die(
"obs options",f_confopts)
60 write(err_msg,*)
'ufo_aodcrtm_setup error: H2O must be first in CRTM Absorbers for AOD'
61 call abor1_ftn(err_msg)
64 write(err_msg,*)
'ufo_aodcrtm_setup error: O3 must be included in CRTM Absorbers'
65 call abor1_ftn(err_msg)
71 allocate(self%varin(nvars_in))
76 allocate(self%channels(
size(channels)))
77 self%channels(:) = channels(:)
99 integer,
intent(in) :: nvars, nlocs
100 real(c_double),
intent(inout) :: hofx(nvars, nlocs)
101 type(c_ptr),
value,
intent(in) :: obss
104 character(*),
parameter :: PROGRAM_NAME =
'ufo_aodcrtm_mod.F90'
105 character(255) :: message, version
106 integer :: err_stat, alloc_stat
107 integer :: l, m, n, i
109 real(c_double) :: missing
111 integer :: n_Profiles
113 integer :: n_Channels
116 type(crtm_channelinfo_type) :: chinfo(self%conf%n_Sensors)
117 type(crtm_geometry_type),
allocatable :: geo(:)
120 type(crtm_atmosphere_type),
allocatable :: atm(:)
121 type(crtm_surface_type),
allocatable :: sfc(:)
122 type(crtm_rtsolution_type),
allocatable :: rts(:,:)
126 TYPE(crtm_atmosphere_type),
ALLOCATABLE :: atm_K(:,:)
127 TYPE(crtm_rtsolution_type),
ALLOCATABLE :: rts_K(:,:)
131 n_profiles = geovals%nlocs
151 err_stat = crtm_init( self%conf%SENSOR_ID, &
153 file_path=trim(self%conf%COEFFICIENT_PATH), &
155 if ( err_stat /= success )
THEN
156 message =
'Error initializing CRTM'
157 call display_message( program_name, message, failure )
164 sensor_loop:
DO n = 1, self%conf%n_Sensors
169 n_channels = crtm_channelinfo_n_channels(chinfo(n))
174 allocate( geo( n_profiles ), &
177 rts( n_channels, n_profiles ), &
179 if ( alloc_stat /= 0 )
THEN
180 message =
'Error allocating structure arrays'
181 call display_message( program_name, message, failure )
188 call crtm_atmosphere_create( atm, n_layers, self%conf%n_Absorbers, self%conf%n_Clouds, self%conf%n_Aerosols )
189 if ( any(.NOT. crtm_atmosphere_associated(atm)) )
THEN
190 message =
'Error allocating CRTM Forward Atmosphere structure'
191 CALL display_message( program_name, message, failure )
195 ALLOCATE( atm_k( n_channels, n_profiles ), &
196 rts_k( n_channels, n_profiles ), &
198 IF ( alloc_stat /= 0 )
THEN
199 message =
'Error allocating structure arrays'
200 CALL display_message( program_name, message, failure )
205 CALL crtm_atmosphere_create( atm_k, n_layers, self%conf%n_Absorbers, self%conf%n_Clouds, self%conf%n_Aerosols)
206 IF ( any(.NOT. crtm_atmosphere_associated(atm_k)) )
THEN
207 message =
'Error allocating CRTM K-matrix Atmosphere structure'
208 CALL display_message( program_name, message, failure )
212 CALL crtm_rtsolution_create(rts, n_layers )
213 CALL crtm_rtsolution_create(rts_k, n_layers )
217 CALL load_atm_data(n_profiles,n_layers,geovals,atm,self%conf)
219 IF (trim(self%conf%aerosol_option) /=
"") &
221 &self%conf%aerosol_option,atm)
225 IF (self%conf%inspect > 0)
THEN
226 CALL crtm_atmosphere_inspect(atm(self%conf%inspect))
227 CALL crtm_channelinfo_inspect(chinfo(n))
232 err_stat = crtm_aod_k( atm, &
238 if ( err_stat /= success )
THEN
239 message =
'Error calling CRTM Forward Model for '//trim(self%conf%SENSOR_ID(n))
240 call display_message( program_name, message, failure )
249 missing = missing_value(missing)
253 DO l = 1,
size(self%channels)
254 hofx(l,m) = sum(rts(self%channels(l),m)%layer_optical_depth)
260 call crtm_atmosphere_destroy(atm)
261 call crtm_rtsolution_destroy(rts)
263 call crtm_atmosphere_destroy(atm_k)
264 call crtm_rtsolution_destroy(rts_k)
268 DEALLOCATE(geo, atm, sfc, rts, atm_k, rts_k, stat = alloc_stat)
269 if ( alloc_stat /= 0 )
THEN
270 message =
'Error deallocating structure arrays'
271 call display_message( program_name, message, failure )
280 err_stat = crtm_destroy( chinfo )
281 if ( err_stat /= success )
THEN
282 message =
'Error destroying CRTM'
283 call display_message( program_name, message, failure )
Fortran module to handle aod observations.
character(maxvarlen), parameter varname_tmplate
subroutine ufo_aodcrtm_delete(self)
character(len=maxvarlen), dimension(5), parameter varin_default
subroutine ufo_aodcrtm_simobs(self, geovals, obss, nvars, nlocs, hofx)
subroutine ufo_aodcrtm_setup(self, f_confOper, channels)
Fortran module to provide code shared between nonlinear and tlm/adm radiance calculations.
subroutine, public crtm_conf_setup(conf, f_confOpts, f_confOper)
subroutine, public load_aerosol_data(n_profiles, n_layers, geovals, aerosol_option, atm)
subroutine, public assign_aerosol_names(aerosol_option, var_aerosols)
subroutine, public crtm_conf_delete(conf)
subroutine, public load_atm_data(n_Profiles, n_Layers, geovals, atm, conf)
subroutine, public ufo_geovals_get_var(self, varname, geoval)
character(len=maxvarlen), parameter, public var_prsi
integer function, public ufo_vars_getindex(vars, varname)
character(len=maxvarlen), parameter, public var_oz
character(len=maxvarlen), parameter, public var_prs
character(len=maxvarlen), parameter, public var_rh
character(len=maxvarlen), parameter, public var_mixr
character(len=maxvarlen), parameter, public var_ts
Fortran derived type for aod trajectory.
type to hold interpolated field for one variable, one observation
type to hold interpolated fields required by the obs operators