FV3 Bundle
ODAS_Predictor.f90
Go to the documentation of this file.
1 !
2 ! ODAS_Predictor
3 !
4 ! Module continaing routines to compute the predictors for the
5 ! Optical Depth in Absorber Space (ODAS) .
6 !
7 !
8 ! CREATION HISTORY:
9 ! Written by: Paul van Delst, 29-Aug-2006
10 ! paul.vandelst@noaa.gov
11 !
12 ! Modified by: Yong Han, 25-June-2008
13 ! yong.han@noaa.gov
14 !
15 
17 
18  ! -----------------
19  ! Environment setup
20  ! -----------------
21  ! Module use
22  USE type_kinds , ONLY: fp
24  USE crtm_parameters , ONLY: zero , &
26  one, two, three, ten , &
28  toa_pressure , &
33  h2o_id, o3_id
41  ! Disable implicit typing
42  IMPLICIT NONE
43 
44  ! ------------
45  ! Visibilities
46  ! ------------
47  ! Everything private by default
48  PRIVATE
49  ! Datatypes
50  PUBLIC :: ivar_type
51  ! Procedures
52  PUBLIC :: odas_assemble_predictors
55  ! Parameters
56  PUBLIC :: max_n_absorbers
57  PUBLIC :: wet_absorber_index
58  PUBLIC :: dry_absorber_index
59  PUBLIC :: ozo_absorber_index
60  PUBLIC :: absorber_index
61  PUBLIC :: absorber_name
64  PUBLIC :: max_n_predictors
65  PUBLIC :: max_n_predictors_used
66  PUBLIC :: max_n_orders
67 
68 
69  ! -----------------
70  ! Module parameters
71  ! -----------------
72  CHARACTER(*), PARAMETER :: module_version_id = &
73  '$Id: ODAS_Predictor.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
74 
75 
76  ! Absorbers in the gas absorption model
77  ! -------------------------------------
78  ! The total number
79  INTEGER, PARAMETER :: max_n_absorbers = 3
80  ! The indexing order of the absorbers
81  INTEGER, PARAMETER :: wet_absorber_index = 1
82  INTEGER, PARAMETER :: dry_absorber_index = 2
83  INTEGER, PARAMETER :: ozo_absorber_index = 3
84  ! The absorber index and name arrays
85  INTEGER, PARAMETER :: absorber_index(max_n_absorbers) = &
86  (/ wet_absorber_index, &
89  CHARACTER(*), PARAMETER :: absorber_name(max_n_absorbers) = &
90  (/ 'wet', &
91  'dry', &
92  'ozo' /)
93 
94 
95  ! Predictors in the gas absorption model
96  ! --------------------------------------
97  ! Standard predictors are absorber independent
98  INTEGER, PARAMETER :: max_n_standard_predictors = 11
99  ! Integrated predictors are defined for EACH absoreber
100  INTEGER, PARAMETER :: max_n_integrated_predictors = 6
101  ! The total number of predictors
102  INTEGER, PARAMETER :: max_n_predictors = max_n_standard_predictors + &
104  ! The number selected from the total to be
105  ! used in the gas absorption algorithm
106  INTEGER, PARAMETER :: max_n_predictors_used = 6
107  ! Maximum number of polynomial orders for
108  ! reconstructing the gas absorption coefficients
109  INTEGER, PARAMETER :: max_n_orders = 10
110 
111 
112  ! ------------------------------------------
113  ! Structure definition to hold forward model
114  ! variables across FWD, TL, and AD calls
115  ! ------------------------------------------
116  TYPE :: ivar_type
117  PRIVATE
118  REAL(fp), DIMENSION(0:MAX_N_LAYERS,MAX_N_ABSORBERS) :: a_2 = zero
119  REAL(fp), DIMENSION(MAX_N_LAYERS,MAX_N_ABSORBERS) :: factor_1 = zero
120  REAL(fp), DIMENSION(MAX_N_LAYERS,MAX_N_ABSORBERS) :: factor_2 = zero
121  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS,0:MAX_N_LAYERS,MAX_N_ABSORBERS) :: s ! no need to initialized it to zero
122  REAL(fp), DIMENSION(MAX_N_LAYERS,MAX_N_ABSORBERS) :: a_level ! no need to initialized it to zero
123  END TYPE ivar_type
124 
125 
126 CONTAINS
127 
128 
129 !################################################################################
130 !################################################################################
131 !## ##
132 !## ## PUBLIC MODULE ROUTINES ## ##
133 !## ##
134 !################################################################################
135 !################################################################################
136 
137 !--------------------------------------------------------------------------------
138 !:sdoc+:
139 !
140 ! NAME:
141 ! ODAS_Assemble_Predictors
142 !
143 ! PURPOSE:
144 ! Subroutine to assemble all the gas absorption model predictors
145 ! for the ODAS algorithm.
146 !
147 ! CALLING SEQUENCE:
148 ! CALL ODAS_Assemble_Predictors( &
149 ! Atmosphere , &
150 ! GeometryInfo, &
151 ! Max_Order , &
152 ! Alpha , &
153 ! Predictor , &
154 ! iVar )
155 !
156 ! INPUTS:
157 ! Atmosphere:
158 ! Structure containing the atmospheric state data.
159 ! UNITS: N/A
160 ! TYPE: CRTM_Atmosphere_type
161 ! DIMENSION: Scalar
162 ! ATTRIBUTES: INTENT(IN)
163 !
164 ! GeometryInfo:
165 ! Structure containing the view geometry information.
166 ! UNITS: N/A
167 ! TYPE: CRTM_GeometryInfo_type
168 ! DIMENSION: Scalar
169 ! ATTRIBUTES: INTENT(IN)
170 !
171 ! Max_Order:
172 ! The maximum order of the polynomial function for each absorber
173 ! UNITS: N/A
174 ! TYPE: INTEGER
175 ! DIMENSION: 1D array (n_Absorbers)
176 ! ATTRIBUTES: INTENT(IN)
177 !
178 ! Alpha:
179 ! The alpha coefficients for absorber level calculations
180 ! UNITS: depends on the units of the absorber
181 ! TYPE: INTEGER
182 ! DIMENSION: 2D array (n_Alphas x n_Absorbers)
183 ! ATTRIBUTES: INTENT(IN)
184 !
185 ! OUTPUTS:
186 ! Predictor:
187 ! Structure containing the integrated absorber and predictor profiles.
188 ! UNITS: N/A
189 ! TYPE: ODAS_Predictor_type
190 ! DIMENSION: Scalar
191 ! ATTRIBUTES: INTENT(IN OUT)
192 !
193 ! iVar:
194 ! Structure containing internal variables required for subsequent
195 ! tangent-linear or adjoint model calls. The contents of this
196 ! structure are NOT accessible outside of this module.
197 ! UNITS: N/A
198 ! TYPE: iVar_type
199 ! DIMENSION: Scalar
200 ! ATTRIBUTES: INTENT(OUT)
201 !
202 ! COMMENTS:
203 ! The predictors used in the gas absorption model are organised in
204 ! the following manner:
205 !
206 ! ------------------------------------------------------------------------------
207 ! | 1 | 2 | 3 | ... | 9 | 10 | 11 | 12 |....| 17 | 18 |....| 23 | 24 |....| 29 |
208 ! ------------------------------------------------------------------------------
209 !
210 ! \ /\ /\ /\ /
211 ! \ / \ / \ / \ /
212 ! ---------------------------- ----------- ----------- -----------
213 ! | | | |
214 ! v v v v
215 !
216 ! Standard Integrated Integrated Integrated
217 ! Predictors predictors predictors predictors
218 ! for for for
219 ! Absorber 1 Absorber 2 Absorber 3
220 ! (water vapor) (dry gases) (ozone)
221 !
222 !:sdoc-:
223 !--------------------------------------------------------------------------------
224 
225  SUBROUTINE odas_assemble_predictors( &
226  Atmosphere , & ! Input
227  GeometryInfo, & ! Input
228  Max_Order , & ! Input
229  Alpha , & ! Input
230  Predictor , & ! Output
231  iVar ) ! Internal variable output
232  ! Arguments
233  TYPE(crtm_atmosphere_type), INTENT(IN) :: atmosphere
234  TYPE(crtm_geometryinfo_type), INTENT(IN) :: geometryinfo
235  INTEGER, INTENT(IN) :: max_order(:)
236  REAL(fp), INTENT(IN) :: alpha(:,:)
237  TYPE(odas_predictor_type), INTENT(IN OUT) :: predictor
238  TYPE(ivar_type), INTENT(OUT) :: ivar
239  ! Local variables
240  INTEGER :: i,j,k,n_layers
241  REAL(fp) :: secant_sensor_zenith
242 
243  ! Save the angle information
244  CALL crtm_geometryinfo_getvalue( geometryinfo, &
245  secant_trans_zenith = secant_sensor_zenith )
246  predictor%Secant_Sensor_Zenith = secant_sensor_zenith
247 
248  ! Compute the nadir integrated absorber profiles
249  CALL compute_intabsorber( atmosphere, predictor )
250 
251  ! Compute the predictors
252  ! ...Standard predictors
253  CALL standard_predictors( atmosphere, predictor )
254  ! ...Integrated predictors
255  CALL integrated_predictors( atmosphere, predictor, ivar )
256 
257 
258  ! Calculate absorber space level associated with the average
259  ! absorber amount
260  !
261  ! Absorber level, k, to amount
262  !
263  ! A(k) = C1.exp(Alpha * k) + C2
264  !
265  ! Absorber amount to level
266  !
267  ! 1 A - C2
268  ! k = ----- LN ------
269  ! Alpha C1
270  !
271  ! AP(k, i) = A(k)**(i), i = 1, Max_Order(j)
272  !
273  ! Alpha : absorber amount-level coordinate constant
274  ! C1,C2 : scaling factors for level in the range of 0 to 1
275  n_layers = atmosphere%n_Layers
276  DO j = 1, predictor%n_Absorbers
277 
278  IF( max_order(j) < 0 )cycle
279 
280  DO k = 1, n_layers
281  ivar%A_Level(k,j) = log((predictor%aveA(k,j) - alpha(3,j)) / alpha(2,j)) / &
282  ! ----------------------------------------------------
283  alpha(1,j)
284  END DO
285 
286  predictor%Ap(1:n_layers, 1, j) = ivar%A_Level(1:n_layers,j)
287  DO i = 2, max_order(j)
288  DO k = 1, n_layers
289  predictor%Ap(k, i, j) = predictor%Ap(k, i-1, j) * ivar%A_Level(k,j)
290  END DO
291  END DO
292  END DO
293 
294  END SUBROUTINE odas_assemble_predictors
295 
296 
297 !--------------------------------------------------------------------------------
298 !:sdoc+:
299 !
300 ! NAME:
301 ! ODAS_Assemble_Predictors_TL
302 !
303 ! PURPOSE:
304 ! Subroutine to assemble all the gas absorption model predictors
305 ! for the tangent-linear ODAS algorithm.
306 !
307 ! CALLING SEQUENCE:
308 ! CALL ODAS_Assemble_Predictors_TL ( &
309 ! Atmosphere , & ! FWD Input
310 ! Predictor , & ! FWD Input
311 ! Atmosphere_TL, & ! TL Input
312 ! Max_Order , & ! Input
313 ! Alpha , & ! Input
314 ! Predictor_TL , & ! TL Output
315 ! iVar ) ! Internal variable input
316 !
317 ! INPUTS:
318 ! Atmosphere:
319 ! Structure containing the atmospheric state data.
320 ! UNITS: N/A
321 ! TYPE: CRTM_Atmosphere_type
322 ! DIMENSION: Scalar
323 ! ATTRIBUTES: INTENT(IN)
324 !
325 ! Predictor:
326 ! Structure containing the integrated absorber and predictor profiles.
327 ! UNITS: N/A
328 ! TYPE: ODAS_Predictor_type
329 ! DIMENSION: Scalar
330 ! ATTRIBUTES: INTENT(IN)
331 !
332 ! Atmosphere_TL:
333 ! Structure containing the tanggent-linear atmospheric state data.
334 ! UNITS: N/A
335 ! TYPE: CRTM_Atmosphere_type
336 ! DIMENSION: Scalar
337 ! ATTRIBUTES: INTENT(IN)
338 !
339 ! GeometryInfo:
340 ! Structure containing the view geometry information.
341 ! UNITS: N/A
342 ! TYPE: CRTM_GeometryInfo_type
343 ! DIMENSION: Scalar
344 ! ATTRIBUTES: INTENT(IN)
345 !
346 ! Max_Order:
347 ! The maximum order of the polynomial function for each absorber
348 ! UNITS: N/A
349 ! TYPE: INTEGER
350 ! DIMENSION: 1D array (n_Absorbers)
351 ! ATTRIBUTES: INTENT(IN)
352 !
353 ! Alpha:
354 ! The alpha coefficients for absorber level calculations
355 ! UNITS: depends on the units of the absorber
356 ! TYPE: INTEGER
357 ! DIMENSION: 2D array (n_Alphas x n_Absorbers)
358 ! ATTRIBUTES: INTENT(IN)
359 !
360 ! iVar:
361 ! Structure containing internal variables required for subsequent
362 ! tangent-linear or adjoint model calls. The contents of this
363 ! structure are NOT accessible outside of this module.
364 ! UNITS: N/A
365 ! TYPE: iVar_type
366 ! DIMENSION: Scalar
367 ! ATTRIBUTES: INTENT(OUT)
368 !
369 ! OUTPUTS:
370 ! Predictor_TL:
371 ! Structure containing the tangent-linear integrated absorber
372 ! and predictor profiles.
373 ! UNITS: N/A
374 ! TYPE: ODAS_Predictor_type
375 ! DIMENSION: Scalar
376 ! ATTRIBUTES: INTENT(IN OUT)
377 !
378 ! COMMENTS:
379 ! The predictors used in the gas absorption model are organised in
380 ! the following manner:
381 !
382 ! ------------------------------------------------------------------------------
383 ! | 1 | 2 | 3 | ... | 9 | 10 | 11 | 12 |....| 17 | 18 |....| 23 | 24 |....| 29 |
384 ! ------------------------------------------------------------------------------
385 !
386 ! \ /\ /\ /\ /
387 ! \ / \ / \ / \ /
388 ! ---------------------------- ----------- ----------- -----------
389 ! | | | |
390 ! v v v v
391 !
392 ! Standard Integrated Integrated Integrated
393 ! Predictors predictors predictors predictors
394 ! for for for
395 ! Absorber 1 Absorber 2 Absorber 3
396 ! (water vapor) (dry gases) (ozone)
397 !
398 !:sdoc-:
399 !--------------------------------------------------------------------------------
400 
401  SUBROUTINE odas_assemble_predictors_tl( &
402  Atmosphere , & ! FWD Input
403  Predictor , & ! FWD Input
404  Atmosphere_TL, & ! TL Input
405  Max_Order , & ! Input
406  Alpha , & ! Input
407  Predictor_TL , & ! TL Output
408  iVar ) ! Internal variable input
409  ! Arguments
410  TYPE(crtm_atmosphere_type), INTENT(IN) :: atmosphere
411  TYPE(odas_predictor_type), INTENT(IN) :: predictor
412  TYPE(crtm_atmosphere_type), INTENT(IN) :: atmosphere_tl
413  INTEGER, INTENT(IN) :: max_order(:)
414  REAL(fp), INTENT(IN) :: alpha(:,:)
415  TYPE(odas_predictor_type), INTENT(IN OUT) :: predictor_tl
416  TYPE(ivar_type), INTENT(IN) :: ivar
417  ! Local variables
418  REAL(fp) :: a_level_tl(atmosphere%n_layers)
419  INTEGER :: i, j, k, n_layers
420 
421  ! Save the angle information
422  predictor_tl%Secant_Sensor_Zenith = predictor%Secant_Sensor_Zenith
423 
424  ! Compute the tangent-linear nadir integrated absorber profiles
425  CALL compute_intabsorber_tl( &
426  atmosphere , & ! Input
427  atmosphere_tl, & ! Input
428  predictor_tl ) ! Output
429 
430  ! Compute the tangent-linear predictors
431  ! ...Standard predictors
432  CALL standard_predictors_tl( &
433  atmosphere , & ! Input
434  atmosphere_tl, & ! Input
435  predictor_tl ) ! Output
436  ! ...Integrated predictors
438  atmosphere , & ! Input
439  predictor , & ! Input
440  atmosphere_tl, & ! Input
441  predictor_tl , & ! Output
442  ivar ) ! Internal variable input
443 
444 
445  ! Calculate tangent-linear absorber space level associated
446  ! with the average absorber amount
447  n_layers = atmosphere%n_Layers
448  DO j = 1, predictor%n_Absorbers
449 
450  IF( max_order(j) < 0 )cycle
451 
452  DO k = 1, n_layers
453 
454  a_level_tl(k) = predictor_tl%aveA(k,j) / &
455  ! -------------------------------------------------
456  (alpha(1,j) * (predictor%aveA(k,j) - alpha(3,j)))
457  END DO
458 
459  predictor_tl%Ap(1:n_layers, 1, j) = a_level_tl(1:n_layers)
460  DO i = 2, max_order(j)
461  DO k = 1, n_layers
462  predictor_tl%Ap(k, i, j) = (predictor_tl%Ap(k,i-1,j)*ivar%A_Level(k,j)) + &
463  (predictor%Ap(k,i-1,j) *a_level_tl(k))
464  END DO
465  END DO
466  END DO
467 
468  END SUBROUTINE odas_assemble_predictors_tl
469 
470 
471 !--------------------------------------------------------------------------------
472 !:sdoc+:
473 !
474 ! NAME:
475 ! ODAS_Assemble_Predictors_AD
476 !
477 ! PURPOSE:
478 ! Subroutine to assemble all the gas absorption model predictors
479 ! for the adjoint ODAS algorithm.
480 !
481 ! CALLING SEQUENCE:
482 ! CALL ODAS_Assemble_Predictors_AD ( &
483 ! Atmosphere , & ! FWD Input
484 ! Predictor , & ! FWD Input
485 ! Predictor_AD , & ! AD Input
486 ! Max_Order , & ! Input
487 ! Alpha , & ! Input
488 ! Atmosphere_AD, & ! AD Output
489 ! iVar ) ! Internal variable input
490 !
491 ! INPUTS:
492 ! Atmosphere:
493 ! Structure containing the atmospheric state data.
494 ! UNITS: N/A
495 ! TYPE: CRTM_Atmosphere_type
496 ! DIMENSION: Scalar
497 ! ATTRIBUTES: INTENT(IN)
498 !
499 ! Predictor:
500 ! Structure containing the integrated absorber and predictor profiles.
501 ! UNITS: N/A
502 ! TYPE: ODAS_Predictor_type
503 ! DIMENSION: Scalar
504 ! ATTRIBUTES: INTENT(IN)
505 !
506 ! Predictor_AD:
507 ! Structure containing the adjoint integrated absorber and
508 ! predictor profiles.
509 ! **NOTE: This structure is zeroed upon output
510 ! UNITS: N/A
511 ! TYPE: ODAS_Predictor_type
512 ! DIMENSION: Scalar
513 ! ATTRIBUTES: INTENT(IN OUT)
514 !
515 ! Max_Order:
516 ! The maximum order of the polynomial function for each absorber
517 ! UNITS: N/A
518 ! TYPE: INTEGER
519 ! DIMENSION: 1D array (n_Absorbers)
520 ! ATTRIBUTES: INTENT(IN)
521 !
522 ! Alpha:
523 ! The alpha coefficients for absorber level calculations
524 ! UNITS: depends on the units of the absorber
525 ! TYPE: INTEGER
526 ! DIMENSION: 2D array (n_Alphas x n_Absorbers)
527 ! ATTRIBUTES: INTENT(IN)
528 !
529 ! iVar:
530 ! Structure containing internal variables required for subsequent
531 ! tangent-linear or adjoint model calls. The contents of this
532 ! structure are NOT accessible outside of this module.
533 ! UNITS: N/A
534 ! TYPE: iVar_type
535 ! DIMENSION: Scalar
536 ! ATTRIBUTES: INTENT(OUT)
537 !
538 ! OUTPUTS:
539 ! Atmosphere_AD:
540 ! Structure containing the adjoint atmospheric state data.
541 ! UNITS: N/A
542 ! TYPE: CRTM_Atmosphere_type
543 ! DIMENSION: Scalar
544 ! ATTRIBUTES: INTENT(IN OUT)
545 !
546 ! COMMENTS:
547 ! The predictors used in the gas absorption model are organised in
548 ! the following manner:
549 !
550 ! ------------------------------------------------------------------------------
551 ! | 1 | 2 | 3 | ... | 9 | 10 | 11 | 12 |....| 17 | 18 |....| 23 | 24 |....| 29 |
552 ! ------------------------------------------------------------------------------
553 !
554 ! \ /\ /\ /\ /
555 ! \ / \ / \ / \ /
556 ! ---------------------------- ----------- ----------- -----------
557 ! | | | |
558 ! v v v v
559 !
560 ! Standard Integrated Integrated Integrated
561 ! Predictors predictors predictors predictors
562 ! for for for
563 ! water vapor dry gases ozone
564 !:sdoc-:
565 !--------------------------------------------------------------------------------
566 
567  SUBROUTINE odas_assemble_predictors_ad( &
568  Atmosphere , & ! FWD Input
569  Predictor , & ! FWD Input
570  Predictor_AD , & ! AD Input
571  Max_Order , & ! Input
572  Alpha , & ! Input
573  Atmosphere_AD, & ! AD Output
574  iVar ) ! Internal variable input
575  ! Arguments
576  TYPE(crtm_atmosphere_type), INTENT(IN) :: atmosphere
577  TYPE(odas_predictor_type), INTENT(IN) :: predictor
578  TYPE(odas_predictor_type), INTENT(IN OUT) :: predictor_ad
579  INTEGER, INTENT(IN) :: max_order(:)
580  REAL(fp), INTENT(IN) :: alpha(:,:)
581  TYPE(crtm_atmosphere_type), INTENT(IN OUT) :: atmosphere_ad
582  TYPE(ivar_type), INTENT(IN) :: ivar
583  ! Local variables
584  REAL(fp):: a_level_ad(atmosphere%n_layers)
585  INTEGER :: i, j, k, n_layers
586 
587  ! Save the angle information
588  predictor_ad%Secant_Sensor_Zenith = predictor%Secant_Sensor_Zenith
589 
590  ! Calculate adjoint absorber space level associated
591  ! with the average absorber amount
592  a_level_ad = zero
593  n_layers = atmosphere%n_Layers
594  DO j = 1, predictor%n_Absorbers
595 
596  IF( max_order(j) < 0 )cycle
597 
598  DO i = max_order(j), 2, -1
599  DO k = n_layers, 1, -1
600 
601  predictor_ad%Ap(k, i-1, j) = predictor_ad%Ap(k,i-1,j) + &
602  (predictor_ad%Ap(k,i,j)*ivar%A_Level(k,j))
603  a_level_ad(k) = a_level_ad(k) + (predictor%Ap(k,i-1,j)*predictor_ad%Ap(k,i,j))
604  predictor_ad%Ap(k,i,j) = zero
605 
606  END DO
607  END DO
608 
609  a_level_ad(1:n_layers) = a_level_ad(1:n_layers) + predictor_ad%Ap(1:n_layers,1,j)
610  predictor_ad%Ap(1:n_layers, 1, j) = zero
611 
612  DO k = n_layers, 1, -1
613  predictor_ad%aveA(k,j) = predictor_ad%aveA(k,j) + &
614  (a_level_ad(k) / (alpha(1,j) * (predictor%aveA(k,j) - alpha(3,j))))
615  a_level_ad(k) = zero
616 
617  END DO
618  END DO
619 
620 
621  ! Calculate the predictor adjoints
622  ! ...Integrated predictors
624  atmosphere , & ! Input
625  predictor , & ! Input
626  predictor_ad , & ! In/Output
627  atmosphere_ad, & ! Output
628  ivar ) ! Internal variable input
629  ! ...Standard predictors
630  CALL standard_predictors_ad( &
631  atmosphere , & ! Input
632  predictor_ad , & ! Input
633  atmosphere_ad ) ! Output
634 
635 
636  ! Compute the nadir integrated absorber profile adjoint
637  CALL compute_intabsorber_ad( &
638  atmosphere , & ! Input
639  predictor_ad , & ! Output
640  atmosphere_ad ) ! Input
641 
642 
643  ! Zero the adjoint predictor structure
644  CALL odas_predictor_zero( predictor_ad )
645 
646  END SUBROUTINE odas_assemble_predictors_ad
647 
648 
649 !################################################################################
650 !################################################################################
651 !## ##
652 !## ## PRIVATE MODULE ROUTINES ## ##
653 !## ##
654 !################################################################################
655 !################################################################################
656 
657 !================================================================================
658 ! -- INTEGRATED ABSORBER COMPUTATION ROUTINES --
659 !================================================================================
660 
661 !--------------------------------------------------------------------------------
662 !
663 ! NAME:
664 ! Compute_IntAbsorber
665 !
666 ! PURPOSE:
667 ! Subroutine to compute the integrated absorber profiles.
668 !
669 ! LANGUAGE:
670 ! Fortran-95
671 !
672 ! CALLING SEQUENCE:
673 ! CALL Compute_IntAbsorber( Atmosphere, & ! Input
674 ! Predictor ) ! Output
675 !
676 ! INPUT ARGUMENTS:
677 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
678 ! state data.
679 ! UNITS: N/A
680 ! TYPE: CRTM_Atmosphere_type
681 ! DIMENSION: Scalar
682 ! ATTRIBUTES: INTENT(IN)
683 !
684 ! OUTPUT ARGUMENTS:
685 ! Predictor: Predictor structure containing the calculated
686 ! integrated absorber profiles
687 ! UNITS: N/A
688 ! TYPE: ODAS_Predictor_type
689 ! DIMENSION: Scalar
690 ! ATTRIBUTES: INTENT(IN OUT)
691 !
692 !--------------------------------------------------------------------------------
693 
694  SUBROUTINE compute_intabsorber( Atm, & ! Input
695  Pred ) ! Output
696  ! Arguments
697  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
698  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred
699  ! Local variables
700  INTEGER :: k, j
701  REAL(fp) :: dPonG
702  INTEGER :: H2O_Idx
703  INTEGER :: O3_Idx
704 
705  ! Initialise 0'th level amounts
706  pred%A(0,wet_absorber_index) = zero
707  pred%A(0,dry_absorber_index) = min(toa_pressure,atm%Level_Pressure(0))
708  pred%A(0,ozo_absorber_index) = zero
709 
710  ! Get the atmosphere gaseous absorber indices
711  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
712  o3_idx = crtm_get_absorberidx(atm, o3_id)
713 
714  ! Loop over layers, TOA -> SFC
715  DO k = 1, atm%n_Layers
716 
717  ! Compute dP/g for the current layer
718  dpong = reciprocal_gravity * (atm%Level_Pressure(k) - atm%Level_Pressure(k-1))
719 
720  ! Compute and accumulate the sum for the
721  ! layer absorber amounts for each absorber
722  pred%A( k, wet_absorber_index ) = pred%A(k-1,wet_absorber_index) + &
723  (dpong * atm%Absorber(k,h2o_idx))
724  pred%A( k, dry_absorber_index ) = atm%Level_Pressure(k)
725 
726  pred%A( k, ozo_absorber_index ) = pred%A(k-1,ozo_absorber_index) + &
727  (dpong * atm%Absorber(k,o3_idx))
728 
729  END DO
730 
731  ! Modify absorber quantities by the angle secant
732  pred%A = pred%Secant_Sensor_Zenith * pred%A
733 
734  ! Compute the integrated absorber level
735  ! differences and average layer amount
736  DO j = 1, pred%n_Absorbers
737  DO k = 1, pred%n_Layers
738  pred%dA(k,j) = pred%A(k,j) - pred%A(k-1,j)
739  pred%aveA(k,j) = point_5 * (pred%A(k,j) + pred%A(k-1,j))
740  END DO
741  END DO
742 
743  END SUBROUTINE compute_intabsorber
744 
745 
746 !--------------------------------------------------------------------------------
747 !
748 ! NAME:
749 ! Compute_IntAbsorber_TL
750 !
751 ! PURPOSE:
752 ! Subroutine to compute the tangent-linear integrated absorber profiles.
753 !
754 ! CALLING SEQUENCE:
755 ! CALL Compute_IntAbsorber_TL( Atmosphere, & ! Input
756 ! Atmosphere_TL, & ! Input
757 ! Predictor_TL ) ! Output
758 !
759 ! INPUT ARGUMENTS:
760 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
761 ! state data.
762 ! UNITS: N/A
763 ! TYPE: CRTM_Atmosphere_type
764 ! DIMENSION: Scalar
765 ! ATTRIBUTES: INTENT(IN)
766 !
767 ! Atmosphere_TL: CRTM Atmosphere structure containing the tangent-linear
768 ! atmospheric state data, i.e. the perturbations.
769 ! UNITS: N/A
770 ! TYPE: CRTM_Atmosphere_type
771 ! DIMENSION: Scalar
772 ! ATTRIBUTES: INTENT(IN)
773 !
774 !
775 ! OUTPUT ARGUMENTS:
776 ! Predictor_TL: Predictor structure containing the calculated
777 ! tangent-linear integrated absorber profiles
778 ! UNITS: N/A
779 ! TYPE: ODAS_Predictor_type
780 ! DIMENSION: Scalar
781 ! ATTRIBUTES: INTENT(IN OUT)
782 !
783 !--------------------------------------------------------------------------------
784 
785  SUBROUTINE compute_intabsorber_tl( Atm, & ! Input
786  Atm_TL, & ! Input
787  Pred_TL ) ! Output
788  ! Arguments
789  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
790  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm_TL
791  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_TL
792  ! Local variables
793  INTEGER :: k, j
794  REAL(fp) :: dPonG
795  REAL(fp) :: dPonG_TL
796  INTEGER :: H2O_Idx
797  INTEGER :: O3_Idx
798 
799  ! Initalise 0'th level amounts
800  pred_tl%A(0,:) = zero
801 
802  ! Get the atmosphere gaseous absorber indices
803  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
804  o3_idx = crtm_get_absorberidx(atm, o3_id)
805 
806  ! Loop over layers, TOA -> SFC
807  DO k = 1, atm_tl%n_Layers
808 
809  ! Compute dP/g for the current layer
810  dpong = reciprocal_gravity * (atm%Level_Pressure(k) - atm%Level_Pressure(k-1))
811  dpong_tl = reciprocal_gravity * (atm_tl%Level_Pressure(k) - atm_tl%Level_Pressure(k-1))
812 
813  ! Compute and accumulate the sum for the
814  ! layer absorber amounts for each absorber
815  pred_tl%A(k,wet_absorber_index) = pred_tl%A(k-1,wet_absorber_index) + &
816  (dpong * atm_tl%Absorber(k,h2o_idx)) + &
817  (dpong_tl * atm%Absorber(k,h2o_idx))
818 
819  pred_tl%A(k,dry_absorber_index) = atm_tl%Level_Pressure(k)
820 
821  pred_tl%A(k,ozo_absorber_index) = pred_tl%A(k-1,ozo_absorber_index) + &
822  (dpong * atm_tl%Absorber(k,o3_idx)) + &
823  (dpong_tl * atm%Absorber(k,o3_idx))
824 
825  END DO
826 
827  ! Modify absorber quantities by the angle secant
828  pred_tl%A = pred_tl%Secant_Sensor_Zenith * pred_tl%A
829 
830  ! Compute the tangent-linear integrated absorber level
831  ! differences and average layer amount
832  DO j = 1, pred_tl%n_Absorbers
833  DO k = 1, pred_tl%n_Layers
834  pred_tl%dA(k,j) = pred_tl%A(k,j) - pred_tl%A(k-1,j)
835  pred_tl%aveA(k,j) = point_5 * (pred_tl%A(k,j) + pred_tl%A(k-1,j))
836  END DO
837  END DO
838 
839  END SUBROUTINE compute_intabsorber_tl
840 
841 
842 !--------------------------------------------------------------------------------
843 !
844 ! NAME:
845 ! Compute_IntAbsorber_AD
846 !
847 ! PURPOSE:
848 ! Subroutine to compute the adjoint of the integrated absorber profiles.
849 !
850 ! CALLING SEQUENCE:
851 ! CALL Compute_IntAbsorber_AD( Atmosphere, & ! Input
852 ! Predictor_AD, & ! Input
853 ! Atmosphere_AD ) ! Output
854 !
855 ! INPUT ARGUMENTS:
856 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
857 ! state data.
858 ! UNITS: N/A
859 ! TYPE: CRTM_Atmosphere_type
860 ! DIMENSION: Scalar
861 ! ATTRIBUTES: INTENT(IN)
862 !
863 ! Predictor_AD: Predictor structure that, on input, contains the
864 ! calculated adjoint integrated absorber profiles.
865 ! These values are set to zero on output.
866 ! UNITS: N/A
867 ! TYPE: ODAS_Predictor_type
868 ! DIMENSION: Scalar
869 ! ATTRIBUTES: INTENT(IN OUT)
870 !
871 ! OUTPUT ARGUMENTS:
872 ! Atmosphere_AD: CRTM Atmosphere structure containing the adjoint
873 ! atmospheric state data, i.e. the Jacobians.
874 ! UNITS: N/A
875 ! TYPE: CRTM_Atmosphere_type
876 ! DIMENSION: Scalar
877 ! ATTRIBUTES: INTENT(IN OUT)
878 !
879 ! SIDE EFFECTS:
880 ! Components of the input structure, Predictor_AD, are set to zero
881 ! on output.
882 !
883 !--------------------------------------------------------------------------------
884 
885  SUBROUTINE compute_intabsorber_ad( Atm, & ! Input
886  Pred_AD, & ! Input
887  Atm_AD ) ! Output
888  ! Arguments
889  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
890  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_AD
891  TYPE(CRTM_Atmosphere_type), INTENT(IN OUT) :: Atm_AD
892  ! Local variables
893  INTEGER :: k, j
894  REAL(fp) :: dPonG
895  REAL(fp) :: dPonG_AD
896  INTEGER :: H2O_Idx
897  INTEGER :: O3_Idx
898 
899  ! Get the atmosphere gaseous absorber indices
900  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
901  o3_idx = crtm_get_absorberidx(atm, o3_id)
902 
903  ! Compute the adjoint integrated absorber level
904  ! differences and average layer amount
905  DO j = 1, pred_ad%n_Absorbers
906  DO k = pred_ad%n_Layers, 1, -1
907  pred_ad%A(k-1,j) = pred_ad%A(k-1,j) + (point_5*pred_ad%aveA(k,j))
908  pred_ad%A(k-1,j) = pred_ad%A(k-1,j) - pred_ad%dA(k,j)
909  pred_ad%A(k ,j) = pred_ad%A(k ,j) + (point_5*pred_ad%aveA(k,j))
910  pred_ad%A(k ,j) = pred_ad%A(k ,j) + pred_ad%dA(k,j)
911  pred_ad%dA( k,j) = zero
912  pred_ad%aveA(k,j) = zero
913  END DO
914  END DO
915 
916  ! Modify absorber quantities by the angle secant
917  pred_ad%A = pred_ad%Secant_Sensor_Zenith * pred_ad%A
918 
919  ! Loop over layers, SFC -> TOA
920  DO k = atm_ad%n_Layers, 1, -1
921 
922  ! Compute dP/g for the current layer
923  dpong = reciprocal_gravity * (atm%Level_Pressure(k) - atm%Level_Pressure(k-1))
924 
925  ! Ozone amount adjoint
926  atm_ad%Absorber(k,o3_idx) = atm_ad%Absorber(k,o3_idx) + &
927  (dpong * pred_ad%A(k,ozo_absorber_index))
928 
929  ! Pressure adjoint
930  atm_ad%Level_Pressure(k) = atm_ad%Level_Pressure(k) + pred_ad%A(k,dry_absorber_index)
931 
932  ! Water vapor amount adjoint
933  atm_ad%Absorber(k,h2o_idx) = atm_ad%Absorber(k,h2o_idx) + &
934  (dpong * pred_ad%A(k,wet_absorber_index))
935 
936 
937  ! dP/g adjoint
938  dpong_ad = ( atm%Absorber(k, o3_idx) * pred_ad%A(k,ozo_absorber_index)) + &
939  ( atm%Absorber(k,h2o_idx) * pred_ad%A(k,wet_absorber_index))
940 
941  atm_ad%Level_Pressure(k-1) = atm_ad%Level_Pressure(k-1) - (reciprocal_gravity * dpong_ad)
942  atm_ad%Level_Pressure( k ) = atm_ad%Level_Pressure( k ) + (reciprocal_gravity * dpong_ad)
943 
944  ! Previous layer absorber amounts
945  pred_ad%A(k-1,ozo_absorber_index) = pred_ad%A(k-1,ozo_absorber_index) + &
946  pred_ad%A( k, ozo_absorber_index)
947  pred_ad%A( k, ozo_absorber_index) = zero
948 
949  pred_ad%A( k, dry_absorber_index) = zero
950 
951  pred_ad%A(k-1,wet_absorber_index) = pred_ad%A(k-1,wet_absorber_index) + &
952  pred_ad%A( k, wet_absorber_index)
953  pred_ad%A( k, wet_absorber_index) = zero
954 
955  END DO
956 
957  END SUBROUTINE compute_intabsorber_ad
958 
959 
960 
961 
962 !================================================================================
963 ! -- PREDICTOR COMPUTATION ROUTINES --
964 !================================================================================
965 
966 !--------------------------------------------------------------------------------
967 !
968 ! NAME:
969 ! Standard_Predictors
970 !
971 ! PURPOSE:
972 ! Subroutine to compute the integrated absorber INDEPENDENT
973 ! predictors for the gas absorption model.
974 !
975 ! CALLING SEQUENCE:
976 ! CALL Standard_Predictors( Atmosphere, & ! Input
977 ! Predictor ) ! Output
978 !
979 ! INPUT ARGUMENTS:
980 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
981 ! state data.
982 ! UNITS: N/A
983 ! TYPE: CRTM_Atmosphere_type
984 ! DIMENSION: Scalar
985 ! ATTRIBUTES: INTENT(IN)
986 !
987 ! OUTPUT ARGUMENTS:
988 ! Predictor: Predictor structure containing the calculated
989 ! standard predictors.
990 ! UNITS: N/A
991 ! TYPE: ODAS_Predictor_type
992 ! DIMENSION: Scalar
993 ! ATTRIBUTES: INTENT(IN OUT)
994 !
995 !--------------------------------------------------------------------------------
996 
997  SUBROUTINE standard_predictors( Atm, & ! Input
998  Pred ) ! Output, Istd x K
999  ! Arguments
1000  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1001  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred
1002  ! Local variables
1003  INTEGER :: k
1004  REAL(fp) :: p2
1005  REAL(fp) :: t2
1006  INTEGER :: H2O_Idx
1007 
1008  ! Get the H2O absorber index
1009  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
1010 
1011  ! Compute the standard predictor set
1012  layer_loop: DO k = 1, atm%n_Layers
1013 
1014  ! Precalculate the squared terms
1015  p2 = atm%Pressure(k) * atm%Pressure(k)
1016  t2 = atm%Temperature(k) * atm%Temperature(k)
1017 
1018  ! Calculate the standard predictors
1019  pred%X(k, 1) = atm%Temperature(k)
1020  pred%X(k, 2) = atm%Pressure(k)
1021  pred%X(k, 3) = t2
1022  pred%X(k, 4) = p2
1023  pred%X(k, 5) = atm%Temperature(k) * atm%Pressure(k)
1024  pred%X(k, 6) = t2 * atm%Pressure(k)
1025  pred%X(k, 7) = atm%Temperature(k) * p2
1026  pred%X(k, 8) = t2 * p2
1027  pred%X(k, 9) = atm%Pressure(k)**point_25
1028  pred%X(k,10) = atm%Absorber(k,h2o_idx)
1029  pred%X(k,11) = atm%Absorber(k,h2o_idx) / t2
1030 
1031  END DO layer_loop
1032 
1033  END SUBROUTINE standard_predictors
1034 
1035 
1036 !--------------------------------------------------------------------------------
1037 !
1038 ! NAME:
1039 ! Integrated_Predictors
1040 !
1041 ! PURPOSE:
1042 ! Subroutine to compute the integrated absorber DEPENDENT
1043 ! predictors for the gas absorption model.
1044 !
1045 ! CALLING SEQUENCE:
1046 ! CALL Integrated_Predictors( Atmosphere, & ! Input
1047 ! Predictor, & ! In/Output
1048 ! iVar ) ! Internal variable output
1049 !
1050 ! INPUT ARGUMENTS:
1051 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
1052 ! state data.
1053 ! UNITS: N/A
1054 ! TYPE: CRTM_Atmosphere_type
1055 ! DIMENSION: Scalar
1056 ! ATTRIBUTES: INTENT(IN)
1057 !
1058 ! OUTPUT ARGUMENTS:
1059 ! Predictor: Predictor structure containing the calculated
1060 ! integrated predictors.
1061 ! UNITS: N/A
1062 ! TYPE: ODAS_Predictor_type
1063 ! DIMENSION: Scalar
1064 ! ATTRIBUTES: INTENT(IN OUT)
1065 !
1066 ! iVar: Structure containing internal variables required for
1067 ! subsequent tangent-linear or adjoint model calls.
1068 ! The contents of this structure are NOT accessible
1069 ! outside of the ODAS_Predictor module.
1070 ! UNITS: N/A
1071 ! TYPE: iVar_type
1072 ! DIMENSION: Scalar
1073 ! ATTRIBUTES: INTENT(OUT)
1074 
1075 !--------------------------------------------------------------------------------
1076 
1077  SUBROUTINE integrated_predictors( Atm, & ! Input
1078  Pred, & ! Input/output
1079  iVar ) ! Internal variable output
1080  ! Arguments
1081  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1082  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred
1083  TYPE(iVar_type), INTENT(OUT) :: iVar
1084  ! Local variables
1085  INTEGER :: i, i1, j, k
1086  REAL(fp) :: Inverse_1
1087  REAL(fp) :: Inverse_2
1088  REAL(fp) :: Inverse_3
1089  ! LEVEL Predictor, Iint x 0:K
1090  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS,0:Atm%n_Layers) :: xL
1091 
1092  ! Begin absorber loop
1093  absorber_loop: DO j = 1, pred%n_Absorbers
1094 
1095  ! Determine being index of current absorber predictors
1097 
1098  ! Initialise values
1099  ivar%A_2(0,j) = pred%A(0,j) * pred%A(0,j)
1100  ivar%s(:,0,j) = zero
1101  xl(:,0) = zero
1102 
1103  ! Compute the integrated predictor set
1104  layer_loop: DO k = 1, pred%n_Layers
1105 
1106  ! Calculate Absorber multiplicative Factors
1107  ivar%A_2(k,j) = pred%A(k,j)*pred%A(k,j)
1108  ivar%Factor_1(k,j) = (pred%A(k,j) + pred%A(k-1,j) ) * pred%dA(k,j) ! For ** terms
1109  ivar%Factor_2(k,j) = (ivar%A_2(k,j) + ivar%A_2(k-1,j)) * pred%dA(k,j) ! For *** terms
1110 
1111  ! Calculate the intermediate sums
1112  ivar%s(1,k,j) = ivar%s(1,k-1,j) + ( atm%Temperature(k) * pred%dA(k,j) ) ! T*
1113  ivar%s(2,k,j) = ivar%s(2,k-1,j) + ( atm%Pressure(k) * pred%dA(k,j) ) ! P*
1114  ivar%s(3,k,j) = ivar%s(3,k-1,j) + ( atm%Temperature(k) * ivar%Factor_1(k,j) ) ! T**
1115  ivar%s(4,k,j) = ivar%s(4,k-1,j) + ( atm%Pressure(k) * ivar%Factor_1(k,j) ) ! P**
1116  ivar%s(5,k,j) = ivar%s(5,k-1,j) + ( atm%Temperature(k) * ivar%Factor_2(k,j) ) ! T***
1117  ivar%s(6,k,j) = ivar%s(6,k-1,j) + ( atm%Pressure(k) * ivar%Factor_2(k,j) ) ! P***
1118 
1119  ! Calculate the normalising factors
1120  ! for the integrated predictors
1121  IF ( pred%A(k,j) > minimum_absorber_amount ) THEN
1122  inverse_1 = one / pred%A(k,j)
1123  ELSE
1124  inverse_1 = zero
1125  END IF
1126  inverse_2 = inverse_1 * inverse_1
1127  inverse_3 = inverse_2 * inverse_1
1128 
1129  ! Compute the LEVEL integrated predictors
1130  xl(1,k) = point_5 * ivar%s(1,k,j) * inverse_1 ! T*
1131  xl(2,k) = point_5 * ivar%s(2,k,j) * inverse_1 ! P*
1132  xl(3,k) = point_5 * ivar%s(3,k,j) * inverse_2 ! T**
1133  xl(4,k) = point_5 * ivar%s(4,k,j) * inverse_2 ! P**
1134  xl(5,k) = point_75 * ivar%s(5,k,j) * inverse_3 ! T***
1135  xl(6,k) = point_75 * ivar%s(6,k,j) * inverse_3 ! P***
1136 
1137  ! Sum predictors for current absorber across layers
1138  DO i = 1, max_n_integrated_predictors
1139  pred%X(k,i1+i-1) = xl(i,k) + xl(i,k-1)
1140  END DO
1141 
1142  END DO layer_loop
1143  END DO absorber_loop
1144 
1145  END SUBROUTINE integrated_predictors
1146 
1147 
1148 !--------------------------------------------------------------------------------
1149 !
1150 ! NAME:
1151 ! Standard_Predictors_TL
1152 !
1153 ! PURPOSE:
1154 ! Subroutine to compute the integrated absorber INDEPENDENT
1155 ! tangent-linear predictors for the gas absorption model.
1156 !
1157 ! CALLING SEQUENCE:
1158 ! CALL Standard_Predictors_TL( Atmosphere, & ! Input
1159 ! Atmosphere_TL, & ! Input
1160 ! Predictor_TL ) ! Output
1161 !
1162 ! INPUT ARGUMENTS:
1163 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
1164 ! state data.
1165 ! UNITS: N/A
1166 ! TYPE: CRTM_Atmosphere_type
1167 ! DIMENSION: Scalar
1168 ! ATTRIBUTES: INTENT(IN)
1169 !
1170 ! Atmosphere_TL: CRTM Atmosphere structure containing the tangent-linear
1171 ! atmospheric state data, i.e. the perturbations.
1172 ! UNITS: N/A
1173 ! TYPE: CRTM_Atmosphere_type
1174 ! DIMENSION: Scalar
1175 ! ATTRIBUTES: INTENT(IN)
1176 !
1177 ! OUTPUT ARGUMENTS:
1178 ! Predictor_TL: Predictor structure containing the calculated
1179 ! tangent-linear standard predictors.
1180 ! UNITS: N/A
1181 ! TYPE: ODAS_Predictor_type
1182 ! DIMENSION: Scalar
1183 ! ATTRIBUTES: INTENT(IN OUT)
1184 !
1185 !--------------------------------------------------------------------------------
1186 
1187  SUBROUTINE standard_predictors_tl( Atm, & ! Input
1188  Atm_TL, & ! Input
1189  Pred_TL ) ! Output
1190  ! Arguments
1191  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1192  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm_TL
1193  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_TL
1194  ! Local variables
1195  INTEGER :: k
1196  REAL(fp) :: p2, p2_TL
1197  REAL(fp) :: t2, t2_TL
1198  INTEGER :: H2O_Idx
1199 
1200  ! Get the H2O absorber index
1201  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
1202 
1203  ! Compute the tangent-linear standard predictor set
1204  layer_loop: DO k = 1, atm%n_Layers
1205 
1206  ! Precalculate the squared terms
1207  p2 = atm%Pressure(k) * atm%Pressure(k)
1208  t2 = atm%Temperature(k) * atm%Temperature(k)
1209 
1210  ! Tangent-linear of squared terms
1211  p2_tl = two * atm%Pressure(k) * atm_tl%Pressure(k)
1212  t2_tl = two * atm%Temperature(k) * atm_tl%Temperature(k)
1213 
1214  ! Calculate and assign the integrated absorber independent predictors
1215  pred_tl%X(k, 1) = atm_tl%Temperature(k)
1216  pred_tl%X(k, 2) = atm_tl%Pressure(k)
1217  pred_tl%X(k, 3) = t2_tl
1218  pred_tl%X(k, 4) = p2_tl
1219  pred_tl%X(k, 5) = ( atm%Temperature(k) * atm_tl%Pressure(k) ) + &
1220  ( atm%Pressure(k) * atm_tl%Temperature(k) )
1221  pred_tl%X(k, 6) = ( atm%Pressure(k) * t2_tl ) + &
1222  ( t2 * atm_tl%Pressure(k) )
1223  pred_tl%X(k, 7) = ( atm%Temperature(k) * p2_tl ) + &
1224  ( p2 * atm_tl%Temperature(k) )
1225  pred_tl%X(k, 8) = ( t2 * p2_tl ) + &
1226  ( p2 * t2_tl )
1227  pred_tl%X(k, 9) = point_25 * (atm%Pressure(k)**(-point_75)) * atm_tl%Pressure(k)
1228  pred_tl%X(k,10) = atm_tl%Absorber(k,h2o_idx)
1229  pred_tl%X(k,11) = ( atm_tl%Absorber(k,h2o_idx) - &
1230  ( atm%Absorber(k,h2o_idx) * t2_tl / t2 ) ) / t2
1231 
1232  END DO layer_loop
1233 
1234  END SUBROUTINE standard_predictors_tl
1235 
1236 
1237 !--------------------------------------------------------------------------------
1238 !
1239 ! NAME:
1240 ! Integrated_Predictors_TL
1241 !
1242 ! PURPOSE:
1243 ! Subroutine to compute the integrated absorber amount DEPENDENT
1244 ! tangent-linear predictors for the gas absorption model.
1245 !
1246 ! CALLING SEQUENCE:
1247 ! CALL Integrated_Predictors_TL( Atmosphere, & ! Input
1248 ! Predictor, & ! Input
1249 ! Atmosphere_TL, & ! Input
1250 ! Predictor_TL, & ! In/Output
1251 ! iVar ) ! Internal variable input
1252 !
1253 ! INPUT ARGUMENTS:
1254 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
1255 ! state data.
1256 ! UNITS: N/A
1257 ! TYPE: CRTM_Atmosphere_type
1258 ! DIMENSION: Scalar
1259 ! ATTRIBUTES: INTENT(IN)
1260 !
1261 ! Predictor: Predictor structure containing the calculated
1262 ! integrated predictors.
1263 ! UNITS: N/A
1264 ! TYPE: ODAS_Predictor_type
1265 ! DIMENSION: Scalar
1266 ! ATTRIBUTES: INTENT(IN)
1267 !
1268 ! Atmosphere_TL: CRTM Atmosphere structure containing the tangent-linear
1269 ! atmospheric state data, i.e. the perturbations.
1270 ! UNITS: N/A
1271 ! TYPE: CRTM_Atmosphere_type
1272 ! DIMENSION: Scalar
1273 ! ATTRIBUTES: INTENT(IN)
1274 !
1275 ! iVar: Structure containing internal variables required for
1276 ! subsequent tangent-linear or adjoint model calls.
1277 ! The contents of this structure are NOT accessible
1278 ! outside of the Predictor module.
1279 ! UNITS: N/A
1280 ! TYPE: iVar_type
1281 ! DIMENSION: Scalar
1282 ! ATTRIBUTES: INTENT(IN)
1283 ! OUTPUT ARGUMENTS:
1284 ! Predictor_TL: Predictor structure containing the calculated
1285 ! tangent-linear integrated predictors.
1286 ! UNITS: N/A
1287 ! TYPE: ODAS_Predictor_type
1288 ! DIMENSION: Scalar
1289 ! ATTRIBUTES: INTENT(IN OUT)
1290 !
1291 !--------------------------------------------------------------------------------
1292 
1293  SUBROUTINE integrated_predictors_tl( Atm, & ! Input
1294  Pred, & ! Input
1295  Atm_TL, & ! Input
1296  Pred_TL, & ! Output
1297  iVar ) ! Internal variable input
1298  ! Arguments
1299  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1300  TYPE(ODAS_Predictor_type), INTENT(IN) :: Pred
1301  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm_TL
1302  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_TL
1303  TYPE(iVar_type), INTENT(IN) :: iVar
1304  ! Local variables
1305  INTEGER :: i, i1, j, k
1306  REAL(fp) :: Factor_1_TL
1307  REAL(fp) :: Factor_2_TL
1308  REAL(fp) :: Inverse_1
1309  REAL(fp) :: Inverse_2
1310  REAL(fp) :: Inverse_3
1311  REAL(fp) :: Inverse_4
1312  REAL(fp) :: Inverse_1_TL
1313  REAL(fp) :: Inverse_2_TL
1314  REAL(fp) :: Inverse_3_TL
1315  ! Square of the Absorber amount. 0:K
1316  REAL(fp), DIMENSION(0:Atm%n_Layers) :: A_2_TL
1317  ! Intermediate summation arrays. Iint
1318  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS) :: s_TL
1319  ! LEVEL Predictor, Iint x 0:K
1320  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS,0:Atm%n_Layers) :: xL_TL
1321 
1322  ! Begin absorber loop
1323  absorber_loop: DO j = 1, pred_tl%n_Absorbers
1324 
1325  ! Determine being index of current absorber predictors
1327 
1328  ! Initialise values
1329  a_2_tl(0) = two * pred%A(0,j) * pred_tl%A(0,j)
1330  s_tl(:) = zero
1331  xl_tl(:,0) = zero
1332 
1333  ! Compute the integrated predictor set
1334  layer_loop: DO k = 1, atm%n_Layers
1335 
1336  ! Calculate absorber multiplicative Factors
1337  a_2_tl(k) = two * pred%A(k,j) * pred_tl%A(k,j)
1338  ! For the ** terms
1339  factor_1_tl = ( ( pred%A(k,j) + pred%A(k-1,j) ) * pred_tl%dA(k,j) ) + &
1340  ( ( pred_tl%A(k,j) + pred_tl%A(k-1,j) ) * pred%dA(k,j) )
1341  ! For the *** terms
1342  factor_2_tl = ( ( ivar%A_2(k,j) + ivar%A_2(k-1,j)) * pred_tl%dA(k,j) ) + &
1343  ( ( a_2_tl(k) + a_2_tl(k-1) ) * pred%dA(k,j) )
1344 
1345  ! Calculate the intermediate sums
1346  s_tl(1) = s_tl(1) + ( atm_tl%Temperature(k) * pred%dA(k,j)) + & ! T*
1347  ( atm%Temperature(k) * pred_tl%dA(k,j))
1348  s_tl(2) = s_tl(2) + ( atm_tl%Pressure(k) * pred%dA(k,j)) + & ! P*
1349  ( atm%Pressure(k) * pred_tl%dA(k,j))
1350  s_tl(3) = s_tl(3) + ( atm_tl%Temperature(k) * ivar%Factor_1(k,j)) + & ! T**
1351  ( atm%Temperature(k) * factor_1_tl )
1352  s_tl(4) = s_tl(4) + ( atm_tl%Pressure(k) * ivar%Factor_1(k,j)) + & ! P**
1353  ( atm%Pressure(k) * factor_1_tl )
1354  s_tl(5) = s_tl(5) + ( atm_tl%Temperature(k) * ivar%Factor_2(k,j)) + & ! T***
1355  ( atm%Temperature(k) * factor_2_tl )
1356  s_tl(6) = s_tl(6) + ( atm_tl%Pressure(k) * ivar%Factor_2(k,j)) + & ! P***
1357  ( atm%Pressure(k) * factor_2_tl )
1358 
1359  ! Calculate the normalising factors
1360  ! for the integrated predictors
1361  IF ( pred%A(k,j) > minimum_absorber_amount ) THEN
1362  inverse_1 = one / pred%A(k,j)
1363  ELSE
1364  inverse_1 = zero
1365  END IF
1366  inverse_2 = inverse_1 * inverse_1
1367  inverse_3 = inverse_2 * inverse_1
1368  inverse_4 = inverse_3 * inverse_1
1369  inverse_1_tl = -inverse_2 * pred_tl%A(k,j)
1370  inverse_2_tl = -inverse_3 * pred_tl%A(k,j) * two
1371  inverse_3_tl = -inverse_4 * pred_tl%A(k,j) * three
1372 
1373  ! Compute the tangent-linear LEVEL integrated predictors
1374  xl_tl(1,k) = point_5 * ( ( s_tl(1) * inverse_1 ) + & ! T*
1375  ( ivar%s(1,k,j) * inverse_1_tl ) )
1376  xl_tl(2,k) = point_5 * ( ( s_tl(2) * inverse_1 ) + & ! P*
1377  ( ivar%s(2,k,j) * inverse_1_tl ) )
1378  xl_tl(3,k) = point_5 * ( ( s_tl(3) * inverse_2 ) + & ! T**
1379  ( ivar%s(3,k,j) * inverse_2_tl ) )
1380  xl_tl(4,k) = point_5 * ( ( s_tl(4) * inverse_2 ) + & ! P**
1381  ( ivar%s(4,k,j) * inverse_2_tl ) )
1382  xl_tl(5,k) = point_75 * ( ( s_tl(5) * inverse_3 ) + & ! T***
1383  ( ivar%s(5,k,j) * inverse_3_tl ) )
1384  xl_tl(6,k) = point_75 * ( ( s_tl(6) * inverse_3 ) + & ! P***
1385  ( ivar%s(6,k,j) * inverse_3_tl ) )
1386 
1387  ! Sum predictors across layers
1388  DO i = 1, max_n_integrated_predictors
1389  pred_tl%X(k,i1+i-1) = xl_tl(i,k) + xl_tl(i,k-1)
1390  END DO
1391 
1392  END DO layer_loop
1393  END DO absorber_loop
1394 
1395  END SUBROUTINE integrated_predictors_tl
1396 
1397 
1398 !--------------------------------------------------------------------------------
1399 !
1400 ! NAME:
1401 ! Standard_Predictors_AD
1402 !
1403 ! PURPOSE:
1404 ! Subroutine to compute the integrated absorber amount INDEPENDENT
1405 ! predictors for the adjoint gas absorption model.
1406 !
1407 ! CALLING SEQUENCE:
1408 ! CALL Standard_Predictors_AD( Atmosphere, & ! Input
1409 ! Predictor_AD, & ! Input
1410 ! Atmosphere_AD ) ! Output
1411 !
1412 !
1413 ! INPUT ARGUMENTS:
1414 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
1415 ! state data.
1416 ! UNITS: N/A
1417 ! TYPE: CRTM_Atmosphere_type
1418 ! DIMENSION: Scalar
1419 ! ATTRIBUTES: INTENT(IN)
1420 !
1421 ! Predictor_AD: Predictor structure containing the calculated
1422 ! adjoint integrated predictors.
1423 ! UNITS: N/A
1424 ! TYPE: ODAS_Predictor_type
1425 ! DIMENSION: Scalar
1426 ! ATTRIBUTES: INTENT(IN OUT)
1427 !
1428 ! OUTPUT ARGUMENTS:
1429 ! Atmosphere_AD: CRTM Atmosphere structure containing the adjoints of
1430 ! the standard predictors.
1431 ! UNITS: N/A
1432 ! TYPE: CRTM_Atmosphere_type
1433 ! DIMENSION: Scalar
1434 ! ATTRIBUTES: INTENT(IN OUT)
1435 !
1436 ! COMMENTS:
1437 ! Note that the output adjoint argument, Atmosphere_AD, has INTENT of
1438 ! IN OUT. This is because the pressure, temperature, and absorber
1439 ! components of the Atmosphere_AD structure are assumed to have some
1440 ! initial value (which could simply be zero) that is added to when
1441 ! contructing the pressure, temperature and absorber adjoints.
1442 !
1443 !--------------------------------------------------------------------------------
1444 
1445  SUBROUTINE standard_predictors_ad( Atm, & ! Input
1446  Pred_AD, & ! Input
1447  Atm_AD ) ! Output
1448  ! Arguments
1449  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1450  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_AD
1451  TYPE(CRTM_Atmosphere_type), INTENT(IN OUT) :: Atm_AD
1452  ! Local variables
1453  INTEGER :: k
1454  REAL(fp) :: p2, p2_AD
1455  REAL(fp) :: t2, t2_AD
1456  REAL(fp) :: t4
1457  INTEGER :: H2O_Idx
1458 
1459  ! Get the H2O absorber index
1460  h2o_idx = crtm_get_absorberidx(atm,h2o_id)
1461 
1462  ! Compute the standard predictor set
1463  ! Don't have to loop backwards here as this is a parallel loop
1464  layer_loop: DO k = 1, atm%n_Layers
1465 
1466  ! Precalculate the squared terms
1467  p2 = atm%Pressure(k) * atm%Pressure(k)
1468  t2 = atm%Temperature(k) * atm%Temperature(k)
1469  t4 = t2 * t2
1470 
1471  ! Pressure squared adjoint
1472  p2_ad = pred_ad%X(k,4) + & ! Predictor #4, P^2
1473  ( atm%Temperature(k) * pred_ad%X(k,7) ) + & ! Predictor #7, T.P^2
1474  ( t2 * pred_ad%X(k,8) ) ! Predictor #8, T^2.P^2
1475 
1476  ! Temperature squared adjoint
1477  t2_ad = pred_ad%X(k,3) + & ! Predictor #3, T^2
1478  ( atm%Pressure(k) * pred_ad%X(k,6) ) + & ! Predictor #6, T^2.P
1479  ( p2 * pred_ad%X(k,8) ) + & ! Predictor #8, T^2.P^2
1480  (-atm%Absorber(k,h2o_idx) * pred_ad%X(k,11) / t4 ) ! Predictor #11, W/T^2
1481 
1482  ! Water vapor adjoint
1483  atm_ad%Absorber(k,h2o_idx) = atm_ad%Absorber(k,h2o_idx) + &
1484  pred_ad%X(k,10) + & ! Predictor #10, W
1485  ( pred_ad%X(k,11) / t2 ) ! Predictor #11, W/T^2
1486 
1487  ! Temperature adjoint
1488  atm_ad%Temperature(k) = atm_ad%Temperature(k) + &
1489  ( two * atm%Temperature(k) * t2_ad ) + & ! T^2 term
1490  pred_ad%X(k,1) + & ! Predictor #1, T
1491  ( atm%Pressure(k) * pred_ad%X(k,5) ) + & ! Predictor #5, T.P
1492  ( p2 * pred_ad%X(k,7) ) ! Predictor #7, T.P^2
1493 
1494  ! Pressure adjoint
1495  atm_ad%Pressure(k) = atm_ad%Pressure(k) + &
1496  ( two * atm%Pressure(k) * p2_ad ) + & ! P^2 term
1497  pred_ad%X(k,2) + & ! Predictor #2, P
1498  ( atm%Temperature(k) * pred_ad%X(k,5) ) + & ! Predictor #5, T.P
1499  ( t2 * pred_ad%X(k,6) ) + & ! Predictor #6, T^2.P
1500  ( point_25 * (atm%Pressure(k)**(-point_75)) * pred_ad%X(k,9) ) ! Predictor #9, P^1/4
1501 
1502  END DO layer_loop
1503 
1504  END SUBROUTINE standard_predictors_ad
1505 
1506 
1507 !--------------------------------------------------------------------------------
1508 !
1509 ! NAME:
1510 ! Integrated_Predictors_AD
1511 !
1512 ! PURPOSE:
1513 ! Subroutine to compute the integrated absorber amount DEPENDENT
1514 ! predictors for the adjoint gas absorption model.
1515 !
1516 ! CALLING SEQUENCE:
1517 ! CALL Integrated_Predictors_AD( Atmosphere, & ! Input
1518 ! Predictor, & ! Input
1519 ! Predictor_AD, & ! In/Output
1520 ! Atmosphere_AD, & ! Output
1521 ! iVar ) ! Internal variable input
1522 !
1523 ! INPUT ARGUMENTS:
1524 ! Atmosphere: CRTM Atmosphere structure containing the atmospheric
1525 ! state data.
1526 ! UNITS: N/A
1527 ! TYPE: CRTM_Atmosphere_type
1528 ! DIMENSION: Scalar
1529 ! ATTRIBUTES: INTENT(IN)
1530 !
1531 ! Predictor: Predictor structure containing the calculated
1532 ! integrated predictors.
1533 ! UNITS: N/A
1534 ! TYPE: ODAS_Predictor_type
1535 ! DIMENSION: Scalar
1536 ! ATTRIBUTES: INTENT(IN)
1537 !
1538 ! Predictor_AD: Predictor structure that, on input, contains
1539 ! the adjoint integrated predictors.
1540 ! UNITS: N/A
1541 ! TYPE: ODAS_Predictor_type
1542 ! DIMENSION: Scalar
1543 ! ATTRIBUTES: INTENT(IN OUT)
1544 !
1545 ! OUTPUT ARGUMENTS:
1546 ! Predictor_AD: Predictor structure that, on output, contains
1547 ! the adjoint integrated absorber amounts.
1548 ! UNITS: N/A
1549 ! TYPE: ODAS_Predictor_type
1550 ! DIMENSION: Scalar
1551 ! ATTRIBUTES: INTENT(IN OUT)
1552 !
1553 ! Atmosphere_AD: CRTM Atmosphere structure containing the adjoints of
1554 ! the integrated predictors.
1555 ! UNITS: N/A
1556 ! TYPE: CRTM_Atmosphere_type
1557 ! DIMENSION: Scalar
1558 ! ATTRIBUTES: INTENT(IN OUT)
1559 !
1560 ! COMMENTS:
1561 ! Note that all the adjoint arguments have INTENTs of IN OUT. This is
1562 ! because they are assumed to have some value upon entry even if they
1563 ! are labeled as output arguments.
1564 !
1565 !--------------------------------------------------------------------------------
1566 
1567  SUBROUTINE integrated_predictors_ad( Atm, & ! Input
1568  Pred, & ! Input
1569  Pred_AD, & ! In/Output
1570  Atm_AD, & ! Output
1571  iVar ) ! Internal variable input
1572  ! Arguments
1573  TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atm
1574  TYPE(ODAS_Predictor_type), INTENT(IN) :: Pred
1575  TYPE(ODAS_Predictor_type), INTENT(IN OUT) :: Pred_AD
1576  TYPE(CRTM_Atmosphere_type), INTENT(IN OUT) :: Atm_AD
1577  TYPE(iVar_type), INTENT(IN) :: iVar
1578  ! Local variables
1579  INTEGER :: i, i1, j, k
1580  REAL(fp) :: d_A_AD
1581  REAL(fp) :: Factor_1_AD
1582  REAL(fp) :: Factor_2_AD
1583  REAL(fp) :: Inverse_1
1584  REAL(fp) :: Inverse_2
1585  REAL(fp) :: Inverse_3
1586  REAL(fp) :: Inverse_4
1587  REAL(fp) :: Inverse_1_AD
1588  REAL(fp) :: Inverse_2_AD
1589  REAL(fp) :: Inverse_3_AD
1590  REAL(fp) :: Multiplier
1591  REAL(fp) :: Add_Factor
1592  ! Square of the absorber amount. 0:K
1593  REAL(fp), DIMENSION(0:Atm%n_Layers) :: A_2_AD
1594  ! Intermediate summation array, Iint x 0:K and Iint
1595  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS) :: s_AD
1596  ! LEVEL predictor, Iint x 0:K
1597  REAL(fp), DIMENSION(MAX_N_INTEGRATED_PREDICTORS,0:Atm%n_Layers ) :: xL_AD
1598 
1599  ! Begin absorber loop
1600  absorber_loop: DO j = 1, pred_ad%n_Absorbers
1601 
1602  ! Determine being index of current absorber predictors
1604 
1605  ! Initialise values
1606  xl_ad(:,atm%n_Layers) = zero
1607  s_ad(:) = zero
1608  a_2_ad(atm%n_Layers) = zero
1609 
1610  ! Compute the integrated predictor set adjoints
1611  layer_loop: DO k = atm%n_Layers, 1, -1
1612 
1613  ! Calculate the normalising factors
1614  ! for the integrated predictors
1615  IF ( pred%A(k,j) > minimum_absorber_amount ) THEN
1616  inverse_1 = one / pred%A(k,j)
1617  ELSE
1618  inverse_1 = zero
1619  END IF
1620 
1621  inverse_2 = inverse_1 * inverse_1
1622  inverse_3 = inverse_2 * inverse_1
1623  inverse_4 = inverse_3 * inverse_1
1624 
1625  ! Adjoint of predictor summation across layers
1626  DO i = 1, max_n_integrated_predictors
1627  xl_ad(i,k) = xl_ad(i,k) + pred_ad%X(k,i1+i-1)
1628  xl_ad(i,k-1) = pred_ad%X(k,i1+i-1)
1629  END DO
1630 
1631  ! Adjoint of the LEVEL integrated predictors intermediate sums
1632  !
1633  ! Note that the adjoint variables Inverse_X_AD are local to this
1634  ! loop iteration so they are simply assigned when they are first
1635  ! used.
1636  !
1637  ! P* and T*, Predictor indices #2 and 1
1638  ! Simply assign a value for Inverse_1_AD
1639  multiplier = point_5 * inverse_1
1640  s_ad(1) = s_ad(1) + ( multiplier * xl_ad(1,k) )
1641  s_ad(2) = s_ad(2) + ( multiplier * xl_ad(2,k) )
1642  inverse_1_ad = point_5 * ( ( ivar%s(1,k,j) * xl_ad(1,k) ) + &
1643  ( ivar%s(2,k,j) * xl_ad(2,k) ) )
1644  ! P** and T**, Predictor indices #4 and 3
1645  multiplier = point_5 * inverse_2
1646  s_ad(3) = s_ad(3) + ( multiplier * xl_ad(3,k) )
1647  s_ad(4) = s_ad(4) + ( multiplier * xl_ad(4,k) )
1648  inverse_2_ad = point_5 * ( ( ivar%s(3,k,j) * xl_ad(3,k) ) + &
1649  ( ivar%s(4,k,j) * xl_ad(4,k) ) )
1650  ! P*** and T***, Predictor indices #6 and 5
1651  multiplier = point_75 * inverse_3
1652  s_ad(5) = s_ad(5) + ( multiplier * xl_ad(5,k) )
1653  s_ad(6) = s_ad(6) + ( multiplier * xl_ad(6,k) )
1654  inverse_3_ad = point_75 * ( ( ivar%s(5,k,j) * xl_ad(5,k) ) + &
1655  ( ivar%s(6,k,j) * xl_ad(6,k) ) )
1656 
1657  ! Adjoint of Inverse terms. Note that the Inverse_X_AD
1658  ! terms are *not* zeroed out as they are re-assigned values
1659  ! each loop iteration above.
1660  pred_ad%A(k,j) = pred_ad%A(k,j) - (inverse_2 * inverse_1_ad ) - &
1661  (two * inverse_3 * inverse_2_ad ) - &
1662  (three * inverse_4 * inverse_3_ad )
1663 
1664  ! Pressure adjoint
1665  atm_ad%Pressure(k) = atm_ad%Pressure(k) + &
1666  ( pred%dA(k,j) * s_ad(2) ) + & ! P*
1667  ( ivar%Factor_1(k,j) * s_ad(4) ) + & ! P**
1668  ( ivar%Factor_2(k,j) * s_ad(6) ) ! P***
1669 
1670 
1671  ! Temperature adjoint
1672  atm_ad%Temperature(k) = atm_ad%Temperature(k) + &
1673  ( pred%dA(k,j) * s_ad(1) ) + & ! T*
1674  ( ivar%Factor_1(k,j) * s_ad(3) ) + & ! T**
1675  ( ivar%Factor_2(k,j) * s_ad(5) ) ! T***
1676 
1677  ! Adjoint of the absorber amount
1678  !
1679  ! Note that the adjoint variables Factor_X_AD and
1680  ! d_A_AD are local to this loop iteration
1681  ! so they are simply assigned when they are first
1682  ! used (and thus not zeroed out at the end of each
1683  ! iteration)
1684  !
1685  ! Note there are no
1686  ! s_AD() = 0
1687  ! because all the tangent-linear forms are
1688  ! s_TL() = s_TL() + (...)
1689  ! summing from the previous Layer.
1690  !
1691  ! Multiplicative factors
1692  factor_1_ad = ( atm%Temperature(k) * s_ad(3) ) + &
1693  ( atm%Pressure(k) * s_ad(4) )
1694 
1695  factor_2_ad = ( atm%Temperature(k) * s_ad(5) ) + &
1696  ( atm%Pressure(k) * s_ad(6) )
1697 
1698  ! Adjoint of the square integrated absorber amount.
1699  !
1700  ! Note that A_2_AD() is a LOCAL adjoint variable,
1701  ! so the initialisation of A_2_AD(k-1) here for
1702  ! each "k-1" is o.k. rather than
1703  ! A_2_AD(k-1) = A_2_AD(k-1) + ( d_A(k) * Factor_2_AD )
1704  ! A_2_AD( k ) = A_2_AD( k ) + ( d_A(k) * Factor_2_AD )
1705  ! since only A_2_AD( n_Layers ) is initialised outside the
1706  ! current layer loop.
1707  a_2_ad(k-1) = pred%dA(k,j) * factor_2_ad
1708  a_2_ad( k ) = a_2_ad( k ) + a_2_ad(k-1)
1709 
1710  ! Adjoint of A(). Here, since Pred_AD%A() is NOT a local adjoint
1711  ! variable, we can't use the same form as for A_2_AD() above.
1712  d_a_ad = ( atm%Temperature(k) * s_ad(1) ) + &
1713  ( atm%Pressure(k) * s_ad(2) ) + &
1714  ( ( pred%A(k,j) + pred%A(k-1,j) ) * factor_1_ad ) + &
1715  ( ( ivar%A_2(k,j) + ivar%A_2(k-1,j) ) * factor_2_ad )
1716 
1717  add_factor = pred%dA(k,j) * factor_1_ad
1718  pred_ad%A(k-1,j) = pred_ad%A(k-1,j) + add_factor - d_a_ad
1719  pred_ad%A( k ,j) = pred_ad%A( k ,j) + add_factor + d_a_ad + &
1720  ( two * pred%A(k,j) * a_2_ad(k) )
1721  a_2_ad(k) = zero
1722 
1723  END DO layer_loop
1724 
1725  ! Adjoint of level 0 A
1726  pred_ad%A(0,j) = pred_ad%A(0,j) + ( two * pred%A(0,j) * a_2_ad(0) )
1727  a_2_ad(0) = zero
1728 
1729  END DO absorber_loop
1730 
1731  END SUBROUTINE integrated_predictors_ad
1732 
1733 END MODULE odas_predictor
real(fp), parameter, public point_25
character(*), parameter module_version_id
integer, parameter, public failure
integer, parameter, public max_n_standard_predictors
real(fp), parameter, public ten
elemental subroutine, public odas_predictor_zero(self)
real(fp), parameter, public zero
subroutine compute_intabsorber_tl(Atm, Atm_TL, Pred_TL)
subroutine standard_predictors(Atm, Pred)
elemental subroutine, public odas_predictor_create(self, n_Layers, n_Predictors, n_Absorbers, n_Orders)
subroutine standard_predictors_ad(Atm, Pred_AD, Atm_AD)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
real(fp), parameter, public three
integer, parameter, public max_n_absorbers
subroutine compute_intabsorber_ad(Atm, Pred_AD, Atm_AD)
integer, parameter, public ozo_absorber_index
integer, parameter, public h2o_id
real(fp), parameter, public toa_pressure
integer, parameter, public max_n_predictors
subroutine integrated_predictors(Atm, Pred, iVar)
integer, parameter, public max_n_orders
real(fp), parameter, public minimum_absorber_amount
real(fp), parameter, public point_75
integer, parameter, public max_n_predictors_used
subroutine integrated_predictors_ad(Atm, Pred, Pred_AD, Atm_AD, iVar)
real(fp), parameter, public one
subroutine integrated_predictors_tl(Atm, Pred, Atm_TL, Pred_TL, iVar)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer, parameter, public o3_id
elemental subroutine, public odas_predictor_destroy(self)
real(fp), parameter, public two
subroutine compute_intabsorber(Atm, Pred)
character(*), dimension(max_n_absorbers), parameter, public absorber_name
subroutine standard_predictors_tl(Atm, Atm_TL, Pred_TL)
subroutine, public odas_assemble_predictors(Atmosphere, GeometryInfo, Max_Order, Alpha, Predictor, iVar)
integer, parameter, public max_n_layers
real(fp), parameter, public point_5
integer, parameter, public max_n_integrated_predictors
integer, dimension(max_n_absorbers), parameter, public absorber_index
elemental logical function, public odas_predictor_associated(self)
real(fp), parameter, public reciprocal_gravity
integer, parameter, public dry_absorber_index
integer, parameter, public wet_absorber_index
#define min(a, b)
Definition: mosaic_util.h:32
integer function, public crtm_get_absorberidx(Atm, AbsorberId)
integer, parameter, public success
elemental subroutine, public crtm_geometryinfo_getvalue(gInfo, Geometry, iFOV, Longitude, Latitude, Surface_Altitude, Sensor_Scan_Angle, Sensor_Zenith_Angle, Sensor_Azimuth_Angle, Source_Zenith_Angle, Source_Azimuth_Angle, Flux_Zenith_Angle, Year, Month, Day, Distance_Ratio, Sensor_Scan_Radian, Sensor_Zenith_Radian, Sensor_Azimuth_Radian, Secant_Sensor_Zenith, Cosine_Sensor_Zenith, Source_Zenith_Radian, Source_Azimuth_Radian, Secant_Source_Zenith, Flux_Zenith_Radian, Secant_Flux_Zenith, Trans_Zenith_Radian, Secant_Trans_Zenith, AU_ratio2)
subroutine, public odas_assemble_predictors_tl(Atmosphere, Predictor, Atmosphere_TL, Max_Order, Alpha, Predictor_TL, iVar)
subroutine, public odas_assemble_predictors_ad(Atmosphere, Predictor, Predictor_AD, Max_Order, Alpha, Atmosphere_AD, iVar)