FV3 Bundle
ODAS_Predictor_Define.f90
Go to the documentation of this file.
1 !
2 ! ODAS_Predictor_Define
3 !
4 ! Module defining the Predictor object for the Optical Depth in
5 ! Absorber Space (ODAS) algorithm and containing routines to
6 ! manipulate it.
7 !
8 ! CREATION HISTORY:
9 ! Written by: Paul van Delst, 22-Dec-2006
10 ! paul.vandelst@noaa.gov
11 !
12 ! Modifed by: Yong Han, 25-June-2008
13 ! yong.han@noaa.gov
14 !
15 
17 
18  ! ------------------
19  ! Environment set up
20  ! ------------------
21  ! Module use
22  USE type_kinds, ONLY: fp
23  ! Disable implicit typing
24  IMPLICIT NONE
25 
26 
27  ! ------------
28  ! Visibilities
29  ! ------------
30  ! Everything private by default
31  PRIVATE
32  ! Datatypes
33  PUBLIC :: odas_predictor_type
34 ! ! Operators
35 ! PUBLIC :: OPERATOR(==)
36  ! Procedures
38  PUBLIC :: odas_predictor_destroy
39  PUBLIC :: odas_predictor_create
40  PUBLIC :: odas_predictor_inspect
41  PUBLIC :: odas_predictor_zero
42 ! PUBLIC :: ODAS_Predictor_ValidRelease
43 ! PUBLIC :: ODAS_Predictor_Info
44 ! PUBLIC :: ODAS_Predictor_DefineVersion
45 ! PUBLIC :: ODAS_Predictor_InquireFile
46 ! PUBLIC :: ODAS_Predictor_ReadFile
47 ! PUBLIC :: ODAS_Predictor_WriteFile
48 
49 
50  ! ---------------------
51  ! Procedure overloading
52  ! ---------------------
53 ! INTERFACE OPERATOR(==)
54 ! MODULE PROCEDURE ODAS_Predictor_Equal
55 ! END INTERFACE OPERATOR(==)
56 
57 
58  ! -----------------
59  ! Module parameters
60  ! -----------------
61  CHARACTER(*), PARAMETER :: module_version_id = &
62  '$Id: ODAS_Predictor_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
63  ! Release and version
64  INTEGER, PARAMETER :: odas_predictor_release = 3 ! This determines structure and file formats.
65  INTEGER, PARAMETER :: odas_predictor_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  ! Message string length
71  INTEGER, PARAMETER :: ml = 256
72 
73 
74  ! -----------------------
75  ! Derived type definition
76  ! -----------------------
77  !:tdoc+:
79  ! Allocation indicator
80  LOGICAL :: is_allocated = .false.
81  ! Release and version information
82  INTEGER :: release = odas_predictor_release
83  INTEGER :: version = odas_predictor_version
84  ! Dimension variables
85  INTEGER :: n_layers = 0 ! K
86  INTEGER :: n_predictors = 0 ! I
87  INTEGER :: n_absorbers = 0 ! J
88  INTEGER :: n_orders = 0 ! IO
89  ! Scalars
90  REAL(fp) :: secant_sensor_zenith = zero
91  ! Arrays
92  REAL(fp), ALLOCATABLE :: a(:,:) ! 0:K x J, Integrated absorber
93  REAL(fp), ALLOCATABLE :: da(:,:) ! K x J, Integrated absorber level difference
94  REAL(fp), ALLOCATABLE :: avea(:,:) ! K x J, Integrated absorber layer average
95  REAL(fp), ALLOCATABLE :: ap(:,:,:) ! K x IO x J, Power of absorber level
96  REAL(fp), ALLOCATABLE :: x(:,:) ! K x I, Predictors
97  END TYPE odas_predictor_type
98  !:tdoc-:
99 
100 
101 CONTAINS
102 
103 
104 !##################################################################################
105 !##################################################################################
106 !## ##
107 !## ## PUBLIC MODULE ROUTINES ## ##
108 !## ##
109 !##################################################################################
110 !##################################################################################
111 
112 !--------------------------------------------------------------------------------
113 !:sdoc+:
114 !
115 ! NAME:
116 ! ODAS_Predictor_Associated
117 !
118 ! PURPOSE:
119 ! Elemental function to test the status of the allocatable components
120 ! of the ODAS_Predictor structure.
121 !
122 ! CALLING SEQUENCE:
123 ! Status = ODAS_Predictor_Associated( ODAS_Predictor )
124 !
125 ! OBJECTS:
126 ! ODAS_Predictor:
127 ! Structure which is to have its member's
128 ! status tested.
129 ! UNITS: N/A
130 ! TYPE: ODAS_Predictor_type
131 ! DIMENSION: Scalar or any rank
132 ! ATTRIBUTES: INTENT(IN)
133 !
134 ! FUNCTION RESULT:
135 ! Status:
136 ! The return value is a logical value indicating the
137 ! status of the allocated members.
138 ! .TRUE. - if the ODAS_Predictor object has been allocated.
139 ! .FALSE. - if the ODAS_Predictor object has NOT been allocated.
140 ! UNITS: N/A
141 ! TYPE: LOGICAL
142 ! DIMENSION: Same as input
143 !
144 !:sdoc-:
145 !--------------------------------------------------------------------------------
146 
147  ELEMENTAL FUNCTION odas_predictor_associated( self ) RESULT( Status )
148  TYPE(odas_predictor_type), INTENT(IN) :: self
149  LOGICAL :: status
150  status = self%Is_Allocated
151  END FUNCTION odas_predictor_associated
152 
153 
154 !--------------------------------------------------------------------------------
155 !:sdoc+:
156 !
157 ! NAME:
158 ! ODAS_Predictor_Destroy
159 !
160 ! PURPOSE:
161 ! Elemental subroutine to re-initialize ODAS_Predictor objects.
162 !
163 ! CALLING SEQUENCE:
164 ! CALL ODAS_Predictor_Destroy( ODAS_Predictor )
165 !
166 ! OBJECTS:
167 ! ODAS_Predictor:
168 ! Re-initialized ODAS_Predictor structure.
169 ! UNITS: N/A
170 ! TYPE: ODAS_Predictor_type
171 ! DIMENSION: Scalar or any rank
172 ! ATTRIBUTES: INTENT(OUT)
173 !
174 !:sdoc-:
175 !--------------------------------------------------------------------------------
176 
177  ELEMENTAL SUBROUTINE odas_predictor_destroy( self )
178  TYPE(odas_predictor_type), INTENT(OUT) :: self
179  self%Is_Allocated = .false.
180  END SUBROUTINE odas_predictor_destroy
181 
182 
183 !--------------------------------------------------------------------------------
184 !:sdoc+:
185 !
186 ! NAME:
187 ! ODAS_Predictor_Create
188 !
189 ! PURPOSE:
190 ! Elemental subroutine to create an instance of an ODAS_Predictor object.
191 !
192 ! CALLING SEQUENCE:
193 ! CALL ODAS_Predictor_Create( &
194 ! ODAS_Predictor, &
195 ! n_Layers , &
196 ! n_Predictors , &
197 ! n_Absorbers , &
198 ! n_Orders )
199 !
200 ! OBJECTS:
201 ! ODAS_Predictor:
202 ! ODAS_Predictor object structure.
203 ! UNITS: N/A
204 ! TYPE: ODAS_Predictor_type
205 ! DIMENSION: Scalar or any rank
206 ! ATTRIBUTES: INTENT(OUT)
207 !
208 ! INPUTS:
209 ! n_Layers:
210 ! Number of atmospheric layers.
211 ! Must be > 0.
212 ! UNITS: N/A
213 ! TYPE: INTEGER
214 ! DIMENSION: Conformable with the ODAS_Predictor object
215 ! ATTRIBUTES: INTENT(IN)
216 !
217 ! n_Predictors:
218 ! Number of absorption predictors.
219 ! Must be > 0.
220 ! UNITS: N/A
221 ! TYPE: INTEGER
222 ! DIMENSION: Conformable with the ODAS_Predictor object
223 ! ATTRIBUTES: INTENT(IN)
224 !
225 ! n_Absorbers:
226 ! Number of atmospheric absorbers.
227 ! Must be > 0.
228 ! UNITS: N/A
229 ! TYPE: INTEGER
230 ! DIMENSION: Conformable with the ODAS_Predictor object
231 ! ATTRIBUTES: INTENT(IN)
232 !
233 ! n_Orders:
234 ! The polynormial function order for all absorbers
235 ! Must be > 0
236 ! UNITS: N/A
237 ! TYPE: INTEGER
238 ! DIMENSION: Conformable with the ODAS_Predictor object
239 ! ATTRIBUTES: INTENT(IN)
240 !
241 !:sdoc-:
242 !--------------------------------------------------------------------------------
243 
244  ELEMENTAL SUBROUTINE odas_predictor_create( &
245  self , & ! Output
246  n_Layers , & ! Input
247  n_Predictors , & ! Input
248  n_Absorbers , & ! Input
249  n_Orders ) ! Input
250  ! Arguments
251  TYPE(odas_predictor_type), INTENT(OUT) :: self
252  INTEGER, INTENT(IN) :: n_layers
253  INTEGER, INTENT(IN) :: n_predictors
254  INTEGER, INTENT(IN) :: n_absorbers
255  INTEGER, INTENT(IN) :: n_orders
256  ! Local variables
257  INTEGER :: alloc_stat
258 
259  ! Check input
260  IF ( n_layers < 1 .OR. &
261  n_predictors < 1 .OR. &
262  n_absorbers < 1 .OR. &
263  n_orders < 1 ) RETURN
264 
265 
266  ! Perform the allocation
267  ALLOCATE( self%A(0:n_layers,n_absorbers), &
268  self%dA(n_layers,n_absorbers), &
269  self%aveA(n_layers,n_absorbers), &
270  self%Ap(n_layers,n_orders,n_absorbers), &
271  self%X(n_layers,n_predictors), &
272  stat = alloc_stat )
273  IF ( alloc_stat /= 0 ) RETURN
274 
275 
276  ! Initialise dimensions
277  self%n_Layers = n_layers
278  self%n_Predictors = n_predictors
279  self%n_Absorbers = n_absorbers
280  self%n_Orders = n_orders
281 
282 
283  ! Set allocation indicator
284  self%Is_Allocated = .true.
285 
286 
287  ! Initialise array data
288  CALL odas_predictor_zero(self)
289 
290  END SUBROUTINE odas_predictor_create
291 
292 
293 
294 !--------------------------------------------------------------------------------
295 !:sdoc+:
296 !
297 ! NAME:
298 ! ODAS_Predictor_Inspect
299 !
300 ! PURPOSE:
301 ! Subroutine to print the contents of a ODAS_Predictor object to stdout.
302 !
303 ! CALLING SEQUENCE:
304 ! CALL ODAS_Predictor_Inspect( ODAS_Predictor )
305 !
306 ! OBJECTS:
307 ! ODAS_Predictor:
308 ! ODAS_Predictor object to display.
309 ! UNITS: N/A
310 ! TYPE: ODAS_Predictor_type
311 ! DIMENSION: Scalar
312 ! ATTRIBUTES: INTENT(IN)
313 !
314 !:sdoc-:
315 !--------------------------------------------------------------------------------
316 
317  SUBROUTINE odas_predictor_inspect(self)
318  TYPE(odas_predictor_type), INTENT(IN) :: self
319  CHARACTER(*), PARAMETER :: rfmt='es13.6'
320  INTEGER :: i, j
321  WRITE(*,'(1x,"ODAS_Predictor OBJECT")')
322  ! Release/version info
323  WRITE(*,'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
324  ! Dimensions
325  WRITE(*,'(3x,"n_Layers :",1x,i0)') self%n_Layers
326  WRITE(*,'(3x,"n_Predictors :",1x,i0)') self%n_Predictors
327  WRITE(*,'(3x,"n_Absorbers :",1x,i0)') self%n_Absorbers
328  WRITE(*,'(3x,"n_Orders :",1x,i0)') self%n_Orders
329  ! ODAS scalar data
330  WRITE(*,'(3x,"ODAS scalar data :")')
331  WRITE(*,'(5x,"Secant_Sensor_Zenith :",'//rfmt//')') self%Secant_Sensor_Zenith
332  ! ODAS array data
333  IF ( .NOT. odas_predictor_associated(self) ) RETURN
334  WRITE(*,'(3x,"ODAS data arrays :")')
335  WRITE(*,'(5x,"Integrated Absorber :")')
336  DO j = 1, self%n_Absorbers
337  WRITE(*,'(7x,"Absorber#: ",i0)') j
338  WRITE(*,'(5(1x,'//rfmt//',:))') self%A(:,j)
339  END DO
340  WRITE(*,'(5x,"Integrated Absorber Level Difference:")')
341  DO j = 1, self%n_Absorbers
342  WRITE(*,'(7x,"Absorber#: ",i0)') j
343  WRITE(*,'(5(1x,'//rfmt//',:))') self%dA(:,j)
344  END DO
345  WRITE(*,'(5x,"Integrated Absorber Layer Average:")')
346  DO j = 1, self%n_Absorbers
347  WRITE(*,'(7x,"Absorber#: ",i0)') j
348  WRITE(*,'(5(1x,'//rfmt//',:))') self%aveA(:,j)
349  END DO
350  WRITE(*,'(5x,"Exponent Power of Absorber Level :")')
351  DO j = 1, self%n_Absorbers
352  DO i = 1, self%n_Orders
353  WRITE(*,'(7x,"Absorber#: ",i0,"; Order#: ",i0)') j, i
354  WRITE(*,'(5(1x,'//rfmt//',:))') self%Ap(:,i,j)
355  END DO
356  WRITE(*,*)
357  END DO
358  DO i = 1, self%n_Predictors
359  WRITE(*,'(7x,"Predictor#: ",i0)') i
360  WRITE(*,'(5(1x,'//rfmt//',:))') self%X(:,i)
361  END DO
362  END SUBROUTINE odas_predictor_inspect
363 
364 
365 !--------------------------------------------------------------------------------
366 !:sdoc+:
367 !
368 ! NAME:
369 ! ODAS_Predictor_Zero
370 !
371 ! PURPOSE:
372 ! Elemental subroutine to zero-out an instance of an ODAS predictor object.
373 !
374 ! CALLING SEQUENCE:
375 ! CALL ODAS_Predictor_Zero( ODAS_Predictor )
376 !
377 ! OUTPUTS:
378 ! ODAS_Predictor:
379 ! ODAS_Predictor object structure.
380 ! UNITS: N/A
381 ! TYPE: ODAS_Predictor_type
382 ! DIMENSION: Scalar or any rank
383 ! ATTRIBUTES: INTENT(IN OUT)
384 !
385 !:sdoc-:
386 !--------------------------------------------------------------------------------
387 
388  ELEMENTAL SUBROUTINE odas_predictor_zero( self )
389  TYPE(odas_predictor_type), INTENT(IN OUT) :: self
390  IF ( .NOT. odas_predictor_associated(self) ) RETURN
391  self%Secant_Sensor_Zenith = zero
392  self%A = zero
393  self%dA = zero
394  self%aveA = zero
395  self%Ap = zero
396  self%X = zero
397  END SUBROUTINE odas_predictor_zero
398 
399 END MODULE odas_predictor_define
integer, parameter odas_predictor_release
elemental subroutine, public odas_predictor_zero(self)
real(fp), parameter, public zero
elemental subroutine, public odas_predictor_create(self, n_Layers, n_Predictors, n_Absorbers, n_Orders)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
character(*), parameter write_error_status
subroutine, public odas_predictor_inspect(self)
elemental subroutine, public odas_predictor_destroy(self)
character(*), parameter module_version_id
elemental logical function, public odas_predictor_associated(self)
integer, parameter odas_predictor_version