FV3 Bundle
AOvar_Define.f90
Go to the documentation of this file.
1 !
2 ! AOvar_Define
3 !
4 ! Module defining the CRTM AtmOptics module internal
5 ! variable object.
6 !
7 !
8 ! CREATION HISTORY:
9 ! Written by: Paul van Delst, 01-Jul-2013
10 ! paul.vandelst@noaa.gov
11 !
12 
14 
15  ! -----------------
16  ! Environment setup
17  ! -----------------
18  ! Module use
19  USE type_kinds , ONLY: fp
21  USE compare_float_numbers, ONLY: OPERATOR(.equalto.)
26  ! Disable implicit typing
27  IMPLICIT NONE
28 
29 
30  ! ------------
31  ! Visibilities
32  ! ------------
33  ! Everything private by default
34  PRIVATE
35  ! Datatypes
36  PUBLIC :: aovar_type
37  ! Operators
38  PUBLIC :: OPERATOR(==)
39  ! Procedures
40  PUBLIC :: aovar_associated
41  PUBLIC :: aovar_destroy
42  PUBLIC :: aovar_create
43  PUBLIC :: aovar_inspect
44  PUBLIC :: aovar_validrelease
45  PUBLIC :: aovar_info
46  PUBLIC :: aovar_defineversion
47  PUBLIC :: aovar_inquirefile
48  PUBLIC :: aovar_readfile
49  PUBLIC :: aovar_writefile
50 
51 
52  ! ---------------------
53  ! Procedure overloading
54  ! ---------------------
55  INTERFACE OPERATOR(==)
56  MODULE PROCEDURE aovar_equal
57  END INTERFACE OPERATOR(==)
58 
59 
60  ! -----------------
61  ! Module parameters
62  ! -----------------
63  CHARACTER(*), PARAMETER :: module_version_id = &
64  '$Id: AOvar_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
65  ! Release and version
66  INTEGER, PARAMETER :: aovar_release = 1 ! This determines structure and file formats.
67  INTEGER, PARAMETER :: aovar_version = 1 ! This is just the default data version.
68  ! Close status for write errors
69  CHARACTER(*), PARAMETER :: write_error_status = 'DELETE'
70  ! Literal constants
71  REAL(fp), PARAMETER :: zero = 0.0_fp
72  REAL(fp), PARAMETER :: one = 1.0_fp
73  ! String lengths
74  INTEGER, PARAMETER :: ml = 256 ! Message length
75  INTEGER, PARAMETER :: sl = 80 ! String length
76 
77 
78  ! ---------------------
79  ! Structure definitions
80  ! ---------------------
81  ! The internal variable definition to hold information
82  ! between FWD, TL, AD, and K-matrix calls
83  TYPE :: aovar_type
84  ! Allocation indicator
85  LOGICAL :: is_allocated = .false.
86  ! Release and version information
87  INTEGER :: release = aovar_release
88  INTEGER :: version = aovar_version
89  ! Dimensions
90  INTEGER :: n_layers = 0
91  ! The total atmospheric transmittance
92  REAL(fp) :: transmittance = zero
93  ! The profile data
94  REAL(fp), ALLOCATABLE :: optical_depth(:)
95  REAL(fp), ALLOCATABLE :: bs(:)
96  REAL(fp), ALLOCATABLE :: w(:)
97  END TYPE aovar_type
98 
99 
100 CONTAINS
101 
102 
103 !################################################################################
104 !################################################################################
105 !## ##
106 !## ## PUBLIC PROCEDURES ## ##
107 !## ##
108 !################################################################################
109 !################################################################################
110 
111  ELEMENTAL FUNCTION aovar_associated( self ) RESULT( Status )
112  TYPE(aovar_type), INTENT(IN) :: self
113  LOGICAL :: status
114  status = self%Is_Allocated
115  END FUNCTION aovar_associated
116 
117 
118  ELEMENTAL SUBROUTINE aovar_destroy( self )
119  TYPE(aovar_type), INTENT(OUT) :: self
120  self%Is_Allocated = .false.
121  self%n_Layers = 0
122  END SUBROUTINE aovar_destroy
123 
124 
125  ELEMENTAL SUBROUTINE aovar_create( &
126  self , & ! Output
127  n_Layers ) ! Input
128  ! Arguments
129  TYPE(aovar_type), INTENT(OUT) :: self
130  INTEGER , INTENT(IN) :: n_layers
131  ! Local variables
132  INTEGER :: alloc_stat
133 
134  ! Check input
135  IF ( n_layers < 1 ) RETURN
136 
137  ! Perform the allocation
138  ALLOCATE( self%optical_depth(n_layers), &
139  self%bs(n_layers), &
140  self%w(n_layers), &
141  stat = alloc_stat )
142  IF ( alloc_stat /= 0 ) RETURN
143 
144  ! Initialise dimensions only!
145  self%n_Layers = n_layers
146 
147  ! Set allocation indicator
148  self%Is_Allocated = .true.
149  END SUBROUTINE aovar_create
150 
151 
152  SUBROUTINE aovar_inspect( self)
153  TYPE(aovar_type), INTENT(IN) :: self
154  WRITE(*,'(1x,"AOvar OBJECT")')
155 
156  ! Release/version info
157  WRITE(*,'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
158 
159  ! Dimensions
160  WRITE(*,'(3x,"n_Layers :",1x,i0)') self%n_Layers
161  IF ( .NOT. aovar_associated(self) ) RETURN
162 
163  ! Data
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
171  END SUBROUTINE aovar_inspect
172 
173 
174  FUNCTION aovar_validrelease( self ) RESULT( IsValid )
175  ! Arguments
176  TYPE(aovar_type), INTENT(IN) :: self
177  ! Function result
178  LOGICAL :: isvalid
179  ! Local parameters
180  CHARACTER(*), PARAMETER :: routine_name = 'AOvar_ValidRelease'
181  ! Local variables
182  CHARACTER(ML) :: msg
183 
184  ! Set up
185  isvalid = .true.
186 
187  ! Check release is not too old
188  IF ( self%Release < aovar_release ) THEN
189  isvalid = .false.
190  WRITE( msg,'("An AOvar data update is needed. ", &
191  &"AOvar release is ",i0,". Valid release is ",i0,"." )' ) &
192  self%Release, aovar_release
193  CALL display_message( routine_name, msg, information ); RETURN
194  END IF
195 
196  ! Check release is not too new
197  IF ( self%Release > aovar_release ) THEN
198  isvalid = .false.
199  WRITE( msg,'("An AOvar software update is needed. ", &
200  &"AOvar release is ",i0,". Valid release is ",i0,"." )' ) &
201  self%Release, aovar_release
202  CALL display_message( routine_name, msg, information ); RETURN
203  END IF
204  END FUNCTION aovar_validrelease
205 
206 
207  SUBROUTINE aovar_info( self, Info )
208  ! Arguments
209  TYPE(aovar_type), INTENT(IN) :: self
210  CHARACTER(*), INTENT(OUT) :: info
211  ! Parameters
212  INTEGER, PARAMETER :: carriage_return = 13
213  INTEGER, PARAMETER :: linefeed = 10
214  ! Local variables
215  CHARACTER(2000) :: long_string
216 
217  ! Write the required data to the local 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), &
224  self%n_Layers
225 
226  ! Trim the output based on the
227  ! dummy argument string length
228  info = long_string(1:min(len(info), len_trim(long_string)))
229  END SUBROUTINE aovar_info
230 
231 
232  SUBROUTINE aovar_defineversion( Id )
233  CHARACTER(*), INTENT(OUT) :: id
234  id = module_version_id
235  END SUBROUTINE aovar_defineversion
236 
237 
238  FUNCTION aovar_inquirefile( &
239  Filename, & ! Input
240  n_Layers, & ! Optional output
241  Release , & ! Optional output
242  Version , & ! Optional output
243  Title , & ! Optional output
244  History , & ! Optional output
245  Comment ) & ! Optional output
246  result( err_stat )
247  ! Arguments
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
255  ! Function result
256  INTEGER :: err_stat
257  ! Function parameters
258  CHARACTER(*), PARAMETER :: routine_name = 'AOvar_InquireFile'
259  ! Function variables
260  CHARACTER(ML) :: msg
261  CHARACTER(ML) :: io_msg
262  INTEGER :: io_stat
263  INTEGER :: fid
264  TYPE(aovar_type) :: aovar
265 
266 
267  ! Setup
268  err_stat = success
269  ! ...Check that the file exists
270  IF ( .NOT. file_exists( filename ) ) THEN
271  msg = 'File '//trim(filename)//' not found.'
272  CALL inquire_cleanup(); RETURN
273  END IF
274 
275 
276  ! Open the file
277  err_stat = open_binary_file( filename, fid )
278  IF ( err_stat /= success ) THEN
279  msg = 'Error opening '//trim(filename)
280  CALL inquire_cleanup(); RETURN
281  END IF
282 
283 
284  ! Read the release and version
285  READ( fid, iostat=io_stat, iomsg=io_msg ) &
286  aovar%Release, &
287  aovar%Version
288  IF ( io_stat /= 0 ) THEN
289  msg = 'Error reading Release/Version - '//trim(io_msg)
290  CALL inquire_cleanup(); RETURN
291  END IF
292  IF ( .NOT. aovar_validrelease( aovar ) ) THEN
293  msg = 'AOvar Release check failed.'
294  CALL inquire_cleanup(); RETURN
295  END IF
296 
297 
298  ! Read the dimensions
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)
302  CALL inquire_cleanup(); RETURN
303  END IF
304 
305 
306  ! Read the global attributes
307  err_stat = readgatts_binary_file( &
308  fid, &
309  title = title , &
310  history = history, &
311  comment = comment )
312  IF ( err_stat /= success ) THEN
313  msg = 'Error reading global attributes'
314  CALL inquire_cleanup(); RETURN
315  END IF
316 
317 
318  ! Close the file
319  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
320  IF ( io_stat /= 0 ) THEN
321  msg = 'Error closing '//trim(filename)//' - '//trim(io_msg)
322  CALL inquire_cleanup(); RETURN
323  END IF
324 
325 
326  ! Assign the return arguments
327  IF ( PRESENT(n_layers) ) n_layers = aovar%n_Layers
328  IF ( PRESENT(release ) ) release = aovar%Release
329  IF ( PRESENT(version ) ) version = aovar%Version
330 
331  CONTAINS
332 
333  SUBROUTINE inquire_cleanup()
334  ! Close file if necessary
335  IF ( file_open(fid) ) THEN
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)
339  END IF
340  ! Set error status and print error message
341  err_stat = failure
342  CALL display_message( routine_name, msg, err_stat )
343  END SUBROUTINE inquire_cleanup
344 
345  END FUNCTION aovar_inquirefile
346 
347 
348  FUNCTION aovar_readfile( &
349  AOvar , & ! Output
350  Filename , & ! Input
351  No_Close , & ! Optional input
352  Quiet , & ! Optional input
353  Title , & ! Optional output
354  History , & ! Optional output
355  Comment , & ! Optional output
356  Debug ) & ! Optional input (Debug output control)
357  result( err_stat )
358  ! Arguments
359  TYPE(aovar_type), INTENT(OUT) :: aovar
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
367  ! Function result
368  INTEGER :: err_stat
369  ! Function parameters
370  CHARACTER(*), PARAMETER :: routine_name = 'AOvar_ReadFile'
371  ! Function variables
372  CHARACTER(ML) :: msg
373  CHARACTER(ML) :: io_msg
374  LOGICAL :: close_file
375  LOGICAL :: noisy
376  INTEGER :: io_stat
377  INTEGER :: fid
378  TYPE(aovar_type) :: dummy
379 
380  ! Setup
381  err_stat = success
382  ! ...Check No_Close argument
383  close_file = .true.
384  IF ( PRESENT(no_close) ) close_file = .NOT. no_close
385  ! ...Check Quiet argument
386  noisy = .true.
387  IF ( PRESENT(quiet) ) noisy = .NOT. quiet
388  ! ...Override Quiet settings if debug set.
389  IF ( PRESENT(debug) ) THEN
390  IF ( debug ) noisy = .true.
391  END IF
392 
393 
394  ! Check if the file is open.
395  IF ( file_open( filename ) ) THEN
396  ! ...Inquire for the logical unit number
397  INQUIRE( file=filename, number=fid )
398  ! ...Ensure it's valid
399  IF ( fid < 0 ) THEN
400  msg = 'Error inquiring '//trim(filename)//' for its FileID'
401  CALL read_cleanup(); RETURN
402  END IF
403  ELSE
404  ! ...Open the file if it exists
405  IF ( file_exists( filename ) ) THEN
406  err_stat = open_binary_file( filename, fid )
407  IF ( err_stat /= success ) THEN
408  msg = 'Error opening '//trim(filename)
409  CALL read_cleanup(); RETURN
410  END IF
411  ELSE
412  msg = 'File '//trim(filename)//' not found.'
413  CALL read_cleanup(); RETURN
414  END IF
415  END IF
416 
417 
418  ! Read and check the release and version
419  READ( fid, iostat=io_stat, iomsg=io_msg ) &
420  dummy%Release, &
421  dummy%Version
422  IF ( io_stat /= 0 ) THEN
423  msg = 'Error reading Release/Version - '//trim(io_msg)
424  CALL read_cleanup(); RETURN
425  END IF
426  IF ( .NOT. aovar_validrelease( dummy ) ) THEN
427  msg = 'AOvar Release check failed.'
428  CALL read_cleanup(); RETURN
429  END IF
430 
431 
432  ! Read the dimensions
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)
436  CALL read_cleanup(); RETURN
437  END IF
438  ! ...Allocate the object
439  CALL aovar_create( aovar, dummy%n_Layers )
440  IF ( .NOT. aovar_associated( aovar ) ) THEN
441  msg = 'AOvar object allocation failed.'
442  CALL read_cleanup(); RETURN
443  END IF
444  ! ...Explicitly assign the version number
445  aovar%Version = dummy%Version
446 
447 
448  ! Read the global attributes
449  err_stat = readgatts_binary_file( &
450  fid, &
451  title = title , &
452  history = history, &
453  comment = comment )
454  IF ( err_stat /= success ) THEN
455  msg = 'Error reading global attributes'
456  CALL read_cleanup(); RETURN
457  END IF
458 
459 
460  ! Read the data
461  ! ...total transmittance
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)
465  CALL read_cleanup(); RETURN
466  END IF
467  ! ...optical depth
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)
471  CALL read_cleanup(); RETURN
472  END IF
473  ! ...volume scattering coefficient
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)
477  CALL read_cleanup(); RETURN
478  END IF
479  ! ...single scatter albedo
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)
483  CALL read_cleanup(); RETURN
484  END IF
485 
486 
487  ! Close the file
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)
492  CALL read_cleanup(); RETURN
493  END IF
494  END IF
495 
496 
497  ! Output an info message
498  IF ( noisy ) THEN
499  CALL aovar_info( aovar, msg )
500  CALL display_message( routine_name, 'FILE: '//trim(filename)//'; '//trim(msg), information )
501  END IF
502 
503  CONTAINS
504 
505  SUBROUTINE read_cleanup()
506  IF ( file_open(filename) ) THEN
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)
510  END IF
511  CALL aovar_destroy( aovar )
512  err_stat = failure
513  CALL display_message( routine_name, msg, err_stat )
514  END SUBROUTINE read_cleanup
515 
516  END FUNCTION aovar_readfile
517 
518 
519  FUNCTION aovar_writefile( &
520  AOvar , & ! Input
521  Filename , & ! Input
522  No_Close , & ! Optional input
523  Quiet , & ! Optional input
524  Title , & ! Optional input
525  History , & ! Optional input
526  Comment , & ! Optional input
527  Debug ) & ! Optional input (Debug output control)
528  result( err_stat )
529  ! Arguments
530  TYPE(aovar_type), INTENT(IN) :: aovar
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
538  ! Function result
539  INTEGER :: err_stat
540  ! Function parameters
541  CHARACTER(*), PARAMETER :: routine_name = 'AOvar_WriteFile'
542  ! Function variables
543  CHARACTER(ML) :: msg
544  CHARACTER(ML) :: io_msg
545  LOGICAL :: close_file
546  LOGICAL :: noisy
547  INTEGER :: io_stat
548  INTEGER :: fid
549 
550 
551  ! Setup
552  err_stat = success
553  ! ...Check No_Close argument
554  close_file = .true.
555  IF ( PRESENT(no_close) ) close_file = .NOT. no_close
556  ! ...Check Quiet argument
557  noisy = .true.
558  IF ( PRESENT(quiet) ) noisy = .NOT. quiet
559  ! ...Override Quiet settings if debug set.
560  IF ( PRESENT(debug) ) THEN
561  IF ( debug ) noisy = .true.
562  END IF
563  ! ...Check there is data to write
564  IF ( .NOT. aovar_associated( aovar ) ) THEN
565  msg = 'AOvar object is empty.'
566  CALL write_cleanup(); RETURN
567  END IF
568 
569 
570  ! Check if the file is open.
571  IF ( file_open( filename ) ) THEN
572  ! ...Inquire for the logical unit number
573  INQUIRE( file=filename, number=fid )
574  ! ...Ensure it's valid
575  IF ( fid < 0 ) THEN
576  msg = 'Error inquiring '//trim(filename)//' for its FileID'
577  CALL write_cleanup(); RETURN
578  END IF
579  ELSE
580  ! ...Open the file for output
581  err_stat = open_binary_file( filename, fid, for_output=.true. )
582  IF ( err_stat /= success ) THEN
583  msg = 'Error opening '//trim(filename)
584  CALL write_cleanup(); RETURN
585  END IF
586  END IF
587 
588 
589  ! Write the release and version
590  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
591  aovar%Release, &
592  aovar%Version
593  IF ( io_stat /= 0 ) THEN
594  msg = 'Error writing Release/Version - '//trim(io_msg)
595  CALL write_cleanup(); RETURN
596  END IF
597 
598 
599  ! Write the dimensions
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)
603  CALL write_cleanup(); RETURN
604  END IF
605 
606 
607  ! Write the global attributes
608  err_stat = writegatts_binary_file( &
609  fid, &
610  write_module = module_version_id, &
611  title = title , &
612  history = history, &
613  comment = comment )
614  IF ( err_stat /= success ) THEN
615  msg = 'Error writing global attributes'
616  CALL write_cleanup(); RETURN
617  END IF
618 
619 
620  ! Write the data
621  ! ...total transmittance
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)
625  CALL write_cleanup(); RETURN
626  END IF
627  ! ...optical depth
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)
631  CALL write_cleanup(); RETURN
632  END IF
633  ! ...volume scattering coefficient
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)
637  CALL write_cleanup(); RETURN
638  END IF
639  ! ...single scatter albedo
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)
643  CALL write_cleanup(); RETURN
644  END IF
645 
646 
647  ! Close the file
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)
652  CALL write_cleanup(); RETURN
653  END IF
654  END IF
655 
656 
657  ! Output an info message
658  IF ( noisy ) THEN
659  CALL aovar_info( aovar, msg )
660  CALL display_message( routine_name, 'FILE: '//trim(filename)//'; '//trim(msg), information )
661  END IF
662 
663  CONTAINS
664 
665  SUBROUTINE write_cleanup()
666  IF ( file_open(filename) ) THEN
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)
670  END IF
671  err_stat = failure
672  CALL display_message( routine_name, msg, err_stat )
673  END SUBROUTINE write_cleanup
674 
675  END FUNCTION aovar_writefile
676 
677 
678 !################################################################################
679 !################################################################################
680 !## ##
681 !## ## PRIVATE PROCEDURES ## ##
682 !## ##
683 !################################################################################
684 !################################################################################
685 
686  ELEMENTAL FUNCTION aovar_equal( x, y ) RESULT( is_equal )
687  TYPE(aovar_type), INTENT(IN) :: x, y
688  LOGICAL :: is_equal
689 
690  ! Set up
691  is_equal = .false.
692 
693  ! Check the object association status
694  IF ( (.NOT. aovar_associated(x)) .OR. &
695  (.NOT. aovar_associated(y)) ) RETURN
696 
697  ! Check contents
698  ! ...Release/version info
699  IF ( (x%Release /= y%Release) .OR. &
700  (x%Version /= y%Version) ) RETURN
701  ! ...Dimensions
702  IF ( (x%n_Layers /= y%n_Layers ) ) RETURN
703  ! ...Data
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 ) ) &
708  is_equal = .true.
709  END FUNCTION aovar_equal
710 
711 END MODULE aovar_define
712 
real(fp), parameter one
integer, parameter, public failure
character(*), parameter module_version_id
elemental subroutine, public aovar_destroy(self)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
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)
real(fp), parameter zero
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
integer, parameter ml
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)
#define min(a, b)
Definition: mosaic_util.h:32
integer function, public aovar_readfile(AOvar, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer, parameter, public success
integer, parameter sl
integer, parameter, public information
subroutine, public aovar_inspect(self)