55 '$Id: ODSSU_Binary_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 57 INTEGER,
PARAMETER ::
set = 1
59 INTEGER,
PARAMETER ::
ml = 512
171 Quiet , & ! Optional input
172 Process_ID , & ! Optional input
173 Output_Process_ID, & ! Optional input
174 RCS_Id , & ! Revision control
176 result( error_status )
178 CHARACTER(*) ,
INTENT(IN) :: filename
180 INTEGER ,
OPTIONAL,
INTENT(IN) :: quiet
181 INTEGER ,
OPTIONAL,
INTENT(IN) :: process_id
182 INTEGER ,
OPTIONAL,
INTENT(IN) :: output_process_id
183 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
184 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
186 INTEGER :: error_status
188 CHARACTER(*),
PARAMETER :: routine_name =
'Read_ODSSU_Binary' 190 CHARACTER(ML) :: message
191 CHARACTER(ML) :: process_id_tag
195 INTEGER(Long) :: version
196 INTEGER(Long) :: algorithm
197 INTEGER(Long) :: n_absorbers
198 INTEGER(Long) :: n_channels
199 INTEGER(Long) :: n_tc_cellpressures
200 INTEGER(Long) :: n_ref_cellpressures
210 message =
'File '//trim(filename)//
' not found.' 217 IF (
PRESENT(quiet) )
THEN 219 IF ( quiet ==
set ) noisy = .false.
222 IF (
PRESENT(process_id) .AND.
PRESENT(output_process_id) )
THEN 223 IF ( process_id /= output_process_id ) noisy = .false.
229 IF (
PRESENT(process_id) )
THEN 230 WRITE( process_id_tag,
'("; MPI Process ID: ",i0)' ) process_id
238 IF ( error_status /=
success )
THEN 239 message =
'Error opening '//trim(filename)
246 READ( fileid, iostat=io_status ) odssu%Release, version
247 IF ( io_status /= 0 )
THEN 248 WRITE( message,
'("Error reading Release/Version values from ",a,& 249 &". IOSTAT = ",i0)' ) &
250 trim(filename), io_status
256 IF ( error_status /=
success )
THEN 257 message =
'ODSSU Release check failed for '//trim(filename)
263 READ( fileid, iostat=io_status ) algorithm
264 IF ( io_status /= 0 )
THEN 265 WRITE( message,
'("Error reading Algorithm ID from ",a,& 266 &". IOSTAT = ",i0)' ) &
267 trim(filename), io_status
273 IF ( error_status /=
success )
THEN 274 message =
'ODSSU Algorithm check failed for '//trim(filename)
280 READ( fileid, iostat=io_status ) odssu%subAlgorithm
281 IF ( io_status /= 0 )
THEN 282 WRITE( message,
'("Error reading subAlgorithm ID from ",a,& 283 &". IOSTAT = ",i0)' ) &
284 trim(filename), io_status
293 READ( fileid, iostat=io_status ) n_channels , &
295 n_tc_cellpressures , &
297 IF ( io_status /= 0 )
THEN 298 WRITE( message,
'("Error reading dimension values from ",a,& 299 &". IOSTAT = ",i0)' ) &
300 trim(filename), io_status
304 IF( n_channels < 1 .OR. n_tc_cellpressures < 1 .OR. n_ref_cellpressures < 1 )
THEN 305 message =
'One or more dimensions of the cell pressure arrays are < or = 0.' 311 n_tc_cellpressures , &
312 n_ref_cellpressures, &
314 message_log = message_log)
315 IF ( error_status /=
success )
THEN 316 message =
'Error allocating memory for the ODSSU structure ' 323 READ( fileid, iostat=io_status ) odssu%TC_CellPressure, &
325 odssu%Ref_CellPressure
326 IF ( io_status /= 0 )
THEN 327 WRITE( message,
'("Error reading cell pressure and time data from ",a,& 328 &". IOSTAT = ",i0)' ) &
329 trim(filename), io_status
336 DO i = 1, n_tc_cellpressures
342 message_log = message_log)
343 IF ( error_status /=
success )
THEN 344 message =
'Error reading data from '//trim(filename)
352 odssu%Sensor_Channel = odssu%ODAS(1)%Sensor_Channel
353 odssu%Absorber_ID = odssu%ODAS(1)%Absorber_ID
354 odssu%Sensor_Id = odssu%ODAS(1)%Sensor_Id
355 odssu%WMO_Satellite_ID = odssu%ODAS(1)%WMO_Satellite_ID
356 odssu%WMO_Sensor_ID = odssu%ODAS(1)%WMO_Sensor_ID
357 odssu%Sensor_Type = odssu%ODAS(1)%Sensor_Type
363 DO i = 1, n_tc_cellpressures
369 message_log = message_log)
370 IF ( error_status /=
success )
THEN 371 message =
'Error reading data from '//trim(filename)
378 odssu%Sensor_Channel = odssu%ODPS(1)%Sensor_Channel
379 odssu%Absorber_ID = odssu%ODPS(1)%Absorber_ID
380 odssu%Sensor_Id = odssu%ODPS(1)%Sensor_Id
381 odssu%WMO_Satellite_ID = odssu%ODPS(1)%WMO_Satellite_ID
382 odssu%WMO_Sensor_ID = odssu%ODPS(1)%WMO_Sensor_ID
383 odssu%Sensor_Type = odssu%ODPS(1)%Sensor_Type
390 CLOSE( fileid, iostat=io_status )
391 IF ( io_status /= 0 )
THEN 393 WRITE( message,
'("Error closing ",a," after read. IOSTAT = ",i0)' ) &
394 trim(filename), io_status
396 trim(message)//trim(process_id_tag), &
398 message_log=message_log )
406 'FILE: '//trim(filename)//
'; '//trim(message), &
408 message_log = message_log )
414 CHARACTER(ML) :: Close_Message
415 INTEGER :: Destroy_Status
419 CLOSE( fileid, iostat=io_status )
420 IF ( io_status /= 0 )
THEN 421 WRITE( close_message,
'("; Error closing ",a," during error cleanup. IOSTAT=",i0)') &
422 trim(filename), io_status
423 message = trim(message)//trim(close_message)
428 destroy_status =
destroy_odssu( odssu, message_log=message_log )
429 IF ( destroy_status /=
success ) &
430 message = trim(message)//
'; Error destroying ODSSU structure during error cleanup.' 434 trim(message)//trim(process_id_tag), &
436 message_log=message_log )
522 result( error_status )
524 CHARACTER(*) ,
INTENT(IN) :: filename
526 INTEGER ,
OPTIONAL,
INTENT(IN) :: quiet
527 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
528 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
530 INTEGER :: error_status
532 CHARACTER(*),
PARAMETER :: routine_name =
'Write_ODSSU_Binary' 534 CHARACTER(ML) :: message
546 IF( odssu%n_TC_CellPressures < 1 .OR. &
547 odssu%n_Ref_CellPressures < 1 .OR. &
548 odssu%n_Channels < 1 .OR. &
549 odssu%n_Absorbers < 1)
THEN 550 message =
'One or more dimensions in ODSSU are < or = 0.' 557 IF ( error_status /=
success )
THEN 558 message =
'Error opening '//trim( filename )
566 IF (
PRESENT( quiet ) )
THEN 567 IF ( quiet == 1 ) noisy = .false.
572 WRITE( fileid, iostat=io_status ) odssu%Release, odssu%Version
573 IF ( io_status /= 0 )
THEN 574 WRITE( message,
'("Error writing Release/Version values to ",a,& 575 &". IOSTAT = ",i0)' ) &
576 trim(filename), io_status
583 WRITE( fileid, iostat=io_status ) odssu%Algorithm
584 IF ( io_status /= 0 )
THEN 585 WRITE( message,
'("Error writing Algorithm ID to ",a,& 586 &". IOSTAT = ",i0)' ) &
587 trim(filename), io_status
593 WRITE( fileid, iostat=io_status ) odssu%subAlgorithm
594 IF ( io_status /= 0 )
THEN 595 WRITE( message,
'("Error writing Algorithm ID to ",a,& 596 &". IOSTAT = ",i0)' ) &
597 trim(filename), io_status
602 WRITE( fileid, iostat=io_status ) odssu%n_Channels , &
603 odssu%n_Absorbers , &
604 odssu%n_TC_CellPressures , &
605 odssu%n_Ref_CellPressures
606 IF ( io_status /= 0 )
THEN 607 WRITE( message,
'("Error writing dimension values for ODSSU to ",a,& 608 &". IOSTAT = ",i0)' ) &
609 trim(filename), io_status
615 WRITE( fileid, iostat=io_status ) odssu%TC_CellPressure, &
617 odssu%Ref_CellPressure
618 IF ( io_status /= 0 )
THEN 619 WRITE( message,
'("Error writing cell pressure and time data to ",a,& 620 &". IOSTAT = ",i0)' ) &
621 trim(filename), io_status
628 DO i = 1, odssu%n_TC_CellPressures
632 message_log = message_log)
633 IF ( error_status /=
success )
THEN 634 message =
'Error writing data to '//trim(filename)
645 DO i = 1, odssu%n_TC_CellPressures
649 message_log = message_log)
650 IF ( error_status /=
success )
THEN 651 message =
'Error writing data to '//trim(filename)
662 CLOSE( fileid, iostat=io_status )
663 IF ( io_status /= 0 )
THEN 664 WRITE( message,
'("Error closing ",a," after write. IOSTAT = ",i0)' ) &
665 trim(filename), io_status
669 message_log=message_log )
678 'FILE: '//trim(filename)//
'; '//trim(message), &
680 message_log = message_log )
686 CHARACTER(ML) :: Close_Message
690 CLOSE( fileid, iostat=io_status, status=
'DELETE' )
691 IF ( io_status /= 0 )
THEN 692 WRITE( close_message,
'("; Error deleting ",a," during error cleanup. IOSTAT=",i0)') &
693 trim(filename), io_status
694 message = trim(message)//trim(close_message)
703 message_log=message_log )
integer function, public write_odssu_binary(Filename, ODSSU, Quiet, RCS_Id, Message_Log)
integer, parameter, public failure
integer, parameter, public set
integer, parameter, public warning
integer, parameter, public long
integer function, public checkalgorithm_odssu(ODSSU, RCS_Id, Message_Log)
integer function, public write_odps_data(Filename, FileID, ODPS, Message_Log)
integer function, public read_odas_data(Filename, FileID, ODAS, Process_ID_Tag, Message_Log)
integer, parameter, public double
integer function, public read_odssu_binary(Filename, ODSSU, Quiet, Process_ID, Output_Process_ID, RCS_Id, Message_Log)
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_odssu(ODSSU, No_Clear, RCS_Id, Message_Log)
subroutine, public info_odssu(ODSSU, Info, RCS_Id)
integer, parameter, public odps_algorithm
integer function, public allocate_odssu(n_Absorbers, n_Channels, n_TC_CellPressures, n_Ref_CellPressures, ODSSU, RCS_Id, Message_Log)
integer, parameter, public odas_algorithm
integer function, public read_odps_data(Filename, FileID, ODPS, Process_ID_Tag, Message_Log)
integer function, public checkrelease_odssu(ODSSU, RCS_Id, Message_Log)
character(*), parameter module_rcs_id
integer, parameter, public success
integer, parameter, public information