FV3 Bundle
PAFV_Define.f90
Go to the documentation of this file.
1 !
2 ! PAFV_Define
3 !
4 ! Module defining the PAFV object.
5 !
6 !
7 ! CREATION HISTORY:
8 ! Written by: Paul van Delst, 21-Mar-2012
9 ! paul.vandelst@noaa.gov
10 
12 
13  ! -----------------
14  ! Environment setup
15  ! -----------------
16  ! Module use
17  USE type_kinds , ONLY: fp
19  USE compare_float_numbers, ONLY: OPERATOR(.equalto.)
24  ! Disable implicit typing
25  IMPLICIT NONE
26 
27 
28  ! ------------
29  ! Visibilities
30  ! ------------
31  ! Everything private by default
32  PRIVATE
33  ! Datatypes
34  PUBLIC :: pafv_type
35  ! Operators
36  PUBLIC :: OPERATOR(==)
37  ! Procedures
38  PUBLIC :: pafv_associated
39  PUBLIC :: pafv_destroy
40  PUBLIC :: pafv_create
41  PUBLIC :: pafv_inspect
42  PUBLIC :: pafv_validrelease
43  PUBLIC :: pafv_info
44  PUBLIC :: pafv_defineversion
45  PUBLIC :: pafv_inquirefile
46  PUBLIC :: pafv_readfile
47  PUBLIC :: pafv_writefile
48 
49 
50  ! ---------------------
51  ! Procedure overloading
52  ! ---------------------
53  INTERFACE OPERATOR(==)
54  MODULE PROCEDURE pafv_equal
55  END INTERFACE OPERATOR(==)
56 
57 
58  ! -----------------
59  ! Module parameters
60  ! -----------------
61  CHARACTER(*), PARAMETER :: module_version_id = &
62  '$Id: PAFV_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
63  ! Release and version
64  INTEGER, PARAMETER :: pafv_release = 2 ! This determines structure and file formats.
65  INTEGER, PARAMETER :: pafv_version = 1 ! This is just the default data version.
66  ! Close status for write errors
67  CHARACTER(*), PARAMETER :: write_error_status = 'DELETE'
68  ! Literal constants
69  REAL(fp), PARAMETER :: zero = 0.0_fp
70  REAL(fp), PARAMETER :: one = 1.0_fp
71  ! String lengths
72  INTEGER, PARAMETER :: ml = 256 ! Message length
73  ! Compact-OPTRAN data indicator
74  INTEGER, PARAMETER :: data_missing = 0
75  INTEGER, PARAMETER :: data_present = 1
76  ! Compact-OPTRAN max. order and number of predictors
77  INTEGER, PUBLIC, PARAMETER :: max_optran_order = 10
78  INTEGER, PUBLIC, PARAMETER :: max_optran_predictors = 14
79  INTEGER, PUBLIC, PARAMETER :: max_optran_used_predictors = 6
80 
81 
82  ! -------------------------
83  ! PAFV data type definition
84  ! -------------------------
85  !:tdoc+:
86  TYPE :: pafv_type
87  ! Allocation indicator
88  LOGICAL :: is_allocated = .false.
89  ! Release and version information
90  INTEGER :: release = pafv_release
91  INTEGER :: version = pafv_version
92  ! Dimensions variables
93  INTEGER :: n_odps_layers = 0 ! K
94  INTEGER :: n_absorbers = 0 ! J
95  INTEGER :: n_user_layers = 0 ! uK
96  ! ODPS Forward variables
97  ! ...Index array for ODPS to user profile interpolations
98  INTEGER, ALLOCATABLE :: odps2user_idx(:,:) ! 2 x 0:uK
99  ! ...Index array for user to ODPS profile interpolations
100  INTEGER, ALLOCATABLE :: interp_index(:,:) ! 2 x K
101  ! ...Accumulated weighting factors array for user to ODPS profile interpolations
102  REAL(fp), ALLOCATABLE :: acc_weighting(:,:) ! uK x K
103  ! ...Profile data
104  REAL(fp), ALLOCATABLE :: temperature(:) ! K
105  REAL(fp), ALLOCATABLE :: absorber(:,:) ! K x J
106  INTEGER, ALLOCATABLE :: idx_map(:) ! K
107  INTEGER :: h2o_idx = 0
108  ! Pressure profiles for interpolations
109  REAL(fp), ALLOCATABLE :: ref_lnpressure(:) ! K
110  REAL(fp), ALLOCATABLE :: user_lnpressure(:) ! uK
111  ! Predictor Forward variables
112  REAL(fp), ALLOCATABLE :: pdp(:) ! K
113  REAL(fp), ALLOCATABLE :: tz_ref(:) ! K
114  REAL(fp), ALLOCATABLE :: tz(:) ! K
115  REAL(fp), ALLOCATABLE :: tzp_ref(:) ! K
116  REAL(fp), ALLOCATABLE :: tzp(:) ! K
117  ! ...
118  REAL(fp), ALLOCATABLE :: gaz_ref(:,:) ! K x J
119  REAL(fp), ALLOCATABLE :: gaz_sum(:,:) ! K x J
120  REAL(fp), ALLOCATABLE :: gaz(:,:) ! K x J
121  REAL(fp), ALLOCATABLE :: gazp_ref(:,:) ! K x J
122  REAL(fp), ALLOCATABLE :: gazp_sum(:,:) ! K x J
123  REAL(fp), ALLOCATABLE :: gazp(:,:) ! K x J
124  REAL(fp), ALLOCATABLE :: gatzp_ref(:,:) ! K x J
125  REAL(fp), ALLOCATABLE :: gatzp_sum(:,:) ! K x J
126  REAL(fp), ALLOCATABLE :: gatzp(:,:) ! K x J
127  ! ...
128  REAL(fp), ALLOCATABLE :: dt(:) ! K
129  REAL(fp), ALLOCATABLE :: t(:) ! K
130  REAL(fp), ALLOCATABLE :: t2(:) ! K
131  REAL(fp), ALLOCATABLE :: dt2(:) ! K
132  REAL(fp), ALLOCATABLE :: h2o(:) ! K
133  REAL(fp), ALLOCATABLE :: h2o_a(:) ! K
134  REAL(fp), ALLOCATABLE :: h2o_r(:) ! K
135  REAL(fp), ALLOCATABLE :: h2o_s(:) ! K
136  REAL(fp), ALLOCATABLE :: h2o_r4(:) ! K
137  REAL(fp), ALLOCATABLE :: h2odh2otzp(:) ! K
138  REAL(fp), ALLOCATABLE :: co2(:) ! K
139  REAL(fp), ALLOCATABLE :: o3(:) ! K
140  REAL(fp), ALLOCATABLE :: o3_a(:) ! K
141  REAL(fp), ALLOCATABLE :: o3_r(:) ! K
142  REAL(fp), ALLOCATABLE :: co(:) ! K
143  REAL(fp), ALLOCATABLE :: co_a(:) ! K
144  REAL(fp), ALLOCATABLE :: co_r(:) ! K
145  REAL(fp), ALLOCATABLE :: co_s(:) ! K
146  REAL(fp), ALLOCATABLE :: co_acodcozp(:) ! K
147  REAL(fp), ALLOCATABLE :: n2o(:) ! K
148  REAL(fp), ALLOCATABLE :: n2o_a(:) ! K
149  REAL(fp), ALLOCATABLE :: n2o_r(:) ! K
150  REAL(fp), ALLOCATABLE :: n2o_s(:) ! K
151  REAL(fp), ALLOCATABLE :: ch4(:) ! K
152  REAL(fp), ALLOCATABLE :: ch4_a(:) ! K
153  REAL(fp), ALLOCATABLE :: ch4_r(:) ! K
154  REAL(fp), ALLOCATABLE :: ch4_ach4zp(:) ! K
155  ! Optical depth Forward variables
156  REAL(fp), ALLOCATABLE :: od(:) ! K
157  REAL(fp), ALLOCATABLE :: od_path(:) ! K
158  ! Zeeman specific Forward variables
159  REAL(fp) :: w1, w2 ! weights for two-points linear interpolation
160  INTEGER :: inode ! node position
161  ! Compact-OPTRAN Forward variables
162  LOGICAL :: optran = .false.
163  ! ...Dimensions
164  INTEGER :: n_oused_pred = max_optran_used_predictors ! oI; No. of OPTRAN used predictors
165  ! ...Predictor variables
166  REAL(fp), ALLOCATABLE :: dpong(:) ! K
167  REAL(fp), ALLOCATABLE :: d_absorber(:) ! K
168  REAL(fp), ALLOCATABLE :: int_vapor(:) ! K
169  REAL(fp), ALLOCATABLE :: avea(:) ! K
170  REAL(fp), ALLOCATABLE :: inverse(:) ! K
171  REAL(fp), ALLOCATABLE :: s_t(:) ! K
172  REAL(fp), ALLOCATABLE :: s_p(:) ! K
173  REAL(fp), ALLOCATABLE :: ap1(:) ! K
174  ! ...Optical depth variables
175  REAL(fp), ALLOCATABLE :: b(:,:) ! K x 0:oI
176  REAL(fp), ALLOCATABLE :: ln_chi(:) ! K
177  REAL(fp), ALLOCATABLE :: chi(:) ! K
178  END TYPE pafv_type
179  !:tdoc-:
180 
181 
182 CONTAINS
183 
184 
185 !--------------------------------------------------------------------------------
186 !:sdoc+:
187 !
188 ! NAME:
189 ! PAFV_Associated
190 !
191 ! PURPOSE:
192 ! Elemental function to test the status of the allocatable components
193 ! of the PAFV structure.
194 !
195 ! CALLING SEQUENCE:
196 ! Status = PAFV_Associated( PAFV )
197 !
198 ! OBJECTS:
199 ! PAFV:
200 ! Structure which is to have its member's
201 ! status tested.
202 ! UNITS: N/A
203 ! TYPE: PAFV_type
204 ! DIMENSION: Scalar or any rank
205 ! ATTRIBUTES: INTENT(IN)
206 !
207 ! FUNCTION RESULT:
208 ! Status:
209 ! The return value is a logical value indicating the
210 ! status of the allocated members.
211 ! .TRUE. - if ANY of the PAFV allocatable members
212 ! are in use.
213 ! .FALSE. - if ALL of the PAFV allocatable members
214 ! are not in use.
215 ! UNITS: N/A
216 ! TYPE: LOGICAL
217 ! DIMENSION: Same as input
218 !
219 !:sdoc-:
220 !--------------------------------------------------------------------------------
221 
222  ELEMENTAL FUNCTION pafv_associated( self ) RESULT( Status )
223  TYPE(pafv_type), INTENT(IN) :: self
224  LOGICAL :: status
225  status = self%Is_Allocated
226  END FUNCTION pafv_associated
227 
228 
229 !--------------------------------------------------------------------------------
230 !:sdoc+:
231 !
232 ! NAME:
233 ! PAFV_Destroy
234 !
235 ! PURPOSE:
236 ! Elemental subroutine to re-initialize PAFV objects.
237 !
238 ! CALLING SEQUENCE:
239 ! CALL PAFV_Destroy( PAFV )
240 !
241 ! OBJECTS:
242 ! PAFV:
243 ! Re-initialized PAFV structure.
244 ! UNITS: N/A
245 ! TYPE: PAFV_type
246 ! DIMENSION: Scalar or any rank
247 ! ATTRIBUTES: INTENT(OUT)
248 !
249 !:sdoc-:
250 !--------------------------------------------------------------------------------
251 
252  ELEMENTAL SUBROUTINE pafv_destroy( self )
253  TYPE(pafv_type), INTENT(OUT) :: self
254  self%Is_Allocated = .false.
255  END SUBROUTINE pafv_destroy
256 
257 
258 !--------------------------------------------------------------------------------
259 !:sdoc+:
260 !
261 ! NAME:
262 ! PAFV_Create
263 !
264 ! PURPOSE:
265 ! Elemental subroutine to create an instance of an PAFV object.
266 !
267 ! CALLING SEQUENCE:
268 ! CALL PAFV_Create( &
269 ! PAFV , &
270 ! n_ODPS_Layers, &
271 ! n_User_Layers, &
272 ! n_Absorbers , &
273 ! No_OPTRAN = No_OPTRAN )
274 !
275 ! OBJECTS:
276 ! PAFV:
277 ! PAFV object structure.
278 ! UNITS: N/A
279 ! TYPE: PAFV_type
280 ! DIMENSION: Scalar or any rank
281 ! ATTRIBUTES: INTENT(OUT)
282 !
283 ! INPUTS:
284 ! n_ODPS_Layers:
285 ! Number of internal ODPS layers that are defined
286 ! in the ODPS TauCoeff data file.
287 ! Must be > 0.
288 ! UNITS: N/A
289 ! TYPE: INTEGER
290 ! DIMENSION: Conformable with the PAFV object
291 ! ATTRIBUTES: INTENT(IN)
292 !
293 ! n_User_Layers:
294 ! Number of atmospheric layers defined by user.
295 ! Must be > 0.
296 ! UNITS: N/A
297 ! TYPE: INTEGER
298 ! DIMENSION: Conformable with the PAFV object
299 ! ATTRIBUTES: INTENT(IN)
300 !
301 ! n_Absorbers:
302 ! Number of gaseous absorbers.
303 ! Must be > 0.
304 ! UNITS: N/A
305 ! TYPE: INTEGER
306 ! DIMENSION: Conformable with the PAFV object
307 ! ATTRIBUTES: INTENT(IN)
308 !
309 ! OPTIONAL INPUTS:
310 ! No_OPTRAN:
311 ! Logical switch to disable allocation of Compact-OPTRAN
312 ! arrays for use with water vapour absorption.
313 ! If == .FALSE., arrays are allocated [DEFAULT]
314 ! == .TRUE., arrays are NOT allocated
315 ! If not specified, arrays are allocated.
316 ! UNITS: N/A
317 ! TYPE: LOGICAL
318 ! DIMENSION: Conformable with the PAFV object
319 ! ATTRIBUTES: INTENT(IN), OPTIONAL
320 !
321 !:sdoc-:
322 !--------------------------------------------------------------------------------
323 
324  ELEMENTAL SUBROUTINE pafv_create( &
325  self , & ! Output
326  n_ODPS_Layers, & ! Input
327  n_User_Layers, & ! Input
328  n_Absorbers , & ! Input
329  No_OPTRAN ) ! Optional Input
331  ! Arguments
332  TYPE(pafv_type), INTENT(OUT) :: self
333  INTEGER, INTENT(IN) :: n_odps_layers
334  INTEGER, INTENT(IN) :: n_user_layers
335  INTEGER, INTENT(IN) :: n_absorbers
336  LOGICAL, OPTIONAL, INTENT(IN) :: no_optran
337  ! Local variables
338  LOGICAL :: use_optran
339  INTEGER :: alloc_stat
340 
341  ! Check input
342  IF ( n_odps_layers < 1 .OR. &
343  n_absorbers < 1 .OR. &
344  n_user_layers < 1 ) RETURN
345  ! ...Process options
346  use_optran = .true.
347  IF ( PRESENT(no_optran) ) use_optran = .NOT. no_optran
348 
349  ! Perform the ODPS allocations
350  ! ...ODPS Forward variables
351  ALLOCATE( self%ODPS2User_Idx(2, 0:n_user_layers), &
352  self%interp_index(2, n_odps_layers), &
353  self%Acc_Weighting(n_user_layers,n_odps_layers), &
354  self%Temperature(n_odps_layers), &
355  self%Absorber(n_odps_layers, n_absorbers), &
356  self%idx_map(n_absorbers), &
357  stat = alloc_stat )
358  IF ( alloc_stat /= 0 ) RETURN
359  ! ...Pressure profiles for interpolations
360  ALLOCATE( self%Ref_LnPressure(n_odps_layers), &
361  self%User_LnPressure(n_user_layers), &
362  stat = alloc_stat )
363  IF ( alloc_stat /= 0 ) RETURN
364  ! Predictor forward variables
365  ! ...
366  ALLOCATE( self%PDP(n_odps_layers), &
367  self%Tz_ref(n_odps_layers), &
368  self%Tz(n_odps_layers), &
369  self%Tzp_ref(n_odps_layers), &
370  self%Tzp(n_odps_layers), &
371  self%GAz_ref(n_odps_layers, n_absorbers), &
372  self%GAz_sum(n_odps_layers, n_absorbers), &
373  self%GAz(n_odps_layers, n_absorbers), &
374  self%GAzp_ref(n_odps_layers, n_absorbers), &
375  self%GAzp_sum(n_odps_layers, n_absorbers), &
376  self%GAzp(n_odps_layers, n_absorbers), &
377  self%GATzp_ref(n_odps_layers, n_absorbers), &
378  self%GATzp_sum(n_odps_layers, n_absorbers), &
379  self%GATzp(n_odps_layers, n_absorbers), &
380  stat = alloc_stat )
381  IF ( alloc_stat /= 0 ) RETURN
382  ! ...
383  ALLOCATE( self%DT(n_odps_layers), &
384  self%T(n_odps_layers), &
385  self%T2(n_odps_layers), &
386  self%DT2(n_odps_layers), &
387  self%H2O(n_odps_layers), &
388  self%H2O_A(n_odps_layers), &
389  self%H2O_R(n_odps_layers), &
390  self%H2O_S(n_odps_layers), &
391  self%H2O_R4(n_odps_layers), &
392  self%H2OdH2OTzp(n_odps_layers), &
393  self%CO2(n_odps_layers), &
394  self%O3(n_odps_layers), &
395  self%O3_A(n_odps_layers), &
396  self%O3_R(n_odps_layers), &
397  self%CO(n_odps_layers), &
398  self%CO_A(n_odps_layers), &
399  self%CO_R(n_odps_layers), &
400  self%CO_S(n_odps_layers), &
401  self%CO_ACOdCOzp(n_odps_layers), &
402  self%N2O(n_odps_layers), &
403  self%N2O_A(n_odps_layers), &
404  self%N2O_R(n_odps_layers), &
405  self%N2O_S(n_odps_layers), &
406  self%CH4(n_odps_layers), &
407  self%CH4_A(n_odps_layers), &
408  self%CH4_R(n_odps_layers), &
409  self%CH4_ACH4zp(n_odps_layers), &
410  stat = alloc_stat )
411  IF ( alloc_stat /= 0 ) RETURN
412  ! ...Optical depth variables
413  ALLOCATE( self%OD(n_odps_layers), &
414  self%OD_path(0:n_odps_layers), &
415  stat = alloc_stat )
416  IF ( alloc_stat /= 0 ) RETURN
417 
418  ! Initialise dimensions (not arrays)
419  self%n_ODPS_Layers = n_odps_layers
420  self%n_Absorbers = n_absorbers
421  self%n_User_Layers = n_user_layers
422 
423 
424  ! Allocate OPTRAN if required
425  IF ( use_optran ) THEN
426  ALLOCATE( self%dPonG(n_odps_layers), &
427  self%d_Absorber(n_odps_layers), &
428  self%Int_vapor(n_odps_layers), &
429  self%AveA(n_odps_layers), &
430  self%Inverse(n_odps_layers), &
431  self%s_t(n_odps_layers), &
432  self%s_p(n_odps_layers), &
433  self%Ap1(n_odps_layers), &
434  self%b(n_odps_layers, 0:max_optran_used_predictors), &
435  self%LN_Chi(n_odps_layers), &
436  self%Chi(n_odps_layers), &
437  stat = alloc_stat )
438  IF ( alloc_stat /= 0 ) RETURN
439  ! ...Initialise dimensions
440  self%n_OUsed_Pred = max_optran_used_predictors
441  ! ...Flag OPTRAN section as usuable
442  self%OPTRAN = .true.
443  END IF
444 
445  ! Set allocation indicator
446  self%Is_Allocated = .true.
447 
448  END SUBROUTINE pafv_create
449 
450 
451 !--------------------------------------------------------------------------------
452 !:sdoc+:
453 !
454 ! NAME:
455 ! PAFV_Inspect
456 !
457 ! PURPOSE:
458 ! Subroutine to print the contents of a PAFV object to stdout.
459 !
460 ! CALLING SEQUENCE:
461 ! CALL PAFV_Inspect( PAFV )
462 !
463 ! OBJECTS:
464 ! PAFV:
465 ! PAFV object to display.
466 ! UNITS: N/A
467 ! TYPE: PAFV_type
468 ! DIMENSION: Scalar
469 ! ATTRIBUTES: INTENT(IN)
470 !
471 !:sdoc-:
472 !--------------------------------------------------------------------------------
473 
474  SUBROUTINE pafv_inspect(self)
475  TYPE(pafv_type), INTENT(IN) :: self
476  WRITE(*,'(1x,"PAFV OBJECT")')
477  ! Release/version info
478  WRITE(*,'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
479  ! Dimensions
480  WRITE(*,'(3x,"n_ODPS_Layers :",1x,i0)') self%n_ODPS_Layers
481  WRITE(*,'(3x,"n_User_Layers :",1x,i0)') self%n_User_Layers
482  WRITE(*,'(3x,"n_Absorbers :",1x,i0)') self%n_Absorbers
483  IF ( .NOT. pafv_associated(self) ) RETURN
484  ! ODPS data arrays
485  WRITE(*,'(3x,"ODPS data arrays :")')
486  ! ...ODPS Forward variables
487  WRITE(*,'(5x,"ODPS2User_Idx :")'); WRITE(*,'(10(1x,i3,:))') self%ODPS2User_Idx
488  WRITE(*,'(5x,"interp_index :")'); WRITE(*,'(10(1x,i3,:))') self%interp_index
489  WRITE(*,'(5x,"Acc_Weighting :")'); WRITE(*,'(5(1x,es13.6,:))') self%Acc_Weighting
490  WRITE(*,'(5x,"Temperature :")'); WRITE(*,'(5(1x,es13.6,:))') self%Temperature
491  WRITE(*,'(5x,"Absorber :")'); WRITE(*,'(5(1x,es13.6,:))') self%Absorber
492  WRITE(*,'(5x,"idx_map :")'); WRITE(*,'(10(1x,i3,:))') self%idx_map
493  WRITE(*,'(5x,"H2O_idx :",1x,i0)') self%H2O_idx
494  ! ...Pressure profiles for interpolations
495  WRITE(*,'(5x,"Ref_LnPressure :")'); WRITE(*,'(5(1x,es13.6,:))') self%Ref_LnPressure
496  WRITE(*,'(5x,"User_LnPressure :")'); WRITE(*,'(5(1x,es13.6,:))') self%User_LnPressure
497  ! ...Predictor forward variables
498  WRITE(*,'(5x,"PDP :")'); WRITE(*,'(5(1x,es13.6,:))') self%PDP
499  WRITE(*,'(5x,"Tz_ref :")'); WRITE(*,'(5(1x,es13.6,:))') self%Tz_ref
500  WRITE(*,'(5x,"Tz :")'); WRITE(*,'(5(1x,es13.6,:))') self%Tz
501  WRITE(*,'(5x,"Tzp_ref :")'); WRITE(*,'(5(1x,es13.6,:))') self%Tzp_ref
502  WRITE(*,'(5x,"Tzp :")'); WRITE(*,'(5(1x,es13.6,:))') self%Tzp
503  WRITE(*,'(5x,"GAz_ref :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAz_ref
504  WRITE(*,'(5x,"GAz_sum :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAz_sum
505  WRITE(*,'(5x,"GAz :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAz
506  WRITE(*,'(5x,"GAzp_ref :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAzp_ref
507  WRITE(*,'(5x,"GAzp_sum :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAzp_sum
508  WRITE(*,'(5x,"GAzp :")'); WRITE(*,'(5(1x,es13.6,:))') self%GAzp
509  WRITE(*,'(5x,"GATzp_ref :")'); WRITE(*,'(5(1x,es13.6,:))') self%GATzp_ref
510  WRITE(*,'(5x,"GATzp_sum :")'); WRITE(*,'(5(1x,es13.6,:))') self%GATzp_sum
511  WRITE(*,'(5x,"GATzp :")'); WRITE(*,'(5(1x,es13.6,:))') self%GATzp
512  WRITE(*,'(5x,"DT :")'); WRITE(*,'(5(1x,es13.6,:))') self%DT
513  WRITE(*,'(5x,"T :")'); WRITE(*,'(5(1x,es13.6,:))') self%T
514  WRITE(*,'(5x,"T2 :")'); WRITE(*,'(5(1x,es13.6,:))') self%T2
515  WRITE(*,'(5x,"DT2 :")'); WRITE(*,'(5(1x,es13.6,:))') self%DT2
516  WRITE(*,'(5x,"H2O :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2O
517  WRITE(*,'(5x,"H2O_A :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2O_A
518  WRITE(*,'(5x,"H2O_R :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2O_R
519  WRITE(*,'(5x,"H2O_S :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2O_S
520  WRITE(*,'(5x,"H2O_R4 :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2O_R4
521  WRITE(*,'(5x,"H2OdH2OTzp :")'); WRITE(*,'(5(1x,es13.6,:))') self%H2OdH2OTzp
522  WRITE(*,'(5x,"CO2 :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO2
523  WRITE(*,'(5x,"O3 :")'); WRITE(*,'(5(1x,es13.6,:))') self%O3
524  WRITE(*,'(5x,"O3_A :")'); WRITE(*,'(5(1x,es13.6,:))') self%O3_A
525  WRITE(*,'(5x,"O3_R :")'); WRITE(*,'(5(1x,es13.6,:))') self%O3_R
526  WRITE(*,'(5x,"CO :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO
527  WRITE(*,'(5x,"CO_A :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO_A
528  WRITE(*,'(5x,"CO_R :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO_R
529  WRITE(*,'(5x,"CO_S :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO_S
530  WRITE(*,'(5x,"CO_ACOdCOzp :")'); WRITE(*,'(5(1x,es13.6,:))') self%CO_ACOdCOzp
531  WRITE(*,'(5x,"N2O :")'); WRITE(*,'(5(1x,es13.6,:))') self%N2O
532  WRITE(*,'(5x,"N2O_A :")'); WRITE(*,'(5(1x,es13.6,:))') self%N2O_A
533  WRITE(*,'(5x,"N2O_R :")'); WRITE(*,'(5(1x,es13.6,:))') self%N2O_R
534  WRITE(*,'(5x,"N2O_S :")'); WRITE(*,'(5(1x,es13.6,:))') self%N2O_S
535  WRITE(*,'(5x,"CH4 :")'); WRITE(*,'(5(1x,es13.6,:))') self%CH4
536  WRITE(*,'(5x,"CH4_A :")'); WRITE(*,'(5(1x,es13.6,:))') self%CH4_A
537  WRITE(*,'(5x,"CH4_R :")'); WRITE(*,'(5(1x,es13.6,:))') self%CH4_R
538  WRITE(*,'(5x,"CH4_ACH4zp :")'); WRITE(*,'(5(1x,es13.6,:))') self%CH4_ACH4zp
539  ! Optical depth variables
540  WRITE(*,'(3x,"ODPS optical depth arrays :")')
541  WRITE(*,'(5x,"OD :")'); WRITE(*,'(5(1x,es13.6,:))') self%OD
542  WRITE(*,'(5x,"OD_path :")'); WRITE(*,'(5(1x,es13.6,:))') self%OD_path
543  ! Zeeman specific Forward variables
544  WRITE(*,'(3x,"Zeeman-specific data :")')
545  WRITE(*,'(5x,"w1, w2 :")'); WRITE(*,'(2(1x,es13.6))') self%w1, self%w2
546  WRITE(*,'(5x,"inode :")'); WRITE(*,'(1x,i0)') self%inode
547  ! Compact-OPTRAN Forward variables
548  IF ( self%OPTRAN ) THEN
549  WRITE(*,'(3x,"Compact-OPTRAN option :")')
550  WRITE(*,'(3x,"n_OUsed_Pred :",1x,i0)') self%n_OUsed_Pred
551  WRITE(*,'(5x,"dPonG :")'); WRITE(*,'(5(1x,es13.6,:))') self%dPonG
552  WRITE(*,'(5x,"d_Absorber :")'); WRITE(*,'(5(1x,es13.6,:))') self%d_Absorber
553  WRITE(*,'(5x,"Int_vapor :")'); WRITE(*,'(5(1x,es13.6,:))') self%Int_vapor
554  WRITE(*,'(5x,"AveA :")'); WRITE(*,'(5(1x,es13.6,:))') self%AveA
555  WRITE(*,'(5x,"Inverse :")'); WRITE(*,'(5(1x,es13.6,:))') self%Inverse
556  WRITE(*,'(5x,"s_t :")'); WRITE(*,'(5(1x,es13.6,:))') self%s_t
557  WRITE(*,'(5x,"s_p :")'); WRITE(*,'(5(1x,es13.6,:))') self%s_p
558  WRITE(*,'(5x,"Ap1 :")'); WRITE(*,'(5(1x,es13.6,:))') self%Ap1
559  WRITE(*,'(5x,"b :")'); WRITE(*,'(5(1x,es13.6,:))') self%b
560  WRITE(*,'(5x,"LN_Chi :")'); WRITE(*,'(5(1x,es13.6,:))') self%LN_Chi
561  WRITE(*,'(5x,"Chi :")'); WRITE(*,'(5(1x,es13.6,:))') self%Chi
562  END IF
563  END SUBROUTINE pafv_inspect
564 
565 
566 !----------------------------------------------------------------------------------
567 !:sdoc+:
568 !
569 ! NAME:
570 ! PAFV_ValidRelease
571 !
572 ! PURPOSE:
573 ! Function to check the PAFV Release value.
574 !
575 ! CALLING SEQUENCE:
576 ! IsValid = PAFV_ValidRelease( PAFV )
577 !
578 ! INPUTS:
579 ! PAFV:
580 ! PAFV object for which the Release component
581 ! is to be checked.
582 ! UNITS: N/A
583 ! TYPE: PAFV_type
584 ! DIMENSION: Scalar
585 ! ATTRIBUTES: INTENT(IN)
586 !
587 ! FUNCTION RESULT:
588 ! IsValid:
589 ! Logical value defining the release validity.
590 ! UNITS: N/A
591 ! TYPE: LOGICAL
592 ! DIMENSION: Scalar
593 !
594 !:sdoc-:
595 !----------------------------------------------------------------------------------
596 
597  FUNCTION pafv_validrelease( self ) RESULT( IsValid )
598  ! Arguments
599  TYPE(pafv_type), INTENT(IN) :: self
600  ! Function result
601  LOGICAL :: isvalid
602  ! Local parameters
603  CHARACTER(*), PARAMETER :: routine_name = 'PAFV_ValidRelease'
604  ! Local variables
605  CHARACTER(ML) :: msg
606 
607  ! Set up
608  isvalid = .true.
609 
610 
611  ! Check release is not too old
612  IF ( self%Release < pafv_release ) THEN
613  isvalid = .false.
614  WRITE( msg,'("An PAFV data update is needed. ", &
615  &"PAFV release is ",i0,". Valid release is ",i0,"." )' ) &
616  self%Release, pafv_release
617  CALL display_message( routine_name, msg, information ); RETURN
618  END IF
619 
620 
621  ! Check release is not too new
622  IF ( self%Release > pafv_release ) THEN
623  isvalid = .false.
624  WRITE( msg,'("An PAFV software update is needed. ", &
625  &"PAFV release is ",i0,". Valid release is ",i0,"." )' ) &
626  self%Release, pafv_release
627  CALL display_message( routine_name, msg, information ); RETURN
628  END IF
629 
630  END FUNCTION pafv_validrelease
631 
632 
633 !--------------------------------------------------------------------------------
634 !:sdoc+:
635 !
636 ! NAME:
637 ! PAFV_Info
638 !
639 ! PURPOSE:
640 ! Subroutine to return a string containing version and dimension
641 ! information about a PAFV object.
642 !
643 ! CALLING SEQUENCE:
644 ! CALL PAFV_Info( PAFV, Info )
645 !
646 ! OBJECTS:
647 ! PAFV:
648 ! PAFV object about which info is required.
649 ! UNITS: N/A
650 ! TYPE: PAFV_type
651 ! DIMENSION: Scalar
652 ! ATTRIBUTES: INTENT(IN)
653 !
654 ! OUTPUTS:
655 ! Info:
656 ! String containing version and dimension information
657 ! about the PAFV object.
658 ! UNITS: N/A
659 ! TYPE: CHARACTER(*)
660 ! DIMENSION: Scalar
661 ! ATTRIBUTES: INTENT(OUT)
662 !
663 !:sdoc-:
664 !--------------------------------------------------------------------------------
665 
666  SUBROUTINE pafv_info( self, Info )
667  ! Arguments
668  TYPE(pafv_type), INTENT(IN) :: self
669  CHARACTER(*), INTENT(OUT) :: info
670  ! Parameters
671  INTEGER, PARAMETER :: carriage_return = 13
672  INTEGER, PARAMETER :: linefeed = 10
673  ! Local variables
674  CHARACTER(1000) :: s1, s2
675  CHARACTER(2000) :: long_string
676 
677  ! Write the required data to the local string
678  WRITE( s1, &
679  '(a,1x,"PAFV RELEASE.VERSION: ",i2,".",i2.2,a,3x, &
680  &"N_ODPS_LAYERS=",i0,2x,&
681  &"N_ABSORBERS =",i0,2x,&
682  &"N_USER_LAYERS=",i0,2x)' ) &
683  achar(carriage_return)//achar(linefeed), &
684  self%Release, self%Version, &
685  achar(carriage_return)//achar(linefeed), &
686  self%n_ODPS_Layers, &
687  self%n_Absorbers, &
688  self%n_User_Layers
689  ! Compact-OPTRAN Forward variables
690  IF ( self%OPTRAN ) THEN
691  WRITE( s2, &
692  '(a,1x,"PAFV ODAS Option",a,3x, &
693  &"N_OUSED_PRED=",i0,2x)' ) &
694  achar(carriage_return)//achar(linefeed), &
695  achar(carriage_return)//achar(linefeed), &
696  self%n_OUsed_Pred
697  END IF
698 
699  ! Trim the output based on the
700  ! dummy argument string length
701  long_string = trim(s1)//trim(s2)
702  info = long_string(1:min(len(info), len_trim(long_string)))
703 
704  END SUBROUTINE pafv_info
705 
706 
707 !--------------------------------------------------------------------------------
708 !:sdoc+:
709 !
710 ! NAME:
711 ! PAFV_DefineVersion
712 !
713 ! PURPOSE:
714 ! Subroutine to return the module version information.
715 !
716 ! CALLING SEQUENCE:
717 ! CALL PAFV_DefineVersion( Id )
718 !
719 ! OUTPUTS:
720 ! Id: Character string containing the version Id information
721 ! for the module.
722 ! UNITS: N/A
723 ! TYPE: CHARACTER(*)
724 ! DIMENSION: Scalar
725 ! ATTRIBUTES: INTENT(OUT)
726 !
727 !:sdoc-:
728 !--------------------------------------------------------------------------------
729 
730  SUBROUTINE pafv_defineversion( Id )
731  CHARACTER(*), INTENT(OUT) :: id
732  id = module_version_id
733  END SUBROUTINE pafv_defineversion
734 
735 
736 !------------------------------------------------------------------------------
737 !:sdoc+:
738 !
739 ! NAME:
740 ! PAFV_InquireFile
741 !
742 ! PURPOSE:
743 ! Function to inquire PAFV object files.
744 !
745 ! CALLING SEQUENCE:
746 ! Error_Status = PAFV_InquireFile( &
747 ! Filename, &
748 ! n_ODPS_Layers = n_ODPS_Layers, &
749 ! n_Absorbers = n_Absorbers , &
750 ! n_User_Layers = n_User_Layers, &
751 ! Release = Release , &
752 ! Version = Version )
753 !
754 ! INPUTS:
755 ! Filename:
756 ! Character string specifying the name of the
757 ! data file to inquire.
758 ! UNITS: N/A
759 ! TYPE: CHARACTER(*)
760 ! DIMENSION: Scalar
761 ! ATTRIBUTES: INTENT(IN)
762 !
763 ! OPTIONAL OUTPUTS:
764 ! n_ODPS_Layers:
765 ! Number of internal ODPS layers that are defined
766 ! in the ODPS TauCoeff data file.
767 ! UNITS: N/A
768 ! TYPE: INTEGER
769 ! DIMENSION: Scalar
770 ! ATTRIBUTES: INTENT(OUT), OPTIONAL
771 !
772 ! n_Absorbers:
773 ! Number of gaseous absorbers.
774 ! UNITS: N/A
775 ! TYPE: INTEGER
776 ! DIMENSION: Scalar
777 ! ATTRIBUTES: INTENT(OUT), OPTIONAL
778 !
779 ! n_Layers:
780 ! Number of atmospheric layers defined by user.
781 ! UNITS: N/A
782 ! TYPE: INTEGER
783 ! DIMENSION: Scalar
784 ! ATTRIBUTES: INTENT(OUT), OPTIONAL
785 !
786 ! Release:
787 ! The data/file release number. Used to check
788 ! for data/software mismatch.
789 ! UNITS: N/A
790 ! TYPE: INTEGER
791 ! DIMENSION: Scalar
792 ! ATTRIBUTES: INTENT(OUT), OPTIONAL
793 !
794 ! Version:
795 ! The data/file version number. Used for
796 ! purposes only in identifying the dataset for
797 ! a particular release.
798 ! UNITS: N/A
799 ! TYPE: INTEGER
800 ! DIMENSION: Scalar
801 ! ATTRIBUTES: INTENT(OUT), OPTIONAL
802 !
803 ! FUNCTION RESULT:
804 ! Error_Status:
805 ! The return value is an integer defining the error
806 ! status. The error codes are defined in the
807 ! Message_Handler module.
808 ! If == SUCCESS the file inquire was successful
809 ! == FAILURE an unrecoverable error occurred.
810 ! UNITS: N/A
811 ! TYPE: INTEGER
812 ! DIMENSION: Scalar
813 !
814 !:sdoc-:
815 !------------------------------------------------------------------------------
816 
817  FUNCTION pafv_inquirefile( &
818  Filename , & ! Input
819  n_ODPS_Layers, & ! Optional output
820  n_Absorbers , & ! Optional output
821  n_User_Layers, & ! Optional output
822  Release , & ! Optional output
823  Version , & ! Optional output
824  Title , & ! Optional output
825  History , & ! Optional output
826  Comment ) & ! Optional output
827  result( err_stat )
828  ! Arguments
829  CHARACTER(*), INTENT(IN) :: filename
830  INTEGER , OPTIONAL, INTENT(OUT) :: n_odps_layers
831  INTEGER , OPTIONAL, INTENT(OUT) :: n_absorbers
832  INTEGER , OPTIONAL, INTENT(OUT) :: n_user_layers
833  INTEGER , OPTIONAL, INTENT(OUT) :: release
834  INTEGER , OPTIONAL, INTENT(OUT) :: version
835  CHARACTER(*), OPTIONAL, INTENT(OUT) :: title
836  CHARACTER(*), OPTIONAL, INTENT(OUT) :: history
837  CHARACTER(*), OPTIONAL, INTENT(OUT) :: comment
838  ! Function result
839  INTEGER :: err_stat
840  ! Function parameters
841  CHARACTER(*), PARAMETER :: routine_name = 'PAFV_InquireFile'
842  ! Function variables
843  CHARACTER(ML) :: msg
844  CHARACTER(ML) :: io_msg
845  INTEGER :: io_stat
846  INTEGER :: fid
847  INTEGER :: optran_present
848  TYPE(pafv_type) :: pafv
849 
850 
851  ! Setup
852  err_stat = success
853  ! ...Check that the file exists
854  IF ( .NOT. file_exists( filename ) ) THEN
855  msg = 'File '//trim(filename)//' not found.'
856  CALL inquire_cleanup(); RETURN
857  END IF
858 
859 
860  ! Open the file
861  err_stat = open_binary_file( filename, fid )
862  IF ( err_stat /= success ) THEN
863  msg = 'Error opening '//trim(filename)
864  CALL inquire_cleanup(); RETURN
865  END IF
866 
867 
868  ! Read the release and version
869  READ( fid, iostat=io_stat, iomsg=io_msg ) &
870  pafv%Release, &
871  pafv%Version
872  IF ( io_stat /= 0 ) THEN
873  msg = 'Error reading Release/Version - '//trim(io_msg)
874  CALL inquire_cleanup(); RETURN
875  END IF
876  IF ( .NOT. pafv_validrelease( pafv ) ) THEN
877  msg = 'PAFV Release check failed.'
878  CALL inquire_cleanup(); RETURN
879  END IF
880 
881 
882  ! Read the dimensions
883  READ( fid, iostat=io_stat, iomsg=io_msg ) &
884  pafv%n_ODPS_Layers, &
885  pafv%n_Absorbers , &
886  pafv%n_User_Layers
887  IF ( io_stat /= 0 ) THEN
888  msg = 'Error reading dimension values from '//trim(filename)//' - '//trim(io_msg)
889  CALL inquire_cleanup(); RETURN
890  END IF
891 
892 
893  ! Read Compact-OPTRAN data indicator
894  READ( fid, iostat=io_stat, iomsg=io_msg ) optran_present
895  IF ( io_stat /= 0 ) THEN
896  msg = 'Error reading Compact-OPTRAN data indicator from '//trim(filename)//' - '//trim(io_msg)
897  CALL inquire_cleanup(); RETURN
898  END IF
899 
900 
901  ! Read the global attributes
902  err_stat = readgatts_binary_file( &
903  fid, &
904  title = title , &
905  history = history, &
906  comment = comment )
907  IF ( err_stat /= success ) THEN
908  msg = 'Error reading global attributes'
909  CALL inquire_cleanup(); RETURN
910  END IF
911 
912 
913  ! Close the file
914  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
915  IF ( io_stat /= 0 ) THEN
916  msg = 'Error closing '//trim(filename)//' - '//trim(io_msg)
917  CALL inquire_cleanup(); RETURN
918  END IF
919 
920 
921  ! Assign the return arguments
922  IF ( PRESENT(n_odps_layers) ) n_odps_layers = pafv%n_ODPS_Layers
923  IF ( PRESENT(n_absorbers ) ) n_absorbers = pafv%n_Absorbers
924  IF ( PRESENT(n_user_layers) ) n_user_layers = pafv%n_User_Layers
925  IF ( PRESENT(release ) ) release = pafv%Release
926  IF ( PRESENT(version ) ) version = pafv%Version
927 
928  CONTAINS
929 
930  SUBROUTINE inquire_cleanup()
931  ! Close file if necessary
932  IF ( file_open(fid) ) THEN
933  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
934  IF ( io_stat /= 0 ) &
935  msg = trim(msg)//'; Error closing input file during error cleanup - '//trim(io_msg)
936  END IF
937  ! Set error status and print error message
938  err_stat = failure
939  CALL display_message( routine_name, msg, err_stat )
940  END SUBROUTINE inquire_cleanup
941 
942  END FUNCTION pafv_inquirefile
943 
944 
945 !--------------------------------------------------------------------------------
946 !:sdoc+:
947 !
948 ! NAME:
949 ! PAFV_ReadFile
950 !
951 ! PURPOSE:
952 ! Function to read PAFV object files.
953 !
954 ! CALLING SEQUENCE:
955 ! Error_Status = PAFV_ReadFile( &
956 ! PAFV , &
957 ! Filename, &
958 ! No_Close = No_Close, &
959 ! Quiet = Quiet )
960 !
961 ! OBJECTS:
962 ! PAFV:
963 ! PAFV object containing the data read from file.
964 ! UNITS: N/A
965 ! TYPE: PAFV_type
966 ! DIMENSION: Scalar
967 ! ATTRIBUTES: INTENT(OUT)
968 !
969 ! INPUTS:
970 ! Filename:
971 ! Character string specifying the name of a
972 ! PAFV data file to read.
973 ! UNITS: N/A
974 ! TYPE: CHARACTER(*)
975 ! DIMENSION: Scalar
976 ! ATTRIBUTES: INTENT(IN)
977 !
978 ! OPTIONAL INPUTS:
979 ! No_Close:
980 ! Set this logical argument to *NOT* close the datafile
981 ! upon exiting this routine. This option is required if
982 ! the PAFV data is embedded within another file.
983 ! If == .FALSE., File is closed upon function exit [DEFAULT].
984 ! == .TRUE., File is NOT closed upon function exit
985 ! If not specified, default is .FALSE.
986 ! UNITS: N/A
987 ! TYPE: LOGICAL
988 ! DIMENSION: Scalar
989 ! ATTRIBUTES: INTENT(IN), OPTIONAL
990 !
991 ! Quiet:
992 ! Set this logical argument to suppress INFORMATION
993 ! messages being printed to stdout
994 ! If == .FALSE., INFORMATION messages are OUTPUT [DEFAULT].
995 ! == .TRUE., INFORMATION messages are SUPPRESSED.
996 ! If not specified, default is .FALSE.
997 ! UNITS: N/A
998 ! TYPE: LOGICAL
999 ! DIMENSION: Scalar
1000 ! ATTRIBUTES: INTENT(IN), OPTIONAL
1001 !
1002 ! FUNCTION RESULT:
1003 ! Error_Status:
1004 ! The return value is an integer defining the error status.
1005 ! The error codes are defined in the Message_Handler module.
1006 ! If == SUCCESS, the file read was successful
1007 ! == FAILURE, an unrecoverable error occurred.
1008 ! UNITS: N/A
1009 ! TYPE: INTEGER
1010 ! DIMENSION: Scalar
1011 !
1012 !:sdoc-:
1013 !------------------------------------------------------------------------------
1014 
1015  FUNCTION pafv_readfile( &
1016  PAFV, & ! Output
1017  Filename , & ! Input
1018  No_Close , & ! Optional input
1019  Quiet , & ! Optional input
1020  Title , & ! Optional output
1021  History , & ! Optional output
1022  Comment , & ! Optional output
1023  Debug ) & ! Optional input (Debug output control)
1024  result( err_stat )
1025  ! Arguments
1026  TYPE(pafv_type), INTENT(OUT) :: pafv
1027  CHARACTER(*), INTENT(IN) :: filename
1028  LOGICAL, OPTIONAL, INTENT(IN) :: no_close
1029  LOGICAL, OPTIONAL, INTENT(IN) :: quiet
1030  CHARACTER(*), OPTIONAL, INTENT(OUT) :: title
1031  CHARACTER(*), OPTIONAL, INTENT(OUT) :: history
1032  CHARACTER(*), OPTIONAL, INTENT(OUT) :: comment
1033  LOGICAL, OPTIONAL, INTENT(IN) :: debug
1034  ! Function result
1035  INTEGER :: err_stat
1036  ! Function parameters
1037  CHARACTER(*), PARAMETER :: routine_name = 'PAFV_ReadFile'
1038  ! Function variables
1039  CHARACTER(ML) :: msg
1040  CHARACTER(ML) :: io_msg
1041  LOGICAL :: close_file
1042  LOGICAL :: noisy
1043  INTEGER :: io_stat
1044  INTEGER :: fid
1045  INTEGER :: optran_present
1046  TYPE(pafv_type) :: dummy
1047 
1048  ! Setup
1049  err_stat = success
1050  ! ...Check No_Close argument
1051  close_file = .true.
1052  IF ( PRESENT(no_close) ) close_file = .NOT. no_close
1053  ! ...Check Quiet argument
1054  noisy = .true.
1055  IF ( PRESENT(quiet) ) noisy = .NOT. quiet
1056  ! ...Override Quiet settings if debug set.
1057  IF ( PRESENT(debug) ) THEN
1058  IF ( debug ) noisy = .true.
1059  END IF
1060 
1061 
1062  ! Check if the file is open.
1063  IF ( file_open( filename ) ) THEN
1064  ! ...Inquire for the logical unit number
1065  INQUIRE( file=filename, number=fid )
1066  ! ...Ensure it's valid
1067  IF ( fid < 0 ) THEN
1068  msg = 'Error inquiring '//trim(filename)//' for its FileID'
1069  CALL read_cleanup(); RETURN
1070  END IF
1071  ELSE
1072  ! ...Open the file if it exists
1073  IF ( file_exists( filename ) ) THEN
1074  err_stat = open_binary_file( filename, fid )
1075  IF ( err_stat /= success ) THEN
1076  msg = 'Error opening '//trim(filename)
1077  CALL read_cleanup(); RETURN
1078  END IF
1079  ELSE
1080  msg = 'File '//trim(filename)//' not found.'
1081  CALL read_cleanup(); RETURN
1082  END IF
1083  END IF
1084 
1085 
1086  ! Read and check the release and version
1087  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1088  dummy%Release, &
1089  dummy%Version
1090  IF ( io_stat /= 0 ) THEN
1091  msg = 'Error reading Release/Version - '//trim(io_msg)
1092  CALL read_cleanup(); RETURN
1093  END IF
1094  IF ( .NOT. pafv_validrelease( dummy ) ) THEN
1095  msg = 'PAFV Release check failed.'
1096  CALL read_cleanup(); RETURN
1097  END IF
1098 
1099 
1100  ! Read the dimensions
1101  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1102  dummy%n_ODPS_Layers, &
1103  dummy%n_Absorbers , &
1104  dummy%n_User_Layers
1105  IF ( io_stat /= 0 ) THEN
1106  msg = 'Error reading dimension values - '//trim(io_msg)
1107  CALL read_cleanup(); RETURN
1108  END IF
1109 
1110 
1111  ! Read Compact-OPTRAN data indicator
1112  READ( fid, iostat=io_stat, iomsg=io_msg ) optran_present
1113  IF ( io_stat /= 0 ) THEN
1114  msg = 'Error reading Compact-OPTRAN data indicator - '//trim(io_msg)
1115  CALL read_cleanup(); RETURN
1116  END IF
1117 
1118 
1119  ! Allocate the object
1120  CALL pafv_create( &
1121  pafv, &
1122  dummy%n_ODPS_Layers, &
1123  dummy%n_Absorbers , &
1124  dummy%n_User_Layers , &
1125  no_optran = (optran_present == data_missing) )
1126  IF ( .NOT. pafv_associated( pafv ) ) THEN
1127  msg = 'PAFV object allocation failed.'
1128  CALL read_cleanup(); RETURN
1129  END IF
1130  ! ...Explicitly assign the version number
1131  pafv%Version = dummy%Version
1132 
1133 
1134  ! Read the global attributes
1135  err_stat = readgatts_binary_file( &
1136  fid, &
1137  title = title , &
1138  history = history, &
1139  comment = comment )
1140  IF ( err_stat /= success ) THEN
1141  msg = 'Error reading global attributes'
1142  CALL read_cleanup(); RETURN
1143  END IF
1144 
1145 
1146  ! Read the ODPS forward variables
1147  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1148  pafv%ODPS2User_Idx, &
1149  pafv%interp_index , &
1150  pafv%Acc_Weighting, &
1151  pafv%Temperature , &
1152  pafv%Absorber , &
1153  pafv%idx_map , &
1154  pafv%H2O_idx
1155  IF ( io_stat /= 0 ) THEN
1156  msg = 'Error reading ODPS forward variables - '//trim(io_msg)
1157  CALL read_cleanup(); RETURN
1158  END IF
1159 
1160 
1161  ! Read the pressure profiles for interpolation
1162  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1163  pafv%Ref_LnPressure, &
1164  pafv%User_LnPressure
1165  IF ( io_stat /= 0 ) THEN
1166  msg = 'Error reading pressure profiles - '//trim(io_msg)
1167  CALL read_cleanup(); RETURN
1168  END IF
1169 
1170 
1171  ! Read the predictor forward variables
1172  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1173  pafv%PDP , &
1174  pafv%Tz_ref , &
1175  pafv%Tz , &
1176  pafv%Tzp_ref , &
1177  pafv%Tzp , &
1178  pafv%GAz_ref , &
1179  pafv%GAz_sum , &
1180  pafv%GAz , &
1181  pafv%GAzp_ref , &
1182  pafv%GAzp_sum , &
1183  pafv%GAzp , &
1184  pafv%GATzp_ref, &
1185  pafv%GATzp_sum, &
1186  pafv%GATzp
1187  IF ( io_stat /= 0 ) THEN
1188  msg = 'Error reading predictor forward variables (set1) - '//trim(io_msg)
1189  CALL read_cleanup(); RETURN
1190  END IF
1191  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1192  pafv%DT , &
1193  pafv%T , &
1194  pafv%T2 , &
1195  pafv%DT2 , &
1196  pafv%H2O , &
1197  pafv%H2O_A , &
1198  pafv%H2O_R , &
1199  pafv%H2O_S , &
1200  pafv%H2O_R4 , &
1201  pafv%H2OdH2OTzp , &
1202  pafv%CO2 , &
1203  pafv%O3 , &
1204  pafv%O3_A , &
1205  pafv%O3_R , &
1206  pafv%CO , &
1207  pafv%CO_A , &
1208  pafv%CO_R , &
1209  pafv%CO_S , &
1210  pafv%CO_ACOdCOzp, &
1211  pafv%N2O , &
1212  pafv%N2O_A , &
1213  pafv%N2O_R , &
1214  pafv%N2O_S , &
1215  pafv%CH4 , &
1216  pafv%CH4_A , &
1217  pafv%CH4_R , &
1218  pafv%CH4_ACH4zp
1219  IF ( io_stat /= 0 ) THEN
1220  msg = 'Error reading predictor forward variables (set2) - '//trim(io_msg)
1221  CALL read_cleanup(); RETURN
1222  END IF
1223 
1224 
1225  ! Read the optical depth variables
1226  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1227  pafv%OD, &
1228  pafv%OD_path
1229  IF ( io_stat /= 0 ) THEN
1230  msg = 'Error reading optical depth variables - '//trim(io_msg)
1231  CALL read_cleanup(); RETURN
1232  END IF
1233 
1234 
1235  ! Read the Zeeman specific Forward variables
1236  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1237  pafv%w1, &
1238  pafv%w2, &
1239  pafv%inode
1240  IF ( io_stat /= 0 ) THEN
1241  msg = 'Error reading Zeeman specific forward variables - '//trim(io_msg)
1242  CALL read_cleanup(); RETURN
1243  END IF
1244 
1245 
1246  ! Read the compact-OPTRAN Forward variables if necessary
1247  IF ( pafv%OPTRAN ) THEN
1248  READ( fid, iostat=io_stat, iomsg=io_msg ) &
1249  pafv%dPonG , &
1250  pafv%d_Absorber, &
1251  pafv%Int_vapor , &
1252  pafv%AveA , &
1253  pafv%Inverse , &
1254  pafv%s_t , &
1255  pafv%s_p , &
1256  pafv%Ap1 , &
1257  pafv%b , &
1258  pafv%LN_Chi , &
1259  pafv%Chi
1260  IF ( io_stat /= 0 ) THEN
1261  msg = 'Error reading compact-OPTRAN variables - '//trim(io_msg)
1262  CALL read_cleanup(); RETURN
1263  END IF
1264  END IF
1265 
1266 
1267  ! Close the file
1268  IF ( close_file ) THEN
1269  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
1270  IF ( io_stat /= 0 ) THEN
1271  msg = 'Error closing '//trim(filename)//' - '//trim(io_msg)
1272  CALL read_cleanup(); RETURN
1273  END IF
1274  END IF
1275 
1276 
1277  ! Output an info message
1278  IF ( noisy ) THEN
1279  CALL pafv_info( pafv, msg )
1280  CALL display_message( routine_name, 'FILE: '//trim(filename)//'; '//trim(msg), information )
1281  END IF
1282 
1283  CONTAINS
1284 
1285  SUBROUTINE read_cleanup()
1286  IF ( file_open(filename) ) THEN
1287  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
1288  IF ( io_stat /= 0 ) &
1289  msg = trim(msg)//'; Error closing output file '//trim(filename)//&
1290  ' during error cleanup - '//trim(io_msg)
1291  END IF
1292  CALL pafv_destroy( pafv )
1293  err_stat = failure
1294  CALL display_message( routine_name, msg, err_stat )
1295  END SUBROUTINE read_cleanup
1296 
1297  END FUNCTION pafv_readfile
1298 
1299 
1300 !--------------------------------------------------------------------------------
1301 !:sdoc+:
1302 !
1303 ! NAME:
1304 ! PAFV_WriteFile
1305 !
1306 ! PURPOSE:
1307 ! Function to write PAFV object files.
1308 !
1309 ! CALLING SEQUENCE:
1310 ! Error_Status = PAFV_WriteFile( &
1311 ! PAFV , &
1312 ! Filename, &
1313 ! No_Close = No_Close, &
1314 ! Quiet = Quiet )
1315 !
1316 ! OBJECTS:
1317 ! PAFV:
1318 ! PAFV object containing the data to write to file.
1319 ! UNITS: N/A
1320 ! TYPE: PAFV_type
1321 ! DIMENSION: Scalar
1322 ! ATTRIBUTES: INTENT(IN)
1323 !
1324 ! INPUTS:
1325 ! Filename:
1326 ! Character string specifying the name of a
1327 ! PAFV format data file to write.
1328 ! UNITS: N/A
1329 ! TYPE: CHARACTER(*)
1330 ! DIMENSION: Scalar
1331 ! ATTRIBUTES: INTENT(IN)
1332 !
1333 ! OPTIONAL INPUTS:
1334 ! No_Close:
1335 ! Set this logical argument to *NOT* close the datafile
1336 ! upon exiting this routine. This option is required if
1337 ! the PAFV data is embedded within another file.
1338 ! If == .FALSE., File is closed upon function exit [DEFAULT].
1339 ! == .TRUE., File is NOT closed upon function exit
1340 ! If not specified, default is .FALSE.
1341 ! UNITS: N/A
1342 ! TYPE: LOGICAL
1343 ! DIMENSION: Scalar
1344 ! ATTRIBUTES: INTENT(IN), OPTIONAL
1345 !
1346 ! Quiet:
1347 ! Set this logical argument to suppress INFORMATION
1348 ! messages being printed to stdout
1349 ! If == .FALSE., INFORMATION messages are OUTPUT [DEFAULT].
1350 ! == .TRUE., INFORMATION messages are SUPPRESSED.
1351 ! If not specified, default is .FALSE.
1352 ! UNITS: N/A
1353 ! TYPE: LOGICAL
1354 ! DIMENSION: Scalar
1355 ! ATTRIBUTES: INTENT(IN), OPTIONAL
1356 !
1357 ! FUNCTION RESULT:
1358 ! Error_Status:
1359 ! The return value is an integer defining the error status.
1360 ! The error codes are defined in the Message_Handler module.
1361 ! If == SUCCESS, the file write was successful
1362 ! == FAILURE, an unrecoverable error occurred.
1363 ! UNITS: N/A
1364 ! TYPE: INTEGER
1365 ! DIMENSION: Scalar
1366 !
1367 !:sdoc-:
1368 !------------------------------------------------------------------------------
1369 
1370  FUNCTION pafv_writefile( &
1371  PAFV , & ! Input
1372  Filename, & ! Input
1373  No_Close, & ! Optional input
1374  Quiet , & ! Optional input
1375  Title , & ! Optional input
1376  History , & ! Optional input
1377  Comment , & ! Optional input
1378  Debug ) & ! Optional input (Debug output control)
1379  result( err_stat )
1380  ! Arguments
1381  TYPE(pafv_type), INTENT(IN) :: pafv
1382  CHARACTER(*), INTENT(IN) :: filename
1383  LOGICAL, OPTIONAL, INTENT(IN) :: no_close
1384  LOGICAL, OPTIONAL, INTENT(IN) :: quiet
1385  CHARACTER(*), OPTIONAL, INTENT(IN) :: title
1386  CHARACTER(*), OPTIONAL, INTENT(IN) :: history
1387  CHARACTER(*), OPTIONAL, INTENT(IN) :: comment
1388  LOGICAL, OPTIONAL, INTENT(IN) :: debug
1389  ! Function result
1390  INTEGER :: err_stat
1391  ! Function parameters
1392  CHARACTER(*), PARAMETER :: routine_name = 'PAFV_WriteFile'
1393  ! Function variables
1394  CHARACTER(ML) :: msg
1395  CHARACTER(ML) :: io_msg
1396  LOGICAL :: close_file
1397  LOGICAL :: noisy
1398  INTEGER :: io_stat
1399  INTEGER :: fid
1400  INTEGER :: optran_present
1401 
1402 
1403  ! Setup
1404  err_stat = success
1405  ! ...Check No_Close argument
1406  close_file = .true.
1407  IF ( PRESENT(no_close) ) close_file = .NOT. no_close
1408  ! ...Check Quiet argument
1409  noisy = .true.
1410  IF ( PRESENT(quiet) ) noisy = .NOT. quiet
1411  ! ...Override Quiet settings if debug set.
1412  IF ( PRESENT(debug) ) THEN
1413  IF ( debug ) noisy = .true.
1414  END IF
1415  ! ...Check there is data to write
1416  IF ( .NOT. pafv_associated( pafv ) ) THEN
1417  msg = 'PAFV object is empty.'
1418  CALL write_cleanup(); RETURN
1419  END IF
1420 
1421 
1422  ! Check if the file is open.
1423  IF ( file_open( filename ) ) THEN
1424  ! ...Inquire for the logical unit number
1425  INQUIRE( file=filename, number=fid )
1426  ! ...Ensure it's valid
1427  IF ( fid < 0 ) THEN
1428  msg = 'Error inquiring '//trim(filename)//' for its FileID'
1429  CALL write_cleanup(); RETURN
1430  END IF
1431  ELSE
1432  ! ...Open the file for output
1433  err_stat = open_binary_file( filename, fid, for_output=.true. )
1434  IF ( err_stat /= success ) THEN
1435  msg = 'Error opening '//trim(filename)
1436  CALL write_cleanup(); RETURN
1437  END IF
1438  END IF
1439 
1440 
1441  ! Write the release and version
1442  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1443  pafv%Release, &
1444  pafv%Version
1445  IF ( io_stat /= 0 ) THEN
1446  msg = 'Error writing Release/Version - '//trim(io_msg)
1447  CALL write_cleanup(); RETURN
1448  END IF
1449 
1450 
1451  ! Write the dimensions
1452  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1453  pafv%n_ODPS_Layers, &
1454  pafv%n_Absorbers , &
1455  pafv%n_User_Layers
1456  IF ( io_stat /= 0 ) THEN
1457  msg = 'Error writing dimension values - '//trim(io_msg)
1458  CALL write_cleanup(); RETURN
1459  END IF
1460 
1461 
1462  ! Write Compact-OPTRAN data indicator
1463  IF ( pafv%OPTRAN) THEN
1464  optran_present = data_present
1465  ELSE
1466  optran_present = data_missing
1467  END IF
1468  WRITE( fid, iostat=io_stat, iomsg=io_msg ) optran_present
1469  IF ( io_stat /= 0 ) THEN
1470  msg = 'Error writing Compact-OPTRAN data indicator - '//trim(io_msg)
1471  CALL write_cleanup(); RETURN
1472  END IF
1473 
1474 
1475  ! Write the global attributes
1476  err_stat = writegatts_binary_file( &
1477  fid, &
1478  title = title , &
1479  history = history, &
1480  comment = comment )
1481  IF ( err_stat /= success ) THEN
1482  msg = 'Error writing global attributes'
1483  CALL write_cleanup(); RETURN
1484  END IF
1485 
1486 
1487  ! Write the ODPS forward variables
1488  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1489  pafv%ODPS2User_Idx, &
1490  pafv%interp_index , &
1491  pafv%Acc_Weighting, &
1492  pafv%Temperature , &
1493  pafv%Absorber , &
1494  pafv%idx_map , &
1495  pafv%H2O_idx
1496  IF ( io_stat /= 0 ) THEN
1497  msg = 'Error writing ODPS forward variables - '//trim(io_msg)
1498  CALL write_cleanup(); RETURN
1499  END IF
1500 
1501 
1502  ! Write the pressure profiles for interpolation
1503  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1504  pafv%Ref_LnPressure , &
1505  pafv%User_LnPressure
1506  IF ( io_stat /= 0 ) THEN
1507  msg = 'Error writing pressure profiles - '//trim(io_msg)
1508  CALL write_cleanup(); RETURN
1509  END IF
1510 
1511 
1512  ! Write the predictor forward variables
1513  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1514  pafv%PDP , &
1515  pafv%Tz_ref , &
1516  pafv%Tz , &
1517  pafv%Tzp_ref , &
1518  pafv%Tzp , &
1519  pafv%GAz_ref , &
1520  pafv%GAz_sum , &
1521  pafv%GAz , &
1522  pafv%GAzp_ref , &
1523  pafv%GAzp_sum , &
1524  pafv%GAzp , &
1525  pafv%GATzp_ref, &
1526  pafv%GATzp_sum, &
1527  pafv%GATzp
1528  IF ( io_stat /= 0 ) THEN
1529  msg = 'Error writing predictor forward variables (set1) - '//trim(io_msg)
1530  CALL write_cleanup(); RETURN
1531  END IF
1532  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1533  pafv%DT , &
1534  pafv%T , &
1535  pafv%T2 , &
1536  pafv%DT2 , &
1537  pafv%H2O , &
1538  pafv%H2O_A , &
1539  pafv%H2O_R , &
1540  pafv%H2O_S , &
1541  pafv%H2O_R4 , &
1542  pafv%H2OdH2OTzp , &
1543  pafv%CO2 , &
1544  pafv%O3 , &
1545  pafv%O3_A , &
1546  pafv%O3_R , &
1547  pafv%CO , &
1548  pafv%CO_A , &
1549  pafv%CO_R , &
1550  pafv%CO_S , &
1551  pafv%CO_ACOdCOzp, &
1552  pafv%N2O , &
1553  pafv%N2O_A , &
1554  pafv%N2O_R , &
1555  pafv%N2O_S , &
1556  pafv%CH4 , &
1557  pafv%CH4_A , &
1558  pafv%CH4_R , &
1559  pafv%CH4_ACH4zp
1560  IF ( io_stat /= 0 ) THEN
1561  msg = 'Error writing predictor forward variables (set2) - '//trim(io_msg)
1562  CALL write_cleanup(); RETURN
1563  END IF
1564 
1565 
1566  ! Write the optical depth variables
1567  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1568  pafv%OD, &
1569  pafv%OD_path
1570  IF ( io_stat /= 0 ) THEN
1571  msg = 'Error writing optical depth variables - '//trim(io_msg)
1572  CALL write_cleanup(); RETURN
1573  END IF
1574 
1575 
1576  ! Write the Zeeman specific Forward variables
1577  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1578  pafv%w1, &
1579  pafv%w2, &
1580  pafv%inode
1581  IF ( io_stat /= 0 ) THEN
1582  msg = 'Error writing Zeeman specific forward variables - '//trim(io_msg)
1583  CALL write_cleanup(); RETURN
1584  END IF
1585 
1586 
1587  ! Write the compact-OPTRAN Forward variables if necessary
1588  IF ( pafv%OPTRAN ) THEN
1589  WRITE( fid, iostat=io_stat, iomsg=io_msg ) &
1590  pafv%dPonG , &
1591  pafv%d_Absorber, &
1592  pafv%Int_vapor , &
1593  pafv%AveA , &
1594  pafv%Inverse , &
1595  pafv%s_t , &
1596  pafv%s_p , &
1597  pafv%Ap1 , &
1598  pafv%b , &
1599  pafv%LN_Chi , &
1600  pafv%Chi
1601  IF ( io_stat /= 0 ) THEN
1602  msg = 'Error writing compac-OPTRAN variables - '//trim(io_msg)
1603  CALL write_cleanup(); RETURN
1604  END IF
1605  END IF
1606 
1607 
1608  ! Close the file
1609  IF ( close_file ) THEN
1610  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
1611  IF ( io_stat /= 0 ) THEN
1612  msg = 'Error closing '//trim(filename)//' - '//trim(io_msg)
1613  CALL write_cleanup(); RETURN
1614  END IF
1615  END IF
1616 
1617 
1618  ! Output an info message
1619  IF ( noisy ) THEN
1620  CALL pafv_info( pafv, msg )
1621  CALL display_message( routine_name, 'FILE: '//trim(filename)//'; '//trim(msg), information )
1622  END IF
1623 
1624  CONTAINS
1625 
1626  SUBROUTINE write_cleanup()
1627  IF ( file_open(filename) ) THEN
1628  CLOSE( fid, iostat=io_stat, iomsg=io_msg )
1629  IF ( io_stat /= 0 ) &
1630  msg = trim(msg)//'; Error closing output file '//trim(filename)//&
1631  ' during error cleanup - '//trim(io_msg)
1632  END IF
1633  err_stat = failure
1634  CALL display_message( routine_name, msg, err_stat )
1635  END SUBROUTINE write_cleanup
1636 
1637  END FUNCTION pafv_writefile
1638 
1639 
1640 !################################################################################
1641 !################################################################################
1642 !## ##
1643 !## ## PRIVATE PROCEDURES ## ##
1644 !## ##
1645 !################################################################################
1646 !################################################################################
1647 
1648 !--------------------------------------------------------------------------------
1649 !
1650 ! NAME:
1651 ! PAFV_Equal
1652 !
1653 ! PURPOSE:
1654 ! Elemental function to test the equality of two PAFV objects.
1655 ! Used in OPERATOR(==) interface block.
1656 !
1657 ! CALLING SEQUENCE:
1658 ! is_equal = PAFV_Equal( x, y )
1659 !
1660 ! or
1661 !
1662 ! IF ( x == y ) THEN
1663 ! ...
1664 ! END IF
1665 !
1666 ! OBJECTS:
1667 ! x, y:
1668 ! Two PAFV objects to be compared.
1669 ! UNITS: N/A
1670 ! TYPE: PAFV_type
1671 ! DIMENSION: Scalar or any rank
1672 ! ATTRIBUTES: INTENT(IN)
1673 !
1674 ! FUNCTION RESULT:
1675 ! is_equal:
1676 ! Logical value indicating whether the inputs are equal.
1677 ! UNITS: N/A
1678 ! TYPE: LOGICAL
1679 ! DIMENSION: Same as inputs.
1680 !
1681 !--------------------------------------------------------------------------------
1682 
1683  ELEMENTAL FUNCTION pafv_equal( x, y ) RESULT( is_equal )
1684  TYPE(pafv_type), INTENT(IN) :: x, y
1685  LOGICAL :: is_equal
1686 
1687  ! Set up
1688  is_equal = .false.
1689 
1690  ! Check the object association status
1691  IF ( (.NOT. pafv_associated(x)) .OR. &
1692  (.NOT. pafv_associated(y)) ) RETURN
1693 
1694  ! Check contents
1695  ! ...Release/version info
1696  IF ( (x%Release /= y%Release) .OR. &
1697  (x%Version /= y%Version) ) RETURN
1698  ! ...Dimensions
1699  IF ( (x%n_ODPS_Layers /= y%n_ODPS_Layers ) .OR. &
1700  (x%n_Absorbers /= y%n_Absorbers ) .OR. &
1701  (x%n_User_Layers /= y%n_User_Layers ) ) RETURN
1702  ! ...Compact-OPTRAN data indicator
1703  IF ( x%OPTRAN .NEQV. y%OPTRAN ) RETURN
1704  ! ...Arrays
1705  IF ( all(x%ODPS2User_Idx == y%ODPS2User_Idx ) .AND. &
1706  all(x%interp_index == y%interp_index ) .AND. &
1707  all(x%Acc_Weighting .equalto. y%Acc_Weighting ) .AND. &
1708  all(x%Temperature .equalto. y%Temperature ) .AND. &
1709  all(x%Absorber .equalto. y%Absorber ) .AND. &
1710  all(x%idx_map == y%idx_map ) ) &
1711  is_equal = .true.
1712  IF ( all(x%Ref_LnPressure .equalto. y%Ref_LnPressure ) .AND. &
1713  all(x%User_LnPressure .equalto. y%User_LnPressure ) ) &
1714  is_equal = is_equal .EQV. .true.
1715  IF ( all(x%PDP .equalto. y%PDP ) .AND. &
1716  all(x%Tz_ref .equalto. y%Tz_ref ) .AND. &
1717  all(x%Tz .equalto. y%Tz ) .AND. &
1718  all(x%Tzp_ref .equalto. y%Tzp_ref ) .AND. &
1719  all(x%Tzp .equalto. y%Tzp ) .AND. &
1720  all(x%GAz_ref .equalto. y%GAz_ref ) .AND. &
1721  all(x%GAz_sum .equalto. y%GAz_sum ) .AND. &
1722  all(x%GAz .equalto. y%GAz ) .AND. &
1723  all(x%GAzp_ref .equalto. y%GAzp_ref ) .AND. &
1724  all(x%GAzp_sum .equalto. y%GAzp_sum ) .AND. &
1725  all(x%GAzp .equalto. y%GAzp ) .AND. &
1726  all(x%GATzp_ref .equalto. y%GATzp_ref ) .AND. &
1727  all(x%GATzp_sum .equalto. y%GATzp_sum ) .AND. &
1728  all(x%GATzp .equalto. y%GATzp ) ) &
1729  is_equal = is_equal .EQV. .true.
1730  IF ( all(x%DT .equalto. y%DT ) .AND. &
1731  all(x%T .equalto. y%T ) .AND. &
1732  all(x%T2 .equalto. y%T2 ) .AND. &
1733  all(x%DT2 .equalto. y%DT2 ) .AND. &
1734  all(x%H2O .equalto. y%H2O ) .AND. &
1735  all(x%H2O_A .equalto. y%H2O_A ) .AND. &
1736  all(x%H2O_R .equalto. y%H2O_R ) .AND. &
1737  all(x%H2O_S .equalto. y%H2O_S ) .AND. &
1738  all(x%H2O_R4 .equalto. y%H2O_R4 ) .AND. &
1739  all(x%H2OdH2OTzp .equalto. y%H2OdH2OTzp ) .AND. &
1740  all(x%CO2 .equalto. y%CO2 ) .AND. &
1741  all(x%O3 .equalto. y%O3 ) .AND. &
1742  all(x%O3_A .equalto. y%O3_A ) .AND. &
1743  all(x%O3_R .equalto. y%O3_R ) .AND. &
1744  all(x%CO .equalto. y%CO ) .AND. &
1745  all(x%CO_A .equalto. y%CO_A ) .AND. &
1746  all(x%CO_R .equalto. y%CO_R ) .AND. &
1747  all(x%CO_S .equalto. y%CO_S ) .AND. &
1748  all(x%CO_ACOdCOzp .equalto. y%CO_ACOdCOzp ) .AND. &
1749  all(x%N2O .equalto. y%N2O ) .AND. &
1750  all(x%N2O_A .equalto. y%N2O_A ) .AND. &
1751  all(x%N2O_R .equalto. y%N2O_R ) .AND. &
1752  all(x%N2O_S .equalto. y%N2O_S ) .AND. &
1753  all(x%CH4 .equalto. y%CH4 ) .AND. &
1754  all(x%CH4_A .equalto. y%CH4_A ) .AND. &
1755  all(x%CH4_R .equalto. y%CH4_R ) .AND. &
1756  all(x%CH4_ACH4zp .equalto. y%CH4_ACH4zp ) ) &
1757  is_equal = is_equal .EQV. .true.
1758  ! ...Optical depth variables
1759  IF ( all(x%OD .equalto. y%OD ) .AND. &
1760  all(x%OD_path .equalto. y%OD_path ) ) &
1761  is_equal = is_equal .EQV. .true.
1762  ! ...Zeeman variables
1763  IF ( (x%w1 .equalto. y%w1 ) .AND. &
1764  (x%w2 .equalto. y%w2 ) .AND. &
1765  (x%inode == y%inode ) ) &
1766  is_equal = is_equal .EQV. .true.
1767  ! ...Compact-OPTRAN data
1768  IF ( x%OPTRAN .AND. y%OPTRAN ) THEN
1769  IF ( all(x%dPonG .equalto. y%dPonG ) .AND. &
1770  all(x%d_Absorber .equalto. y%d_Absorber ) .AND. &
1771  all(x%Int_vapor .equalto. y%Int_vapor ) .AND. &
1772  all(x%AveA .equalto. y%AveA ) .AND. &
1773  all(x%Inverse .equalto. y%Inverse ) .AND. &
1774  all(x%s_t .equalto. y%s_t ) .AND. &
1775  all(x%s_p .equalto. y%s_p ) .AND. &
1776  all(x%Ap1 .equalto. y%Ap1 ) .AND. &
1777  all(x%b .equalto. y%b ) .AND. &
1778  all(x%LN_Chi .equalto. y%LN_Chi ) .AND. &
1779  all(x%Chi .equalto. y%Chi ) ) &
1780  is_equal = is_equal .EQV. .true.
1781  END IF
1782 
1783  END FUNCTION pafv_equal
1784 
1785 END MODULE pafv_define
integer, parameter, public failure
integer function, public pafv_inquirefile(Filename, n_ODPS_Layers, n_Absorbers, n_User_Layers, Release, Version, Title, History, Comment)
integer function, public pafv_writefile(PAFV, Filename, No_Close, Quiet, Title, History, Comment, Debug)
real(fp), parameter, public zero
integer, parameter data_present
Definition: PAFV_Define.f90:75
subroutine, public pafv_defineversion(Id)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
integer function, public readgatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
integer, parameter, public max_optran_predictors
Definition: PAFV_Define.f90:78
elemental subroutine, public pafv_create(self, n_ODPS_Layers, n_User_Layers, n_Absorbers, No_OPTRAN)
character(*), parameter write_error_status
Definition: PAFV_Define.f90:67
logical function, public pafv_validrelease(self)
subroutine, public pafv_inspect(self)
subroutine inquire_cleanup()
character(*), parameter module_version_id
Definition: PAFV_Define.f90:61
integer, parameter data_missing
Definition: PAFV_Define.f90:74
integer, parameter, public max_optran_order
Definition: PAFV_Define.f90:77
subroutine read_cleanup()
integer, parameter, public max_optran_used_predictors
Definition: PAFV_Define.f90:79
subroutine write_cleanup()
integer function, public open_binary_file(Filename, FileID, For_Output, No_Check)
real(fp), parameter, public one
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
elemental logical function, public pafv_associated(self)
integer function, public pafv_readfile(PAFV, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer, parameter pafv_release
Definition: PAFV_Define.f90:64
subroutine, public pafv_info(self, Info)
integer function, public writegatts_binary_file(fid, Write_Module, Created_On, Title, History, Comment)
elemental subroutine, public pafv_destroy(self)
elemental logical function pafv_equal(x, y)
#define min(a, b)
Definition: mosaic_util.h:32
integer, parameter pafv_version
Definition: PAFV_Define.f90:65
integer, parameter ml
Definition: PAFV_Define.f90:72
integer, parameter, public success
integer, parameter, public information