41 PUBLIC ::
OPERATOR(==)
58 INTERFACE OPERATOR(==)
60 END INTERFACE OPERATOR(==)
67 '$Id: ASvar_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 74 REAL(fp),
PARAMETER ::
zero = 0.0_fp
75 REAL(fp),
PARAMETER ::
one = 1.0_fp
77 INTEGER,
PARAMETER ::
ml = 256
78 INTEGER,
PARAMETER ::
sl = 80
108 LOGICAL :: is_allocated = .false.
113 INTEGER :: n_legendre_terms = 0
114 INTEGER :: n_phase_elements = 0
115 INTEGER :: n_layers = 0
116 INTEGER :: n_aerosols = 0
120 REAL(fp),
ALLOCATABLE :: ke(:,:)
121 REAL(fp),
ALLOCATABLE :: w(:,:)
122 REAL(fp),
ALLOCATABLE :: g(:,:)
123 REAL(fp),
ALLOCATABLE :: pcoeff(:,:,:,:)
125 REAL(fp),
ALLOCATABLE :: total_bs(:)
143 status = self%Is_Allocated
149 self%Is_Allocated = .false.
150 self%n_Legendre_Terms = 0
151 self%n_Phase_Elements = 0
159 n_Legendre_Terms, & ! Input
160 n_Phase_Elements, & ! Input
165 INTEGER ,
INTENT(IN) :: n_legendre_terms
166 INTEGER ,
INTENT(IN) :: n_phase_elements
167 INTEGER ,
INTENT(IN) :: n_layers
168 INTEGER ,
INTENT(IN) :: n_aerosols
170 INTEGER :: alloc_stat
173 IF ( n_legendre_terms < 1 .OR. &
174 n_phase_elements < 1 .OR. &
176 n_aerosols < 1 )
RETURN 179 ALLOCATE( self%asi(n_layers, n_aerosols), &
180 self%ke(n_layers, n_aerosols), &
181 self%w(n_layers, n_aerosols), &
182 self%g(n_layers, n_aerosols), &
183 self%pcoeff(0:n_legendre_terms,n_phase_elements,n_layers, n_aerosols), &
184 self%total_bs(n_layers), &
186 IF ( alloc_stat /= 0 )
RETURN 190 self%n_Legendre_Terms = n_legendre_terms
191 self%n_Phase_Elements = n_phase_elements
192 self%n_Layers = n_layers
193 self%n_Aerosols = n_aerosols
196 self%Is_Allocated = .true.
202 INTEGER :: i2, i3, i4
203 WRITE(*,
'(1x,"ASvar OBJECT")')
206 WRITE(*,
'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
209 WRITE(*,
'(3x,"n_Legendre_Terms :",1x,i0)') self%n_Legendre_Terms
210 WRITE(*,
'(3x,"n_Phase_Elements :",1x,i0)') self%n_Phase_Elements
211 WRITE(*,
'(3x,"n_Layers :",1x,i0)') self%n_Layers
212 WRITE(*,
'(3x,"n_Aerosols :",1x,i0)') self%n_Aerosols
216 WRITE(*,
'(3x,"Mass extinction coefficient (ke) :")')
217 DO i4 = 1, self%n_Aerosols
218 WRITE(*,
'(5x,"ke Aerosol index #",i0)') i4
219 WRITE(*,
'(5(1x,es13.6,:))') self%ke(:,i4)
221 WRITE(*,
'(3x,"Single scatter albedo (w) :")')
222 DO i4 = 1, self%n_Aerosols
223 WRITE(*,
'(5x,"w Aerosol index #",i0)') i4
224 WRITE(*,
'(5(1x,es13.6,:))') self%w(:,i4)
226 WRITE(*,
'(3x,"Asymmetry factor (g) :")')
227 DO i4 = 1, self%n_Aerosols
228 WRITE(*,
'(5x,"g Aerosol index #",i0)') i4
229 WRITE(*,
'(5(1x,es13.6,:))') self%g(:,i4)
231 WRITE(*,
'(3x,"Phase coefficients (pcoeff) :")')
232 DO i4 = 1, self%n_Aerosols
233 WRITE(*,
'(5x,"pcoeff Aerosol index #",i0)') i4
234 DO i3 = 1, self%n_Layers
235 WRITE(*,
'(7x,"pcoeff Layer index #",i0)') i3
236 DO i2 = 1, self%n_Phase_Elements
237 WRITE(*,
'(9x,"pcoeff Phase element index #",i0)') i2
238 WRITE(*,
'(5(1x,es13.6,:))') self%pcoeff(0:,i2,i3,i4)
242 WRITE(*,
'(3x,"Volume scattering coefficient (total_bs) :")')
243 WRITE(*,
'(5(1x,es13.6,:))') self%total_bs
253 CHARACTER(*),
PARAMETER :: routine_name =
'ASvar_ValidRelease' 263 WRITE( msg,
'("An ASvar data update is needed. ", & 264 &"ASvar release is ",i0,". Valid release is ",i0,"." )' ) &
273 WRITE( msg,
'("An ASvar software update is needed. ", & 274 &"ASvar release is ",i0,". Valid release is ",i0,"." )' ) &
284 CHARACTER(*),
INTENT(OUT) :: info
286 INTEGER,
PARAMETER :: carriage_return = 13
287 INTEGER,
PARAMETER :: linefeed = 10
289 CHARACTER(2000) :: long_string
292 WRITE( long_string, &
293 '(a,1x,"ASvar RELEASE.VERSION: ",i2,".",i2.2,a,3x, & 294 &"N_LEGENDRE_TERMS=",i0,2x,& 295 &"N_PHASE_ELEMENTS=",i0,2x,& 297 &"N_AEROSOLS=",i0 )' ) &
298 achar(carriage_return)//achar(linefeed), &
299 self%Release, self%Version, &
300 achar(carriage_return)//achar(linefeed), &
301 self%n_Legendre_Terms, &
302 self%n_Phase_Elements, &
308 info = long_string(1:
min(len(info), len_trim(long_string)))
313 CHARACTER(*),
INTENT(OUT) :: id
320 n_Legendre_Terms, & ! Optional output
321 n_Phase_Elements, & ! Optional output
322 n_Layers , & ! Optional output
323 n_Aerosols , & ! Optional output
324 Release , & ! Optional output
325 Version , & ! Optional output
326 Title , & ! Optional output
327 History , & ! Optional output
331 CHARACTER(*),
INTENT(IN) :: filename
332 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_legendre_terms
333 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_phase_elements
334 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_layers
335 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_aerosols
336 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
337 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
338 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
339 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
340 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
344 CHARACTER(*),
PARAMETER :: routine_name =
'ASvar_InquireFile' 347 CHARACTER(ML) :: io_msg
357 msg =
'File '//trim(filename)//
' not found.' 364 IF ( err_stat /=
success )
THEN 365 msg =
'Error opening '//trim(filename)
371 READ( fid, iostat=io_stat, iomsg=io_msg ) &
374 IF ( io_stat /= 0 )
THEN 375 msg =
'Error reading Release/Version - '//trim(io_msg)
379 msg =
'ASvar Release check failed.' 385 READ( fid, iostat=io_stat, iomsg=io_msg ) &
386 asvar%n_Legendre_Terms, &
387 asvar%n_Phase_Elements, &
390 IF ( io_stat /= 0 )
THEN 391 msg =
'Error reading dimension values from '//trim(filename)//
' - '//trim(io_msg)
402 IF ( err_stat /=
success )
THEN 403 msg =
'Error reading global attributes' 409 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
410 IF ( io_stat /= 0 )
THEN 411 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
417 IF (
PRESENT(n_legendre_terms) ) n_legendre_terms = asvar%n_Legendre_Terms
418 IF (
PRESENT(n_phase_elements) ) n_phase_elements = asvar%n_Phase_Elements
419 IF (
PRESENT(n_layers ) ) n_layers = asvar%n_Layers
420 IF (
PRESENT(n_aerosols ) ) n_aerosols = asvar%n_Aerosols
421 IF (
PRESENT(release ) ) release = asvar%Release
422 IF (
PRESENT(version ) ) version = asvar%Version
429 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
430 IF ( io_stat /= 0 ) &
431 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
444 No_Close , & ! Optional input
445 Quiet , & ! Optional input
446 Title , & ! Optional output
447 History , & ! Optional output
448 Comment , & ! Optional output
453 CHARACTER(*),
INTENT(IN) :: filename
454 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
455 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
456 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
457 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
458 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
459 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
463 CHARACTER(*),
PARAMETER :: routine_name =
'ASvar_ReadFile' 466 CHARACTER(ML) :: io_msg
467 LOGICAL :: close_file
477 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
480 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
482 IF (
PRESENT(debug) )
THEN 483 IF ( debug ) noisy = .true.
490 INQUIRE( file=filename, number=fid )
493 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 500 IF ( err_stat /=
success )
THEN 501 msg =
'Error opening '//trim(filename)
505 msg =
'File '//trim(filename)//
' not found.' 512 READ( fid, iostat=io_stat, iomsg=io_msg ) &
515 IF ( io_stat /= 0 )
THEN 516 msg =
'Error reading Release/Version - '//trim(io_msg)
520 msg =
'ASvar Release check failed.' 526 READ( fid, iostat=io_stat, iomsg=io_msg ) &
527 dummy%n_Legendre_Terms, &
528 dummy%n_Phase_Elements, &
531 IF ( io_stat /= 0 )
THEN 532 msg =
'Error reading data dimensions - '//trim(io_msg)
538 dummy%n_Legendre_Terms, &
539 dummy%n_Phase_Elements, &
543 msg =
'ASvar object allocation failed.' 547 asvar%Version = dummy%Version
556 IF ( err_stat /=
success )
THEN 557 msg =
'Error reading global attributes' 564 READ( fid, iostat=io_stat, iomsg=io_msg ) &
566 IF ( io_stat /= 0 )
THEN 567 msg =
'Error reading mass extinction coefficient - '//trim(io_msg)
571 READ( fid, iostat=io_stat, iomsg=io_msg ) &
573 IF ( io_stat /= 0 )
THEN 574 msg =
'Error reading single scatter albedo - '//trim(io_msg)
578 READ( fid, iostat=io_stat, iomsg=io_msg ) &
580 IF ( io_stat /= 0 )
THEN 581 msg =
'Error reading asymmetry factor - '//trim(io_msg)
585 READ( fid, iostat=io_stat, iomsg=io_msg ) &
587 IF ( io_stat /= 0 )
THEN 588 msg =
'Error reading phase coefficients - '//trim(io_msg)
592 READ( fid, iostat=io_stat, iomsg=io_msg ) &
594 IF ( io_stat /= 0 )
THEN 595 msg =
'Error reading total volume scattering coefficient - '//trim(io_msg)
601 IF ( close_file )
THEN 602 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
603 IF ( io_stat /= 0 )
THEN 604 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
620 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
621 IF ( io_stat /= 0 ) &
622 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
635 No_Close , & ! Optional input
636 Quiet , & ! Optional input
637 Title , & ! Optional input
638 History , & ! Optional input
639 Comment , & ! Optional input
644 CHARACTER(*),
INTENT(IN) :: filename
645 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
646 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
647 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: title
648 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: history
649 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: comment
650 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
654 CHARACTER(*),
PARAMETER :: routine_name =
'ASvar_WriteFile' 657 CHARACTER(ML) :: io_msg
658 LOGICAL :: close_file
668 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
671 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
673 IF (
PRESENT(debug) )
THEN 674 IF ( debug ) noisy = .true.
678 msg =
'ASvar object is empty.' 686 INQUIRE( file=filename, number=fid )
689 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 695 IF ( err_stat /=
success )
THEN 696 msg =
'Error opening '//trim(filename)
703 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
706 IF ( io_stat /= 0 )
THEN 707 msg =
'Error writing Release/Version - '//trim(io_msg)
713 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
714 asvar%n_Legendre_Terms, &
715 asvar%n_Phase_Elements, &
718 IF ( io_stat /= 0 )
THEN 719 msg =
'Error writing data dimensions - '//trim(io_msg)
731 IF ( err_stat /=
success )
THEN 732 msg =
'Error writing global attributes' 739 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
741 IF ( io_stat /= 0 )
THEN 742 msg =
'Error writing mass extinction coefficient - '//trim(io_msg)
746 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
748 IF ( io_stat /= 0 )
THEN 749 msg =
'Error writing single scatter albedo - '//trim(io_msg)
753 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
755 IF ( io_stat /= 0 )
THEN 756 msg =
'Error writing asymmetry factor - '//trim(io_msg)
760 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
762 IF ( io_stat /= 0 )
THEN 763 msg =
'Error writing phase coefficients - '//trim(io_msg)
767 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
769 IF ( io_stat /= 0 )
THEN 770 msg =
'Error writing total volume scattering coefficient - '//trim(io_msg)
776 IF ( close_file )
THEN 777 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
778 IF ( io_stat /= 0 )
THEN 779 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
795 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
796 IF ( io_stat /= 0 ) &
797 msg = trim(msg)//
'; Error closing output file during error cleanup - '//trim(io_msg)
814 ELEMENTAL FUNCTION asvar_equal( x, y )
RESULT( is_equal )
827 IF ( (x%Release /= y%Release) .OR. &
828 (x%Version /= y%Version) )
RETURN 830 IF ( (x%n_Legendre_Terms /= y%n_Legendre_Terms ) .OR. &
831 (x%n_Phase_Elements /= y%n_Phase_Elements ) .OR. &
832 (x%n_Layers /= y%n_Layers ) .OR. &
833 (x%n_Aerosols /= y%n_Aerosols ) )
RETURN 835 IF ( all(x%ke .equalto. y%ke ) .AND. &
836 all(x%w .equalto. y%w ) .AND. &
837 all(x%g .equalto. y%g ) .AND. &
838 all(x%pcoeff .equalto. y%pcoeff ) .AND. &
839 all(x%total_bs .equalto. y%total_bs ) ) &
integer, parameter, public failure
subroutine, public asvar_inspect(self)
subroutine, public asvar_defineversion(Id)
character(*), parameter write_error_status
integer, parameter, public fp
integer function, public readgatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
elemental logical function asvar_equal(x, y)
subroutine inquire_cleanup()
integer function, public asvar_inquirefile(Filename, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Aerosols, Release, Version, Title, History, Comment)
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)
elemental subroutine, public asvar_destroy(self)
integer function, public asvar_readfile(ASvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
character(*), parameter module_version_id
logical function, public asvar_validrelease(self)
integer, parameter, public npts
elemental logical function, public asvar_associated(self)
integer, parameter asvar_version
integer function, public writegatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
subroutine, public asvar_info(self, Info)
integer function, public asvar_writefile(ASvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer, parameter asvar_release
elemental subroutine, public asvar_create(self, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Aerosols)
integer, parameter, public success
integer, parameter, public information