32 spccoeff_isvisiblesensor, &
33 spccoeff_ismicrowavesensor
85 nlte_predictor_isactive, &
131 '$Id: CRTM_Forward_Module.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 219 Atmosphere , & ! Input, M
220 Surface , & ! Input, M
221 Geometry , & ! Input, M
222 ChannelInfo, & ! Input, n_Sensors
223 RTSolution , & ! Output, L x M
225 result( error_status )
231 TYPE(crtm_rtsolution_type),
INTENT(IN OUT) :: rtsolution(:,:)
234 INTEGER :: error_status
236 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Forward' 238 CHARACTER(256) :: message
239 LOGICAL :: options_present
240 LOGICAL :: check_input
241 LOGICAL :: user_emissivity, user_direct_reflectivity, user_n_streams
242 LOGICAL :: user_antcorr, compute_antcorr
243 LOGICAL :: apply_nlte_correction
244 LOGICAL :: atmosphere_invalid, surface_invalid, geometry_invalid, options_invalid
245 INTEGER :: rt_algorithm_id
247 INTEGER :: n, n_sensors, sensorindex
248 INTEGER :: l, n_channels, channelindex
249 INTEGER :: m, n_profiles
251 INTEGER :: n_full_streams, mth_azi
252 REAL(fp) :: source_za
253 REAL(fp) :: wavenumber
254 REAL(fp) :: aircraft_pressure
255 REAL(fp) :: transmittance
268 TYPE(crtm_pvar_type) :: pvar
269 TYPE(crtm_aavar_type) :: aavar
272 TYPE(aovar_type) :: aovar
275 TYPE(nlte_predictor_type) :: nlte_predictor
285 n_sensors =
SIZE(channelinfo)
287 IF ( n_sensors == 0 .OR. n_channels == 0 )
RETURN 291 IF (
SIZE(rtsolution,dim=1) < n_channels )
THEN 293 WRITE( message,
'("Output RTSolution structure array too small (",i0,& 294 &") to hold results for the number of requested channels (",i0,")")') &
295 SIZE(rtsolution,dim=1), n_channels
303 n_profiles =
SIZE(atmosphere)
305 IF (
SIZE(surface) /= n_profiles .OR. &
306 SIZE(geometry) /= n_profiles .OR. &
307 SIZE(rtsolution,dim=2) /= n_profiles )
THEN 309 message =
'Inconsistent profile dimensionality for input arguments.' 314 options_present = .false.
315 IF (
PRESENT(options) )
THEN 316 options_present = .true.
317 IF (
SIZE(options) /= n_profiles )
THEN 319 message =
'Inconsistent profile dimensionality for Options optional input argument.' 330 message =
'Error allocating SfcOptics data structures' 339 profile_loop:
DO m = 1, n_profiles
345 WRITE( message,
'("The CloudCoeff data must be loaded (with CRTM_Init routine) ", & 346 &"for the cloudy case profile #",i0)' ) m
352 WRITE( message,
'("The AerosolCoeff data must be loaded (with CRTM_Init routine) ", & 353 &"for the aerosol case profile #",i0)' ) m
361 check_input = default_options%Check_Input
362 user_emissivity = default_options%Use_Emissivity
363 user_antcorr = default_options%Use_Antenna_Correction
364 apply_nlte_correction = default_options%Apply_NLTE_Correction
365 rt_algorithm_id = default_options%RT_Algorithm_Id
366 user_n_streams = default_options%Use_N_Streams
367 aircraft_pressure = default_options%Aircraft_Pressure
369 IF (options_present)
THEN 371 check_input = options(m)%Check_Input
373 user_emissivity = options(m)%Use_Emissivity
374 IF ( options(m)%Use_Emissivity )
THEN 376 IF ( options(m)%n_Channels < n_channels )
THEN 378 WRITE( message,
'( "Input Options channel dimension (", i0, ") is less ", & 379 &"than the number of requested channels (",i0, ")" )' ) &
380 options(m)%n_Channels, n_channels
385 user_direct_reflectivity = options(m)%Use_Direct_Reflectivity
388 user_antcorr = options(m)%Use_Antenna_Correction
390 apply_nlte_correction = options(m)%Apply_NLTE_Correction
392 aircraft_pressure = options(m)%Aircraft_Pressure
395 ancillaryinput%SSU = options(m)%SSU
396 ancillaryinput%Zeeman = options(m)%Zeeman
398 sfcoptics%Use_New_MWSSEM = .NOT. options(m)%Use_Old_MWSSEM
400 rt_algorithm_id = options(m)%RT_Algorithm_Id
402 user_n_streams = options(m)%Use_N_Streams
404 IF ( user_n_streams )
THEN 405 IF ( options(m)%n_Streams <= 0 .OR. mod(options(m)%n_Streams,2) /= 0 .OR. &
408 WRITE( message,
'( "Input Options n_Streams (", i0, ") is invalid" )' ) &
418 IF ( check_input )
THEN 423 IF ( atmosphere_invalid .OR. surface_invalid .OR. geometry_invalid )
THEN 425 WRITE( message,
'("Input data check failed for profile #",i0)' ) m
430 IF ( options_present )
THEN 432 IF ( options_invalid )
THEN 434 WRITE( message,
'("Options data check failed for profile #",i0)' ) m
450 source_zenith_angle = source_za )
460 IF ( error_status /=
success )
THEN 462 WRITE( message,
'("Error adding extra layers to profile #",i0)' ) m
468 WRITE( message,
'("Added layers [",i0,"] cause total [",i0,"] to exceed the ",& 469 &"maximum allowed [",i0,"] for profile #",i0)' ) &
479 IF (options_present)
THEN 481 atmoptics%Include_Scattering = options(m)%Include_Scattering
485 WRITE( message,
'("Error allocating AtmOptics data structure for profile #",i0)' ) m
490 CALL aovar_create( aovar, atm%n_Layers )
494 IF ( aircraft_pressure >
zero )
THEN 495 rtv%aircraft%rt = .true.
499 WRITE( message,
'("Difference between aircraft pressure level (",es13.6,& 500 &"hPa) and closest input profile level (",es13.6,& 501 &"hPa) is larger than recommended (",f4.1,"hPa) for profile #",i0)') &
502 aircraft_pressure, atm%Level_Pressure(rtv%aircraft%idx), &
507 rtv%aircraft%rt = .false.
513 IF ( atm%n_Clouds > 0 )
THEN 521 IF ( atm%n_Aerosols > 0 )
THEN 536 sensor_loop:
DO n = 1, n_sensors
540 sensorindex = channelinfo(n)%Sensor_Index
544 IF ( user_antcorr .AND. &
547 compute_antcorr = .true.
549 compute_antcorr = .false.
561 WRITE( message,
'("Error allocating predictor structure for profile #",i0, & 562 &" and ",a," sensor.")' ) m,
sc(sensorindex)%Sensor_Id
576 IF( (atm%n_Clouds > 0 .OR. &
577 atm%n_Aerosols > 0 .OR. &
578 spccoeff_isvisiblesensor(
sc(sensorindex) ) ) .and. atmoptics%Include_Scattering )
THEN 582 WRITE( message,
'("Error allocating RTV structure for profile #",i0, & 583 &" and ",a," sensor.")' ) m, trim(
sc(sensorindex)%Sensor_Id)
588 rtv%RT_Algorithm_Id = rt_algorithm_id
593 IF ( apply_nlte_correction )
THEN 595 sc(sensorindex)%NC, &
605 channel_loop:
DO l = 1, channelinfo(n)%n_Channels
609 IF ( .NOT. channelinfo(n)%Process_Channel(l) ) cycle channel_loop
611 channelindex = channelinfo(n)%Channel_Index(l)
615 rtsolution(ln,m)%Sensor_Id = channelinfo(n)%Sensor_Id
616 rtsolution(ln,m)%WMO_Satellite_Id = channelinfo(n)%WMO_Satellite_Id
617 rtsolution(ln,m)%WMO_Sensor_Id = channelinfo(n)%WMO_Sensor_Id
618 rtsolution(ln,m)%Sensor_Channel = channelinfo(n)%Sensor_Channel(l)
625 IF ( user_n_streams )
THEN 626 n_full_streams = options(m)%n_Streams
627 rtsolution(ln,m)%n_Full_Streams = n_full_streams + 2
628 rtsolution(ln,m)%Scattering_Flag = .true.
636 atmoptics%n_Legendre_Terms = n_full_streams
655 IF(
sc(sensorindex)%Solar_Irradiance(channelindex) >
zero .AND. &
657 rtv%Solar_Flag_true = .true.
660 IF( spccoeff_isvisiblesensor(
sc(sensorindex) ) .AND. rtv%Solar_Flag_true )
THEN 661 rtv%Visible_Flag_true = .true.
663 IF( atmoptics%n_Legendre_Terms < 4 )
THEN 664 atmoptics%n_Legendre_Terms = 4
665 rtsolution(ln,m)%Scattering_FLAG = .true.
666 rtsolution(ln,m)%n_Full_Streams = atmoptics%n_Legendre_Terms + 2
670 wavenumber =
sc(sensorindex)%Wavenumber(channelindex)
675 IF ( error_status /=
success )
THEN 676 WRITE( message,
'("Error computing MoleculeScatter for ",a,& 677 &", channel ",i0,", profile #",i0)') &
678 trim(channelinfo(n)%Sensor_ID), &
679 channelinfo(n)%Sensor_Channel(l), &
685 rtv%Visible_Flag_true = .false.
691 IF( atm%n_Clouds > 0 )
THEN 697 IF ( error_status /=
success )
THEN 698 WRITE( message,
'("Error computing CloudScatter for ",a,& 699 &", channel ",i0,", profile #",i0)' ) &
700 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
708 IF ( atm%n_Aerosols > 0 )
THEN 714 IF ( error_status /=
success )
THEN 715 WRITE( message,
'("Error computing AerosolScatter for ",a,& 716 &", channel ",i0,", profile #",i0)' ) &
717 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
725 IF( atmoptics%Include_Scattering )
THEN 729 rtsolution(ln,m)%SOD = atmoptics%Scattering_Optical_Depth
734 sfcoptics%Transmittance = -
one 736 sfcoptics%Transmittance = transmittance
743 sfcoptics%Compute = .true.
745 IF ( user_emissivity )
THEN 746 sfcoptics%Compute = .false.
747 sfcoptics%Emissivity(1,1) = options(m)%Emissivity(ln)
748 sfcoptics%Reflectivity(1,1,1,1) =
one - options(m)%Emissivity(ln)
749 IF ( user_direct_reflectivity )
THEN 750 sfcoptics%Direct_Reflectivity(1,1) = options(m)%Direct_Reflectivity(ln)
752 sfcoptics%Direct_Reflectivity(1,1) = sfcoptics%Reflectivity(1,1,1,1)
760 rtsolution(ln,m)%Radiance =
zero 762 azimuth_fourier_loop:
DO mth_azi = 0, rtv%n_Azi
765 rtv%mth_Azi = mth_azi
766 sfcoptics%mth_Azi = mth_azi
779 IF ( error_status /=
success )
THEN 780 WRITE( message,
'( "Error computing RTSolution for ", a, & 781 &", channel ", i0,", profile #",i0)' ) &
782 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
786 END DO azimuth_fourier_loop
789 IF ( apply_nlte_correction .AND. nlte_predictor_isactive(nlte_predictor) )
THEN 791 sc(sensorindex)%NC , &
794 rtsolution(ln,m)%Radiance )
801 rtsolution(ln,m)%Radiance , &
802 rtsolution(ln,m)%Brightness_Temperature )
805 IF ( compute_antcorr )
THEN 862 CHARACTER(*),
INTENT(OUT) :: id
subroutine, public crtm_compute_transmittance(atmoptics, transmittance)
logical function, public crtm_aerosolcoeff_isloaded()
integer, parameter, public max_n_azimuth_fourier
logical function, public crtm_cloudcoeff_isloaded()
integer, parameter, public failure
integer, parameter, public set
real(fp), parameter, public zero
integer, parameter, public warning
integer, parameter, public max_n_phase_elements
subroutine, public crtm_combine_atmoptics(AtmOptics, AOvar)
logical function, public crtm_options_isvalid(self)
integer, parameter, public fp
elemental subroutine, public crtm_atmosphere_destroy(Atm)
integer, parameter, public max_n_angles
real(fp), parameter, public scattering_albedo_threshold
subroutine, public crtm_forward_version(Id)
elemental subroutine, public crtm_geometryinfo_setvalue(gInfo, Geometry, iFOV, Longitude, Latitude, Surface_Altitude, Sensor_Scan_Angle, Sensor_Zenith_Angle, Sensor_Azimuth_Angle, Source_Zenith_Angle, Source_Azimuth_Angle, Flux_Zenith_Angle, Year, Month, Day, Distance_Ratio, Sensor_Scan_Radian, Sensor_Zenith_Radian, Sensor_Azimuth_Radian, Secant_Sensor_Zenith, Cosine_Sensor_Zenith, Source_Zenith_Radian, Source_Azimuth_Radian, Secant_Source_Zenith, Flux_Zenith_Radian, Secant_Flux_Zenith, Trans_Zenith_Radian, Secant_Trans_Zenith, AU_ratio2)
logical function, public crtm_atmosphere_isvalid(Atm)
elemental subroutine, public crtm_atmoptics_destroy(self)
elemental subroutine, public csvar_create(self, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Clouds)
elemental subroutine, public crtm_geometryinfo_compute(gInfo)
elemental subroutine, public crtm_predictor_create(self, n_Layers, SensorIndex, SaveFWV)
pure logical function, public crtm_include_scattering(atmoptics)
integer, parameter, public max_n_legendre_terms
elemental subroutine, public crtm_sfcoptics_create(SfcOptics, n_Angles, n_Stokes)
integer function, public crtm_compute_rtsolution(Atmosphere, Surface, AtmOptics, SfcOptics, GeometryInfo, SensorIndex, ChannelIndex, RTSolution, RTV)
elemental logical function, public crtm_atmoptics_associated(self)
real(fp), parameter, public max_source_zenith_angle
elemental subroutine, public rtv_create(RTV, n_Angles, n_Legendre_Terms, n_Layers)
elemental subroutine, public crtm_atmoptics_zero(self)
integer, parameter, public max_n_streams
integer, parameter, public max_n_stokes
integer function, public crtm_compute_aerosolscatter(Atm, SensorIndex, ChannelIndex, AScat, ASV)
integer function, public crtm_forward(Atmosphere, Surface, Geometry, ChannelInfo, RTSolution, Options)
integer function, public crtm_compute_cloudscatter(Atm, SensorIndex, ChannelIndex, CScat, CSV)
integer, parameter, public not_set
real(fp), parameter, public one
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer function, public crtm_compute_moleculescatter(Wavenumber, Atmosphere, AtmOptics, Message_Log)
elemental logical function, public csvar_associated(self)
subroutine, public crtm_compute_surfacet(Surface, SfcOptics)
subroutine, public crtm_compute_antcorr(gI, n, l, RT)
elemental subroutine, public asvar_destroy(self)
elemental logical function, public crtm_sfcoptics_associated(SfcOptics)
elemental subroutine, public csvar_destroy(self)
integer function, public crtm_compute_nstreams(Atmosphere, SensorIndex, ChannelIndex, RTSolution)
elemental subroutine, public crtm_atmoptics_create(self, n_Layers, n_Legendre_Terms, n_Phase_Elements)
logical function, public crtm_surface_isvalid(Sfc)
logical function, public crtm_geometry_isvalid(geo)
elemental subroutine, public crtm_predictor_destroy(self)
subroutine, public crtm_compute_predictors(SensorIndex, Atmosphere, GeometryInfo, AncillaryInput, Predictor, iVar)
type(spccoeff_type), dimension(:), allocatable, save, public sc
elemental logical function, public asvar_associated(self)
integer, parameter, public max_n_layers
subroutine, public compute_nlte_correction(NLTECoeff, ChannelIndex, NLTE_Predictor, Radiance)
subroutine, public crtm_compute_atmabsorption(SensorIndex, ChannelIndex, AncillaryInput, Predictor, AtmOptics, iVar)
elemental subroutine, public crtm_sfcoptics_destroy(SfcOptics)
integer function, public crtm_atmosphere_addlayers(Atm_In, Atm_Out)
subroutine, public crtm_planck_temperature(n, l, Radiance, Temperature)
elemental integer function, public crtm_channelinfo_n_channels(ChannelInfo)
subroutine, public compute_nlte_predictor(NLTECoeff, Atm, gInfo, NLTE_Predictor)
elemental logical function, public crtm_predictor_associated(self)
elemental logical function, public rtv_associated(RTV)
elemental subroutine, public asvar_create(self, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Aerosols)
real(fp), parameter, public aircraft_pressure_threshold
integer, parameter, public success
elemental subroutine, public crtm_geometryinfo_getvalue(gInfo, Geometry, iFOV, Longitude, Latitude, Surface_Altitude, Sensor_Scan_Angle, Sensor_Zenith_Angle, Sensor_Azimuth_Angle, Source_Zenith_Angle, Source_Azimuth_Angle, Flux_Zenith_Angle, Year, Month, Day, Distance_Ratio, Sensor_Scan_Radian, Sensor_Zenith_Radian, Sensor_Azimuth_Radian, Secant_Sensor_Zenith, Cosine_Sensor_Zenith, Source_Zenith_Radian, Source_Azimuth_Radian, Secant_Source_Zenith, Flux_Zenith_Radian, Secant_Flux_Zenith, Trans_Zenith_Radian, Secant_Trans_Zenith, AU_ratio2)
elemental logical function, public accoeff_associated(ACCoeff)
elemental subroutine, public rtv_destroy(RTV)
character(*), parameter module_version_id
integer function, public crtm_get_pressurelevelidx(Atm, Level_Pressure)
elemental logical function, public nltecoeff_associated(NLTECoeff)