FV3 Bundle
CRTM_SEcategory.f90
Go to the documentation of this file.
1 !
2 ! CRTM_SEcategory
3 !
4 ! Module to compute the surface optical properties using
5 ! a surface type category look-up-table.
6 !
7 !
8 ! CREATION HISTORY:
9 ! Written by: Paul van Delst, 26-Aug-2011
10 ! paul.vandelst@noaa.gov
11 !
12 
14 
15  ! -----------------
16  ! Environment setup
17  ! -----------------
18  ! Module use
19  USE type_kinds , ONLY: fp
21  USE crtm_parameters , ONLY: zero, one
22  USE crtm_interpolation, ONLY: npts , &
23  lpoly_type , &
24  find_index , &
25  interp_1d , &
26  interp_1d_tl, &
27  interp_1d_ad, &
28  clear_lpoly , &
29  lpoly , &
30  lpoly_tl , &
31  lpoly_ad
33  ! Disable implicit typing
34  IMPLICIT NONE
35 
36 
37  ! ------------
38  ! Visibilities
39  ! ------------
40  ! Everything private by default
41  PRIVATE
42  ! Data types
43  PUBLIC :: ivar_type
44  ! Science routines
45  PUBLIC :: secategory_emissivity
46 
47 
48  ! -----------------
49  ! Module parameters
50  ! -----------------
51  ! Version Id for the module
52  CHARACTER(*), PARAMETER :: module_version_id = &
53  '$Id: CRTM_SEcategory.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
54  ! Message string length
55  INTEGER, PARAMETER :: ml = 256
56 
57 
58  ! --------------------------------------
59  ! Structure definitions to hold forward
60  ! variables across FWD, TL, and AD calls
61  ! --------------------------------------
62  TYPE :: ivar_type
63  PRIVATE
64  ! The interpolating polynomials
65  TYPE(lpoly_type) :: xlp
66  ! The LUT interpolation indices
67  INTEGER :: i1, i2
68  ! The LUT interpolation boundary check
69  LOGICAL :: x_outbound
70  ! The interpolation input
71  REAL(fp) :: x_int
72  ! The data to be interpolated
73  REAL(fp) :: x(npts)
74  END TYPE ivar_type
75 
76 
77 CONTAINS
78 
79 
80 !----------------------------------------------------------------------------------
81 !:sdoc+:
82 !
83 ! NAME:
84 ! SEcategory_Emissivity
85 !
86 ! PURPOSE:
87 ! Function to compute surface emissivities from an emissivity or
88 ! reflectance LUT as a function of surface type category.
89 !
90 ! CALLING SEQUENCE:
91 ! Error_Status = SEcategory_Emissivity( &
92 ! SEcategory , &
93 ! Frequency , &
94 ! Surface_Type, &
95 ! Emissivity , &
96 ! iVar )
97 !
98 ! INPUTS:
99 ! SEcategory: Emissivity/reflectivity LUT.
100 ! UNITS: N/A
101 ! TYPE: SEcategory_type
102 ! DIMENSION: Scalar
103 ! ATTRIBUTES: INTENT(IN)
104 !
105 ! Frequency: Spectral frequency at which an emissivity is required.
106 ! UNITS: Inverse centimetres (cm^-1)
107 ! TYPE: REAL(fp)
108 ! DIMENSION: Scalar
109 ! ATTRIBUTES: INTENT(IN)
110 !
111 ! Surface_Type: Index into the surface type dimension of the LUT indicating
112 ! the surface type for which an emissivity is required.
113 ! UNITS: N/A
114 ! TYPE: INTEGER
115 ! DIMENSION: Scalar
116 ! ATTRIBUTES: INTENT(IN)
117 !
118 ! OUTPUTS:
119 ! Emissivity: Surface emissivity for the specified surface type
120 ! interpolated to the requested frequency.
121 ! UNITS: N/A
122 ! TYPE: REAL(fp)
123 ! DIMENSION: Scalar
124 ! ATTRIBUTES: INTENT(OUT)
125 !
126 ! iVar: Structure containing internal variables required for
127 ! subsequent tangent-linear or adjoint model calls.
128 ! The contents of this structure are NOT accessible
129 ! outside of the module containing this procedure.
130 ! UNITS: N/A
131 ! TYPE: iVar_type
132 ! DIMENSION: Scalar
133 ! ATTRIBUTES: INTENT(OUT)
134 !
135 ! FUNCTION RESULT:
136 ! Error_Status: The return value is an integer defining the error status.
137 ! The error codes are defined in the Message_Handler module.
138 ! If == SUCCESS the computation was successful
139 ! == FAILURE an unrecoverable error occurred
140 ! UNITS: N/A
141 ! TYPE: INTEGER
142 ! DIMENSION: Scalar
143 !
144 !:sdoc-:
145 !----------------------------------------------------------------------------------
146 
147  FUNCTION secategory_emissivity( &
148  SEcategory , &
149  Frequency , &
150  Surface_Type, &
151  Emissivity , &
152  iVar ) &
153  result( err_stat )
154  ! Arguments
155  TYPE(secategory_type), INTENT(IN) :: secategory
156  REAL(fp) , INTENT(IN) :: frequency
157  INTEGER , INTENT(IN) :: surface_type
158  REAL(fp) , INTENT(OUT) :: emissivity
159  TYPE(ivar_type) , INTENT(OUT) :: ivar
160  ! Function result
161  INTEGER :: err_stat
162  ! Local parameters
163  CHARACTER(*), PARAMETER :: routine_name = 'SEcategory_Emissivity'
164  ! Local variables
165  CHARACTER(ML) :: msg
166  REAL(fp) :: reflectance
167 
168  ! Setup
169  err_stat = success
170  ! ...Check surface type valid range
171  IF ( surface_type < 1 .OR. &
172  surface_type > secategory%n_Surface_Types ) THEN
173  emissivity = zero
174  err_stat = failure
175  msg = 'Invalid surface type index specified'
176  CALL display_message( routine_name, msg, err_stat ); RETURN
177  END IF
178  ! ...Check surface type valid for classification
179  IF ( .NOT. secategory%Surface_Type_IsValid(surface_type) ) THEN
180  emissivity = zero
181  err_stat = failure
182  msg = 'Invalid surface type index specified for '//&
183  trim(secategory%Classification_Name)//' classification'
184  CALL display_message( routine_name, msg, err_stat ); RETURN
185  END IF
186 
187 
188  ! Find the frequency indices for interpolation
189  ivar%x_int = max(min(secategory%Frequency(secategory%n_Frequencies),&
190  frequency), &
191  secategory%Frequency(1))
192  CALL find_index(secategory%Frequency, ivar%x_int, ivar%i1, ivar%i2, ivar%x_outbound)
193  ivar%x = secategory%Frequency(ivar%i1:ivar%i2)
194 
195 
196  ! Calculate the interpolating polynomial
197  CALL lpoly( ivar%x, ivar%x_int, & ! Input
198  ivar%xlp ) ! Output
199 
200 
201  ! Perform Interpolation
202  CALL interp_1d( secategory%Reflectance(ivar%i1:ivar%i2, surface_type), ivar%xlp, reflectance )
203  emissivity = one - reflectance
204 
205  END FUNCTION secategory_emissivity
206 
207 END MODULE crtm_secategory
integer, parameter, public failure
real(fp), parameter, public zero
integer, parameter, public fp
Definition: Type_Kinds.f90:124
character(*), parameter module_version_id
subroutine, public interp_1d_ad(z, ulp, z_int_AD, z_AD, ulp_AD)
subroutine, public clear_lpoly(p)
subroutine, public lpoly_ad(x, x_int, p, p_AD, x_AD, x_int_AD)
integer, parameter ml
real(fp), parameter, public one
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
subroutine, public interp_1d_tl(z, ulp, z_TL, ulp_TL, z_int_TL)
integer function, public secategory_emissivity(SEcategory, Frequency, Surface_Type, Emissivity, iVar)
subroutine, public lpoly(x, x_int, p)
integer, parameter, public npts
#define max(a, b)
Definition: mosaic_util.h:33
#define min(a, b)
Definition: mosaic_util.h:32
subroutine, public lpoly_tl(x, x_int, p, x_TL, x_int_TL, p_TL)
subroutine, public interp_1d(z, ulp, z_int)
integer, parameter, public success