50 '$Id: ODAS_Binary_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 52 INTEGER,
PARAMETER ::
ml = 512
54 INTEGER,
PARAMETER ::
set = 1
198 n_Predictors , & ! Optional output
199 n_Absorbers , & ! Optional output
200 n_Channels , & ! Optional output
201 n_Alphas , & ! Optional output
202 n_Coeffs , & ! Optional output
203 Release , & ! Optional Output
204 Version , & ! Optional Output
205 Sensor_Id , & ! Optional Output
206 WMO_Satellite_Id, & ! Optional Output
207 WMO_Sensor_Id , & ! Optional Output
208 RCS_Id , & ! Revision control
210 result( error_status )
212 CHARACTER(*),
INTENT(IN) :: filename
213 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_predictors
214 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_absorbers
215 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_channels
216 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_alphas
217 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_coeffs
218 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
219 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
220 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: sensor_id
221 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_satellite_id
222 INTEGER ,
OPTIONAL,
INTENT(OUT) :: wmo_sensor_id
223 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
224 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
226 INTEGER :: error_status
228 CHARACTER(*),
PARAMETER :: routine_name =
'Inquire_ODAS_Binary' 230 CHARACTER(ML) :: message
243 message =
'File '//trim(filename)//
' not found.' 251 IF ( error_status /=
success )
THEN 252 message =
'Error opening ODAS Binary file '//trim(filename)
259 READ( fileid, iostat=io_status ) odas%Release, odas%Version
260 IF ( io_status /= 0 )
THEN 261 WRITE( message,
'("Error reading Release/Version values from ",a,& 262 &". IOSTAT = ",i0)' ) &
263 trim(filename), io_status
270 READ( fileid, iostat=io_status ) odas%Algorithm
271 IF ( io_status /= 0 )
THEN 272 WRITE( message,
'("Error reading Algorithm ID from ",a,& 273 &". IOSTAT = ",i0)' ) &
274 trim(filename), io_status
281 READ( fileid, iostat=io_status ) odas%n_Predictors, &
286 IF ( io_status /= 0 )
THEN 287 WRITE( message,
'("Error reading dimension values from ",a,& 288 &". IOSTAT = ",i0)' ) &
289 trim(filename), io_status
296 READ( fileid, iostat=io_status ) odas%Sensor_Id , &
297 odas%WMO_Satellite_Id, &
299 IF ( io_status /= 0 )
THEN 300 WRITE( message,
'("Error reading sensor information from ",a,& 301 &". IOSTAT = ",i0)' ) &
302 trim(filename), io_status
309 CLOSE( fileid, iostat=io_status )
310 IF ( io_status /= 0 )
THEN 311 WRITE( message,
'("Error closing ",a,". IOSTAT = ",i0)' ) &
312 trim(filename), io_status
320 IF (
PRESENT(n_predictors) ) n_predictors = odas%n_Predictors
321 IF (
PRESENT(n_absorbers ) ) n_absorbers = odas%n_Absorbers
322 IF (
PRESENT(n_channels ) ) n_channels = odas%n_Channels
323 IF (
PRESENT(n_alphas ) ) n_alphas = odas%n_Alphas
324 IF (
PRESENT(n_coeffs ) ) n_coeffs = odas%n_Coeffs
327 IF (
PRESENT(release) ) release = odas%Release
328 IF (
PRESENT(version) ) version = odas%Version
331 IF (
PRESENT(sensor_id ) ) sensor_id = odas%Sensor_Id(1:
min(len(sensor_id),len_trim(odas%Sensor_Id)))
332 IF (
PRESENT(wmo_satellite_id) ) wmo_satellite_id = odas%WMO_Satellite_Id
333 IF (
PRESENT(wmo_sensor_id ) ) wmo_sensor_id = odas%WMO_Sensor_Id
338 INTEGER,
OPTIONAL,
INTENT(IN) :: Close_File
339 CHARACTER(256) :: Close_Message
341 IF (
PRESENT(close_file) )
THEN 342 IF ( close_file ==
set )
THEN 343 CLOSE( fileid, iostat=io_status )
344 IF ( io_status /= 0 )
THEN 345 WRITE( close_message,
'("; Error closing input file during error cleanup. IOSTAT=",i0)') &
347 message = trim(message)//trim(close_message)
356 message_log=message_log )
470 Quiet , & ! Optional input
471 Process_ID , & ! Optional input
472 Output_Process_ID, & ! Optional input
473 RCS_Id , & ! Revision control
475 result( error_status )
477 CHARACTER(*) ,
INTENT(IN) :: filename
479 INTEGER ,
OPTIONAL,
INTENT(IN) :: quiet
480 INTEGER ,
OPTIONAL,
INTENT(IN) :: process_id
481 INTEGER ,
OPTIONAL,
INTENT(IN) :: output_process_id
482 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
483 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
485 INTEGER :: error_status
487 CHARACTER(*),
PARAMETER :: routine_name =
'Read_ODAS_Binary' 489 CHARACTER(ML) :: message
490 CHARACTER(ML) :: process_id_tag
502 message =
'File '//trim(filename)//
' not found.' 510 IF (
PRESENT(quiet) )
THEN 511 IF ( quiet ==
set ) noisy = .false.
513 IF ( noisy .AND.
PRESENT(process_id) .AND.
PRESENT(output_process_id) )
THEN 514 IF ( process_id /= output_process_id ) noisy = .false.
519 IF (
PRESENT(process_id) )
THEN 520 WRITE( process_id_tag,
'("; MPI Process ID: ",i0)' ) process_id
528 IF ( error_status /=
success )
THEN 529 message =
'Error opening '//trim(filename)
540 message_log = message_log )
541 IF ( error_status /=
success )
THEN 542 message =
'Error reading data from '//trim(filename)
549 CLOSE( fileid, iostat=io_status )
550 IF ( io_status /= 0 )
THEN 551 WRITE( message,
'("Error closing ",a," after read. IOSTAT = ",i0)' ) &
552 trim(filename), io_status
554 trim(message)//trim(process_id_tag), &
556 message_log=message_log )
564 'FILE: '//trim(filename)//
'; '//trim(message), &
566 message_log = message_log )
577 result( error_status )
580 CHARACTER(*) ,
INTENT(IN) :: filename
581 INTEGER ,
INTENT(IN) :: fileid
583 CHARACTER(*) ,
INTENT(IN) :: process_id_tag
584 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
586 INTEGER :: error_status
588 CHARACTER(*),
PARAMETER :: routine_name =
'Read_ODAS_Data' 590 CHARACTER(ML) :: message
592 INTEGER(Long) :: version
593 INTEGER(Long) :: algorithm
594 INTEGER(Long) :: n_predictors
595 INTEGER(Long) :: n_absorbers
596 INTEGER(Long) :: n_channels
597 INTEGER(Long) :: n_alphas
598 INTEGER(Long) :: n_coeffs
602 READ( fileid, iostat=io_status ) odas%Release, version
603 IF ( io_status /= 0 )
THEN 604 WRITE( message,
'("Error reading Release/Version values from ",a,& 605 &". IOSTAT = ",i0)' ) &
606 trim(filename), io_status
612 IF ( error_status /=
success )
THEN 613 message =
'ODAS Release check failed for '//trim(filename)
619 READ( fileid, iostat=io_status ) algorithm
620 IF ( io_status /= 0 )
THEN 621 WRITE( message,
'("Error reading Algorithm ID from ",a,& 622 &". IOSTAT = ",i0)' ) &
623 trim(filename), io_status
629 IF ( error_status /=
success )
THEN 630 message =
'ODAS Algorithm check failed for '//trim(filename)
637 READ( fileid, iostat=io_status ) n_predictors, &
642 IF ( io_status /= 0 )
THEN 643 WRITE( message,
'("Error reading dimension values from ",a,& 644 &". IOSTAT = ",i0)' ) &
645 trim(filename), io_status
658 message_log=message_log)
659 IF ( error_status /=
success )
THEN 660 message =
'ODAS allocation failed' 665 odas%Version = version
670 READ( fileid, iostat=io_status ) odas%Sensor_Id , &
671 odas%WMO_Satellite_Id, &
672 odas%WMO_Sensor_Id , &
674 IF ( io_status /= 0 )
THEN 675 WRITE( message,
'("Error reading sensor information from ",a,& 676 &". IOSTAT = ",i0)' ) &
677 trim(filename), io_status
684 READ( fileid, iostat=io_status ) odas%Sensor_Channel
685 IF ( io_status /= 0 )
THEN 686 WRITE( message,
'("Error reading sensor channel data from ",a,& 687 &". IOSTAT = ",i0)' ) &
688 trim(filename), io_status
695 READ( fileid, iostat=io_status ) odas%Absorber_ID, &
698 IF ( io_status /= 0 )
THEN 699 WRITE( message,
'("Error reading absorber information from ",a,& 700 &". IOSTAT = ",i0)' ) &
701 trim(filename), io_status
708 READ( fileid, iostat=io_status ) odas%Order, &
711 IF ( io_status /= 0 )
THEN 712 WRITE( message,
'("Error reading order and index arrays from ",a,& 713 &". IOSTAT = ",i0)' ) &
714 trim(filename), io_status
721 READ( fileid, iostat=io_status ) odas%C
722 IF ( io_status /= 0 )
THEN 723 WRITE( message,
'("Error reading regression coefficients from ",a,& 724 &". IOSTAT = ",i0)' ) &
725 trim(filename), io_status
732 CHARACTER(ML) :: Close_Message
733 INTEGER :: Destroy_Status
737 CLOSE( fileid, iostat=io_status )
738 IF ( io_status /= 0 )
THEN 739 WRITE( close_message,
'("; Error closing ",a," during error cleanup. IOSTAT=",i0)') &
740 trim(filename), io_status
741 message = trim(message)//trim(close_message)
746 destroy_status =
destroy_odas( odas, message_log=message_log )
747 IF ( destroy_status /=
success ) &
748 message = trim(message)//
'; Error destroying ODAS structure during error cleanup.' 752 trim(message)//trim(process_id_tag), &
754 message_log=message_log )
838 Quiet , & ! Optional input
839 RCS_Id , & ! Revision control
841 result( error_status )
843 CHARACTER(*) ,
INTENT(IN) :: filename
845 INTEGER ,
OPTIONAL,
INTENT(IN) :: quiet
846 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
847 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
849 INTEGER :: error_status
851 CHARACTER(*),
PARAMETER :: routine_name =
'Write_ODAS_Binary' 853 CHARACTER(ML) :: message
866 IF ( error_status /=
success )
THEN 867 message =
'Error opening '//trim( filename )
875 IF (
PRESENT( quiet ) )
THEN 876 IF ( quiet == 1 ) noisy = .false.
882 message_log=message_log )
884 IF ( error_status /=
success )
THEN 885 message =
'Error writing data to '//trim( filename )
893 CLOSE( fileid, iostat=io_status )
894 IF ( io_status /= 0 )
THEN 895 WRITE( message,
'("Error closing ",a," after write. IOSTAT = ",i0)' ) &
896 trim(filename), io_status
900 message_log=message_log )
909 'FILE: '//trim(filename)//
'; '//trim(message), &
911 message_log = message_log )
920 result( error_status )
922 CHARACTER(*) ,
INTENT(IN) :: filename
923 INTEGER ,
INTENT(IN) :: fileid
925 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
926 CHARACTER(*),
PARAMETER :: routine_name =
'Write_ODAS_Data' 928 INTEGER :: error_status
930 CHARACTER(ML) :: message
935 message =
'Some or all INPUT ODAS pointer members are NOT associated.' 941 IF ( error_status /=
success )
THEN 942 message =
'ODAS structure Release check failed.' 948 IF ( error_status /=
success )
THEN 949 message =
'ODAS Algorithm check failed' 954 IF ( odas%n_Predictors < 1 .OR. &
955 odas%n_Absorbers < 1 .OR. &
956 odas%n_Channels < 1 .OR. &
957 odas%n_Alphas < 1 .OR. &
958 odas%n_Coeffs < 1 )
THEN 959 message =
'One or more dimensions of ODAS structure are < or = 0.' 965 WRITE( fileid, iostat=io_status ) odas%Release, odas%Version
966 IF ( io_status /= 0 )
THEN 967 WRITE( message,
'("Error writing Release/Version values to ",a,& 968 &". IOSTAT = ",i0)' ) &
969 trim(filename), io_status
976 WRITE( fileid, iostat=io_status ) odas%Algorithm
977 IF ( io_status /= 0 )
THEN 978 WRITE( message,
'("Error writing Algorithm ID to ",a,& 979 &". IOSTAT = ",i0)' ) &
980 trim(filename), io_status
987 WRITE( fileid, iostat=io_status ) odas%n_Predictors, &
992 IF ( io_status /= 0 )
THEN 993 WRITE( message,
'("Error writing dimension values to ",a,& 994 &". IOSTAT = ",i0)' ) &
995 trim(filename), io_status
1002 WRITE( fileid, iostat=io_status ) odas%Sensor_Id , &
1003 odas%WMO_Satellite_Id, &
1004 odas%WMO_Sensor_Id , &
1006 IF ( io_status /= 0 )
THEN 1007 WRITE( message,
'("Error writing sensor information to ",a,& 1008 &". IOSTAT = ",i0)' ) &
1009 trim(filename), io_status
1016 WRITE( fileid, iostat=io_status ) odas%Sensor_Channel
1017 IF ( io_status /= 0 )
THEN 1018 WRITE( message,
'("Error writing sensor channel data to ",a,& 1019 &". IOSTAT = ",i0)' ) &
1020 trim(filename), io_status
1027 WRITE( fileid, iostat=io_status ) odas%Absorber_ID, &
1030 IF ( io_status /= 0 )
THEN 1031 WRITE( message,
'("Error writing absorber information to ",a,& 1032 &". IOSTAT = ",i0)' ) &
1033 trim(filename), io_status
1040 WRITE( fileid, iostat=io_status ) odas%Order , &
1043 IF ( io_status /= 0 )
THEN 1044 WRITE( message,
'("Error writing order and index arrays to ",a,& 1045 &". IOSTAT = ",i0)' ) &
1046 trim(filename), io_status
1053 WRITE( fileid, iostat=io_status ) odas%C
1054 IF ( io_status /= 0 )
THEN 1055 WRITE( message,
'("Error writing regression coefficients to ",a,& 1056 &". IOSTAT = ",i0)' ) &
1057 trim(filename), io_status
1064 CHARACTER(ML) :: Close_Message
1068 CLOSE( fileid, iostat=io_status, status=
'DELETE' )
1069 IF ( io_status /= 0 )
THEN 1070 WRITE( close_message,
'("; Error deleting ",a," during error cleanup. IOSTAT=",i0)') &
1071 trim(filename), io_status
1072 message = trim(message)//trim(close_message)
1081 message_log=message_log )
integer, parameter, public failure
integer, parameter, public set
integer function, public inquire_odas_binary(Filename, n_Predictors, n_Absorbers, n_Channels, n_Alphas, n_Coeffs, Release, Version, Sensor_Id, WMO_Satellite_Id, WMO_Sensor_Id, RCS_Id, Message_Log)
integer, parameter, public warning
integer function, public write_odas_binary(Filename, ODAS, Quiet, RCS_Id, Message_Log)
integer, parameter, public long
character(*), parameter module_rcs_id
integer function, public read_odas_data(Filename, FileID, ODAS, Process_ID_Tag, Message_Log)
integer, parameter, public double
subroutine inquire_cleanup()
integer function, public write_odas_data(Filename, FileID, ODAS, Message_Log)
subroutine read_cleanup()
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)
integer function, public destroy_odas(ODAS, No_Clear, RCS_Id, Message_Log)
logical function, public associated_odas(ODAS, ANY_Test)
subroutine, public info_odas(ODAS, Info, RCS_Id)
integer function, public allocate_odas(n_Predictors, n_Absorbers, n_Channels, n_Alphas, n_Coeffs, ODAS, RCS_Id, Message_Log)
integer function, public checkalgorithm_odas(ODAS, RCS_Id, Message_Log)
integer function, public checkrelease_odas(ODAS, RCS_Id, Message_Log)
integer, parameter, public success
integer function, public read_odas_binary(Filename, ODAS, Quiet, Process_ID, Output_Process_ID, RCS_Id, Message_Log)
integer, parameter, public information