FV3 Bundle
CRTM_LifeCycle.f90
Go to the documentation of this file.
1 !
2 ! CRTM_LifeCycle
3 !
4 ! Module containing CRTM life cycle functions to initialize and destroy
5 ! the CRTM space.
6 !
7 ! Written by: Paul van Delst, 21-May-2004
8 ! paul.vandelst@noaa.gov
9 !
10 
12 
13 
14  ! -----------------
15  ! Environment setup
16  ! -----------------
17  ! Module usage
18  USE message_handler
23  ! ...Spectral coefficients
24  USE crtm_spccoeff , ONLY: sc, &
27  spccoeff_ismicrowavesensor , &
28  spccoeff_isinfraredsensor , &
29  spccoeff_isvisiblesensor , &
30  spccoeff_isultravioletsensor
31  ! ...Transmittance model coefficients
32  USE crtm_taucoeff
33  ! ...Aerosol optical properties
36  ! ...Cloud optical properties
39  ! ...Infrared surface emissivities
48  ! ...Visible surface emissivities
57  ! ...Microwave surface emissivities
60  ! Disable all implicit typing
61  IMPLICIT NONE
62 
63 
64  ! ------------
65  ! Visibilities
66  ! ------------
67  ! Everything private by default
68  PRIVATE
69  ! Public procedures
70  PUBLIC :: crtm_init
71  PUBLIC :: crtm_destroy
72  PUBLIC :: crtm_isinitialized
73  PUBLIC :: crtm_lifecycleversion
74 
75  ! -----------------
76  ! Module parameters
77  ! -----------------
78  CHARACTER(*), PARAMETER :: module_version_id = &
79  '$Id: CRTM_LifeCycle.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
80  ! String lengths
81  INTEGER, PARAMETER :: ml = 256 ! Error message length
82  INTEGER, PARAMETER :: sl = 5000 ! Maximum length for path+filenames
83 
84 
85 CONTAINS
86 
87 
88 !------------------------------------------------------------------------------
89 !:sdoc+:
90 !
91 ! NAME:
92 ! CRTM_Init
93 !
94 ! PURPOSE:
95 ! Function to initialise the CRTM.
96 !
97 ! CALLING SEQUENCE:
98 ! Error_Status = CRTM_Init( Sensor_ID , &
99 ! ChannelInfo, &
100 ! CloudCoeff_File = CloudCoeff_File , &
101 ! AerosolCoeff_File = AerosolCoeff_File , &
102 ! Load_CloudCoeff = Load_CloudCoeff , &
103 ! Load_AerosolCoeff = Load_AerosolCoeff , &
104 ! IRwaterCoeff_File = IRwaterCoeff_File , &
105 ! IRlandCoeff_File = IRlandCoeff_File , &
106 ! IRsnowCoeff_File = IRsnowCoeff_File , &
107 ! IRiceCoeff_File = IRiceCoeff_File , &
108 ! VISwaterCoeff_File = VISwaterCoeff_File, &
109 ! VISlandCoeff_File = VISlandCoeff_File , &
110 ! VISsnowCoeff_File = VISsnowCoeff_File , &
111 ! VISiceCoeff_File = VISiceCoeff_File , &
112 ! MWwaterCoeff_File = MWwaterCoeff_File , &
113 ! File_Path = File_Path , &
114 ! Quiet = Quiet , &
115 ! Process_ID = Process_ID , &
116 ! Output_Process_ID = Output_Process_ID )
117 !
118 ! INPUTS:
119 ! Sensor_ID: List of the sensor IDs (e.g. hirs3_n17, amsua_n18,
120 ! ssmis_f16, etc) with which the CRTM is to be
121 ! initialised. These sensor ids are used to construct
122 ! the sensor specific SpcCoeff and TauCoeff filenames
123 ! containing the necessary coefficient data, i.e.
124 ! <Sensor_ID>.SpcCoeff.bin
125 ! and
126 ! <Sensor_ID>.TauCoeff.bin
127 ! for each sensor Id in the list.
128 ! UNITS: N/A
129 ! TYPE: CHARACTER(*)
130 ! DIMENSION: Rank-1 (n_Sensors)
131 ! ATTRIBUTES: INTENT(IN), OPTIONAL
132 !
133 ! OUTPUTS:
134 ! ChannelInfo: ChannelInfo structure array populated based on
135 ! the contents of the coefficient files and the
136 ! user inputs.
137 ! UNITS: N/A
138 ! TYPE: CRTM_ChannelInfo_type
139 ! DIMENSION: Same as input Sensor_Id argument
140 ! ATTRIBUTES: INTENT(OUT)
141 !
142 ! OPTIONAL INPUTS:
143 ! CloudCoeff_File: Name of the data file containing the cloud optical
144 ! properties data for scattering calculations.
145 ! Available datafiles:
146 ! - CloudCoeff.bin [DEFAULT]
147 ! UNITS: N/A
148 ! TYPE: CHARACTER(*)
149 ! DIMENSION: Scalar
150 ! ATTRIBUTES: INTENT(IN), OPTIONAL
151 !
152 ! AerosolCoeff_File: Name of the data file containing the aerosol optical
153 ! properties data for scattering calculations.
154 ! Available datafiles:
155 ! - AerosolCoeff.bin [DEFAULT]
156 ! UNITS: N/A
157 ! TYPE: CHARACTER(*)
158 ! DIMENSION: Scalar
159 ! ATTRIBUTES: INTENT(IN), OPTIONAL
160 !
161 ! Load_CloudCoeff: Set this logical argument for not loading the CloudCoeff data
162 ! to save memory space under the clear conditions
163 ! If == .FALSE., the CloudCoeff data will not be loaded;
164 ! == .TRUE., the CloudCoeff data will be loaded.
165 ! If not specified, default is .TRUE. (will be loaded)
166 ! UNITS: N/A
167 ! TYPE: LOGICAL
168 ! DIMENSION: Scalar
169 ! ATTRIBUTES: INTENT(IN), OPTIONAL
170 !
171 ! Load_AerosolCoeff: Set this logical argument for not loading the AerosolCoeff data
172 ! to save memory space under the clear conditions
173 ! If == .FALSE., the AerosolCoeff data will not be loaded;
174 ! == .TRUE., the AerosolCoeff data will be loaded.
175 ! If not specified, default is .TRUE. (will be loaded)
176 ! UNITS: N/A
177 ! TYPE: LOGICAL
178 ! DIMENSION: Scalar
179 ! ATTRIBUTES: INTENT(IN), OPTIONAL
180 !
181 ! MWwaterCoeff_File: Name of the data file containing the coefficient
182 ! data for the microwave water emissivity model.
183 ! Available datafiles:
184 ! - FASTEM6.MWwater.EmisCoeff.bin [DEFAULT]
185 ! - FASTEM5.MWwater.EmisCoeff.bin
186 ! - FASTEM4.MWwater.EmisCoeff.bin
187 ! UNITS: N/A
188 ! TYPE: CHARACTER(*)
189 ! DIMENSION: Scalar
190 ! ATTRIBUTES: INTENT(IN), OPTIONAL
191 !
192 ! IRwaterCoeff_File: Name of the data file containing the coefficient
193 ! data for the infrared water emissivity model.
194 ! Available datafiles:
195 ! - Nalli.IRwater.EmisCoeff.bin [DEFAULT]
196 ! - WuSmith.IRwater.EmisCoeff.bin
197 ! If not specified the Nalli datafile is read.
198 ! UNITS: N/A
199 ! TYPE: CHARACTER(*)
200 ! DIMENSION: Scalar
201 ! ATTRIBUTES: INTENT(IN), OPTIONAL
202 !
203 ! IRlandCoeff_File: Name of the data file containing the coefficient
204 ! data for the infrared land emissivity model.
205 ! Available datafiles:
206 ! - NPOESS.IRland.EmisCoeff.bin [DEFAULT]
207 ! - IGBP.IRland.EmisCoeff.bin
208 ! - USGS.IRland.EmisCoeff.bin
209 ! UNITS: N/A
210 ! TYPE: CHARACTER(*)
211 ! DIMENSION: Scalar
212 ! ATTRIBUTES: INTENT(IN), OPTIONAL
213 !
214 ! IRsnowCoeff_File: Name of the data file containing the coefficient
215 ! data for the infrared snow emissivity model.
216 ! Available datafiles:
217 ! - NPOESS.IRsnow.EmisCoeff.bin [DEFAULT]
218 ! - IGBP.IRsnow.EmisCoeff.bin
219 ! - USGS.IRsnow.EmisCoeff.bin
220 ! UNITS: N/A
221 ! TYPE: CHARACTER(*)
222 ! DIMENSION: Scalar
223 ! ATTRIBUTES: INTENT(IN), OPTIONAL
224 !
225 ! IRiceCoeff_File: Name of the data file containing the coefficient
226 ! data for the infrared ice emissivity model.
227 ! Available datafiles:
228 ! - NPOESS.IRice.EmisCoeff.bin [DEFAULT]
229 ! - IGBP.IRice.EmisCoeff.bin
230 ! - USGS.IRice.EmisCoeff.bin
231 ! UNITS: N/A
232 ! TYPE: CHARACTER(*)
233 ! DIMENSION: Scalar
234 ! ATTRIBUTES: INTENT(IN), OPTIONAL
235 !
236 ! VISwaterCoeff_File: Name of the data file containing the coefficient
237 ! data for the visible water emissivity model.
238 ! Available datafiles:
239 ! - NPOESS.VISwater.EmisCoeff.bin [DEFAULT]
240 ! - IGBP.VISwater.EmisCoeff.bin
241 ! - USGS.VISwater.EmisCoeff.bin
242 ! UNITS: N/A
243 ! TYPE: CHARACTER(*)
244 ! DIMENSION: Scalar
245 ! ATTRIBUTES: INTENT(IN), OPTIONAL
246 !
247 ! VISlandCoeff_File: Name of the data file containing the coefficient
248 ! data for the visible land emissivity model.
249 ! Available datafiles:
250 ! - NPOESS.VISland.EmisCoeff.bin [DEFAULT]
251 ! - IGBP.VISland.EmisCoeff.bin
252 ! - USGS.VISland.EmisCoeff.bin
253 ! UNITS: N/A
254 ! TYPE: CHARACTER(*)
255 ! DIMENSION: Scalar
256 ! ATTRIBUTES: INTENT(IN), OPTIONAL
257 !
258 ! VISsnowCoeff_File: Name of the data file containing the coefficient
259 ! data for the visible snow emissivity model.
260 ! Available datafiles:
261 ! - NPOESS.VISsnow.EmisCoeff.bin [DEFAULT]
262 ! - IGBP.VISsnow.EmisCoeff.bin
263 ! - USGS.VISsnow.EmisCoeff.bin
264 ! UNITS: N/A
265 ! TYPE: CHARACTER(*)
266 ! DIMENSION: Scalar
267 ! ATTRIBUTES: INTENT(IN), OPTIONAL
268 !
269 ! VISiceCoeff_File: Name of the data file containing the coefficient
270 ! data for the visible ice emissivity model.
271 ! Available datafiles:
272 ! - NPOESS.VISice.EmisCoeff.bin [DEFAULT]
273 ! - IGBP.VISice.EmisCoeff.bin
274 ! - USGS.VISice.EmisCoeff.bin
275 ! UNITS: N/A
276 ! TYPE: CHARACTER(*)
277 ! DIMENSION: Scalar
278 ! ATTRIBUTES: INTENT(IN), OPTIONAL
279 !
280 ! File_Path: Character string specifying a file path for the
281 ! input data files. If not specified, the current
282 ! directory is the default.
283 ! UNITS: N/A
284 ! TYPE: CHARACTER(*)
285 ! DIMENSION: Scalar
286 ! ATTRIBUTES: INTENT(IN), OPTIONAL
287 !
288 ! Quiet: Set this logical argument to suppress INFORMATION
289 ! messages being printed to stdout
290 ! If == .FALSE., INFORMATION messages are OUTPUT [DEFAULT].
291 ! == .TRUE., INFORMATION messages are SUPPRESSED.
292 ! If not specified, default is .FALSE.
293 ! UNITS: N/A
294 ! TYPE: LOGICAL
295 ! DIMENSION: Scalar
296 ! ATTRIBUTES: INTENT(IN), OPTIONAL
297 !
298 ! Process_ID: Set this argument to the MPI process ID that this
299 ! function call is running under. This value is used
300 ! solely for controlling INFORMATION message output.
301 ! If MPI is not being used, ignore this argument.
302 ! This argument is ignored if the Quiet argument is set.
303 ! UNITS: N/A
304 ! TYPE: INTEGER
305 ! DIMENSION: Scalar
306 ! ATTRIBUTES: INTENT(IN), OPTIONAL
307 !
308 ! Output_Process_ID: Set this argument to the MPI process ID in which
309 ! all INFORMATION messages are to be output. If
310 ! the passed Process_ID value agrees with this value
311 ! the INFORMATION messages are output.
312 ! This argument is ignored if the Quiet argument
313 ! is set.
314 ! UNITS: N/A
315 ! TYPE: INTEGER
316 ! DIMENSION: Scalar
317 ! ATTRIBUTES: INTENT(IN), OPTIONAL
318 !
319 ! FUNCTION RESULT:
320 ! Error_Status: The return value is an integer defining the error
321 ! status. The error codes are defined in the
322 ! Message_Handler module.
323 ! If == SUCCESS the CRTM initialisation was successful
324 ! == FAILURE an unrecoverable error occurred.
325 ! UNITS: N/A
326 ! TYPE: INTEGER
327 ! DIMENSION: Scalar
328 !
329 ! SIDE EFFECTS:
330 ! All public data arrays accessed by this module and its dependencies
331 ! are overwritten.
332 !
333 !:sdoc-:
334 !------------------------------------------------------------------------------
335 
336  FUNCTION crtm_init( &
337  Sensor_ID , & ! Input
338  ChannelInfo , & ! Output
339  CloudCoeff_File , & ! Optional input
340  AerosolCoeff_File , & ! Optional input
341  EmisCoeff_File , & ! Optional input ! *** DEPRECATED. Replaced by IRwaterCoeff_File
342  IRwaterCoeff_File , & ! Optional input
343  IRlandCoeff_File , & ! Optional input
344  IRsnowCoeff_File , & ! Optional input
345  IRiceCoeff_File , & ! Optional input
346  VISwaterCoeff_File, & ! Optional input
347  VISlandCoeff_File , & ! Optional input
348  VISsnowCoeff_File , & ! Optional input
349  VISiceCoeff_File , & ! Optional input
350  MWwaterCoeff_File , & ! Optional input
351  File_Path , & ! Optional input
352  Load_CloudCoeff , & ! Optional input
353  Load_AerosolCoeff , & ! Optional input
354  Quiet , & ! Optional input
355  Process_ID , & ! Optional input
356  Output_Process_ID ) & ! Optional input
357  result( err_stat )
358  ! Arguments
359  CHARACTER(*) , INTENT(IN) :: sensor_id(:)
360  TYPE(crtm_channelinfo_type), INTENT(OUT) :: channelinfo(:)
361  CHARACTER(*), OPTIONAL, INTENT(IN) :: cloudcoeff_file
362  CHARACTER(*), OPTIONAL, INTENT(IN) :: aerosolcoeff_file
363  CHARACTER(*), OPTIONAL, INTENT(IN) :: emiscoeff_file ! *** DEPRECATED. Replaced by IRwaterCoeff_File
364  CHARACTER(*), OPTIONAL, INTENT(IN) :: irwatercoeff_file
365  CHARACTER(*), OPTIONAL, INTENT(IN) :: irlandcoeff_file
366  CHARACTER(*), OPTIONAL, INTENT(IN) :: irsnowcoeff_file
367  CHARACTER(*), OPTIONAL, INTENT(IN) :: iricecoeff_file
368  CHARACTER(*), OPTIONAL, INTENT(IN) :: viswatercoeff_file
369  CHARACTER(*), OPTIONAL, INTENT(IN) :: vislandcoeff_file
370  CHARACTER(*), OPTIONAL, INTENT(IN) :: vissnowcoeff_file
371  CHARACTER(*), OPTIONAL, INTENT(IN) :: visicecoeff_file
372  CHARACTER(*), OPTIONAL, INTENT(IN) :: mwwatercoeff_file
373  CHARACTER(*), OPTIONAL, INTENT(IN) :: file_path
374  LOGICAL , OPTIONAL, INTENT(IN) :: load_cloudcoeff
375  LOGICAL , OPTIONAL, INTENT(IN) :: load_aerosolcoeff
376  LOGICAL , OPTIONAL, INTENT(IN) :: quiet
377  INTEGER , OPTIONAL, INTENT(IN) :: process_id
378  INTEGER , OPTIONAL, INTENT(IN) :: output_process_id
379  ! Function result
380  INTEGER :: err_stat
381  ! Local parameters
382  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_Init'
383  ! Local variables
384  CHARACTER(ML) :: msg, pid_msg
385  CHARACTER(SL) :: default_cloudcoeff_file
386  CHARACTER(SL) :: default_aerosolcoeff_file
387  CHARACTER(SL) :: default_irwatercoeff_file
388  CHARACTER(SL) :: default_irlandcoeff_file
389  CHARACTER(SL) :: default_irsnowcoeff_file
390  CHARACTER(SL) :: default_iricecoeff_file
391  CHARACTER(SL) :: default_viswatercoeff_file
392  CHARACTER(SL) :: default_vislandcoeff_file
393  CHARACTER(SL) :: default_vissnowcoeff_file
394  CHARACTER(SL) :: default_visicecoeff_file
395  CHARACTER(SL) :: default_mwwatercoeff_file
396 
397  INTEGER :: l, n, n_sensors
398  LOGICAL :: local_load_cloudcoeff
399  LOGICAL :: local_load_aerosolcoeff
400 
401  ! ******
402  ! TEMPORARY UNTIL LOAD ROUTINE INTERFACES HAVE BEEN MODIFIED
403  INTEGER :: iquiet
404  iquiet = 0
405  IF ( PRESENT(quiet) ) THEN
406  IF ( quiet ) THEN
407  iquiet = 1 ! Set
408  END IF
409  END IF
410  ! ******
411 
412  ! Set up
413  err_stat = success
414  ! ...Create a process ID message tag for error messages
415  IF ( PRESENT(process_id) ) THEN
416  WRITE( pid_msg,'("; Process ID: ",i0)' ) process_id
417  ELSE
418  pid_msg = ''
419  END IF
420  ! ...Check coefficient loading flags
421  local_load_cloudcoeff = .true.
422  IF( PRESENT(load_cloudcoeff) ) local_load_cloudcoeff = load_cloudcoeff
423  local_load_aerosolcoeff = .true.
424  IF( PRESENT(load_aerosolcoeff) ) local_load_aerosolcoeff = load_aerosolcoeff
425  ! ...Check dimensionality
426  n_sensors = SIZE(sensor_id)
427  IF ( SIZE(channelinfo) /= n_sensors ) THEN
428  err_stat = failure
429  msg = 'Inconsistent Sensor_ID and ChannelInfo dimensions'
430  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
431  RETURN
432  END IF
433  ! ...Check for deprecated EmisCoeff_File argument
434  IF ( PRESENT(emiscoeff_file) ) THEN
435  err_stat = failure
436  msg = 'The EmisCoeff_File optional argument is deprecated. Use IRwaterCoeff_File instead'
437  CALL display_message( routine_name, trim(msg)//trim(pid_msg), err_stat )
438  RETURN
439  END IF
440 
441 
442  ! Specify sensor-independent coefficient filenames
443  ! ...Default filenames
444  default_cloudcoeff_file = 'CloudCoeff.bin'
445  default_aerosolcoeff_file = 'AerosolCoeff.bin'
446  default_irwatercoeff_file = 'Nalli.IRwater.EmisCoeff.bin'
447  default_irlandcoeff_file = 'NPOESS.IRland.EmisCoeff.bin'
448  default_irsnowcoeff_file = 'NPOESS.IRsnow.EmisCoeff.bin'
449  default_iricecoeff_file = 'NPOESS.IRice.EmisCoeff.bin'
450  default_viswatercoeff_file = 'NPOESS.VISwater.EmisCoeff.bin'
451  default_vislandcoeff_file = 'NPOESS.VISland.EmisCoeff.bin'
452  default_vissnowcoeff_file = 'NPOESS.VISsnow.EmisCoeff.bin'
453  default_visicecoeff_file = 'NPOESS.VISice.EmisCoeff.bin'
454  default_mwwatercoeff_file = 'FASTEM6.MWwater.EmisCoeff.bin'
455  ! ...Were other filenames specified?
456  IF ( PRESENT(cloudcoeff_file ) ) default_cloudcoeff_file = trim(adjustl(cloudcoeff_file))
457  IF ( PRESENT(aerosolcoeff_file ) ) default_aerosolcoeff_file = trim(adjustl(aerosolcoeff_file))
458  IF ( PRESENT(irwatercoeff_file ) ) default_irwatercoeff_file = trim(adjustl(irwatercoeff_file))
459  IF ( PRESENT(irlandcoeff_file ) ) default_irlandcoeff_file = trim(adjustl(irlandcoeff_file))
460  IF ( PRESENT(irsnowcoeff_file ) ) default_irsnowcoeff_file = trim(adjustl(irsnowcoeff_file))
461  IF ( PRESENT(iricecoeff_file ) ) default_iricecoeff_file = trim(adjustl(iricecoeff_file))
462  IF ( PRESENT(viswatercoeff_file) ) default_viswatercoeff_file = trim(adjustl(viswatercoeff_file))
463  IF ( PRESENT(vislandcoeff_file ) ) default_vislandcoeff_file = trim(adjustl(vislandcoeff_file))
464  IF ( PRESENT(vissnowcoeff_file ) ) default_vissnowcoeff_file = trim(adjustl(vissnowcoeff_file))
465  IF ( PRESENT(visicecoeff_file ) ) default_visicecoeff_file = trim(adjustl(visicecoeff_file))
466  IF ( PRESENT(mwwatercoeff_file ) ) default_mwwatercoeff_file = trim(adjustl(mwwatercoeff_file))
467  ! ...Was a path specified?
468  IF ( PRESENT(file_path) ) THEN
469  default_cloudcoeff_file = trim(adjustl(file_path)) // trim(default_cloudcoeff_file)
470  default_aerosolcoeff_file = trim(adjustl(file_path)) // trim(default_aerosolcoeff_file)
471  default_irwatercoeff_file = trim(adjustl(file_path)) // trim(default_irwatercoeff_file)
472  default_irlandcoeff_file = trim(adjustl(file_path)) // trim(default_irlandcoeff_file)
473  default_irsnowcoeff_file = trim(adjustl(file_path)) // trim(default_irsnowcoeff_file)
474  default_iricecoeff_file = trim(adjustl(file_path)) // trim(default_iricecoeff_file)
475  default_viswatercoeff_file = trim(adjustl(file_path)) // trim(default_viswatercoeff_file)
476  default_vislandcoeff_file = trim(adjustl(file_path)) // trim(default_vislandcoeff_file)
477  default_vissnowcoeff_file = trim(adjustl(file_path)) // trim(default_vissnowcoeff_file)
478  default_visicecoeff_file = trim(adjustl(file_path)) // trim(default_visicecoeff_file)
479  default_mwwatercoeff_file = trim(adjustl(file_path)) // trim(default_mwwatercoeff_file)
480  END IF
481 
482 
483  ! Load the spectral coefficients
484  err_stat = crtm_spccoeff_load( &
485  sensor_id , &
486  file_path = file_path , &
487  quiet = quiet , &
488  process_id = process_id , &
489  output_process_id = output_process_id )
490  IF ( err_stat /= success ) THEN
491  CALL display_message( routine_name,'Error loading SpcCoeff data'//trim(pid_msg),err_stat )
492  RETURN
493  END IF
494 
495 
496  ! Load the transmittance model coefficients
497  err_stat = crtm_load_taucoeff( &
498  sensor_id = sensor_id , &
499  file_path = file_path , &
500  quiet = iquiet , & ! *** Use of iQuiet temporary
501  process_id = process_id , &
502  output_process_id = output_process_id )
503  IF ( err_stat /= success ) THEN
504  CALL display_message( routine_name,'Error loading TauCoeff data'//trim(pid_msg),err_stat )
505  RETURN
506  END IF
507 
508 
509  ! Load the cloud coefficients
510  IF ( local_load_cloudcoeff ) THEN
511  err_stat = crtm_cloudcoeff_load( &
512  default_cloudcoeff_file, &
513  quiet = quiet , &
514  process_id = process_id , &
515  output_process_id = output_process_id )
516  IF ( err_stat /= success ) THEN
517  msg = 'Error loading CloudCoeff data from '//trim(default_cloudcoeff_file)
518  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
519  RETURN
520  END IF
521  END IF
522 
523 
524  ! Load the aerosol coefficients
525  IF ( local_load_aerosolcoeff ) THEN
526  err_stat = crtm_aerosolcoeff_load( &
527  default_aerosolcoeff_file, &
528  quiet = quiet , &
529  process_id = process_id , &
530  output_process_id = output_process_id )
531  IF ( err_stat /= success ) THEN
532  msg = 'Error loading AerosolCoeff data from '//trim(default_aerosolcoeff_file)
533  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
534  RETURN
535  END IF
536  END IF
537 
538 
539  ! Load the emissivity model coefficients
540  ! ...Infrared
541  infrared_sensor: IF ( any(spccoeff_isinfraredsensor(sc)) ) THEN
542  ! ...IR land
543  err_stat = crtm_irlandcoeff_load( &
544  default_irlandcoeff_file, &
545  quiet = quiet , &
546  process_id = process_id , &
547  output_process_id = output_process_id )
548  IF ( err_stat /= success ) THEN
549  msg = 'Error loading IRlandCoeff data from '//trim(default_irlandcoeff_file)
550  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
551  RETURN
552  END IF
553  ! ...IR Water
554  err_stat = crtm_irwatercoeff_load( &
555  default_irwatercoeff_file, &
556  quiet = quiet , &
557  process_id = process_id , &
558  output_process_id = output_process_id )
559  IF ( err_stat /= success ) THEN
560  msg = 'Error loading IRwaterCoeff data from '//trim(default_irwatercoeff_file)
561  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
562  RETURN
563  END IF
564  ! ...IR snow
565  err_stat = crtm_irsnowcoeff_load( &
566  default_irsnowcoeff_file, &
567  quiet = quiet , &
568  process_id = process_id , &
569  output_process_id = output_process_id )
570  IF ( err_stat /= success ) THEN
571  msg = 'Error loading IRsnowCoeff data from '//trim(default_irsnowcoeff_file)
572  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
573  RETURN
574  END IF
575  ! ...IR ice
576  err_stat = crtm_iricecoeff_load( &
577  default_iricecoeff_file, &
578  quiet = quiet , &
579  process_id = process_id , &
580  output_process_id = output_process_id )
581  IF ( err_stat /= success ) THEN
582  msg = 'Error loading IRiceCoeff data from '//trim(default_iricecoeff_file)
583  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
584  RETURN
585  END IF
586  END IF infrared_sensor
587 
588  ! ...Visible
589  visible_sensor: IF ( any(spccoeff_isvisiblesensor(sc)) ) THEN
590  ! ...VIS land
591  err_stat = crtm_vislandcoeff_load( &
592  default_vislandcoeff_file, &
593  quiet = quiet , &
594  process_id = process_id , &
595  output_process_id = output_process_id )
596  IF ( err_stat /= success ) THEN
597  msg = 'Error loading VISlandCoeff data from '//trim(default_vislandcoeff_file)
598  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
599  RETURN
600  END IF
601  ! ...VIS water
602  err_stat = crtm_viswatercoeff_load( &
603  default_viswatercoeff_file, &
604  quiet = quiet , &
605  process_id = process_id , &
606  output_process_id = output_process_id )
607  IF ( err_stat /= success ) THEN
608  msg = 'Error loading VISwaterCoeff data from '//trim(default_viswatercoeff_file)
609  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
610  RETURN
611  END IF
612  ! ...VIS snow
613  err_stat = crtm_vissnowcoeff_load( &
614  default_vissnowcoeff_file, &
615  quiet = quiet , &
616  process_id = process_id , &
617  output_process_id = output_process_id )
618  IF ( err_stat /= success ) THEN
619  msg = 'Error loading VISsnowCoeff data from '//trim(default_vissnowcoeff_file)
620  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
621  RETURN
622  END IF
623  ! ...VIS ice
624  err_stat = crtm_visicecoeff_load( &
625  default_visicecoeff_file, &
626  quiet = quiet , &
627  process_id = process_id , &
628  output_process_id = output_process_id )
629  IF ( err_stat /= success ) THEN
630  msg = 'Error loading VISiceCoeff data from '//trim(default_visicecoeff_file)
631  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
632  RETURN
633  END IF
634  END IF visible_sensor
635 
636  ! ...Microwave
637  microwave_sensor: IF ( any(spccoeff_ismicrowavesensor(sc)) ) THEN
638  ! ...MW water
639  err_stat = crtm_mwwatercoeff_load( &
640  default_mwwatercoeff_file, &
641  quiet = quiet , &
642  process_id = process_id , &
643  output_process_id = output_process_id )
644  IF ( err_stat /= success ) THEN
645  msg = 'Error loading MWwaterCoeff data from '//trim(default_mwwatercoeff_file)
646  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
647  RETURN
648  END IF
649  END IF microwave_sensor
650 
651 
652  ! Load the ChannelInfo structure
653  DO n = 1, n_sensors
654  ! ...Allocate the ChannelInfo structure
655  CALL crtm_channelinfo_create( channelinfo(n), sc(n)%n_Channels )
656  IF ( .NOT. crtm_channelinfo_associated(channelinfo(n)) ) THEN
657  err_stat = failure
658  msg = 'ChannelInfo allocation failed for '//trim(sensor_id(n))//' sensor'
659  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
660  RETURN
661  END IF
662  ! ...Fill the structure for the current sensor
663  channelinfo(n)%Sensor_Index = n
664  channelinfo(n)%Channel_Index = (/(l, l=1,sc(n)%n_Channels)/)
665  channelinfo(n)%Sensor_ID = sc(n)%Sensor_Id
666  channelinfo(n)%Sensor_Type = sc(n)%Sensor_Type
667  channelinfo(n)%WMO_Satellite_ID = sc(n)%WMO_Satellite_ID
668  channelinfo(n)%WMO_Sensor_ID = sc(n)%WMO_Sensor_ID
669  channelinfo(n)%Sensor_Channel = sc(n)%Sensor_Channel
670  END DO
671 
672  END FUNCTION crtm_init
673 
674 
675 !------------------------------------------------------------------------------
676 !:sdoc+:
677 !
678 ! NAME:
679 ! CRTM_Destroy
680 !
681 ! PURPOSE:
682 ! Function to deallocate all the shared data arrays allocated and
683 ! populated during the CRTM initialization.
684 !
685 ! CALLING SEQUENCE:
686 ! Error_Status = CRTM_Destroy( ChannelInfo , &
687 ! Process_ID = Process_ID )
688 !
689 ! OUTPUTS:
690 ! ChannelInfo: Reinitialized ChannelInfo structure.
691 ! UNITS: N/A
692 ! TYPE: CRTM_ChannelInfo_type
693 ! DIMENSION: Rank-1
694 ! ATTRIBUTES: INTENT(IN OUT)
695 !
696 ! OPTIONAL INPUTS:
697 ! Process_ID: Set this argument to the MPI process ID that this
698 ! function call is running under. This value is used
699 ! solely for controlling message output. If MPI is not
700 ! being used, ignore this argument.
701 ! UNITS: N/A
702 ! TYPE: INTEGER
703 ! DIMENSION: Scalar
704 ! ATTRIBUTES: INTENT(IN), OPTIONAL
705 !
706 ! FUNCTION RESULT:
707 ! Error_Status: The return value is an integer defining the error
708 ! status. The error codes are defined in the
709 ! Message_Handler module.
710 ! If == SUCCESS the CRTM deallocations were successful
711 ! == FAILURE an unrecoverable error occurred.
712 ! UNITS: N/A
713 ! TYPE: INTEGER
714 ! DIMENSION: Scalar
715 !
716 ! SIDE EFFECTS:
717 ! All CRTM shared data arrays and structures are deallocated.
718 !
719 ! COMMENTS:
720 ! Note the INTENT on the output ChannelInfo argument is IN OUT rather than
721 ! just OUT. This is necessary because the argument may be defined upon
722 ! input. To prevent memory leaks, the IN OUT INTENT is a must.
723 !
724 !:sdoc-:
725 !------------------------------------------------------------------------------
726 
727  FUNCTION crtm_destroy( &
728  ChannelInfo, & ! Output
729  Process_ID ) & ! Optional input
730  result( err_stat )
731  ! Arguments
732  TYPE(crtm_channelinfo_type), INTENT(IN OUT) :: channelinfo(:)
733  INTEGER, OPTIONAL, INTENT(IN) :: process_id
734  ! Function result
735  INTEGER :: err_stat
736  ! Local parameters
737  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_Destroy'
738  ! Local variables
739  CHARACTER(ML) :: msg, pid_msg
740  INTEGER :: destroy_status
741 
742  ! Set up
743  err_stat = success
744  ! ...Create a process ID message tag for error messages
745  IF ( PRESENT(process_id) ) THEN
746  WRITE( pid_msg,'("; Process ID: ",i0)' ) process_id
747  ELSE
748  pid_msg = ''
749  END IF
750 
751 
752  ! Destroy all the ChannelInfo structures
753  CALL crtm_channelinfo_destroy( channelinfo )
754  IF ( any(crtm_channelinfo_associated(channelinfo)) ) THEN
755  err_stat = failure
756  msg = 'Error deallocating ChannelInfo structure(s)'
757  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
758  END IF
759 
760 
761  ! Destroy the shared data structure
762  destroy_status = crtm_visicecoeff_destroy( process_id = process_id )
763  IF ( destroy_status /= success ) THEN
764  err_stat = destroy_status
765  msg = 'Error deallocating shared VISiceCoeff data structure'//trim(pid_msg)
766  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
767  END IF
768 
769  destroy_status = crtm_vissnowcoeff_destroy( process_id = process_id )
770  IF ( destroy_status /= success ) THEN
771  err_stat = destroy_status
772  msg = 'Error deallocating shared VISsnowCoeff data structure'//trim(pid_msg)
773  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
774  END IF
775 
776  destroy_status = crtm_viswatercoeff_destroy( process_id = process_id )
777  IF ( destroy_status /= success ) THEN
778  err_stat = destroy_status
779  msg = 'Error deallocating shared VISwaterCoeff data structure'//trim(pid_msg)
780  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
781  END IF
782 
783  destroy_status = crtm_vislandcoeff_destroy( process_id = process_id )
784  IF ( destroy_status /= success ) THEN
785  err_stat = destroy_status
786  msg = 'Error deallocating shared VISlandCoeff data structure'//trim(pid_msg)
787  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
788  END IF
789 
790  destroy_status = crtm_iricecoeff_destroy( process_id = process_id )
791  IF ( destroy_status /= success ) THEN
792  err_stat = destroy_status
793  msg = 'Error deallocating shared IRiceCoeff data structure'//trim(pid_msg)
794  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
795  END IF
796 
797  destroy_status = crtm_irsnowcoeff_destroy( process_id = process_id )
798  IF ( destroy_status /= success ) THEN
799  err_stat = destroy_status
800  msg = 'Error deallocating shared IRsnowCoeff data structure'//trim(pid_msg)
801  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
802  END IF
803 
804  destroy_status = crtm_irwatercoeff_destroy( process_id = process_id )
805  IF ( destroy_status /= success ) THEN
806  err_stat = destroy_status
807  msg = 'Error deallocating shared IRwaterCoeff data structure'//trim(pid_msg)
808  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
809  END IF
810 
811  destroy_status = crtm_irlandcoeff_destroy( process_id = process_id )
812  IF ( destroy_status /= success ) THEN
813  err_stat = destroy_status
814  msg = 'Error deallocating shared IRlandCoeff data structure'//trim(pid_msg)
815  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
816  END IF
817 
818  destroy_status = crtm_aerosolcoeff_destroy( process_id = process_id )
819  IF ( destroy_status /= success ) THEN
820  err_stat = destroy_status
821  msg = 'Error deallocating shared AerosolCoeff data structure'//trim(pid_msg)
822  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
823  END IF
824 
825  destroy_status = crtm_cloudcoeff_destroy( process_id = process_id )
826  IF ( destroy_status /= success ) THEN
827  err_stat = destroy_status
828  msg = 'Error deallocating shared CloudCoeff data structure'//trim(pid_msg)
829  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
830  END IF
831 
832  destroy_status = crtm_destroy_taucoeff( process_id = process_id )
833  IF ( destroy_status /= success ) THEN
834  err_stat = destroy_status
835  msg = 'Error deallocating shared TauCoeff data structure(s)'//trim(pid_msg)
836  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
837  END IF
838 
839  destroy_status = crtm_spccoeff_destroy( process_id = process_id )
840  IF ( destroy_status /= success ) THEN
841  err_stat = destroy_status
842  msg = 'Error deallocating shared SpcCoeff data structure(s)'//trim(pid_msg)
843  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
844  END IF
845 
846  destroy_status = crtm_mwwatercoeff_destroy( process_id = process_id )
847  IF ( destroy_status /= success ) THEN
848  err_stat = destroy_status
849  msg = 'Error deallocating shared MWwaterCoeff data structure'//trim(pid_msg)
850  CALL display_message( routine_name,trim(msg)//trim(pid_msg),err_stat )
851  END IF
852 
853  END FUNCTION crtm_destroy
854 
855 
856 !--------------------------------------------------------------------------------
857 !:sdoc+:
858 !
859 ! NAME:
860 ! CRTM_IsInitialized
861 !
862 ! PURPOSE:
863 ! Logical function to test if the CRTM has been correctly initialized.
864 !
865 ! CALLING SEQUENCE:
866 ! status = CRTM_IsInitialized( ChannelInfo )
867 !
868 ! INPUTS:
869 ! ChannelInfo: ChannelInfo structure array.
870 ! UNITS: N/A
871 ! TYPE: CRTM_ChannelInfo_type
872 ! DIMENSION: Rank-1
873 ! ATTRIBUTES: INTENT(IN)
874 !
875 ! FUNCTION RESULT:
876 ! Status: The return value is a logical result indicating if the
877 ! CRTM has been correctly initialised.
878 ! If == .TRUE., all the ChannelInfo entries are valid.
879 ! == .FALSE., any of the ChannelInfo entries are invalid.
880 ! UNITS: N/A
881 ! TYPE: LOGICAL
882 ! DIMENSION: Scalar
883 !
884 !:sdoc-:
885 !--------------------------------------------------------------------------------
886 
887  FUNCTION crtm_isinitialized( ChannelInfo ) RESULT( Status )
888  TYPE(crtm_channelinfo_type), INTENT(IN) :: channelinfo(:)
889  LOGICAL :: status
890  status = all(crtm_channelinfo_associated(channelinfo))
891  END FUNCTION crtm_isinitialized
892 
893 
894 !--------------------------------------------------------------------------------
895 !:sdoc+:
896 !
897 ! NAME:
898 ! CRTM_LifeCycleVersion
899 !
900 ! PURPOSE:
901 ! Subroutine to return the module version information.
902 !
903 ! CALLING SEQUENCE:
904 ! CALL CRTM_LifeCycleVersion( Id )
905 !
906 ! OUTPUT ARGUMENTS:
907 ! Id: Character string containing the version Id information
908 ! for the module.
909 ! UNITS: N/A
910 ! TYPE: CHARACTER(*)
911 ! DIMENSION: Scalar
912 ! ATTRIBUTES: INTENT(OUT)
913 !
914 !:sdoc-:
915 !--------------------------------------------------------------------------------
916 
917  SUBROUTINE crtm_lifecycleversion( Id )
918  CHARACTER(*), INTENT(OUT) :: id
919  id = module_version_id
920  END SUBROUTINE crtm_lifecycleversion
921 
922 END MODULE crtm_lifecycle
integer function, public crtm_vislandcoeff_destroy(Process_ID)
integer function, public crtm_spccoeff_destroy(Process_ID)
integer function, public crtm_mwwatercoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer, parameter, public failure
subroutine, public crtm_lifecycleversion(Id)
elemental subroutine, public crtm_channelinfo_destroy(ChannelInfo)
integer function, public crtm_visicecoeff_destroy(Process_ID)
integer, parameter sl
integer function, public crtm_aerosolcoeff_destroy(Process_ID)
integer function, public crtm_iricecoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_irwatercoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_vislandcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_init(Sensor_ID, ChannelInfo, CloudCoeff_File, AerosolCoeff_File, EmisCoeff_File, IRwaterCoeff_File, IRlandCoeff_File, IRsnowCoeff_File, IRiceCoeff_File, VISwaterCoeff_File, VISlandCoeff_File, VISsnowCoeff_File, VISiceCoeff_File, MWwaterCoeff_File, File_Path, Load_CloudCoeff, Load_AerosolCoeff, Quiet, Process_ID, Output_Process_ID)
elemental logical function, public crtm_channelinfo_associated(ChannelInfo)
integer function, public crtm_viswatercoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
elemental subroutine, public crtm_channelinfo_create(ChannelInfo, n_Channels)
character(*), parameter module_version_id
integer function, public crtm_vissnowcoeff_destroy(Process_ID)
integer function, public crtm_irsnowcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer function, public crtm_cloudcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_aerosolcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer, parameter ml
integer function, public crtm_cloudcoeff_destroy(Process_ID)
integer function, public crtm_destroy(ChannelInfo, Process_ID)
integer function, public crtm_spccoeff_load(Sensor_ID, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_irlandcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
type(spccoeff_type), dimension(:), allocatable, save, public sc
integer function, public crtm_iricecoeff_destroy(Process_ID)
integer function, public crtm_irlandcoeff_destroy(Process_ID)
integer function, public crtm_load_taucoeff(Sensor_ID, File_Path, Quiet, Process_ID, Output_Process_ID, Message_Log)
logical function, public crtm_isinitialized(ChannelInfo)
integer function, public crtm_mwwatercoeff_destroy(Process_ID)
integer function, public crtm_vissnowcoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer, parameter, public success
integer function, public crtm_destroy_taucoeff(Process_ID, Message_Log)
integer function, public crtm_viswatercoeff_destroy(Process_ID)
integer function, public crtm_visicecoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
integer function, public crtm_irsnowcoeff_destroy(Process_ID)
integer function, public crtm_irwatercoeff_destroy(Process_ID)