57 PUBLIC ::
OPERATOR(==)
79 INTERFACE OPERATOR(==)
81 END INTERFACE OPERATOR(==)
88 '$Id: CRTM_Options_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 90 REAL(Double),
PARAMETER ::
zero = 0.0_double
91 REAL(Double),
PARAMETER ::
one = 1.0_double
93 INTEGER(Long),
PARAMETER ::
false = 0_long
94 INTEGER(Long),
PARAMETER ::
true = 1_long
96 INTEGER,
PARAMETER ::
ml = 256
110 LOGICAL :: check_input = .
true.
116 LOGICAL :: use_antenna_correction = .
false.
119 LOGICAL :: apply_nlte_correction = .
true.
122 INTEGER(Long) :: rt_algorithm_id =
rt_ada 126 REAL(Double) :: aircraft_pressure = -
one 130 INTEGER(Long) :: n_streams = 0
134 LOGICAL :: include_scattering = .
true.
138 INTEGER(Long) :: n_channels = 0
140 INTEGER(Long) :: channel = 0
143 REAL(Double),
ALLOCATABLE :: emissivity(:)
145 LOGICAL :: use_direct_reflectivity = .
false.
146 REAL(Double),
ALLOCATABLE :: direct_reflectivity(:)
204 status = self%Is_Allocated
232 self%Is_Allocated = .
false.
271 INTEGER,
INTENT(IN) :: n_channels
273 INTEGER :: alloc_stat
276 IF ( n_channels < 1 )
RETURN 279 ALLOCATE( self%Emissivity(n_channels), &
280 self%Direct_Reflectivity(n_channels), &
282 IF ( alloc_stat /= 0 )
RETURN 286 self%n_Channels = n_channels
288 self%Emissivity =
zero 289 self%Direct_Reflectivity =
zero 292 self%Is_Allocated = .
true.
340 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_IsValid' 347 IF ( self%Use_Emissivity .OR. self%Use_Direct_Reflectivity )
THEN 349 IF ( .NOT. isvalid )
THEN 350 msg =
'Options structure not allocated' 354 IF ( self%Use_Emissivity )
THEN 355 IF ( any(self%Emissivity <
zero) .OR. any(self%Emissivity >
one) )
THEN 356 msg =
'Invalid emissivity' 361 IF ( self%Use_Direct_Reflectivity )
THEN 362 IF ( any(self%Direct_Reflectivity <
zero) .OR. any(self%Direct_Reflectivity >
one) )
THEN 363 msg =
'Invalid direct reflectivity' 403 WRITE(*,
'(1x,"Options OBJECT")')
405 WRITE(*,
'(3x,"Check input flag :",1x,l1)') self%Check_Input
406 WRITE(*,
'(3x,"Use old MWSSEM flag :",1x,l1)') self%Use_Old_MWSSEM
407 WRITE(*,
'(3x,"Use antenna correction flag :",1x,l1)') self%Use_Antenna_Correction
408 WRITE(*,
'(3x,"Apply NLTE correction flag :",1x,l1)') self%Apply_NLTE_Correction
409 WRITE(*,
'(3x,"Aircraft pressure altitude :",1x,es13.6)') self%Aircraft_Pressure
410 WRITE(*,
'(3x,"RT algorithm Id :",1x,i0)') self%RT_Algorithm_Id
411 WRITE(*,
'(3x,"Include scattering flag :",1x,l1)') self%Include_Scattering
412 WRITE(*,
'(3x,"Use n_Streams flag :",1x,l1)') self%Use_N_Streams
413 WRITE(*,
'(3x,"n_Streams :",1x,i0)') self%n_Streams
416 WRITE(*,
'(3x,"Emissivity component")')
417 WRITE(*,
'(5x,"n_Channels :",1x,i0)') self%n_Channels
418 WRITE(*,
'(5x,"Channel index :",1x,i0)') self%Channel
419 WRITE(*,
'(5x,"Use emissivity flag :",1x,l1)') self%Use_Emissivity
420 WRITE(*,
'(5x,"Use direct reflectivity flag :",1x,l1)') self%Use_Direct_Reflectivity
421 WRITE(*,
'(5x,"Emissivity :")')
422 WRITE(*,
'(5(1x,es13.6,:))') self%Emissivity
423 WRITE(*,
'(5x,"Direct reflectivity :")')
424 WRITE(*,
'(5(1x,es13.6,:))') self%Direct_Reflectivity
458 CHARACTER(*),
INTENT(OUT) :: id
509 CHARACTER(*),
INTENT(IN) :: filename
510 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_profiles
514 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_InquireFile' 517 CHARACTER(ML) :: io_msg
526 msg =
'File '//trim(filename)//
' not found.' 533 IF ( err_stat /=
success )
THEN 534 msg =
'Error opening '//trim(filename)
540 READ( fid, iostat=io_stat,iomsg=io_msg ) m
541 IF ( io_stat /= 0 )
THEN 542 msg =
'Error reading dimensions from '//trim(filename)//
' - '//trim(io_msg)
548 CLOSE( fid,iostat=io_stat,iomsg=io_msg )
549 IF ( io_stat /= 0 )
THEN 550 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
556 IF (
PRESENT(n_profiles) ) n_profiles = m
562 CLOSE( fid,iostat=io_stat,iomsg=io_msg )
564 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
639 Quiet , & ! Optional input
640 n_Profiles, & ! Optional output
644 CHARACTER(*),
INTENT(IN) :: filename
646 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
647 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_profiles
648 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
652 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_ReadFile' 655 CHARACTER(ML) :: io_msg
659 INTEGER :: m, n_file_profiles, n_input_profiles
666 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
668 IF (
PRESENT(debug) ) noisy = debug
671 msg =
'File '//trim(filename)//
' not found.' 678 IF ( err_stat /=
success )
THEN 679 msg =
'Error opening '//trim(filename)
685 READ( fid,iostat=io_stat,iomsg=io_msg ) n_file_profiles
686 IF ( io_stat /= 0 )
THEN 687 msg =
'Error reading dimensions from '//trim(filename)//
' - '//trim(io_msg)
691 n_input_profiles =
SIZE(options)
692 IF ( n_file_profiles > n_input_profiles )
THEN 693 WRITE( msg,
'("Number of profiles, ",i0,", > size of the output Options", & 694 &" array, ",i0,". Only the first ",i0, & 695 &" profiles will be read.")' ) &
696 n_file_profiles, n_input_profiles, n_input_profiles
699 n_input_profiles =
min(n_input_profiles, n_file_profiles)
703 profile_loop:
DO m = 1, n_input_profiles
707 IF ( err_stat /=
success )
THEN 708 WRITE( msg,
'("Error reading Options element (",i0,") from ",a)' ) m, trim(filename)
715 CLOSE( fid,iostat=io_stat,iomsg=io_msg )
716 IF ( io_stat /= 0 )
THEN 717 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
723 IF (
PRESENT(n_profiles) ) n_profiles = n_input_profiles
728 WRITE( msg,
'("Number of profiles read from ",a,": ",i0)' ) trim(filename), n_input_profiles
736 CLOSE( fid,iostat=io_stat,iomsg=io_msg )
737 IF ( io_stat /= 0 ) &
738 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
808 Quiet , & ! Optional input
812 CHARACTER(*),
INTENT(IN) :: filename
814 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
815 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
819 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_WriteFile' 822 CHARACTER(ML) :: io_msg
826 INTEGER :: m, n_output_profiles
832 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
834 IF (
PRESENT(debug) ) noisy = debug
838 n_output_profiles =
SIZE(options)
839 IF ( n_output_profiles == 0 )
THEN 840 msg =
'Zero dimension profiles in input!' 847 IF ( err_stat /=
success )
THEN 848 msg =
'Error opening '//trim(filename)
854 WRITE( fid,iostat=io_stat,iomsg=io_msg ) n_output_profiles
855 IF ( io_stat /= 0 )
THEN 856 msg =
'Error writing dimensions to '//trim(filename)//
'- '//trim(io_msg)
862 profile_loop:
DO m = 1, n_output_profiles
866 IF ( err_stat /=
success )
THEN 867 WRITE( msg,
'("Error writing Options element (",i0,") to ",a)' ) m, trim(filename)
874 CLOSE( fid,status=
'KEEP',iostat=io_stat,iomsg=io_msg )
875 IF ( io_stat /= 0 )
THEN 876 msg =
'Error closing '//trim(filename)//
'- '//trim(io_msg)
883 WRITE( msg,
'("Number of profiles written to ",a,": ",i0)' ) trim(filename), n_output_profiles
892 IF ( io_stat /= 0 ) &
893 msg = trim(msg)//
'; Error deleting output file during error cleanup - '//trim(io_msg)
951 is_equal = (x%Check_Input .EQV. y%Check_Input ) .AND. &
952 (x%Use_Old_MWSSEM .EQV. y%Use_Old_MWSSEM ) .AND. &
953 (x%Use_Antenna_Correction .EQV. y%Use_Antenna_Correction) .AND. &
954 (x%Apply_NLTE_Correction .EQV. y%Apply_NLTE_Correction ) .AND. &
955 (x%RT_Algorithm_Id == y%RT_Algorithm_Id ) .AND. &
956 (x%Aircraft_Pressure .equalto. y%Aircraft_Pressure ) .AND. &
957 (x%Use_n_Streams .EQV. y%Use_n_Streams ) .AND. &
958 (x%n_Streams == y%n_Streams ) .AND. &
959 (x%Include_Scattering .EQV. y%Include_Scattering )
962 is_equal = is_equal .AND. &
963 ( (x%n_Channels == y%n_Channels) .AND. &
964 (x%Channel == y%Channel ) .AND. &
965 (x%Use_Emissivity .EQV. y%Use_Emissivity ) .AND. &
966 (x%Use_Direct_Reflectivity .EQV. y%Use_Direct_Reflectivity ) .AND. &
969 is_equal = is_equal .AND. &
970 all(x%Emissivity .equalto. y%Emissivity ) .AND. &
971 all(x%Direct_Reflectivity .equalto. y%Direct_Reflectivity)
974 is_equal = is_equal .AND. &
978 is_equal = is_equal .AND. &
979 (x%Zeeman == y%Zeeman)
995 Quiet , & ! Optional input
999 INTEGER,
INTENT(IN) :: fid
1001 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
1002 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
1006 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_ReadFile(Record)' 1008 CHARACTER(ML) :: fname
1009 CHARACTER(ML) :: msg
1010 CHARACTER(ML) :: io_msg
1012 INTEGER :: n_channels
1013 LOGICAL :: emissivity_data_present
1020 READ( fid,iostat=io_stat,iomsg=io_msg ) n_channels
1021 IF ( io_stat /= 0 )
THEN 1022 msg =
'Error reading dimensions - '//trim(io_msg)
1026 emissivity_data_present = (n_channels > 0)
1031 IF ( emissivity_data_present )
THEN 1034 msg =
'Error creating output object.' 1043 IF ( err_stat /=
success )
THEN 1044 msg =
'Error reading input checking option' 1049 IF ( err_stat /=
success )
THEN 1050 msg =
'Error reading old MW water emissivity algorithm switch option' 1055 IF ( err_stat /=
success )
THEN 1056 msg =
'Error reading antenna correction option' 1061 IF ( err_stat /=
success )
THEN 1062 msg =
'Error reading NLTE correction option' 1066 READ( fid,iostat=io_stat,iomsg=io_msg ) opt%RT_Algorithm_Id
1067 IF ( io_stat /= 0 )
THEN 1068 msg =
'Error reading RT algorithm id option - '//trim(io_msg)
1072 READ( fid,iostat=io_stat,iomsg=io_msg ) opt%Aircraft_Pressure
1073 IF ( io_stat /= 0 )
THEN 1074 msg =
'Error reading aircraft flight level pressure option - '//trim(io_msg)
1079 IF ( err_stat /=
success )
THEN 1080 msg =
'Error reading n_Streams option' 1083 READ( fid,iostat=io_stat,iomsg=io_msg ) opt%n_Streams
1084 IF ( io_stat /= 0 )
THEN 1085 msg =
'Error reading n_Streams optional value - '//trim(io_msg)
1090 IF ( err_stat /=
success )
THEN 1091 msg =
'Error reading include scattering option' 1097 IF ( emissivity_data_present )
THEN 1101 IF ( err_stat /=
success )
THEN 1102 msg =
'Error reading emissivity option' 1106 READ( fid,iostat=io_stat,iomsg=io_msg ) opt%Emissivity
1107 IF ( io_stat /= 0 )
THEN 1108 msg =
'Error reading emissivity data - '//trim(io_msg)
1115 IF ( err_stat /=
success )
THEN 1116 msg =
'Error reading direct reflectivity option' 1120 READ( fid,iostat=io_stat,iomsg=io_msg ) opt%Direct_Reflectivity
1121 IF ( io_stat /= 0 )
THEN 1122 msg =
'Error reading direct reflectivity data - '//trim(io_msg)
1129 INQUIRE( unit=fid,name=fname )
1135 no_close = .
true., &
1137 IF ( err_stat /=
success )
THEN 1138 msg =
'Error reading SSU input data' 1146 no_close = .
true., &
1148 IF ( err_stat /=
success )
THEN 1149 msg =
'Error reading Zeeman input data' 1157 CLOSE( fid,iostat=io_stat,iomsg=io_msg )
1159 msg = trim(msg)//
'; Error closing file during error cleanup - '//trim(io_msg)
1178 Quiet , & ! Optional input
1182 INTEGER,
INTENT(IN) :: fid
1184 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
1185 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
1189 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Options_WriteFile(Record)' 1191 CHARACTER(ML) :: fname
1192 CHARACTER(ML) :: msg
1193 CHARACTER(ML) :: io_msg
1201 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%n_channels
1202 IF ( io_stat /= 0 )
THEN 1203 msg =
'Error writing dimensions - '//trim(io_msg)
1211 IF ( err_stat /=
success )
THEN 1212 msg =
'Error writing input checking option' 1217 IF ( err_stat /=
success )
THEN 1218 msg =
'Error writing old MW water emissivity algorithm switch option' 1223 IF ( err_stat /=
success )
THEN 1224 msg =
'Error writing antenna correction option' 1229 IF ( err_stat /=
success )
THEN 1230 msg =
'Error writing NLTE correction option' 1234 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%RT_Algorithm_Id
1235 IF ( io_stat /= 0 )
THEN 1236 msg =
'Error writing RT algorithm id option - '//trim(io_msg)
1240 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%Aircraft_Pressure
1241 IF ( io_stat /= 0 )
THEN 1242 msg =
'Error writing aircraft flight level pressure option - '//trim(io_msg)
1247 IF ( err_stat /=
success )
THEN 1248 msg =
'Error writing n_Streams option' 1251 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%n_Streams
1252 IF ( io_stat /= 0 )
THEN 1253 msg =
'Error writing n_Streams optional value - '//trim(io_msg)
1258 IF ( err_stat /=
success )
THEN 1259 msg =
'Error writing include scattering option' 1269 IF ( err_stat /=
success )
THEN 1270 msg =
'Error writing emissivity option' 1274 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%Emissivity
1275 IF ( io_stat /= 0 )
THEN 1276 msg =
'Error writing emissivity data - '//trim(io_msg)
1283 IF ( err_stat /=
success )
THEN 1284 msg =
'Error writing direct reflectivity option' 1288 WRITE( fid,iostat=io_stat,iomsg=io_msg ) opt%Direct_Reflectivity
1289 IF ( io_stat /= 0 )
THEN 1290 msg =
'Error writing direct reflectivity data - '//trim(io_msg)
1297 INQUIRE( unit=fid,name=fname )
1303 no_close = .
true., &
1305 IF ( err_stat /=
success )
THEN 1306 msg =
'Error writing SSU input data' 1314 no_close = .
true., &
1316 IF ( err_stat /=
success )
THEN 1317 msg =
'Error writing Zeeman input data' 1326 msg = trim(msg)//
'; Error closing file during error cleanup - '//trim(io_msg)
real(double), parameter one
character(*), parameter, private module_version_id
elemental subroutine, public crtm_options_destroy(self)
character(*), parameter write_error_status
integer, parameter, public failure
integer, parameter, public warning
elemental logical function crtm_options_equal(x, y)
integer, parameter, public long
logical function, public crtm_options_isvalid(self)
integer function read_record(fid, opt, Quiet, Debug)
integer, parameter, public fp
integer function, public readgatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer function, public crtm_options_inquirefile(Filename, n_Profiles)
integer, parameter, public double
integer(long), parameter true
subroutine inquire_cleanup()
subroutine read_cleanup()
integer function, public crtm_options_writefile(Filename, Options, Quiet, Debug)
subroutine write_cleanup()
integer function, public crtm_options_readfile(Filename, Options, Quiet, n_Profiles, Debug)
subroutine read_record_cleanup()
integer(long), parameter false
integer function, public open_binary_file(Filename, FileID, For_Output, No_Check)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
elemental subroutine, public crtm_options_create(self, n_Channels)
elemental logical function, public crtm_options_associated(self)
integer function, public writegatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer, parameter, public rt_ada
real(double), parameter zero
subroutine write_record_cleanup()
subroutine, public crtm_options_inspect(self)
subroutine, public crtm_options_defineversion(Id)
integer, parameter, public success
integer, parameter, public information