41 PUBLIC ::
OPERATOR(==)
58 INTERFACE OPERATOR(==)
60 END INTERFACE OPERATOR(==)
67 '$Id: CSvar_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
113 LOGICAL :: is_allocated = .false.
118 INTEGER :: n_legendre_terms = 0
119 INTEGER :: n_phase_elements = 0
120 INTEGER :: n_layers = 0
121 INTEGER :: n_clouds = 0
125 REAL(fp),
ALLOCATABLE :: ke(:,:)
126 REAL(fp),
ALLOCATABLE :: w(:,:)
127 REAL(fp),
ALLOCATABLE :: g(:,:)
128 REAL(fp),
ALLOCATABLE :: pcoeff(:,:,:,:)
130 REAL(fp),
ALLOCATABLE :: total_bs(:)
148 status = self%Is_Allocated
154 self%Is_Allocated = .false.
155 self%n_Legendre_Terms = 0
156 self%n_Phase_Elements = 0
164 n_Legendre_Terms, & ! Input
165 n_Phase_Elements, & ! Input
170 INTEGER ,
INTENT(IN) :: n_legendre_terms
171 INTEGER ,
INTENT(IN) :: n_phase_elements
172 INTEGER ,
INTENT(IN) :: n_layers
173 INTEGER ,
INTENT(IN) :: n_clouds
175 INTEGER :: alloc_stat
178 IF ( n_legendre_terms < 1 .OR. &
179 n_phase_elements < 1 .OR. &
181 n_clouds < 1 )
RETURN 184 ALLOCATE( self%csi(n_layers, n_clouds), &
185 self%ke(n_layers, n_clouds), &
186 self%w(n_layers, n_clouds), &
187 self%g(n_layers, n_clouds), &
188 self%pcoeff(0:n_legendre_terms,n_phase_elements,n_layers, n_clouds), &
189 self%total_bs(n_layers), &
191 IF ( alloc_stat /= 0 )
RETURN 195 self%n_Legendre_Terms = n_legendre_terms
196 self%n_Phase_Elements = n_phase_elements
197 self%n_Layers = n_layers
198 self%n_Clouds = n_clouds
201 self%Is_Allocated = .true.
207 INTEGER :: i2, i3, i4
208 WRITE(*,
'(1x,"CSvar OBJECT")')
211 WRITE(*,
'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
214 WRITE(*,
'(3x,"n_Legendre_Terms :",1x,i0)') self%n_Legendre_Terms
215 WRITE(*,
'(3x,"n_Phase_Elements :",1x,i0)') self%n_Phase_Elements
216 WRITE(*,
'(3x,"n_Layers :",1x,i0)') self%n_Layers
217 WRITE(*,
'(3x,"n_Clouds :",1x,i0)') self%n_Clouds
221 WRITE(*,
'(3x,"Mass extinction coefficient (ke) :")')
222 DO i4 = 1, self%n_Clouds
223 WRITE(*,
'(5x,"ke Cloud index #",i0)') i4
224 WRITE(*,
'(5(1x,es13.6,:))') self%ke(:,i4)
226 WRITE(*,
'(3x,"Single scatter albedo (w) :")')
227 DO i4 = 1, self%n_Clouds
228 WRITE(*,
'(5x,"w Cloud index #",i0)') i4
229 WRITE(*,
'(5(1x,es13.6,:))') self%w(:,i4)
231 WRITE(*,
'(3x,"Asymmetry factor (g) :")')
232 DO i4 = 1, self%n_Clouds
233 WRITE(*,
'(5x,"g Cloud index #",i0)') i4
234 WRITE(*,
'(5(1x,es13.6,:))') self%g(:,i4)
236 WRITE(*,
'(3x,"Phase coefficients (pcoeff) :")')
237 DO i4 = 1, self%n_Clouds
238 WRITE(*,
'(5x,"pcoeff Cloud index #",i0)') i4
239 DO i3 = 1, self%n_Layers
240 WRITE(*,
'(7x,"pcoeff Layer index #",i0)') i3
241 DO i2 = 1, self%n_Phase_Elements
242 WRITE(*,
'(9x,"pcoeff Phase element index #",i0)') i2
243 WRITE(*,
'(5(1x,es13.6,:))') self%pcoeff(0:,i2,i3,i4)
247 WRITE(*,
'(3x,"Volume scattering coefficient (total_bs) :")')
248 WRITE(*,
'(5(1x,es13.6,:))') self%total_bs
258 CHARACTER(*),
PARAMETER :: routine_name =
'CSvar_ValidRelease' 268 WRITE( msg,
'("An CSvar data update is needed. ", & 269 &"CSvar release is ",i0,". Valid release is ",i0,"." )' ) &
278 WRITE( msg,
'("An CSvar software update is needed. ", & 279 &"CSvar release is ",i0,". Valid release is ",i0,"." )' ) &
289 CHARACTER(*),
INTENT(OUT) :: info
291 INTEGER,
PARAMETER :: carriage_return = 13
292 INTEGER,
PARAMETER :: linefeed = 10
294 CHARACTER(2000) :: long_string
297 WRITE( long_string, &
298 '(a,1x,"CSvar RELEASE.VERSION: ",i2,".",i2.2,a,3x, & 299 &"N_LEGENDRE_TERMS=",i0,2x,& 300 &"N_PHASE_ELEMENTS=",i0,2x,& 302 &"N_CLOUDS=",i0 )' ) &
303 achar(carriage_return)//achar(linefeed), &
304 self%Release, self%Version, &
305 achar(carriage_return)//achar(linefeed), &
306 self%n_Legendre_Terms, &
307 self%n_Phase_Elements, &
313 info = long_string(1:
min(len(info), len_trim(long_string)))
318 CHARACTER(*),
INTENT(OUT) :: id
325 n_Legendre_Terms, & ! Optional output
326 n_Phase_Elements, & ! Optional output
327 n_Layers , & ! Optional output
328 n_Clouds , & ! Optional output
329 Release , & ! Optional output
330 Version , & ! Optional output
331 Title , & ! Optional output
332 History , & ! Optional output
336 CHARACTER(*),
INTENT(IN) :: filename
337 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_legendre_terms
338 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_phase_elements
339 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_layers
340 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_clouds
341 INTEGER ,
OPTIONAL,
INTENT(OUT) :: release
342 INTEGER ,
OPTIONAL,
INTENT(OUT) :: version
343 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
344 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
345 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
349 CHARACTER(*),
PARAMETER :: routine_name =
'CSvar_InquireFile' 352 CHARACTER(ML) :: io_msg
362 msg =
'File '//trim(filename)//
' not found.' 369 IF ( err_stat /=
success )
THEN 370 msg =
'Error opening '//trim(filename)
376 READ( fid, iostat=io_stat, iomsg=io_msg ) &
379 IF ( io_stat /= 0 )
THEN 380 msg =
'Error reading Release/Version - '//trim(io_msg)
384 msg =
'CSvar Release check failed.' 390 READ( fid, iostat=io_stat, iomsg=io_msg ) &
391 csvar%n_Legendre_Terms, &
392 csvar%n_Phase_Elements, &
395 IF ( io_stat /= 0 )
THEN 396 msg =
'Error reading dimension values from '//trim(filename)//
' - '//trim(io_msg)
407 IF ( err_stat /=
success )
THEN 408 msg =
'Error reading global attributes' 414 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
415 IF ( io_stat /= 0 )
THEN 416 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
422 IF (
PRESENT(n_legendre_terms) ) n_legendre_terms = csvar%n_Legendre_Terms
423 IF (
PRESENT(n_phase_elements) ) n_phase_elements = csvar%n_Phase_Elements
424 IF (
PRESENT(n_layers ) ) n_layers = csvar%n_Layers
425 IF (
PRESENT(n_clouds ) ) n_clouds = csvar%n_Clouds
426 IF (
PRESENT(release ) ) release = csvar%Release
427 IF (
PRESENT(version ) ) version = csvar%Version
434 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
435 IF ( io_stat /= 0 ) &
436 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
449 No_Close , & ! Optional input
450 Quiet , & ! Optional input
451 Title , & ! Optional output
452 History , & ! Optional output
453 Comment , & ! Optional output
458 CHARACTER(*),
INTENT(IN) :: filename
459 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
460 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
461 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
462 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: history
463 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: comment
464 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
468 CHARACTER(*),
PARAMETER :: routine_name =
'CSvar_ReadFile' 471 CHARACTER(ML) :: io_msg
472 LOGICAL :: close_file
482 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
485 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
487 IF (
PRESENT(debug) )
THEN 488 IF ( debug ) noisy = .true.
495 INQUIRE( file=filename, number=fid )
498 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 505 IF ( err_stat /=
success )
THEN 506 msg =
'Error opening '//trim(filename)
510 msg =
'File '//trim(filename)//
' not found.' 517 READ( fid, iostat=io_stat, iomsg=io_msg ) &
520 IF ( io_stat /= 0 )
THEN 521 msg =
'Error reading Release/Version - '//trim(io_msg)
525 msg =
'CSvar Release check failed.' 531 READ( fid, iostat=io_stat, iomsg=io_msg ) &
532 dummy%n_Legendre_Terms, &
533 dummy%n_Phase_Elements, &
536 IF ( io_stat /= 0 )
THEN 537 msg =
'Error reading data dimensions - '//trim(io_msg)
543 dummy%n_Legendre_Terms, &
544 dummy%n_Phase_Elements, &
548 msg =
'CSvar object allocation failed.' 552 csvar%Version = dummy%Version
561 IF ( err_stat /=
success )
THEN 562 msg =
'Error reading global attributes' 569 READ( fid, iostat=io_stat, iomsg=io_msg ) &
571 IF ( io_stat /= 0 )
THEN 572 msg =
'Error reading mass extinction coefficient - '//trim(io_msg)
576 READ( fid, iostat=io_stat, iomsg=io_msg ) &
578 IF ( io_stat /= 0 )
THEN 579 msg =
'Error reading single scatter albedo - '//trim(io_msg)
583 READ( fid, iostat=io_stat, iomsg=io_msg ) &
585 IF ( io_stat /= 0 )
THEN 586 msg =
'Error reading asymmetry factor - '//trim(io_msg)
590 READ( fid, iostat=io_stat, iomsg=io_msg ) &
592 IF ( io_stat /= 0 )
THEN 593 msg =
'Error reading phase coefficients - '//trim(io_msg)
597 READ( fid, iostat=io_stat, iomsg=io_msg ) &
599 IF ( io_stat /= 0 )
THEN 600 msg =
'Error reading total volume scattering coefficient - '//trim(io_msg)
606 IF ( close_file )
THEN 607 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
608 IF ( io_stat /= 0 )
THEN 609 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
625 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
626 IF ( io_stat /= 0 ) &
627 msg = trim(msg)//
'; Error closing input file during error cleanup - '//trim(io_msg)
640 No_Close , & ! Optional input
641 Quiet , & ! Optional input
642 Title , & ! Optional input
643 History , & ! Optional input
644 Comment , & ! Optional input
649 CHARACTER(*),
INTENT(IN) :: filename
650 LOGICAL,
OPTIONAL,
INTENT(IN) :: no_close
651 LOGICAL,
OPTIONAL,
INTENT(IN) :: quiet
652 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: title
653 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: history
654 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: comment
655 LOGICAL,
OPTIONAL,
INTENT(IN) :: debug
659 CHARACTER(*),
PARAMETER :: routine_name =
'CSvar_WriteFile' 662 CHARACTER(ML) :: io_msg
663 LOGICAL :: close_file
673 IF (
PRESENT(no_close) ) close_file = .NOT. no_close
676 IF (
PRESENT(quiet) ) noisy = .NOT. quiet
678 IF (
PRESENT(debug) )
THEN 679 IF ( debug ) noisy = .true.
683 msg =
'CSvar object is empty.' 691 INQUIRE( file=filename, number=fid )
694 msg =
'Error inquiring '//trim(filename)//
' for its FileID' 700 IF ( err_stat /=
success )
THEN 701 msg =
'Error opening '//trim(filename)
708 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
711 IF ( io_stat /= 0 )
THEN 712 msg =
'Error writing Release/Version - '//trim(io_msg)
718 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
719 csvar%n_Legendre_Terms, &
720 csvar%n_Phase_Elements, &
723 IF ( io_stat /= 0 )
THEN 724 msg =
'Error writing data dimensions - '//trim(io_msg)
736 IF ( err_stat /=
success )
THEN 737 msg =
'Error writing global attributes' 744 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
746 IF ( io_stat /= 0 )
THEN 747 msg =
'Error writing mass extinction coefficient - '//trim(io_msg)
751 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
753 IF ( io_stat /= 0 )
THEN 754 msg =
'Error writing single scatter albedo - '//trim(io_msg)
758 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
760 IF ( io_stat /= 0 )
THEN 761 msg =
'Error writing asymmetry factor - '//trim(io_msg)
765 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
767 IF ( io_stat /= 0 )
THEN 768 msg =
'Error writing phase coefficients - '//trim(io_msg)
772 WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
774 IF ( io_stat /= 0 )
THEN 775 msg =
'Error writing total volume scattering coefficient - '//trim(io_msg)
781 IF ( close_file )
THEN 782 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
783 IF ( io_stat /= 0 )
THEN 784 msg =
'Error closing '//trim(filename)//
' - '//trim(io_msg)
800 CLOSE( fid, iostat=io_stat, iomsg=io_msg )
801 IF ( io_stat /= 0 ) &
802 msg = trim(msg)//
'; Error closing output file during error cleanup - '//trim(io_msg)
819 ELEMENTAL FUNCTION csvar_equal( x, y )
RESULT( is_equal )
832 IF ( (x%Release /= y%Release) .OR. &
833 (x%Version /= y%Version) )
RETURN 835 IF ( (x%n_Legendre_Terms /= y%n_Legendre_Terms ) .OR. &
836 (x%n_Phase_Elements /= y%n_Phase_Elements ) .OR. &
837 (x%n_Layers /= y%n_Layers ) .OR. &
838 (x%n_Clouds /= y%n_Clouds ) )
RETURN 840 IF ( all(x%ke .equalto. y%ke ) .AND. &
841 all(x%w .equalto. y%w ) .AND. &
842 all(x%g .equalto. y%g ) .AND. &
843 all(x%pcoeff .equalto. y%pcoeff ) .AND. &
844 all(x%total_bs .equalto. y%total_bs ) ) &
subroutine, public csvar_defineversion(Id)
logical function, public csvar_validrelease(self)
integer, parameter, public failure
integer, parameter, public fp
integer function, public readgatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer function, public csvar_writefile(CSvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
subroutine inquire_cleanup()
elemental subroutine, public csvar_create(self, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Clouds)
character(*), parameter write_error_status
subroutine read_cleanup()
subroutine write_cleanup()
subroutine, public csvar_inspect(self)
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 logical function, public csvar_associated(self)
subroutine, public csvar_info(self, Info)
elemental subroutine, public csvar_destroy(self)
elemental logical function csvar_equal(x, y)
integer function, public csvar_readfile(CSvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer, parameter, public npts
character(*), parameter module_version_id
integer, parameter csvar_release
integer function, public writegatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer, parameter, public success
integer, parameter, public information
integer function, public csvar_inquirefile(Filename, n_Legendre_Terms, n_Phase_Elements, n_Layers, n_Clouds, Release, Version, Title, History, Comment)
integer, parameter csvar_version