38 PUBLIC ::
OPERATOR(==)
55 INTERFACE OPERATOR(==)
57 END INTERFACE OPERATOR(==)
64 '$Id: AOvar_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 71 REAL(fp),
PARAMETER ::
zero = 0.0_fp
72 REAL(fp),
PARAMETER ::
one = 1.0_fp
74 INTEGER,
PARAMETER ::
ml = 256
75 INTEGER,
PARAMETER ::
sl = 80
85 LOGICAL :: is_allocated = .false.
90 INTEGER :: n_layers = 0
92 REAL(fp) :: transmittance =
zero 94 REAL(fp),
ALLOCATABLE :: optical_depth(:)
95 REAL(fp),
ALLOCATABLE :: bs(:)
96 REAL(fp),
ALLOCATABLE :: w(:)
114 status = self%Is_Allocated
120 self%Is_Allocated = .false.
130 INTEGER ,
INTENT(IN) :: n_layers
132 INTEGER :: alloc_stat
135 IF ( n_layers < 1 )
RETURN 138 ALLOCATE( self%optical_depth(n_layers), &
142 IF ( alloc_stat /= 0 )
RETURN 145 self%n_Layers = n_layers
148 self%Is_Allocated = .true.
154 WRITE(*,
'(1x,"AOvar OBJECT")')
157 WRITE(*,
'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
160 WRITE(*,
'(3x,"n_Layers :",1x,i0)') self%n_Layers
164 WRITE(*,
'(3x,"Total transmittance :",1x,es13.6)') self%transmittance
165 WRITE(*,
'(3x,"Optical depth (sigma) :")')
166 WRITE(*,
'(5(1x,es13.6,:))') self%optical_depth
167 WRITE(*,
'(3x,"Volume scattering coefficient (bs) :")')
168 WRITE(*,
'(5(1x,es13.6,:))') self%bs
169 WRITE(*,
'(3x,"Single scatter albedo (w) :")')
170 WRITE(*,
'(5(1x,es13.6,:))') self%w
180 CHARACTER(*),
PARAMETER :: routine_name =
'AOvar_ValidRelease' 190 WRITE( msg,
'("An AOvar data update is needed. ", & 191 &"AOvar release is ",i0,". Valid release is ",i0,"." )' ) &
199 WRITE( msg,
'("An AOvar software update is needed. ", & 200 &"AOvar release is ",i0,". Valid release is ",i0,"." )' ) &
210 CHARACTER(*),
INTENT(OUT) :: info
212 INTEGER,
PARAMETER :: carriage_return = 13
213 INTEGER,
PARAMETER :: linefeed = 10
215 CHARACTER(2000) :: long_string
218 WRITE( long_string, &
219 '(a,1x,"AOvar RELEASE.VERSION: ",i2,".",i2.2,a,3x, & 220 &"N_LAYERS=",i0 )' ) &
221 achar(carriage_return)//achar(linefeed), &
222 self%Release, self%Version, &
223 achar(carriage_return)//achar(linefeed), &
228 info = long_string(1:
min(len(info), len_trim(long_string)))
233 CHARACTER(*),
INTENT(OUT) :: id
240 n_Layers, & ! Optional output
241 Release , & ! Optional output
242 Version , & ! Optional output
243 Title , & ! Optional output
244 History , & ! Optional output
248 CHARACTER(*),
INTENT(IN) :: filename
249 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_layers
250 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
251 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
252 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
253 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
254 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
258 CHARACTER(*),
PARAMETER :: routine_name =
'AOvar_InquireFile' 261 CHARACTER(ML) :: io_msg
271 msg =
'File '//trim(filename)//
' not found.' 278 IF ( err_stat /=
success )
THEN 279 msg =
'Error opening '//trim(filename)
285 READ( fid, iostat=io_stat, iomsg=io_msg ) &
288 IF ( io_stat /= 0 )
THEN 289 msg =
'Error reading Release/Version - '//trim(io_msg)
293 msg =
'AOvar Release check failed.' 299 READ( fid, iostat=io_stat, iomsg=io_msg ) aovar%n_Layers
300 IF ( io_stat /= 0 )
THEN 301 msg =
'Error reading dimension values from '//trim(filename)//
' - '//trim(io_msg)
312 IF ( err_stat /=
success )
THEN 313 msg =
'Error reading global attributes' 319 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
320 IF ( io_stat /= 0 )
THEN 321 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
327 IF (
PRESENT(n_layers) ) n_layers = aovar%n_Layers
328 IF (
PRESENT(release ) ) release = aovar%Release
329 IF (
PRESENT(version ) ) version = aovar%Version
336 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
337 IF ( io_stat /= 0 ) &
338 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
351 No_Close , & ! Optional input
352 Quiet , & ! Optional input
353 Title , & ! Optional output
354 History , & ! Optional output
355 Comment , & ! Optional output
360 CHARACTER(*),
INTENT(IN) :: filename
361 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
362 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
363 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
364 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
365 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
366 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
370 CHARACTER(*),
PARAMETER :: routine_name =
'AOvar_ReadFile' 373 CHARACTER(ML) :: io_msg
374 LOGICAL :: close_file
384 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
387 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
389 IF (
PRESENT(debug) )
THEN 390 IF ( debug ) noisy = .true.
397 INQUIRE( file=filename, number=fid )
400 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 407 IF ( err_stat /=
success )
THEN 408 msg =
'Error opening '//trim(filename)
412 msg =
'File '//trim(filename)//
' not found.' 419 READ( fid, iostat=io_stat, iomsg=io_msg ) &
422 IF ( io_stat /= 0 )
THEN 423 msg =
'Error reading Release/Version - '//trim(io_msg)
427 msg =
'AOvar Release check failed.' 433 READ( fid, iostat=io_stat, iomsg=io_msg ) dummy%n_Layers
434 IF ( io_stat /= 0 )
THEN 435 msg =
'Error reading data dimensions - '//trim(io_msg)
441 msg =
'AOvar object allocation failed.' 445 aovar%Version = dummy%Version
454 IF ( err_stat /=
success )
THEN 455 msg =
'Error reading global attributes' 462 READ( fid, iostat=io_stat, iomsg=io_msg ) aovar%transmittance
463 IF ( io_stat /= 0 )
THEN 464 msg =
'Error reading total transmittance - '//trim(io_msg)
468 READ( fid, iostat=io_stat, iomsg=io_msg ) aovar%optical_depth
469 IF ( io_stat /= 0 )
THEN 470 msg =
'Error reading optical depth - '//trim(io_msg)
474 READ( fid, iostat=io_stat, iomsg=io_msg ) aovar%bs
475 IF ( io_stat /= 0 )
THEN 476 msg =
'Error reading volume scattering coefficient - '//trim(io_msg)
480 READ( fid, iostat=io_stat, iomsg=io_msg ) aovar%w
481 IF ( io_stat /= 0 )
THEN 482 msg =
'Error reading single scatter albedo - '//trim(io_msg)
488 IF ( close_file )
THEN 489 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
490 IF ( io_stat /= 0 )
THEN 491 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
507 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
508 IF ( io_stat /= 0 ) &
509 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
522 No_Close , & ! Optional input
523 Quiet , & ! Optional input
524 Title , & ! Optional input
525 History , & ! Optional input
526 Comment , & ! Optional input
531 CHARACTER(*),
INTENT(IN) :: filename
532 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
533 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
534 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: title
535 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: history
536 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: comment
537 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
541 CHARACTER(*),
PARAMETER :: routine_name =
'AOvar_WriteFile' 544 CHARACTER(ML) :: io_msg
545 LOGICAL :: close_file
555 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
558 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
560 IF (
PRESENT(debug) )
THEN 561 IF ( debug ) noisy = .true.
565 msg =
'AOvar object is empty.' 573 INQUIRE( file=filename, number=fid )
576 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 582 IF ( err_stat /=
success )
THEN 583 msg =
'Error opening '//trim(filename)
590 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
593 IF ( io_stat /= 0 )
THEN 594 msg =
'Error writing Release/Version - '//trim(io_msg)
600 WRITE( fid, iostat=io_stat, iomsg=io_msg ) aovar%n_Layers
601 IF ( io_stat /= 0 )
THEN 602 msg =
'Error writing data dimensions - '//trim(io_msg)
614 IF ( err_stat /=
success )
THEN 615 msg =
'Error writing global attributes' 622 WRITE( fid, iostat=io_stat, iomsg=io_msg ) aovar%transmittance
623 IF ( io_stat /= 0 )
THEN 624 msg =
'Error writing total transmittance - '//trim(io_msg)
628 WRITE( fid, iostat=io_stat, iomsg=io_msg ) aovar%optical_depth
629 IF ( io_stat /= 0 )
THEN 630 msg =
'Error writing optical depth - '//trim(io_msg)
634 WRITE( fid, iostat=io_stat, iomsg=io_msg ) aovar%bs
635 IF ( io_stat /= 0 )
THEN 636 msg =
'Error writing volume scattering coefficient - '//trim(io_msg)
640 WRITE( fid, iostat=io_stat, iomsg=io_msg ) aovar%w
641 IF ( io_stat /= 0 )
THEN 642 msg =
'Error writing single scatter albedo - '//trim(io_msg)
648 IF ( close_file )
THEN 649 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
650 IF ( io_stat /= 0 )
THEN 651 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
667 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
668 IF ( io_stat /= 0 ) &
669 msg = trim(msg)//
'; Error closing output file during error cleanup - '//trim(io_msg)
686 ELEMENTAL FUNCTION aovar_equal( x, y )
RESULT( is_equal )
699 IF ( (x%Release /= y%Release) .OR. &
700 (x%Version /= y%Version) )
RETURN 702 IF ( (x%n_Layers /= y%n_Layers ) )
RETURN 704 IF ( (x%transmittance .equalto. y%transmittance ) .AND. &
705 all(x%optical_depth .equalto. y%optical_depth ) .AND. &
706 all(x%bs .equalto. y%bs ) .AND. &
707 all(x%w .equalto. y%w ) ) &
integer, parameter, public failure
character(*), parameter module_version_id
elemental subroutine, public aovar_destroy(self)
integer, parameter, public fp
integer function, public readgatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
subroutine, public aovar_defineversion(Id)
elemental logical function aovar_equal(x, y)
character(*), parameter write_error_status
subroutine inquire_cleanup()
logical function, public aovar_validrelease(self)
elemental logical function, public aovar_associated(self)
subroutine, public aovar_info(self, Info)
subroutine read_cleanup()
integer, parameter aovar_release
subroutine write_cleanup()
integer function, public aovar_inquirefile(Filename, n_Layers, Release, Version, Title, History, Comment)
integer function, public aovar_writefile(AOvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
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 writegatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer, parameter aovar_version
elemental subroutine, public aovar_create(self, n_Layers)
integer function, public aovar_readfile(AOvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer, parameter, public success
integer, parameter, public information
subroutine, public aovar_inspect(self)