45 '$Id: NLTE_Predictor_IO.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 48 INTEGER,
PARAMETER ::
ml = 256
124 n_Profiles, & ! Optional output
125 Release , & ! Optional Output
129 CHARACTER(*),
INTENT(IN) :: filename
130 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_profiles
131 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
132 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
136 CHARACTER(*),
PARAMETER :: routine_name =
'NLTE_Predictor_InquireFile' 141 INTEGER :: rel, ver, m
148 msg =
'File '//trim(filename)//
' not found.' 155 IF ( err_stat /=
success )
THEN 156 msg =
'Error opening '//trim(filename)
162 READ( fid, iostat=io_stat ) rel, ver
163 IF ( io_stat /= 0 )
THEN 164 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
170 READ( fid, iostat=io_stat ) m
171 IF ( io_stat /= 0 )
THEN 172 WRITE( msg,
'("Error reading dimensions from ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
178 CLOSE( fid, iostat=io_stat )
179 IF ( io_stat /= 0 )
THEN 180 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
186 IF (
PRESENT(n_profiles) ) n_profiles = m
187 IF (
PRESENT(release ) ) release = rel
188 IF (
PRESENT(version ) ) version = ver
195 CLOSE( fid, iostat=io_stat )
196 IF ( io_stat /= 0 ) &
197 msg = trim(msg)//
'; Error closing input file during error cleanup' 271 NLTE_Predictor, & ! Output
272 Quiet , & ! Optional input
273 n_Profiles , & ! Optional output
277 CHARACTER(*),
INTENT(IN) :: filename
279 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
280 INTEGER,
OPTIONAL,
INTENT(OUT) :: n_profiles
281 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
285 CHARACTER(*),
PARAMETER :: routine_name =
'NLTE_Predictor_ReadFile' 291 INTEGER :: n_file_profiles
292 INTEGER :: m, n_input_profiles
300 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
302 IF (
PRESENT(debug) )
THEN 303 IF ( debug ) noisy = .true.
310 IF ( err_stat /=
success )
THEN 311 msg =
'Error opening '//trim(filename)
315 msg =
'File '//trim(filename)//
' not found.' 321 READ( fid, iostat=io_stat ) dummy%Release, dummy%Version
322 IF ( io_stat /= 0 )
THEN 323 WRITE( msg,
'("Error reading Release/Version. IOSTAT = ",i0)' ) io_stat
327 msg =
'NLTE_Predictor Release check failed.' 333 READ( fid, iostat=io_stat ) n_file_profiles
334 IF ( io_stat /= 0 )
THEN 335 WRITE( msg,
'("Error reading profile dimension from ",a,". IOSTAT = ",i0)' ) &
336 trim(filename), io_stat
340 n_input_profiles =
SIZE(nlte_predictor)
341 IF ( n_file_profiles > n_input_profiles )
THEN 342 WRITE( msg,
'("Number of profiles, ",i0," > size of the output NLTE_Predictor ", & 343 &" array, ",i0,". Only the first ",i0, & 344 &" profiles will be read.")' ) &
345 n_file_profiles, n_input_profiles, n_input_profiles
348 n_input_profiles =
min(n_input_profiles, n_file_profiles)
352 profile_loop:
DO m = 1, n_input_profiles
356 READ( fid, iostat=io_stat ) &
357 nlte_predictor(m)%n_Layers , &
358 nlte_predictor(m)%n_Predictors
359 IF ( io_stat /= 0 )
THEN 360 WRITE( msg,
'("Error reading data dimensions for profile ",i0, & 361 &". IOSTAT = ",i0)' ) m, io_stat
365 READ( fid, iostat=io_stat ) &
366 nlte_predictor(m)%Is_Active , &
367 nlte_predictor(m)%Compute_Tm
368 IF ( io_stat /= 0 )
THEN 369 WRITE( msg,
'("Error reading logical indicators for profile ",i0, & 370 &". IOSTAT = ",i0)' ) m, io_stat
374 READ( fid, iostat=io_stat ) &
375 nlte_predictor(m)%k1, &
376 nlte_predictor(m)%k2, &
377 nlte_predictor(m)%isen, &
378 nlte_predictor(m)%isol
379 IF ( io_stat /= 0 )
THEN 380 WRITE( msg,
'("Error reading array indices for profile ",i0, & 381 &". IOSTAT = ",i0)' ) m, io_stat
385 READ( fid, iostat=io_stat ) &
386 nlte_predictor(m)%Tm , &
387 nlte_predictor(m)%Predictor, &
389 IF ( io_stat /= 0 )
THEN 390 WRITE( msg,
'("Error reading predictors and interpolation weights for profile ",i0, & 391 &". IOSTAT = ",i0)' ) m, io_stat
396 nlte_predictor(m)%Version = dummy%Version
402 CLOSE( fid, iostat=io_stat )
403 IF ( io_stat /= 0 )
THEN 404 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
410 IF (
PRESENT(n_profiles) ) n_profiles = n_input_profiles
415 WRITE( msg,
'("Number of profiles read from ",a,": ",i0)' ) trim(filename), n_input_profiles
423 CLOSE( fid, iostat=io_stat )
424 IF ( io_stat /= 0 ) &
425 msg = trim(msg)//
'; Error closing input file during error cleanup.' 490 NLTE_Predictor, & ! Input
491 Quiet , & ! Optional input
495 CHARACTER(*),
INTENT(IN) :: filename
497 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
498 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
502 CHARACTER(*),
PARAMETER :: routine_name =
'NLTE_Predictor_WriteFile' 508 INTEGER :: m, n_output_profiles
515 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
517 IF (
PRESENT(debug) )
THEN 518 IF ( debug ) noisy = .true.
524 IF ( err_stat /=
success )
THEN 525 msg =
'Error opening '//trim(filename)
531 WRITE( fid,iostat=io_stat ) nlte_predictor(1)%Release, nlte_predictor(1)%Version
532 IF ( io_stat /= 0 )
THEN 533 WRITE( msg,
'("Error writing Release/Version. IOSTAT = ",i0)' ) io_stat
539 n_output_profiles =
SIZE(nlte_predictor)
540 WRITE( fid, iostat=io_stat ) n_output_profiles
541 IF ( io_stat /= 0 )
THEN 542 WRITE( msg,
'("Error writing profile dimension to ",a,". IOSTAT = ",i0)' ) &
543 trim(filename), io_stat
549 profile_loop:
DO m = 1, n_output_profiles
553 WRITE( fid, iostat=io_stat ) &
554 nlte_predictor(m)%n_Layers , &
555 nlte_predictor(m)%n_Predictors
556 IF ( io_stat /= 0 )
THEN 557 WRITE( msg,
'("Error writing data dimensions for profile ",i0, & 558 &". IOSTAT = ",i0)' ) m, io_stat
562 WRITE( fid, iostat=io_stat ) &
563 nlte_predictor(m)%Is_Active , &
564 nlte_predictor(m)%Compute_Tm
565 IF ( io_stat /= 0 )
THEN 566 WRITE( msg,
'("Error writing logical indicators for profile ",i0, & 567 &". IOSTAT = ",i0)' ) m, io_stat
571 WRITE( fid, iostat=io_stat ) &
572 nlte_predictor(m)%k1, &
573 nlte_predictor(m)%k2, &
574 nlte_predictor(m)%isen, &
575 nlte_predictor(m)%isol
576 IF ( io_stat /= 0 )
THEN 577 WRITE( msg,
'("Error writing array indices for profile ",i0, & 578 &". IOSTAT = ",i0)' ) m, io_stat
582 WRITE( fid, iostat=io_stat ) &
583 nlte_predictor(m)%Tm , &
584 nlte_predictor(m)%Predictor, &
586 IF ( io_stat /= 0 )
THEN 587 WRITE( msg,
'("Error writing predictors and interpolation weights for profile ",i0, & 588 &". IOSTAT = ",i0)' ) m, io_stat
596 CLOSE( fid, iostat=io_stat )
597 IF ( io_stat /= 0 )
THEN 598 WRITE( msg,
'("Error closing ",a,". IOSTAT = ",i0)' ) trim(filename), io_stat
605 WRITE( msg,
'("Number of profiles written to ",a,": ",i0)' ) trim(filename), n_output_profiles
614 IF ( io_stat /= 0 ) &
615 msg = trim(msg)//
'; Error closing output file during error cleanup.' 648 CHARACTER(*),
INTENT(OUT) :: id
integer, parameter, public failure
integer function, public nlte_predictor_writefile(Filename, NLTE_Predictor, Quiet, Debug)
elemental subroutine, public nlte_predictor_destroy(NLTE_Predictor)
integer, parameter, public warning
integer, parameter, public long
logical function, public nlte_predictor_validrelease(NLTE_Predictor)
subroutine, public nlte_predictor_info(NLTE_Predictor, Info)
character(*), parameter write_error_status
integer, parameter, public double
character(*), parameter, private module_version_id
subroutine, public nlte_predictor_ioversion(Id)
subroutine inquire_cleanup()
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 nlte_predictor_inquirefile(Filename, n_Profiles, Release, Version)
integer function, public nlte_predictor_readfile(Filename, NLTE_Predictor, Quiet, n_Profiles, Debug)
integer, parameter, public success
integer, parameter, public information