FV3 Bundle
ODSSU_TauCoeff.f90
Go to the documentation of this file.
1 !
2 ! ODSSU_TauCoeff
3 !
4 ! Module containing the shared absorption coefficients (TauCoeff)
5 ! and their load/destruction routines for the ODSSU algorithm
6 !
7 ! PUBLIC DATA:
8 ! TC: Data structure array containing the transmittance model
9 ! coefficient data for the requested sensors.
10 !
11 ! SIDE EFFECTS:
12 ! Routines in this module modify the contents of the public
13 ! data structure TC.
14 !
15 ! RESTRICTIONS:
16 ! Routines in this module should only be called during the
17 ! CRTM initialisation.
18 !
19 ! CREATION HISTORY:
20 ! Written by: Paul van Delst, CIMSS/SSEC 12-Jun-2000
21 ! paul.vandelst@ssec.wisc.edu
22 !
23 ! Modifed by: Yong Han, NESDIS/STAR 26-June-2008
24 ! yong.han@noaa.gov
25 !
27 
28  ! -----------------
29  ! Environment setup
30  ! -----------------
31  ! Module use
33  USE odssu_define , ONLY: odssu_taucoeff_type => odssu_type, &
34  odssu_destroy_taucoeff => destroy_odssu
35  USE odssu_binary_io , ONLY: read_taucoeff_binary => read_odssu_binary
36  USE crtm_parameters , ONLY: max_n_sensors , &
41  ! Disable all implicit typing
42  IMPLICIT NONE
43 
44 
45  ! ------------
46  ! Visibilities
47  ! ------------
48  ! Everything private by default
49  PRIVATE
50  ! The shared data
51  PUBLIC :: tc
52  ! Structure defined in ODSSU_Define
53  PUBLIC :: odssu_taucoeff_type
54  ! Public routines in this module
55  PUBLIC :: load_taucoeff
56  PUBLIC :: destroy_taucoeff
57 
58 
59  ! -----------------
60  ! Module parameters
61  ! -----------------
62  CHARACTER(*), PARAMETER, PRIVATE :: module_rcs_id = &
63  '$Id: ODSSU_TauCoeff.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
64 
65 
66  ! --------------------------------------
67  ! The shared data for the gas absorption
68  ! (AtmAbsorption) model
69  ! --------------------------------------
70  TYPE(odssu_taucoeff_type), SAVE, ALLOCATABLE, TARGET :: tc(:)
71 
72 
73 CONTAINS
74 
75 
76 !------------------------------------------------------------------------------
77 !
78 ! NAME:
79 ! Load_TauCoeff
80 !
81 ! PURPOSE:
82 ! Function to load the TauCoeff transmittance coefficient data into
83 ! the shared data structure.
84 !
85 ! CALLING SEQUENCE:
86 ! Error_Status = Load_TauCoeff( Sensor_ID =Sensor_ID, & ! Optional input
87 ! File_Path =File_Path, & ! Optional input
88 ! Quiet =Quiet, & ! Optional input
89 ! Process_ID =Process_ID, & ! Optional input
90 ! Output_Process_ID=Output_Process_ID, & ! Optional input
91 ! Message_Log =Message_Log ) ! Error messaging
92 !
93 ! OPTIONAL INPUT ARGUMENTS:
94 ! Sensor_ID: List of the sensor IDs (e.g. hirs3_n17, amsua_n18,
95 ! ssmis_f16, etc) with which the CRTM is to be
96 ! initialised. These Sensor ID are used to construct
97 ! the sensor specific TauCoeff filenames containing
98 ! the necessary coefficient data, i.e.
99 ! <Sensor_ID>.TauCoeff.bin
100 ! If this argument is not specified, the default
101 ! TauCoeff filename is
102 ! TauCoeff.bin
103 ! UNITS: N/A
104 ! TYPE: CHARACTER(*)
105 ! DIMENSION: Rank-1
106 ! ATTRIBUTES: INTENT(IN)
107 !
108 ! File_Path: Character string specifying a file path for the
109 ! input data files. If not specified, the current
110 ! directory is the default.
111 ! UNITS: N/A
112 ! TYPE: CHARACTER(*)
113 ! DIMENSION: Scalar
114 ! ATTRIBUTES: INTENT(IN), OPTIONAL
115 !
116 ! Quiet: Set this argument to suppress INFORMATION messages
117 ! being printed to standard output (or the message
118 ! log file if the Message_Log optional argument is
119 ! used.) By default, INFORMATION messages are printed.
120 ! If QUIET = 0, INFORMATION messages are OUTPUT.
121 ! QUIET = 1, INFORMATION messages are SUPPRESSED.
122 ! UNITS: N/A
123 ! TYPE: INTEGER
124 ! DIMENSION: Scalar
125 ! ATTRIBUTES: INTENT(IN), OPTIONAL
126 !
127 ! Process_ID: Set this argument to the MPI process ID that this
128 ! function call is running under. This value is used
129 ! solely for controlling INFORMATIOn message output.
130 ! If MPI is not being used, ignore this argument.
131 ! This argument is ignored if the Quiet argument is set.
132 ! UNITS: N/A
133 ! TYPE: INTEGER
134 ! DIMENSION: Scalar
135 ! ATTRIBUTES: INTENT(IN), OPTIONAL
136 !
137 ! Output_Process_ID: Set this argument to the MPI process ID in which
138 ! all INFORMATION messages are to be output. If
139 ! the passed Process_ID value agrees with this value
140 ! the INFORMATION messages are output.
141 ! This argument is ignored if the Quiet argument
142 ! is set.
143 ! UNITS: N/A
144 ! TYPE: INTEGER
145 ! DIMENSION: Scalar
146 ! ATTRIBUTES: INTENT(IN), OPTIONAL
147 !
148 ! Message_Log: Character string specifying a filename in which
149 ! any messages will be logged. If not specified,
150 ! or if an error occurs opening the log file, the
151 ! default action is to output messages to standard
152 ! output.
153 ! UNITS: N/A
154 ! TYPE: CHARACTER(*)
155 ! DIMENSION: Scalar
156 ! ATTRIBUTES: INTENT(IN), OPTIONAL
157 !
158 ! FUNCTION RESULT:
159 ! Error_Status: The return value is an integer defining the error
160 ! status. The error codes are defined in the
161 ! Message_Handler module.
162 ! If == SUCCESS the TauCoeff data load was successful
163 ! == FAILURE an unrecoverable error occurred.
164 ! == WARNING the number of channels read in differs
165 ! from that stored in the CRTM_Parameters
166 ! module.
167 ! UNITS: N/A
168 ! TYPE: INTEGER
169 ! DIMENSION: Scalar
170 !
171 ! SIDE EFFECTS:
172 ! This function modifies the contents of the public data structures
173 ! in this module.
174 !
175 !------------------------------------------------------------------------------
176 
177  FUNCTION load_taucoeff( Sensor_ID , & ! Input
178  File_Path , & ! Optional input
179  Quiet , & ! Optional input
180  Process_ID , & ! Optional input
181  Output_Process_ID, & ! Optional input
182  Message_Log ) & ! Error messaging
183  result( error_status )
184  ! Arguments
185  CHARACTER(*), DIMENSION(:), OPTIONAL, INTENT(IN) :: sensor_id
186  CHARACTER(*), OPTIONAL, INTENT(IN) :: file_path
187  INTEGER, OPTIONAL, INTENT(IN) :: quiet
188  INTEGER, OPTIONAL, INTENT(IN) :: process_id
189  INTEGER, OPTIONAL, INTENT(IN) :: output_process_id
190  CHARACTER(*), OPTIONAL, INTENT(IN) :: message_log
191  ! Function result
192  INTEGER :: error_status
193  ! Local parameters
194  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_Load_TauCoeff'
195  ! Local variables
196  CHARACTER(256) :: message
197  CHARACTER(256) :: process_id_tag
198  CHARACTER(256), DIMENSION(MAX_N_SENSORS) :: taucoeff_file
199  INTEGER :: allocate_status
200  INTEGER :: n, n_sensors
201 
202  ! Set up
203  error_status = success
204  ! Create a process ID message tag for
205  ! WARNING and FAILURE messages
206  IF ( PRESENT(process_id) ) THEN
207  WRITE( process_id_tag, '("; MPI Process ID: ",i0)' ) process_id
208  ELSE
209  process_id_tag = ' '
210  END IF
211 
212  ! Determine the number of sensors and construct their filenames
213  IF ( PRESENT(sensor_id) ) THEN
214  ! Construct filenames for specified sensors
215  n_sensors = SIZE(sensor_id)
216  IF ( n_sensors > max_n_sensors ) THEN
217  error_status = failure
218  WRITE(message,'("Too many sensors, ",i0," specified. Maximum of ",i0," sensors allowed.")') &
219  n_sensors, max_n_sensors
220  CALL display_message( routine_name, &
221  trim(message)//trim(process_id_tag), &
222  error_status, &
223  message_log=message_log)
224  RETURN
225  END IF
226  DO n=1,n_sensors
227  taucoeff_file(n) = trim(adjustl(sensor_id(n)))//'.TauCoeff.bin'
228  END DO
229  ELSE
230  ! No sensors specified. Use default filename.
231  n_sensors=1
232  taucoeff_file(1) = 'TauCoeff.bin'
233  END IF
234 
235  ! Add the file path
236  IF ( PRESENT(file_path) ) THEN
237  DO n=1,n_sensors
238  taucoeff_file(n) = trim(adjustl(file_path))//trim(taucoeff_file(n))
239  END DO
240  END IF
241 
242  ! Allocate the TauCoeff shared data structure array
243  ALLOCATE(tc(n_sensors), stat=allocate_status)
244  IF( allocate_status /= 0 )THEN
245  WRITE(message,'("TauCoeff structure array allocation failed. STAT=",i0)') allocate_status
246  error_status = failure
247  CALL display_message( routine_name, &
248  trim(message)//trim(process_id_tag), &
249  error_status, &
250  message_log = message_log )
251  RETURN
252  END IF
253 
254  ! Read the TauCoeff data files
255  DO n = 1, n_sensors
256  error_status = read_taucoeff_binary( trim(taucoeff_file(n)) , & ! Input
257  tc(n) , & ! Output
258  quiet =quiet , &
259  process_id =process_id , &
260  output_process_id=output_process_id, &
261  message_log =message_log )
262  IF ( error_status /= success ) THEN
263  WRITE(message,'("Error reading TauCoeff file #",i0,", ",a)') &
264  n, trim(taucoeff_file(n))
265  CALL display_message( routine_name, &
266  trim(message)//trim(process_id_tag), &
267  error_status, &
268  message_log=message_log )
269  RETURN
270  END IF
271  END DO
272 
273  END FUNCTION load_taucoeff
274 
275 
276 !------------------------------------------------------------------------------
277 !
278 ! NAME:
279 ! CRTM_Destroy_TauCoeff
280 !
281 ! PURPOSE:
282 ! Function to deallocate the public shared data structure containing
283 ! the CRTM TauCoeff transmittance coefficient data.
284 !
285 ! CALLING SEQUENCE:
286 ! Error_Status = Destroy_TauCoeff( Process_ID = Process_ID, & ! Optional input
287 ! Message_Log = Message_Log ) ! Error messaging
288 !
289 ! OPTIONAL INPUT ARGUMENTS:
290 ! Process_ID: Set this argument to the MPI process ID that this
291 ! function call is running under. This value is used
292 ! solely for controlling message output. If MPI is not
293 ! being used, ignore this argument.
294 ! UNITS: N/A
295 ! TYPE: INTEGER
296 ! DIMENSION: Scalar
297 ! ATTRIBUTES: INTENT(IN), OPTIONAL
298 !
299 ! Message_Log: Character string specifying a filename in which any
300 ! messages will be logged. If not specified, or if an
301 ! error occurs opening the log file, the default action
302 ! is to output messages to the screen.
303 ! UNITS: N/A
304 ! TYPE: CHARACTER(*)
305 ! DIMENSION: Scalar
306 ! ATTRIBUTES: INTENT(IN), OPTIONAL
307 !
308 ! FUNCTION RESULT:
309 ! Error_Status: The return value is an integer defining the error
310 ! status. The error codes are defined in the
311 ! Message_Handler module.
312 ! If == SUCCESS the deallocation of the public TC data
313 ! structure was successful
314 ! == FAILURE an unrecoverable error occurred.
315 ! UNITS: N/A
316 ! TYPE: INTEGER
317 ! DIMENSION: Scalar
318 !
319 !
320 ! SIDE EFFECTS:
321 ! This function modifies the contents of the public data structures
322 ! in this module.
323 !
324 !------------------------------------------------------------------------------
325 
326  FUNCTION destroy_taucoeff( Process_ID, & ! Optional input
327  Message_Log ) & ! Error messaging
328  result( error_status )
329  ! Arguments
330  INTEGER, OPTIONAL, INTENT(IN) :: process_id
331  CHARACTER(*), OPTIONAL, INTENT(IN) :: message_log
332  ! Function result
333  INTEGER :: error_status
334  ! Local parameters
335  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_Destroy_TauCoeff'
336  ! Local variables
337  CHARACTER(256) :: message
338  CHARACTER(256) :: process_id_tag
339  INTEGER :: n, destroy_status, allocate_status
340 
341  ! Set up
342  error_status = success
343  ! Create a process ID message tag for
344  ! WARNING and FAILURE messages
345  IF ( PRESENT( process_id ) ) THEN
346  WRITE( process_id_tag, '("; MPI Process ID: ",i0)' ) process_id
347  ELSE
348  process_id_tag = ' '
349  END IF
350 
351  ! Destroy the structure array elements
352  DO n = 1, SIZE(tc)
353  destroy_status = odssu_destroy_taucoeff( tc(n), &
354  message_log=message_log )
355  IF ( destroy_status /= success ) THEN
356  error_status = failure
357  WRITE(message,'("Error destroying TauCoeff structure array element #",i0)') n
358  CALL display_message( routine_name, &
359  trim(message)//trim(process_id_tag), &
360  error_status, &
361  message_log=message_log )
362  ! No return here. Continue deallocating
363  END IF
364  END DO
365 
366  ! Deallocate the structure array
367  DEALLOCATE(tc, stat=allocate_status)
368  IF( allocate_status /= 0 )THEN
369  WRITE(message,'("RTTOV TC structure deallocation failed. STAT=",i0)') allocate_status
370  error_status = failure
371  CALL display_message( routine_name, &
372  trim(message)//trim(process_id_tag), &
373  error_status, &
374  message_log=message_log)
375 
376  ! Again, no return.
377  END IF
378 
379  ! Reset the protected variable Max_n_Channels
381 
382  END FUNCTION destroy_taucoeff
383 
384 END MODULE odssu_taucoeff
integer, parameter, public failure
integer, parameter, public warning
integer function, public crtm_get_max_nchannels()
subroutine, public crtm_reset_max_nchannels()
integer function, public read_odssu_binary(Filename, ODSSU, Quiet, Process_ID, Output_Process_ID, RCS_Id, Message_Log)
integer function, public load_taucoeff(Sensor_ID, File_Path, Quiet, Process_ID, Output_Process_ID, Message_Log)
integer function, public destroy_taucoeff(Process_ID, Message_Log)
logical function, public crtm_isset_max_nchannels()
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer function, public destroy_odssu(ODSSU, No_Clear, RCS_Id, Message_Log)
subroutine, public crtm_set_max_nchannels(Value)
character(*), parameter, private module_rcs_id
type(odssu_taucoeff_type), dimension(:), allocatable, target, save, public tc
integer, parameter, public success
integer, parameter, public max_n_sensors