31 spccoeff_isvisiblesensor, &
32 spccoeff_ismicrowavesensor
101 nlte_predictor_isactive , &
147 '$Id: CRTM_Tangent_Linear_Module.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 257 Atmosphere , & ! FWD Input, M
258 Surface , & ! FWD Input, M
259 Atmosphere_TL, & ! TL Input, M
260 Surface_TL , & ! TL Input, M
261 Geometry , & ! Input, M
262 ChannelInfo , & ! Input, n_Sensors
263 RTSolution , & ! FWD Output, L x M
264 RTSolution_TL, & ! TL Output, L x M
266 result( error_status )
274 TYPE(crtm_rtsolution_type) ,
INTENT(IN OUT) :: rtsolution(:,:)
275 TYPE(crtm_rtsolution_type) ,
INTENT(IN OUT) :: rtsolution_tl(:,:)
278 INTEGER :: error_status
280 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Tangent_Linear' 282 CHARACTER(256) :: message
283 LOGICAL :: options_present
284 LOGICAL :: check_input
285 LOGICAL :: user_emissivity, user_direct_reflectivity, user_n_streams
286 LOGICAL :: user_antcorr, compute_antcorr
287 LOGICAL :: apply_nlte_correction
288 LOGICAL :: atmosphere_invalid, surface_invalid, geometry_invalid, options_invalid
289 INTEGER :: rt_algorithm_id
290 INTEGER :: status_fwd, status_tl
292 INTEGER :: n, n_sensors, sensorindex
293 INTEGER :: l, n_channels, channelindex
294 INTEGER :: m, n_profiles
296 INTEGER :: n_full_streams, mth_azi
297 REAL(fp) :: source_za
298 REAL(fp) :: wavenumber
299 REAL(fp) :: transmittance, transmittance_tl
312 TYPE(crtm_pvar_type) :: pvar
313 TYPE(crtm_aavar_type) :: aavar
316 TYPE(aovar_type) :: aovar
319 TYPE(nlte_predictor_type) :: nlte_predictor, nlte_predictor_tl
329 n_sensors =
SIZE(channelinfo)
331 IF ( n_sensors == 0 .OR. n_channels == 0 )
RETURN 335 IF (
SIZE(rtsolution, dim=1) < n_channels .OR. &
336 SIZE(rtsolution_tl,dim=1) < n_channels )
THEN 338 WRITE( message,
'("Output RTSolution structure arrays too small (",i0," and ",i0,& 339 &") to hold results for the number of requested channels (",i0,")")') &
340 SIZE(rtsolution,dim=1),
SIZE(rtsolution_tl,dim=1), n_channels
348 n_profiles =
SIZE(atmosphere)
350 IF (
SIZE(surface) /= n_profiles .OR. &
351 SIZE(atmosphere_tl) /= n_profiles .OR. &
352 SIZE(surface_tl) /= n_profiles .OR. &
353 SIZE(geometry) /= n_profiles .OR. &
354 SIZE(rtsolution, dim=2) /= n_profiles .OR. &
355 SIZE(rtsolution_tl,dim=2) /= n_profiles )
THEN 357 message =
'Inconsistent profile dimensionality for input arguments.' 362 options_present = .false.
363 IF (
PRESENT(options) )
THEN 364 options_present = .true.
365 IF (
SIZE(options) /= n_profiles )
THEN 367 message =
'Inconsistent profile dimensionality for Options optional input argument.' 380 message =
'Error allocating SfcOptics data structures' 389 profile_loop:
DO m = 1, n_profiles
395 WRITE( message,
'("The CloudCoeff data must be loaded (with CRTM_Init routine) ", & 396 &"for the cloudy case profile #",i0)' ) m
402 WRITE( message,
'("The AerosolCoeff data must be loaded (with CRTM_Init routine) ", & 403 &"for the aerosol case profile #",i0)' ) m
411 check_input = default_options%Check_Input
412 user_emissivity = default_options%Use_Emissivity
413 user_antcorr = default_options%Use_Antenna_Correction
414 apply_nlte_correction = default_options%Apply_NLTE_Correction
415 rt_algorithm_id = default_options%RT_Algorithm_Id
416 user_n_streams = default_options%Use_N_Streams
418 IF (options_present)
THEN 420 check_input = options(m)%Check_Input
422 user_emissivity = options(m)%Use_Emissivity
423 IF ( options(m)%Use_Emissivity )
THEN 425 IF ( options(m)%n_Channels < n_channels )
THEN 427 WRITE( message,
'( "Input Options channel dimension (", i0, ") is less ", & 428 &"than the number of requested channels (",i0, ")" )' ) &
429 options(m)%n_Channels, n_channels
434 user_direct_reflectivity = options(m)%Use_Direct_Reflectivity
437 user_antcorr = options(m)%Use_Antenna_Correction
439 apply_nlte_correction = options(m)%Apply_NLTE_Correction
442 ancillaryinput%SSU = options(m)%SSU
443 ancillaryinput%Zeeman = options(m)%Zeeman
445 sfcoptics%Use_New_MWSSEM = .NOT. options(m)%Use_Old_MWSSEM
447 rt_algorithm_id = options(m)%RT_Algorithm_Id
449 user_n_streams = options(m)%Use_N_Streams
451 IF ( user_n_streams )
THEN 452 IF ( options(m)%n_Streams <= 0 .OR. mod(options(m)%n_Streams,2) /= 0 .OR. &
455 WRITE( message,
'( "Input Options n_Streams (", i0, ") is invalid" )' ) &
465 IF ( check_input )
THEN 470 IF ( atmosphere_invalid .OR. surface_invalid .OR. geometry_invalid )
THEN 472 WRITE( message,
'("Input data check failed for profile #",i0)' ) m
477 IF ( options_present )
THEN 479 IF ( options_invalid )
THEN 481 WRITE( message,
'("Options data check failed for profile #",i0)' ) m
497 source_zenith_angle = source_za )
508 IF ( error_status /=
success )
THEN 510 WRITE( message,
'("Error adding FWD extra layers to profile #",i0)' ) m
515 IF ( error_status /=
success )
THEN 517 WRITE( message,
'("Error adding TL extra layers to profile #",i0)' ) m
524 WRITE( message,
'("Added layers [",i0,"] cause total [",i0,"] to exceed the ",& 525 &"maximum allowed [",i0,"] for profile #",i0)' ) &
542 WRITE( message,
'("Error allocating AtmOptics data structures for profile #",i0)' ) m
546 IF (options_present)
THEN 548 atmoptics%Include_Scattering = options(m)%Include_Scattering
549 atmoptics_tl%Include_Scattering = options(m)%Include_Scattering
552 CALL aovar_create( aovar, atm%n_Layers )
557 IF ( atm%n_Clouds > 0 )
THEN 565 IF ( atm%n_Aerosols > 0 )
THEN 580 sensor_loop:
DO n = 1, n_sensors
584 sensorindex = channelinfo(n)%Sensor_Index
588 IF ( user_antcorr .AND. &
591 compute_antcorr = .true.
593 compute_antcorr = .false.
611 WRITE( message,
'("Error allocating predictor structures for profile #",i0, & 612 &" and ",a," sensor.")' ) m,
sc(sensorindex)%Sensor_Id
633 IF( (atm%n_Clouds > 0 .OR. &
634 atm%n_Aerosols > 0 .OR. &
635 spccoeff_isvisiblesensor(
sc(sensorindex) ) ) .and. atmoptics%Include_Scattering )
THEN 639 WRITE( message,
'("Error allocating RTV structure for profile #",i0, & 640 &" and ",a," sensor.")' ) m, trim(
sc(sensorindex)%Sensor_Id)
645 rtv%RT_Algorithm_Id = rt_algorithm_id
650 IF ( apply_nlte_correction )
THEN 652 sc(sensorindex)%NC, &
666 channel_loop:
DO l = 1, channelinfo(n)%n_Channels
670 IF ( .NOT. channelinfo(n)%Process_Channel(l) ) cycle channel_loop
672 channelindex = channelinfo(n)%Channel_Index(l)
676 rtsolution(ln,m)%Sensor_Id = channelinfo(n)%Sensor_Id
677 rtsolution(ln,m)%WMO_Satellite_Id = channelinfo(n)%WMO_Satellite_Id
678 rtsolution(ln,m)%WMO_Sensor_Id = channelinfo(n)%WMO_Sensor_Id
679 rtsolution(ln,m)%Sensor_Channel = channelinfo(n)%Sensor_Channel(l)
680 rtsolution_tl(ln,m)%Sensor_Id = rtsolution(ln,m)%Sensor_Id
681 rtsolution_tl(ln,m)%WMO_Satellite_Id = rtsolution(ln,m)%WMO_Satellite_Id
682 rtsolution_tl(ln,m)%WMO_Sensor_Id = rtsolution(ln,m)%WMO_Sensor_Id
683 rtsolution_tl(ln,m)%Sensor_Channel = rtsolution(ln,m)%Sensor_Channel
692 IF ( user_n_streams )
THEN 693 n_full_streams = options(m)%n_Streams
694 rtsolution(ln,m)%n_Full_Streams = n_full_streams + 2
695 rtsolution(ln,m)%Scattering_Flag = .true.
703 atmoptics%n_Legendre_Terms = n_full_streams
704 atmoptics_tl%n_Legendre_Terms = n_full_streams
725 sfcoptics%Transmittance = transmittance
727 sfcoptics_tl%Transmittance = transmittance_tl
732 IF(
sc(sensorindex)%Solar_Irradiance(channelindex) >
zero .AND. &
734 rtv%Solar_Flag_true = .true.
737 IF( spccoeff_isvisiblesensor(
sc(sensorindex) ) .AND. rtv%Solar_Flag_true )
THEN 738 rtv%Visible_Flag_true = .true.
740 IF( atmoptics%n_Legendre_Terms < 4 )
THEN 741 atmoptics%n_Legendre_Terms = 4
742 atmoptics_tl%n_Legendre_Terms = atmoptics%n_Legendre_Terms
743 rtsolution(ln,m)%Scattering_FLAG = .true.
744 rtsolution(ln,m)%n_Full_Streams = atmoptics%n_Legendre_Terms + 2
748 wavenumber =
sc(sensorindex)%Wavenumber(channelindex)
759 WRITE( message,
'("Error computing MoleculeScatter for ",a,& 760 &", channel ",i0,", profile #",i0)') &
761 trim(channelinfo(n)%Sensor_ID), &
762 channelinfo(n)%Sensor_Channel(l), &
768 rtv%Visible_Flag_true = .false.
774 IF( atm%n_Clouds > 0 )
THEN 789 WRITE( message,
'("Error computing CloudScatter for ",a,& 790 &", channel ",i0,", profile #",i0)' ) &
791 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
799 IF ( atm%n_Aerosols > 0 )
THEN 814 WRITE( message,
'("Error computing AerosolScatter for ",a,& 815 &", channel ",i0,", profile #",i0)' ) &
816 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
824 IF( atmoptics%Include_Scattering )
THEN 829 rtsolution(ln,m)%SOD = atmoptics%Scattering_Optical_Depth
834 sfcoptics%Transmittance = -
one 836 sfcoptics%Transmittance = transmittance
842 sfcoptics%Compute = .true.
844 IF ( user_emissivity )
THEN 845 sfcoptics%Compute = .false.
846 sfcoptics%Emissivity(1,1) = options(m)%Emissivity(ln)
847 sfcoptics%Reflectivity(1,1,1,1) =
one - options(m)%Emissivity(ln)
848 IF ( user_direct_reflectivity )
THEN 849 sfcoptics%Direct_Reflectivity(1,1) = options(m)%Direct_Reflectivity(ln)
851 sfcoptics%Direct_Reflectivity(1,1) = sfcoptics%Reflectivity(1,1,1,1)
859 rtsolution(ln,m)%Radiance =
zero 860 rtsolution_tl(ln,m)%Radiance =
zero 862 azimuth_fourier_loop:
DO mth_azi = 0, rtv%n_Azi
865 rtv%mth_Azi = mth_azi
866 sfcoptics%mth_Azi = mth_azi
880 IF ( error_status /=
success )
THEN 881 WRITE( message,
'( "Error computing RTSolution for ", a, & 882 &", channel ", i0,", profile #",i0)' ) &
883 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
901 rtsolution_tl(ln,m), &
903 IF ( error_status /=
success )
THEN 904 WRITE( message,
'( "Error computing RTSolution_TL for ", a, & 905 &", channel ", i0,", profile #",i0)' ) &
906 trim(channelinfo(n)%Sensor_ID), channelinfo(n)%Sensor_Channel(l), m
910 END DO azimuth_fourier_loop
913 IF ( apply_nlte_correction .AND. nlte_predictor_isactive(nlte_predictor) )
THEN 915 sc(sensorindex)%NC , &
918 rtsolution(ln,m)%Radiance )
920 sc(sensorindex)%NC , &
922 nlte_predictor_tl , &
923 rtsolution_tl(ln,m)%Radiance )
930 rtsolution(ln,m)%Radiance , &
931 rtsolution(ln,m)%Brightness_Temperature )
935 rtsolution(ln,m)%Radiance , &
936 rtsolution_tl(ln,m)%Radiance , &
937 rtsolution_tl(ln,m)%Brightness_Temperature )
940 IF ( compute_antcorr )
THEN 950 rtsolution_tl(ln,m) )
1006 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
subroutine, public crtm_compute_transmittance_tl(atmoptics, atmoptics_TL, transmittance_TL)
real(fp), parameter, public zero
integer, parameter, public warning
subroutine, public crtm_compute_antcorr_tl(gI, n, l, RT_TL)
integer, parameter, public max_n_phase_elements
subroutine, public crtm_combine_atmoptics(AtmOptics, AOvar)
logical function, public crtm_options_isvalid(self)
integer function, public crtm_atmosphere_addlayers_tl(Atm_In, Atm_In_TL, Atm_Out_TL)
integer function, public crtm_compute_aerosolscatter_tl(Atm, AScat, Atm_TL, SensorIndex, ChannelIndex, AScat_TL, ASV)
integer, parameter, public fp
elemental subroutine, public crtm_atmosphere_destroy(Atm)
integer, parameter, public max_n_angles
real(fp), parameter, public scattering_albedo_threshold
integer function, public crtm_compute_rtsolution_tl(Atmosphere, Surface, AtmOptics, SfcOptics, RTSolution, Atmosphere_TL, Surface_TL, AtmOptics_TL, SfcOptics_TL, GeometryInfo, SensorIndex, ChannelIndex, RTSolution_TL, RTV)
subroutine, public compute_nlte_predictor_tl(NLTE_Predictor, Atm_TL, NLTE_Predictor_TL)
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)
integer function, public crtm_tangent_linear(Atmosphere, Surface, Atmosphere_TL, Surface_TL, Geometry, ChannelInfo, RTSolution, RTSolution_TL, Options)
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
subroutine, public crtm_compute_atmabsorption_tl(SensorIndex, ChannelIndex, Predictor, Predictor_TL, AtmOptics_TL, iVar)
integer, parameter, public max_n_stokes
integer function, public crtm_compute_aerosolscatter(Atm, SensorIndex, ChannelIndex, AScat, ASV)
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_planck_temperature_tl(n, l, Radiance, Radiance_TL, Temperature_TL)
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_surfacet_tl(Surface, Surface_TL, SfcOptics_TL)
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)
subroutine, public crtm_compute_predictors_tl(SensorIndex, Atmosphere, Predictor, Atmosphere_TL, AncillaryInput, Predictor_TL, iVar)
integer function, public crtm_atmosphere_addlayers(Atm_In, Atm_Out)
subroutine, public crtm_planck_temperature(n, l, Radiance, Temperature)
integer function, public crtm_compute_cloudscatter_tl(Atm, CScat, Atm_TL, SensorIndex, ChannelIndex, CScat_TL, CSV)
character(*), parameter module_version_id
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)
integer function, public crtm_compute_moleculescatter_tl(Wavenumber, Atmosphere_TL, AtmOptics_TL, Message_Log)
elemental logical function, public rtv_associated(RTV)
subroutine, public compute_nlte_correction_tl(NLTECoeff, ChannelIndex, NLTE_Predictor_TL, Radiance_TL)
elemental subroutine, public asvar_create(self, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Aerosols)
subroutine, public crtm_tangent_linear_version(Id)
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)
integer function, public crtm_get_pressurelevelidx(Atm, Level_Pressure)
elemental logical function, public nltecoeff_associated(NLTECoeff)
subroutine, public crtm_combine_atmoptics_tl(AtmOptics, AtmOptics_TL, AOvar)