50 '$Id: NLTECoeff_Binary_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 53 INTEGER,
PARAMETER ::
ml = 256
178 n_Predictors , & ! Optional output
179 n_Sensor_Angles , & ! Optional output
180 n_Solar_Angles , & ! Optional output
181 n_NLTE_Channels , & ! Optional output
182 n_Channels , & ! Optional output
183 Release , & ! Optional Output
184 Version , & ! Optional Output
185 Sensor_Id , & ! Optional Output
186 WMO_Satellite_Id, & ! Optional Output
190 CHARACTER(*),
INTENT(IN) :: filename
191 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_predictors
192 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_sensor_angles
193 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_solar_angles
194 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_nlte_channels
195 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_channels
196 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
197 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
198 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: sensor_id
199 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_satellite_id
200 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_sensor_id
204 CHARACTER(*),
PARAMETER :: routine_name =
'NLTECoeff_Binary_InquireFile' 216 msg =
'File '//trim(filename)//
' not found.' 223 IF ( err_stat /=
success )
THEN 224 msg =
'Error opening '//trim(filename)
230 READ( fid,iostat=io_stat ) nltecoeff%Release, nltecoeff%Version
231 IF ( io_stat /= 0 )
THEN 232 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
238 READ( fid, iostat=io_stat ) &
239 nltecoeff%n_Predictors , &
240 nltecoeff%n_Sensor_Angles , &
241 nltecoeff%n_Solar_Angles , &
242 nltecoeff%n_NLTE_Channels , &
244 IF ( io_stat /= 0 )
THEN 245 WRITE( msg,
'("Error reading dimension values from ",a,". IOSTAT = ",i0)' ) &
246 trim(filename), io_stat
252 READ( fid, iostat=io_stat ) &
253 nltecoeff%Sensor_Id , &
254 nltecoeff%WMO_Satellite_Id, &
255 nltecoeff%WMO_Sensor_Id
256 IF ( io_stat /= 0 )
THEN 257 WRITE( msg,
'("Error reading sensor information from ",a,". IOSTAT = ",i0)' ) &
258 trim(filename), io_stat
264 CLOSE( fid, iostat=io_stat )
265 IF ( io_stat /= 0 )
THEN 266 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
272 IF (
PRESENT(n_predictors ) ) n_predictors = nltecoeff%n_Predictors
273 IF (
PRESENT(n_sensor_angles ) ) n_sensor_angles = nltecoeff%n_Sensor_Angles
274 IF (
PRESENT(n_solar_angles ) ) n_solar_angles = nltecoeff%n_Solar_Angles
275 IF (
PRESENT(n_nlte_channels ) ) n_nlte_channels = nltecoeff%n_NLTE_Channels
276 IF (
PRESENT(n_channels ) ) n_channels = nltecoeff%n_Channels
277 IF (
PRESENT(release ) ) release = nltecoeff%Release
278 IF (
PRESENT(version ) ) version = nltecoeff%Version
279 IF (
PRESENT(sensor_id ) ) sensor_id = trim(nltecoeff%Sensor_Id)
280 IF (
PRESENT(wmo_satellite_id) ) wmo_satellite_id = nltecoeff%WMO_Satellite_Id
281 IF (
PRESENT(wmo_sensor_id ) ) wmo_sensor_id = nltecoeff%WMO_Sensor_Id
288 CLOSE( fid,iostat=io_stat )
289 IF ( io_stat /= 0 ) &
290 msg = trim(msg)//
'; Error closing input file during error cleanup' 369 NLTECoeff, & ! Output
370 No_Close , & ! Optional input
371 Quiet , & ! Optional input
375 CHARACTER(*),
INTENT(IN) :: filename
377 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
378 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
379 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
383 CHARACTER(*),
PARAMETER :: routine_name =
'NLTECoeff_ReadFile(Binary)' 386 LOGICAL :: close_file
397 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
400 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
402 IF (
PRESENT(debug) )
THEN 403 IF ( debug ) noisy = .true.
410 INQUIRE( file=filename, number=fid )
413 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 420 IF ( err_stat /=
success )
THEN 421 msg =
'Error opening '//trim(filename)
425 msg =
'File '//trim(filename)//
' not found.' 432 READ( fid,iostat=io_stat ) dummy%Release, dummy%Version
433 IF ( io_stat /= 0 )
THEN 434 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
438 msg =
'NLTECoeff Release check failed.' 445 READ( fid, iostat=io_stat ) dummy%n_Predictors , &
446 dummy%n_Sensor_Angles , &
447 dummy%n_Solar_Angles , &
448 dummy%n_NLTE_Channels , &
450 IF ( io_stat /= 0 )
THEN 451 WRITE( msg,
'("Error reading data dimensions. IOSTAT = ",i0)' ) io_stat
456 dummy%n_Predictors , &
457 dummy%n_Sensor_Angles , &
458 dummy%n_Solar_Angles , &
459 dummy%n_NLTE_Channels , &
462 msg =
'NLTECoeff object allocation failed.' 466 READ( fid, iostat=io_stat ) nltecoeff%Sensor_Id , &
467 nltecoeff%WMO_Satellite_Id, &
468 nltecoeff%WMO_Sensor_Id , &
469 nltecoeff%Sensor_Channel
470 IF ( io_stat /= 0 )
THEN 471 WRITE( msg,
'("Error reading sensor information. IOSTAT = ",i0)' ) io_stat
475 READ( fid, iostat=io_stat ) nltecoeff%Upper_Plevel, &
476 nltecoeff%Lower_Plevel
477 IF ( io_stat /= 0 )
THEN 478 WRITE( msg,
'("Error reading pressure level data. IOSTAT = ",i0)' ) io_stat
482 READ( fid, iostat=io_stat ) nltecoeff%Min_Tm , &
485 IF ( io_stat /= 0 )
THEN 486 WRITE( msg,
'("Error reading min/max/mean temperature data. IOSTAT = ",i0)' ) io_stat
490 READ( fid, iostat=io_stat ) nltecoeff%NLTE_Channel
491 IF ( io_stat /= 0 )
THEN 492 WRITE( msg,
'("Error reading NLTE channel numbers. IOSTAT = ",i0)' ) io_stat
496 READ( fid, iostat=io_stat ) nltecoeff%Secant_Sensor_Zenith, &
497 nltecoeff%Secant_Solar_Zenith
498 IF ( io_stat /= 0 )
THEN 499 WRITE( msg,
'("Error reading sensor and solar angle data. IOSTAT = ",i0)' ) io_stat
503 READ( fid, iostat=io_stat ) nltecoeff%C_Index, nltecoeff%C
504 IF ( io_stat /= 0 )
THEN 505 WRITE( msg,
'("Error reading NLTE correction coefficients. IOSTAT = ",i0)' ) io_stat
511 nltecoeff%Version = dummy%Version
515 WHERE( nltecoeff%C_Index > 0 ) nltecoeff%Is_NLTE_Channel = .true.
519 IF ( close_file )
THEN 520 CLOSE( fid,iostat=io_stat )
521 IF ( io_stat /= 0 )
THEN 522 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
538 CLOSE( fid,iostat=io_stat )
539 IF ( io_stat /= 0 ) &
540 msg = trim(msg)//
'; Error closing input file during error cleanup.' 619 No_Close , & ! Optional input
620 Quiet , & ! Optional input
624 CHARACTER(*),
INTENT(IN) :: filename
626 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
627 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
628 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
632 CHARACTER(*),
PARAMETER :: routine_name =
'NLTECoeff_WriteFile(Binary)' 635 LOGICAL :: close_file
645 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
648 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
650 IF (
PRESENT(debug) )
THEN 651 IF ( debug ) noisy = .true.
655 msg =
'NLTECoeff object is empty.' 663 INQUIRE( file=filename, number=fid )
666 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 672 IF ( err_stat /=
success )
THEN 673 msg =
'Error opening '//trim(filename)
680 WRITE( fid,iostat=io_stat ) nltecoeff%Release, nltecoeff%Version
681 IF ( io_stat /= 0 )
THEN 682 WRITE( msg,
'("Error writing Release/Version. IOSTAT = ",i0)' ) io_stat
689 WRITE( fid, iostat=io_stat ) nltecoeff%n_Predictors , &
690 nltecoeff%n_Sensor_Angles , &
691 nltecoeff%n_Solar_Angles , &
692 nltecoeff%n_NLTE_Channels , &
694 IF ( io_stat /= 0 )
THEN 695 WRITE( msg,
'("Error writing data dimensions. IOSTAT = ",i0)' ) io_stat
699 WRITE( fid, iostat=io_stat ) nltecoeff%Sensor_Id , &
700 nltecoeff%WMO_Satellite_Id, &
701 nltecoeff%WMO_Sensor_Id , &
702 nltecoeff%Sensor_Channel
703 IF ( io_stat /= 0 )
THEN 704 WRITE( msg,
'("Error writing sensor information. IOSTAT = ",i0)' ) io_stat
708 WRITE( fid, iostat=io_stat ) nltecoeff%Upper_Plevel, &
709 nltecoeff%Lower_Plevel
710 IF ( io_stat /= 0 )
THEN 711 WRITE( msg,
'("Error writing pressure level data. IOSTAT = ",i0)' ) io_stat
715 WRITE( fid, iostat=io_stat ) nltecoeff%Min_Tm , &
718 IF ( io_stat /= 0 )
THEN 719 WRITE( msg,
'("Error writing min/max/mean temperature data. IOSTAT = ",i0)' ) io_stat
723 WRITE( fid, iostat=io_stat ) nltecoeff%NLTE_Channel
724 IF ( io_stat /= 0 )
THEN 725 WRITE( msg,
'("Error writing NLTE channel numbers. IOSTAT = ",i0)' ) io_stat
729 WRITE( fid, iostat=io_stat ) nltecoeff%Secant_Sensor_Zenith, &
730 nltecoeff%Secant_Solar_Zenith
732 IF ( io_stat /= 0 )
THEN 733 WRITE( msg,
'("Error writing sensor and solar angle data. IOSTAT = ",i0)' ) io_stat
737 WRITE( fid, iostat=io_stat ) nltecoeff%C_Index, nltecoeff%C
738 IF ( io_stat /= 0 )
THEN 739 WRITE( msg,
'("Error writing NLTE correction coefficients. IOSTAT = ",i0)' ) io_stat
745 IF ( close_file )
THEN 746 CLOSE( fid,iostat=io_stat )
747 IF ( io_stat /= 0 )
THEN 748 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
764 CLOSE( fid,iostat=io_stat )
765 IF ( io_stat /= 0 ) &
766 msg = trim(msg)//
'; Error closing input file during error cleanup.' 799 CHARACTER(*),
INTENT(OUT) :: id
integer, parameter, public failure
elemental subroutine, public nltecoeff_create(NLTECoeff, n_Predictors, n_Sensor_Angles, n_Solar_Angles, n_NLTE_Channels, n_Channels)
integer, parameter, public long
integer, parameter, public double
logical function, public nltecoeff_validrelease(NLTECoeff)
integer function, public nltecoeff_binary_readfile(Filename, NLTECoeff, No_Close, Quiet, Debug)
subroutine inquire_cleanup()
integer function, public nltecoeff_binary_writefile(Filename, NLTECoeff, No_Close, Quiet, Debug)
subroutine read_cleanup()
integer function, public nltecoeff_binary_inquirefile(Filename, n_Predictors, n_Sensor_Angles, n_Solar_Angles, n_NLTE_Channels, n_Channels, Release, Version, Sensor_Id, WMO_Satellite_Id, WMO_Sensor_Id)
character(*), parameter, private module_version_id
subroutine write_cleanup()
integer function, public open_binary_file(Filename, FileID, For_Output, No_Check)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
character(*), parameter write_error_status
subroutine, public nltecoeff_info(NLTECoeff, Info)
elemental subroutine, public nltecoeff_destroy(NLTECoeff)
subroutine, public nltecoeff_binary_ioversion(Id)
integer, parameter, public success
integer, parameter, public information
elemental logical function, public nltecoeff_associated(NLTECoeff)