55 '$Id: SpcCoeff_Binary_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 57 INTEGER,
PARAMETER ::
ml = 512
156 n_Channels , & ! Optional output
157 Release , & ! Optional Output
158 Version , & ! Optional Output
159 Sensor_Id , & ! Optional Output
160 WMO_Satellite_Id, & ! Optional Output
164 CHARACTER(*),
INTENT(IN) :: filename
165 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_channels
166 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
167 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
168 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: sensor_id
169 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_satellite_id
170 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_sensor_id
174 CHARACTER(*),
PARAMETER :: routine_name =
'SpcCoeff_InquireFile(Binary)' 186 msg =
'File '//trim(filename)//
' not found.' 193 IF ( err_stat /=
success )
THEN 194 msg =
'Error opening '//trim(filename)
200 READ( fid,iostat=io_stat ) spccoeff%Release, spccoeff%Version
201 IF ( io_stat /= 0 )
THEN 202 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
208 READ( fid, iostat=io_stat ) &
210 IF ( io_stat /= 0 )
THEN 211 WRITE( msg,
'("Error reading dimension values from ",a,". IOSTAT = ",i0)' ) &
212 trim(filename), io_stat
218 READ( fid, iostat=io_stat ) &
219 spccoeff%Sensor_Id , &
220 spccoeff%Sensor_Type , &
221 spccoeff%WMO_Satellite_Id, &
222 spccoeff%WMO_Sensor_Id
223 IF ( io_stat /= 0 )
THEN 224 WRITE( msg,
'("Error reading sensor information from ",a,". IOSTAT = ",i0)' ) &
225 trim(filename), io_stat
231 CLOSE( fid, iostat=io_stat )
232 IF ( io_stat /= 0 )
THEN 233 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
239 IF (
PRESENT(n_channels ) ) n_channels = spccoeff%n_Channels
240 IF (
PRESENT(release ) ) release = spccoeff%Release
241 IF (
PRESENT(version ) ) version = spccoeff%Version
242 IF (
PRESENT(sensor_id ) ) sensor_id = spccoeff%Sensor_Id
243 IF (
PRESENT(wmo_satellite_id) ) wmo_satellite_id = spccoeff%WMO_Satellite_Id
244 IF (
PRESENT(wmo_sensor_id ) ) wmo_sensor_id = spccoeff%WMO_Sensor_Id
251 CLOSE( fid,iostat=io_stat )
252 IF ( io_stat /= 0 ) &
253 msg = trim(msg)//
'; Error closing input file during error cleanup' 320 Quiet , & ! Optional input
324 CHARACTER(*),
INTENT(IN) :: filename
326 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
327 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
331 CHARACTER(*),
PARAMETER :: routine_name =
'SpcCoeff_ReadFile(Binary)' 333 CHARACTER(ML) :: msg, io_msg
337 INTEGER(Long) :: ac_present
338 INTEGER(Long) :: nc_present
346 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
348 IF (
PRESENT(debug) )
THEN 349 IF ( debug ) noisy = .true.
356 IF ( err_stat /=
success )
THEN 357 msg =
'Error opening '//trim(filename)
361 msg =
'File '//trim(filename)//
' not found.' 367 READ( fid, iostat=io_stat ) &
370 IF ( io_stat /= 0 )
THEN 371 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
375 msg =
'SpcCoeff Release check failed.' 382 READ( fid, iostat=io_stat ) dummy%n_Channels
383 IF ( io_stat /= 0 )
THEN 384 WRITE( msg,
'("Error reading data dimensions. IOSTAT = ",i0)' ) io_stat
391 msg =
'SpcCoeff object allocation failed.' 395 READ( fid, iostat=io_stat ) &
396 spccoeff%Sensor_Id , &
397 spccoeff%Sensor_Type , &
398 spccoeff%WMO_Satellite_Id, &
399 spccoeff%WMO_Sensor_Id
400 IF ( io_stat /= 0 )
THEN 401 WRITE( msg,
'("Error reading sensor ids. IOSTAT = ",i0)' ) io_stat
405 READ( fid, iostat=io_stat, iomsg=io_msg ) &
406 spccoeff%Sensor_Channel , &
407 spccoeff%Polarization , &
408 spccoeff%Channel_Flag , &
409 spccoeff%Frequency , &
410 spccoeff%Wavenumber , &
411 spccoeff%Planck_C1 , &
412 spccoeff%Planck_C2 , &
415 spccoeff%Cosmic_Background_Radiance, &
416 spccoeff%Solar_Irradiance
417 IF ( io_stat /= 0 )
THEN 418 msg =
'Error reading channel data. '//trim(io_msg)
424 spccoeff%Version = dummy%Version
429 READ( fid, iostat=io_stat ) ac_present
430 IF ( io_stat /= 0 )
THEN 431 WRITE( msg,
'("Error reading antenna correction data indicator. IOSTAT = ",i0)' ) io_stat
442 IF ( err_stat /=
success )
THEN 443 msg =
'Error reading antenna correction data.' 447 IF ( spccoeff%Sensor_Id /= spccoeff%AC%Sensor_Id .OR. &
448 spccoeff%WMO_Satellite_Id /= spccoeff%AC%WMO_Satellite_Id .OR. &
449 spccoeff%WMO_Sensor_Id /= spccoeff%AC%WMO_Sensor_Id .OR. &
450 any( spccoeff%Sensor_Channel /= spccoeff%AC%Sensor_Channel ) )
THEN 451 msg =
'Antenna correction sensor information is inconsistent with SpcCoeff' 459 READ( fid, iostat=io_stat ) nc_present
460 IF ( io_stat /= 0 )
THEN 461 WRITE( msg,
'("Error reading NLTE correction data indicator. IOSTAT = ",i0)' ) io_stat
472 IF ( err_stat /=
success )
THEN 473 msg =
'Error reading NLTE correction data.' 477 IF ( spccoeff%Sensor_Id /= spccoeff%NC%Sensor_Id .OR. &
478 spccoeff%WMO_Satellite_Id /= spccoeff%NC%WMO_Satellite_Id .OR. &
479 spccoeff%WMO_Sensor_Id /= spccoeff%NC%WMO_Sensor_Id .OR. &
480 any( spccoeff%Sensor_Channel /= spccoeff%NC%Sensor_Channel ) )
THEN 481 msg =
'non-LTE correction sensor information is inconsistent with SpcCoeff' 488 CLOSE( fid,iostat=io_stat )
489 IF ( io_stat /= 0 )
THEN 490 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
505 CLOSE( fid,iostat=io_stat )
506 IF ( io_stat /= 0 ) &
507 msg = trim(msg)//
'; Error closing input file during error cleanup.' 573 Quiet , & ! Optional input
577 CHARACTER(*),
INTENT(IN) :: filename
579 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
580 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
584 CHARACTER(*),
PARAMETER :: routine_name =
'SpcCoeff_WriteFile(Binary)' 585 CHARACTER(*),
PARAMETER :: write_error_status =
'DELETE' 591 INTEGER :: ac_present
592 INTEGER :: nc_present
599 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
601 IF (
PRESENT(debug) )
THEN 602 IF ( debug ) noisy = .true.
606 msg =
'SpcCoeff object is empty.' 613 IF ( err_stat /=
success )
THEN 614 msg =
'Error opening '//trim(filename)
620 WRITE( fid,iostat=io_stat ) &
623 IF ( io_stat /= 0 )
THEN 624 WRITE( msg,
'("Error writing Release/Version. IOSTAT = ",i0)' ) io_stat
631 WRITE( fid, iostat=io_stat ) spccoeff%n_Channels
632 IF ( io_stat /= 0 )
THEN 633 WRITE( msg,
'("Error writing data dimensions. IOSTAT = ",i0)' ) io_stat
637 WRITE( fid, iostat=io_stat ) &
638 spccoeff%Sensor_Id , &
639 spccoeff%Sensor_Type , &
640 spccoeff%WMO_Satellite_Id, &
641 spccoeff%WMO_Sensor_Id
642 IF ( io_stat /= 0 )
THEN 643 WRITE( msg,
'("Error writing sensor ids. IOSTAT = ",i0)' ) io_stat
647 WRITE( fid, iostat=io_stat ) &
648 spccoeff%Sensor_Channel , &
649 spccoeff%Polarization , &
650 spccoeff%Channel_Flag , &
651 spccoeff%Frequency , &
652 spccoeff%Wavenumber , &
653 spccoeff%Planck_C1 , &
654 spccoeff%Planck_C2 , &
657 spccoeff%Cosmic_Background_Radiance, &
658 spccoeff%Solar_Irradiance
659 IF ( io_stat /= 0 )
THEN 660 WRITE( msg,
'("Error writing channel data. IOSTAT = ",i0)' ) io_stat
672 WRITE( fid, iostat=io_stat ) ac_present
673 IF ( io_stat /= 0 )
THEN 674 WRITE( msg,
'("Error writing antenna correction data indicator. IOSTAT = ",i0)' ) io_stat
685 IF ( err_stat /=
success )
THEN 686 msg =
'Error writing antenna correction data.' 690 IF ( spccoeff%Sensor_Id /= spccoeff%AC%Sensor_Id .OR. &
691 spccoeff%WMO_Satellite_Id /= spccoeff%AC%WMO_Satellite_Id .OR. &
692 spccoeff%WMO_Sensor_Id /= spccoeff%AC%WMO_Sensor_Id .OR. &
693 any( spccoeff%Sensor_Channel /= spccoeff%AC%Sensor_Channel ) )
THEN 694 msg =
'Antenna correction sensor information is inconsistent with SpcCoeff' 707 WRITE( fid, iostat=io_stat ) nc_present
708 IF ( io_stat /= 0 )
THEN 709 WRITE( msg,
'("Error writing NLTE correction data indicator. IOSTAT = ",i0)' ) io_stat
720 IF ( err_stat /=
success )
THEN 721 msg =
'Error writing NLTE correction data.' 725 IF ( spccoeff%Sensor_Id /= spccoeff%NC%Sensor_Id .OR. &
726 spccoeff%WMO_Satellite_Id /= spccoeff%NC%WMO_Satellite_Id .OR. &
727 spccoeff%WMO_Sensor_Id /= spccoeff%NC%WMO_Sensor_Id .OR. &
728 any( spccoeff%Sensor_Channel /= spccoeff%NC%Sensor_Channel ) )
THEN 729 msg =
'non-LTE correction sensor information is inconsistent with SpcCoeff' 736 CLOSE( fid,status=
'KEEP',iostat=io_stat )
737 IF ( io_stat /= 0 )
THEN 738 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
753 CLOSE( fid, status=write_error_status, iostat=io_stat )
754 IF ( io_stat /= 0 ) &
755 msg = trim(msg)//
'; Error closing input file during error cleanup.' 792 CHARACTER(*),
INTENT(OUT) :: id
793 INTEGER,
PARAMETER :: carriage_return = 13
794 INTEGER,
PARAMETER :: linefeed = 10
795 INTEGER,
PARAMETER :: sl = 256
796 CHARACTER(SL) :: ac_id
797 CHARACTER(SL) :: nc_id
798 CHARACTER(SL*3) :: io_id
802 ' '//trim(ac_id)//
';'//achar(carriage_return)//achar(linefeed)//&
804 IF ( len_trim(io_id) <= len(id) )
THEN integer, parameter data_present
integer, parameter, public failure
integer function, public accoeff_binary_readfile(Filename, ACCoeff, No_Close, Quiet, Debug)
integer function, public accoeff_binary_writefile(Filename, ACCoeff, No_Close, Quiet, Debug)
integer, parameter, public long
elemental subroutine, public spccoeff_destroy(SpcCoeff)
integer function, public spccoeff_binary_readfile(Filename, SpcCoeff, Quiet, Debug)
integer, parameter, public double
integer function, public nltecoeff_binary_readfile(Filename, NLTECoeff, No_Close, Quiet, Debug)
integer function, public spccoeff_binary_writefile(Filename, SpcCoeff, Quiet, Debug)
subroutine inquire_cleanup()
integer function, public nltecoeff_binary_writefile(Filename, NLTECoeff, No_Close, Quiet, Debug)
integer function, public spccoeff_binary_inquirefile(Filename, n_Channels, Release, Version, Sensor_Id, WMO_Satellite_Id, WMO_Sensor_Id)
subroutine, public spccoeff_info(SpcCoeff, Info, NoComponents)
elemental subroutine, public spccoeff_create(SpcCoeff, n_Channels)
subroutine read_cleanup()
integer, parameter data_missing
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)
subroutine, public nltecoeff_binary_ioversion(Id)
subroutine, public accoeff_binary_ioversion(Id)
logical function, public spccoeff_validrelease(SpcCoeff)
integer, parameter, public success
subroutine, public spccoeff_binary_ioversion(Id)
character(*), parameter module_version_id
elemental logical function, public accoeff_associated(ACCoeff)
elemental logical function, public spccoeff_associated(SpcCoeff)
integer, parameter, public information
elemental logical function, public nltecoeff_associated(NLTECoeff)