47 '$Id: AerosolCoeff_Binary_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 50 INTEGER,
PARAMETER ::
ml = 256
153 n_Wavelengths , & ! Optional output
154 n_Radii , & ! Optional output
155 n_Types , & ! Optional output
156 n_RH , & ! Optional output
157 n_Legendre_Terms, & ! Optional output
158 n_Phase_Elements, & ! Optional output
159 Release , & ! Optional output
163 CHARACTER(*),
INTENT(IN) :: filename
164 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_wavelengths
165 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_radii
166 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_types
167 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_rh
168 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_legendre_terms
169 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_phase_elements
170 INTEGER,
OPTIONAL,
INTENT(OUT) :: release
171 INTEGER,
OPTIONAL,
INTENT(OUT) :: version
175 CHARACTER(*),
PARAMETER :: routine_name =
'AerosolCoeff_Binary_InquireFile' 187 msg =
'File '//trim(filename)//
' not found.' 193 IF ( err_stat /=
success )
THEN 194 msg =
'Error opening '//trim(filename)
199 READ( fid,iostat=io_stat ) aerosolcoeff%Release, aerosolcoeff%Version
200 IF ( io_stat /= 0 )
THEN 201 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
206 READ( fid,iostat=io_stat ) aerosolcoeff%n_Wavelengths , &
207 aerosolcoeff%n_Radii , &
208 aerosolcoeff%n_Types , &
209 aerosolcoeff%n_RH , &
210 aerosolcoeff%n_Legendre_Terms, &
211 aerosolcoeff%n_Phase_Elements
212 IF ( io_stat /= 0 )
THEN 213 WRITE( msg,
'("Error reading dimensions from ",a,". IOSTAT = ",i0)' ) &
214 trim(filename), io_stat
219 CLOSE( fid,iostat=io_stat )
220 IF ( io_stat /= 0 )
THEN 221 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
226 IF (
PRESENT(n_wavelengths ) ) n_wavelengths = aerosolcoeff%n_Wavelengths
227 IF (
PRESENT(n_radii ) ) n_radii = aerosolcoeff%n_Radii
228 IF (
PRESENT(n_types ) ) n_types = aerosolcoeff%n_Types
229 IF (
PRESENT(n_rh ) ) n_rh = aerosolcoeff%n_RH
230 IF (
PRESENT(n_legendre_terms) ) n_legendre_terms = aerosolcoeff%n_Legendre_Terms
231 IF (
PRESENT(n_phase_elements) ) n_phase_elements = aerosolcoeff%n_Phase_Elements
232 IF (
PRESENT(release ) ) release = aerosolcoeff%Release
233 IF (
PRESENT(version ) ) version = aerosolcoeff%Version
240 CLOSE( fid,iostat=io_stat )
241 IF ( io_stat /= 0 ) &
242 msg = trim(msg)//
'; Error closing input file during error cleanup' 307 AerosolCoeff, & ! Output
308 Quiet , & ! Optional input
312 CHARACTER(*),
INTENT(IN) :: filename
314 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
315 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
319 CHARACTER(*),
PARAMETER :: routine_name =
'AerosolCoeff_ReadFile(Binary)' 332 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
334 IF (
PRESENT(debug) )
THEN 335 IF ( debug ) noisy = .true.
341 IF ( err_stat /=
success )
THEN 342 msg =
'Error opening '//trim(filename)
348 READ( fid,iostat=io_stat ) dummy%Release, dummy%Version
349 IF ( io_stat /= 0 )
THEN 350 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
354 msg =
'AerosolCoeff Release check failed.' 361 READ( fid,iostat=io_stat ) dummy%n_Wavelengths , &
365 dummy%n_Legendre_Terms, &
366 dummy%n_Phase_Elements
367 IF ( io_stat /= 0 )
THEN 368 WRITE( msg,
'("Error reading data dimensions. IOSTAT = ",i0)' ) io_stat
374 dummy%n_Wavelengths , &
378 dummy%n_Legendre_Terms, &
379 dummy%n_Phase_Elements )
381 msg =
'AerosolCoeff object allocation failed.' 385 READ( fid,iostat=io_stat ) strlen
386 IF ( io_stat /= 0 )
THEN 387 WRITE( msg,
'("Error reading data source string length. IOSTAT = ",i0)' ) io_stat
390 IF ( strlen /= len(aerosolcoeff%Data_Source) )
THEN 391 msg =
'Data source string length does not match structure definition' 394 READ( fid,iostat=io_stat ) aerosolcoeff%Data_Source
395 IF ( io_stat /= 0 )
THEN 396 WRITE( msg,
'("Error reading data source string. IOSTAT = ",i0)' ) io_stat
400 READ( fid,iostat=io_stat ) aerosolcoeff%Type
401 IF ( io_stat /= 0 )
THEN 402 WRITE( msg,
'("Error reading type vector data. IOSTAT = ",i0)' ) io_stat
406 READ( fid,iostat=io_stat ) strlen
407 IF ( io_stat /= 0 )
THEN 408 WRITE( msg,
'("Error reading type name string length. IOSTAT = ",i0)' ) io_stat
411 IF ( strlen /= len(aerosolcoeff%Type_Name(1)) )
THEN 412 msg =
'Type name string length does not match structure definition' 415 READ( fid,iostat=io_stat ) aerosolcoeff%Type_Name
416 IF ( io_stat /= 0 )
THEN 417 WRITE( msg,
'("Error reading type names. IOSTAT = ",i0)' ) io_stat
421 READ( fid,iostat=io_stat ) aerosolcoeff%Wavelength, &
422 aerosolcoeff%Reff , &
424 IF ( io_stat /= 0 )
THEN 425 WRITE( msg,
'("Error reading dimension vector data. IOSTAT = ",i0)' ) io_stat
429 READ( fid,iostat=io_stat ) aerosolcoeff%ke , &
433 IF ( io_stat /= 0 )
THEN 434 WRITE( msg,
'("Error reading coefficient data. IOSTAT = ",i0)' ) io_stat
438 aerosolcoeff%Version = dummy%Version
444 CLOSE( fid,iostat=io_stat )
445 IF ( io_stat /= 0 )
THEN 446 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
461 CLOSE( fid,iostat=io_stat )
462 IF ( io_stat /= 0 ) &
463 msg = trim(msg)//
'; Error closing input file during error cleanup.' 532 AerosolCoeff, & ! Input
533 Quiet , & ! Optional input
537 CHARACTER(*),
INTENT(IN) :: filename
539 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
540 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
544 CHARACTER(*),
PARAMETER :: routine_name =
'AerosolCoeff_WriteFile(Binary)' 545 CHARACTER(*),
PARAMETER :: file_status_on_error =
'DELETE' 556 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
558 IF (
PRESENT(debug) )
THEN 559 IF ( debug ) noisy = .true.
566 msg =
'Input AerosolCoeff object is not allocated.' 571 msg =
'AerosolCoeff Release check failed.' 578 IF ( err_stat /=
success )
THEN 579 msg =
'Error opening '//trim(filename)
585 WRITE( fid,iostat=io_stat ) aerosolcoeff%Release, aerosolcoeff%Version
586 IF ( io_stat /= 0 )
THEN 587 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
594 WRITE( fid,iostat=io_stat ) aerosolcoeff%n_Wavelengths , &
595 aerosolcoeff%n_Radii , &
596 aerosolcoeff%n_Types , &
597 aerosolcoeff%n_RH , &
598 aerosolcoeff%n_Legendre_Terms, &
599 aerosolcoeff%n_Phase_Elements
600 IF ( io_stat /= 0 )
THEN 601 WRITE( msg,
'("Error writing data dimensions. IOSTAT = ",i0)' ) io_stat
605 WRITE( fid,iostat=io_stat ) len(aerosolcoeff%Data_Source)
606 IF ( io_stat /= 0 )
THEN 607 WRITE( msg,
'("Error writing data source string length. IOSTAT = ",i0)' ) io_stat
610 WRITE( fid,iostat=io_stat ) aerosolcoeff%Data_Source
611 IF ( io_stat /= 0 )
THEN 612 WRITE( msg,
'("Error writing data source string. IOSTAT = ",i0)' ) io_stat
616 WRITE( fid,iostat=io_stat ) aerosolcoeff%Type
617 IF ( io_stat /= 0 )
THEN 618 WRITE( msg,
'("Error writing type vector data. IOSTAT = ",i0)' ) io_stat
622 WRITE( fid,iostat=io_stat ) len(aerosolcoeff%Type_Name(1))
623 IF ( io_stat /= 0 )
THEN 624 WRITE( msg,
'("Error writing type name string length. IOSTAT = ",i0)' ) io_stat
627 WRITE( fid,iostat=io_stat ) aerosolcoeff%Type_Name
628 IF ( io_stat /= 0 )
THEN 629 WRITE( msg,
'("Error writing type names. IOSTAT = ",i0)' ) io_stat
633 WRITE( fid,iostat=io_stat ) aerosolcoeff%Wavelength, &
634 aerosolcoeff%Reff , &
636 IF ( io_stat /= 0 )
THEN 637 WRITE( msg,
'("Error writing dimension vector data. IOSTAT = ",i0)' ) io_stat
641 WRITE( fid,iostat=io_stat ) aerosolcoeff%ke , &
645 IF ( io_stat /= 0 )
THEN 646 WRITE( msg,
'("Error writing coefficient data. IOSTAT = ",i0)' ) io_stat
652 CLOSE( fid,status=
'KEEP',iostat=io_stat )
653 IF ( io_stat /= 0 )
THEN 654 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
670 IF ( io_stat /= 0 ) &
671 msg = trim(msg)//
'; Error deleting output file during error cleanup.' 704 CHARACTER(*),
INTENT(OUT) :: id
integer, parameter, public failure
elemental subroutine, public aerosolcoeff_destroy(AerosolCoeff)
subroutine inquire_cleanup()
subroutine read_cleanup()
integer function, public aerosolcoeff_binary_writefile(Filename, AerosolCoeff, Quiet, Debug)
elemental logical function, public aerosolcoeff_associated(AerosolCoeff)
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)
elemental subroutine, public aerosolcoeff_create(AerosolCoeff, n_Wavelengths, n_Radii, n_Types, n_RH, n_Legendre_Terms, n_Phase_Elements)
subroutine, public aerosolcoeff_info(AerosolCoeff, Info)
elemental subroutine, public aerosolcoeff_frequency(AerosolCoeff)
character(*), parameter write_error_status
integer function, public aerosolcoeff_binary_inquirefile(Filename, n_Wavelengths, n_Radii, n_Types, n_RH, n_Legendre_Terms, n_Phase_Elements, Release, Version)
logical function, public aerosolcoeff_validrelease(AerosolCoeff)
character(*), parameter module_version_id
subroutine, public aerosolcoeff_binary_ioversion(Id)
integer function, public aerosolcoeff_binary_readfile(Filename, AerosolCoeff, Quiet, Debug)
integer, parameter, public success
integer, parameter, public information