FV3 Bundle
CRTM_Predictor_Define.f90
Go to the documentation of this file.
1 !
2 ! CRTM_Predictor_Define
3 !
4 ! Module containing the definition of the container predictor structure for
5 ! the gaseous absorption transmittance models
6 !
7 
8 
10 
11  ! -----------------
12  ! Environment setup
13  ! -----------------
14  ! Module use
15  USE type_kinds, ONLY: fp
18  USE crtm_taucoeff, ONLY: tc
19  ! ODAS modules
25  USE odas_predictor, ONLY: odas_max_n_predictors => max_n_predictors, &
26  odas_max_n_absorbers => max_n_absorbers , &
27  odas_max_n_orders => max_n_orders
28  ! ODPS modules
34  pafv_associated , &
35  pafv_destroy , &
36  pafv_create
42  ! ODZeeman modules
46  ! Disable implicit typing
47  IMPLICIT NONE
48 
49 
50  ! ------------
51  ! Visibilities
52  ! ------------
53  ! Everything private by default
54  PRIVATE
55  ! Datatypes
56  PUBLIC :: crtm_predictor_type
57  ! Procedures
59  PUBLIC :: crtm_predictor_destroy
60  PUBLIC :: crtm_predictor_create
61  PUBLIC :: crtm_predictor_inspect
62 
63 
64  ! -----------------
65  ! Module parameters
66  ! -----------------
67  CHARACTER(*), PARAMETER :: module_version_id = &
68  '$Id: CRTM_Predictor_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
69  ! Message string length
70  INTEGER, PARAMETER :: ml = 256
71 
72 
73  ! ---------------------
74  ! Structure definitions
75  ! ---------------------
76  ! Predictor container structure definition
78  ! Allocation indicator
79  LOGICAL :: is_allocated = .false.
80  ! The predictor sub-objects
81  TYPE(odas_predictor_type) :: odas
82  TYPE(odps_predictor_type) :: odps
83  TYPE(odps_predictor_type) :: odzeeman
84  END TYPE crtm_predictor_type
85 
86 
87 CONTAINS
88 
89 
90 !################################################################################
91 !################################################################################
92 !## ##
93 !## ## PUBLIC MODULE ROUTINES ## ##
94 !## ##
95 !################################################################################
96 !################################################################################
97 
98 !--------------------------------------------------------------------------------
99 !:sdoc+:
100 !
101 ! NAME:
102 ! CRTM_Predictor_Associated
103 !
104 ! PURPOSE:
105 ! Elemental function to test the association status of the
106 ! CRTM_Predictor structure.
107 !
108 ! CALLING SEQUENCE:
109 ! Status = CRTM_Predictor_Associated( CRTM_Predictor )
110 !
111 ! OBJECTS:
112 ! CRTM_Predictor:
113 ! Structure which is to have its member's
114 ! status tested.
115 ! UNITS: N/A
116 ! TYPE: CRTM_Predictor_type
117 ! DIMENSION: Scalar or any rank
118 ! ATTRIBUTES: INTENT(IN)
119 !
120 ! FUNCTION RESULT:
121 ! Status:
122 ! The return value is a logical value indicating the
123 ! status of the allocated members.
124 ! .TRUE. - if the CRTM_Predictor object has been allocated.
125 ! .FALSE. - if the CRTM_Predictor object has NOT been allocated.
126 ! UNITS: N/A
127 ! TYPE: LOGICAL
128 ! DIMENSION: Same as input
129 !
130 !:sdoc-:
131 !--------------------------------------------------------------------------------
132 
133  ELEMENTAL FUNCTION crtm_predictor_associated(self) RESULT(status)
134  TYPE(crtm_predictor_type), INTENT(IN) :: self
135  LOGICAL :: status
136  status = self%Is_Allocated
137  END FUNCTION crtm_predictor_associated
138 
139 
140 !--------------------------------------------------------------------------------
141 !:sdoc+:
142 !
143 ! NAME:
144 ! CRTM_Predictor_Destroy
145 !
146 ! PURPOSE:
147 ! Elemental subroutine to re-initialize CRTM_Predictor container objects.
148 !
149 ! CALLING SEQUENCE:
150 ! CALL CRTM_Predictor_Destroy( CRTM_Predictor )
151 !
152 ! OBJECTS:
153 ! CRTM_Predictor:
154 ! Re-initialized CRTM_Predictor structure.
155 ! UNITS: N/A
156 ! TYPE: CRTM_Predictor_type
157 ! DIMENSION: Scalar or any rank
158 ! ATTRIBUTES: INTENT(OUT)
159 !
160 !:sdoc-:
161 !--------------------------------------------------------------------------------
162 
163  ELEMENTAL SUBROUTINE crtm_predictor_destroy(self)
164  TYPE(crtm_predictor_type), INTENT(OUT) :: self
165  self%Is_Allocated =.false.
166  END SUBROUTINE crtm_predictor_destroy
167 
168 
169 !--------------------------------------------------------------------------------
170 !:sdoc+:
171 !
172 ! NAME:
173 ! CRTM_Predictor_Create
174 !
175 ! PURPOSE:
176 ! Elemental subroutine to create an instance of a CRTM_Predictor object.
177 !
178 ! CALLING SEQUENCE:
179 ! CALL CRTM_Predictor_Create( &
180 ! CRTM_Predictor, &
181 ! n_Layers , &
182 ! SensorIndex )
183 !
184 ! OBJECTS:
185 ! CRTM_Predictor:
186 ! CRTM_Predictor object structure.
187 ! UNITS: N/A
188 ! TYPE: CRTM_Predictor_type
189 ! DIMENSION: Scalar or any rank
190 ! ATTRIBUTES: INTENT(OUT)
191 !
192 ! INPUTS:
193 ! n_Layers:
194 ! Number of atmospheric layers.
195 ! Must be > 0.
196 ! UNITS: N/A
197 ! TYPE: INTEGER
198 ! DIMENSION: Conformable with the CRTM_Predictor object
199 ! ATTRIBUTES: INTENT(IN)
200 !
201 ! SensorIndex:
202 ! Sensor index id. This is a unique index associated
203 ! with a (supported) sensor used to access the
204 ! shared coefficient data for a particular sensor.
205 ! See the ChannelIndex argument.
206 ! UNITS: N/A
207 ! TYPE: INTEGER
208 ! DIMENSION: Conformable with the CRTM_Predictor object
209 ! ATTRIBUTES: INTENT(IN)
210 !
211 !:sdoc-:
212 !--------------------------------------------------------------------------------
213 
214  ELEMENTAL SUBROUTINE crtm_predictor_create( &
215  self , & ! Output
216  n_Layers , & ! Input
217  SensorIndex , & ! Input
218  SaveFWV ) ! Optional Input
219  ! Arguments
220  TYPE(crtm_predictor_type), INTENT(OUT) :: self
221  INTEGER, INTENT(IN) :: n_layers
222  INTEGER, INTENT(IN) :: sensorindex
223  INTEGER, OPTIONAL, INTENT(IN) :: savefwv
224  ! Local variables
225  INTEGER :: i, idx
226  LOGICAL :: no_optran
227  LOGICAL :: allocate_success
228 
229 
230  ! Check input
231  IF ( n_layers < 1 ) RETURN
232 
233 
234  ! Call the required procedure
235  idx = tc%Sensor_LoIndex(sensorindex)
236  SELECT CASE( tc%Algorithm_ID(sensorindex) )
237 
238 
239  ! Predictors for ODAS transmittance model
240  CASE( odas_algorithm )
241  CALL odas_predictor_create( &
242  self%ODAS , &
243  n_layers , &
244  odas_max_n_predictors , &
245  odas_max_n_absorbers , &
246  maxval(tc%ODAS(idx)%Max_Order) )
247  allocate_success = odas_predictor_associated(self%ODAS)
248 
249 
250  ! Predictors for ODPS transmittance model
251  CASE( odps_algorithm )
252  i = tc%ODPS(idx)%Group_Index
253  ! ...Set OPTRAN flag
254  no_optran = .NOT. ((tc%ODPS(idx)%n_OCoeffs > 0) .AND. allow_optran)
255  ! ...Allocate main structure
256  CALL odps_predictor_create( &
257  self%ODPS , &
258  tc%ODPS(idx)%n_Layers , &
259  n_layers , &
260  odps_get_n_components(i) , &
262  no_optran = no_optran )
263  allocate_success = odps_predictor_associated(self%ODPS)
264  ! ...Allocate memory for saved forward variables
265  ! *****FLAW*****
266  ! MUST CHECK FOR SaveFWV *VALUE* NOT JUST PRESCENCE!
267  IF ( PRESENT(savefwv) .AND. odps_get_savefwvflag() ) THEN
268  ! *****FLAW*****
269  CALL pafv_create( &
270  self%ODPS%PAFV , &
271  tc%ODPS(idx)%n_Layers , &
272  n_layers , &
274  no_optran = no_optran )
275  allocate_success = allocate_success .AND. &
276  pafv_associated(self%ODPS%PAFV)
277  END IF
278 
279 
280  ! Predictors for SSU instrument specific model
281  CASE( odssu_algorithm )
282 
283  SELECT CASE( tc%ODSSU(idx)%subAlgorithm )
284 
285  ! Predictors for ODAS SSU transmittance model
286  CASE( odas_algorithm )
287  CALL odas_predictor_create( &
288  self%ODAS , &
289  n_layers , &
290  odas_max_n_predictors, &
291  odas_max_n_absorbers , &
292  odas_max_n_orders )
293  allocate_success = odas_predictor_associated(self%ODAS)
294 
295  ! Predictors for ODPS SSU transmittance model
296  CASE( odps_algorithm )
297  i = tc%ODSSU(idx)%ODPS(1)%Group_Index
298  ! ...Set OPTRAN flag
299  no_optran = .NOT. ((tc%ODSSU(idx)%ODPS(1)%n_OCoeffs > 0) .AND. allow_optran)
300  ! ...Allocate main structure
301  CALL odps_predictor_create( &
302  self%ODPS , &
303  tc%ODSSU(idx)%ODPS(1)%n_Layers, &
304  n_layers , &
305  odps_get_n_components(i) , &
307  no_optran = no_optran )
308  allocate_success = odps_predictor_associated(self%ODPS)
309  ! ...Allocate memory for saved forward variables
310  ! *****FLAW*****
311  ! MUST CHECK FOR SaveFWV *VALUE* NOT JUST PRESCENCE!
312  IF ( PRESENT(savefwv) .AND. odps_get_savefwvflag() ) THEN
313  ! *****FLAW*****
314  CALL pafv_create( &
315  self%ODPS%PAFV , &
316  tc%ODSSU(idx)%ODPS(1)%n_Layers, &
317  n_layers , &
318  odps_get_n_absorbers(i) , &
319  no_optran = no_optran )
320  allocate_success = allocate_success .AND. &
321  pafv_associated(self%ODPS%PAFV)
322  END IF
323  END SELECT
324  END SELECT
325 
326 
327  ! Check status
328  IF ( .NOT. allocate_success ) RETURN
329 
330 
331  ! Is this a Zeeman channel?
332  idx = tc%ZSensor_LoIndex(sensorindex)
333  zeeman_block: IF ( idx > 0 ) THEN
334  i = tc%ODZeeman(idx)%Group_index
335  ! ...Set OPTRAN flag
336  no_optran = .true.
337  ! ...Allocate main structure
338  CALL odps_predictor_create( &
339  self%ODZeeman , &
340  tc%ODZeeman(idx)%n_Layers, &
341  n_layers , &
343  get_numofzpredictors(i) , &
344  no_optran = no_optran )
345  allocate_success = odps_predictor_associated(self%ODZeeman)
346  ! ...Allocate memory for saved forward variables
347  ! *****FLAW*****
348  ! MUST CHECK FOR SaveFWV *VALUE* NOT JUST PRESCENCE!
349  IF ( PRESENT(savefwv) ) THEN
350  ! *****FLAW*****
351  CALL pafv_create( &
352  self%ODZeeman%PAFV , &
353  tc%ODZeeman(idx)%n_Layers, &
354  n_layers , &
355  get_numofzabsorbers() , &
356  no_optran = no_optran )
357  allocate_success = allocate_success .AND. &
358  pafv_associated(self%ODZeeman%PAFV)
359  END IF
360  ! Check status
361  IF ( .NOT. allocate_success ) RETURN
362  END IF zeeman_block
363 
364 
365  ! Explicitly set allocation indicator
366  self%Is_Allocated = .true.
367 
368  END SUBROUTINE crtm_predictor_create
369 
370 
371 !--------------------------------------------------------------------------------
372 !:sdoc+:
373 !
374 ! NAME:
375 ! CRTM_Predictor_Inspect
376 !
377 ! PURPOSE:
378 ! Subroutine to print the contents of a CRTM_Predictor object to stdout
379 !
380 ! CALLING SEQUENCE:
381 ! CALL CRTM_Predictor_Inspect( Predictor )
382 !
383 ! OBJECTSS:
384 ! Predictor:
385 ! Object to display.
386 ! UNITS: N/A
387 ! TYPE: CRTM_Predictor_type
388 ! DIMENSION: Scalar
389 ! ATTRIBUTES: INTENT(IN)
390 !
391 !:sdoc-:
392 !--------------------------------------------------------------------------------
393 
394  SUBROUTINE crtm_predictor_inspect(self)
395  TYPE(crtm_predictor_type), INTENT(IN) :: self
396  WRITE(*,'(1x,"CRTM_Predictor CONTAINER OBJECT -- BEGIN")')
397 ! ! Release/version info
398 ! WRITE(*,'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version
399  ! Container objects
400  IF ( crtm_predictor_associated(self) ) THEN
401  IF ( odas_predictor_associated(self%ODAS) ) CALL odas_predictor_inspect(self%ODAS)
402  IF ( odps_predictor_associated(self%ODPS) ) CALL odps_predictor_inspect(self%ODPS)
403  IF ( odps_predictor_associated(self%ODZeeman) ) CALL odps_predictor_inspect(self%ODZeeman)
404 ! IF ( ODZeeman_Predictor_Associated(self%ODZeeman) ) CALL ODZeeman_Predictor_Inspect(self%ODZeeman)
405  END IF
406  WRITE(*,'(1x,"CRTM_Predictor CONTAINER OBJECT -- END")')
407  END SUBROUTINE crtm_predictor_inspect
408 
409 
410 
411 END MODULE crtm_predictor_define
integer, parameter, public failure
pure integer function, public odps_get_n_components(Group_Index)
subroutine, public crtm_predictor_inspect(self)
elemental subroutine, public odas_predictor_create(self, n_Layers, n_Predictors, n_Absorbers, n_Orders)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
pure integer function, public odps_get_n_absorbers(Group_Index)
integer, parameter, public max_n_absorbers
integer, parameter, public max_n_predictors
elemental subroutine, public odps_predictor_destroy(self)
elemental subroutine, public crtm_predictor_create(self, n_Layers, SensorIndex, SaveFWV)
subroutine, public odps_predictor_inspect(self)
pure integer function, public get_numofzcomponents()
integer, parameter, public max_n_orders
subroutine, public odas_predictor_inspect(self)
character(*), parameter module_version_id
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
elemental subroutine, public odas_predictor_destroy(self)
pure integer function, public get_numofzpredictors(gIndex)
logical, parameter, public allow_optran
integer, parameter, public odssu_algorithm
elemental subroutine, public odps_predictor_create(self, n_Layers, n_User_Layers, n_Components, n_Predictors, No_OPTRAN)
elemental subroutine, public crtm_predictor_destroy(self)
pure integer function, public odps_get_max_n_predictors(Group_Index)
integer, parameter, public odps_algorithm
integer, parameter, public odas_algorithm
elemental logical function, public odps_predictor_associated(self)
elemental logical function, public odas_predictor_associated(self)
pure integer function, public get_numofzabsorbers()
pure logical function, public odps_get_savefwvflag()
elemental logical function, public crtm_predictor_associated(self)
type(taucoeff_type), save, public tc
integer, parameter, public success