FV3 Bundle
CRTM_IRwaterCoeff.f90
Go to the documentation of this file.
1 !
2 ! CRTM_IRwaterCoeff
3 !
4 ! Module containing the shared CRTM infrared water surface emissivity
5 ! data and their load/destruction routines.
6 !
7 ! PUBLIC DATA:
8 ! IRwaterC: Data structure containing the infrared water surface
9 ! emissivity data.
10 !
11 ! SIDE EFFECTS:
12 ! Routines in this module modify the contents of the public
13 ! data structure IRwaterC.
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, 04-May-2012
21 ! paul.vandelst@noaa.gov
22 !
23 
25 
26  ! -----------------
27  ! Environment setup
28  ! -----------------
29  ! Module use
35  ! Disable all implicit typing
36  IMPLICIT NONE
37 
38 
39  ! ------------
40  ! Visibilities
41  ! ------------
42  ! Everything private by default
43  PRIVATE
44  ! The shared data
45  PUBLIC :: irwaterc
46  ! Procedures
47  PUBLIC :: crtm_irwatercoeff_load
50 
51 
52  ! -----------------
53  ! Module parameters
54  ! -----------------
55  CHARACTER(*), PARAMETER :: module_version_id = &
56  '$Id: CRTM_IRwaterCoeff.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
57  ! Message string length
58  INTEGER, PARAMETER :: ml = 512
59 
60 
61  ! ------------------------------------------------
62  ! The shared infrared water surface emissivity data
63  ! ------------------------------------------------
64  TYPE(irwatercoeff_type), SAVE :: irwaterc
65 
66 
67 CONTAINS
68 
69 
70 !------------------------------------------------------------------------------
71 !:sdoc+:
72 !
73 ! NAME:
74 ! CRTM_IRwaterCoeff_Load
75 !
76 ! PURPOSE:
77 ! Function to load the infrared water surface emissivity data into
78 ! the public data structure IRwaterC
79 !
80 ! CALLING SEQUENCE:
81 ! Error_Status = CRTM_IRwaterCoeff_Load( &
82 ! Filename, &
83 ! File_Path = File_Path , &
84 ! Quiet = Quiet , &
85 ! Process_ID = Process_ID , &
86 ! Output_Process_ID = Output_Process_ID )
87 !
88 ! INPUT ARGUMENTS:
89 ! Filename: Name of the IRwaterCoeff file.
90 ! UNITS: N/A
91 ! TYPE: CHARACTER(*)
92 ! DIMENSION: Scalar
93 ! ATTRIBUTES: INTENT(IN)
94 !
95 !
96 ! OPTIONAL INPUT ARGUMENTS:
97 ! File_Path: Character string specifying a file path for the
98 ! input data file. If not specified, the current
99 ! directory is the default.
100 ! UNITS: N/A
101 ! TYPE: CHARACTER(*)
102 ! DIMENSION: Scalar
103 ! ATTRIBUTES: INTENT(IN), OPTIONAL
104 !
105 ! Quiet: Set this logical argument to suppress INFORMATION
106 ! messages being printed to stdout
107 ! If == .FALSE., INFORMATION messages are OUTPUT [DEFAULT].
108 ! == .TRUE., INFORMATION messages are SUPPRESSED.
109 ! If not specified, default is .FALSE.
110 ! UNITS: N/A
111 ! TYPE: LOGICAL
112 ! DIMENSION: Scalar
113 ! ATTRIBUTES: INTENT(IN), OPTIONAL
114 !
115 ! Process_ID: Set this argument to the MPI process ID that this
116 ! function call is running under. This value is used
117 ! solely for controlling INFORMATIOn message output.
118 ! If MPI is not being used, ignore this argument.
119 ! This argument is ignored if the Quiet argument is set.
120 ! UNITS: N/A
121 ! TYPE: INTEGER
122 ! DIMENSION: Scalar
123 ! ATTRIBUTES: INTENT(IN), OPTIONAL
124 !
125 ! Output_Process_ID: Set this argument to the MPI process ID in which
126 ! all INFORMATION messages are to be output. If
127 ! the passed Process_ID value agrees with this value
128 ! the INFORMATION messages are output.
129 ! This argument is ignored if the Quiet argument
130 ! is set.
131 ! UNITS: N/A
132 ! TYPE: INTEGER
133 ! DIMENSION: Scalar
134 ! ATTRIBUTES: INTENT(IN), OPTIONAL
135 !
136 ! FUNCTION RESULT:
137 ! Error_Status: The return value is an integer defining the error
138 ! status. The error codes are defined in the
139 ! Message_Handler module.
140 ! If == SUCCESS the data load was successful
141 ! == FAILURE an unrecoverable error occurred.
142 ! UNITS: N/A
143 ! TYPE: INTEGER
144 ! DIMENSION: Scalar
145 !
146 ! SIDE EFFECTS:
147 ! This function modifies the contents of the public data
148 ! structure IRwaterC.
149 !
150 !:sdoc-:
151 !------------------------------------------------------------------------------
152 
153  FUNCTION crtm_irwatercoeff_load( &
154  Filename , & ! Input
155  File_Path , & ! Optional input
156  Quiet , & ! Optional input
157  Process_ID , & ! Optional input
158  Output_Process_ID) & ! Optional input
159  result( err_stat )
160  ! Arguments
161  CHARACTER(*), INTENT(IN) :: filename
162  CHARACTER(*), OPTIONAL, INTENT(IN) :: file_path
163  LOGICAL , OPTIONAL, INTENT(IN) :: quiet
164  INTEGER , OPTIONAL, INTENT(IN) :: process_id
165  INTEGER , OPTIONAL, INTENT(IN) :: output_process_id
166  ! Function result
167  INTEGER :: err_stat
168  ! Local parameters
169  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_IRwaterCoeff_Load'
170  ! Local variables
171  CHARACTER(ML) :: msg, pid_msg
172  CHARACTER(ML) :: irwatercoeff_file
173  LOGICAL :: noisy
174 
175  ! Setup
176  err_stat = success
177  ! ...Assign the filename to local variable
178  irwatercoeff_file = adjustl(filename)
179  ! ...Add the file path
180  IF ( PRESENT(file_path) ) irwatercoeff_file = trim(adjustl(file_path))//trim(irwatercoeff_file)
181  ! ...Check Quiet argument
182  noisy = .true.
183  IF ( PRESENT(quiet) ) noisy = .NOT. quiet
184  ! ...Check the MPI Process Ids
185  IF ( noisy .AND. PRESENT(process_id) .AND. PRESENT(output_process_id) ) THEN
186  IF ( process_id /= output_process_id ) noisy = .false.
187  END IF
188  ! ...Create a process ID message tag for error messages
189  IF ( PRESENT(process_id) ) THEN
190  WRITE( pid_msg,'("; Process ID: ",i0)' ) process_id
191  ELSE
192  pid_msg = ''
193  END IF
194 
195 
196  ! Read the IR water IRwaterCoeff file
197  err_stat = irwatercoeff_readfile( &
198  irwaterc, &
199  irwatercoeff_file, &
200  quiet = .NOT. noisy )
201  IF ( err_stat /= success ) THEN
202  msg = 'Error reading IRwaterCoeff IRwaterCoeff file '//trim(irwatercoeff_file)//trim(pid_msg)
203  CALL load_cleanup(); RETURN
204  END IF
205 
206  CONTAINS
207 
208  SUBROUTINE load_cleanup()
210  err_stat = failure
211  CALL display_message( routine_name, msg, err_stat )
212  END SUBROUTINE load_cleanup
213 
214  END FUNCTION crtm_irwatercoeff_load
215 
216 
217 !------------------------------------------------------------------------------
218 !:sdoc+:
219 !
220 ! NAME:
221 ! CRTM_IRwaterCoeff_Destroy
222 !
223 ! PURPOSE:
224 ! Function to deallocate the public data structure IRwaterC containing
225 ! the CRTM infrared water surface emissivity data.
226 !
227 ! CALLING SEQUENCE:
228 ! Error_Status = CRTM_IRwaterCoeff_Destroy( Process_ID = Process_ID )
229 !
230 ! OPTIONAL INPUTS:
231 ! Process_ID: Set this argument to the MPI process ID that this
232 ! function call is running under. This value is used
233 ! solely for controlling message output. If MPI is not
234 ! being used, ignore this argument.
235 ! UNITS: N/A
236 ! TYPE: INTEGER
237 ! DIMENSION: Scalar
238 ! ATTRIBUTES: INTENT(IN), OPTIONAL
239 !
240 ! FUNCTION RESULT:
241 ! Error_Status: The return value is an integer defining the error
242 ! status. The error codes are defined in the
243 ! Message_Handler module.
244 ! If == SUCCESS the deallocation of the public data
245 ! structure was successful
246 ! == FAILURE an unrecoverable error occurred.
247 ! UNITS: N/A
248 ! TYPE: INTEGER
249 ! DIMENSION: Scalar
250 !
251 ! SIDE EFFECTS:
252 ! This function modifies the contents of the public data
253 ! structure IRwaterC.
254 !
255 !:sdoc-:
256 !------------------------------------------------------------------------------
257 
258  FUNCTION crtm_irwatercoeff_destroy( Process_ID ) RESULT( err_stat )
259  ! Arguments
260  INTEGER, OPTIONAL, INTENT(IN) :: process_id
261  ! Function result
262  INTEGER :: err_stat
263  ! Local parameters
264  CHARACTER(*), PARAMETER :: routine_name = 'CRTM_IRwaterCoeff_Destroy'
265  ! Local variables
266  CHARACTER(ML) :: msg, pid_msg
267 
268  ! Setup
269  err_stat = success
270  ! ...Create a process ID message tag for error messages
271  IF ( PRESENT(process_id) ) THEN
272  WRITE( pid_msg,'("; Process ID: ",i0)' ) process_id
273  ELSE
274  pid_msg = ''
275  END IF
276 
277  ! Destroy the structure
279  IF ( irwatercoeff_associated( irwaterc ) ) THEN
280  err_stat = failure
281  msg = 'Error deallocating IRwaterCoeff shared data structure'//trim(pid_msg)
282  CALL display_message( routine_name, msg, err_stat ); RETURN
283  END IF
284 
285  END FUNCTION crtm_irwatercoeff_destroy
286 
287 
288 !------------------------------------------------------------------------------
289 !:sdoc+:
290 !
291 ! NAME:
292 ! CRTM_IRwaterCoeff_IsLoaded
293 !
294 ! PURPOSE:
295 ! Function to test if infrared water surface emissivity data has
296 ! been loaded into the public data structure IRwaterC.
297 !
298 ! CALLING SEQUENCE:
299 ! status = CRTM_IRwaterCoeff_IsLoaded()
300 !
301 !:sdoc-:
302 !------------------------------------------------------------------------------
303 
304  FUNCTION crtm_irwatercoeff_isloaded() RESULT( IsLoaded )
305  LOGICAL :: isloaded
306  isloaded = irwatercoeff_associated( irwaterc )
307  END FUNCTION crtm_irwatercoeff_isloaded
308 
309 END MODULE crtm_irwatercoeff
integer, parameter, public failure
subroutine load_cleanup()
type(irwatercoeff_type), save, public irwaterc
elemental subroutine, public irwatercoeff_destroy(self)
integer function, public crtm_irwatercoeff_load(Filename, File_Path, Quiet, Process_ID, Output_Process_ID)
character(*), parameter module_version_id
logical function, public crtm_irwatercoeff_isloaded()
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer, parameter ml
integer, parameter, public success
integer function, public irwatercoeff_readfile(IRwaterCoeff, Filename, No_Close, Quiet, Title, History, Comment, Debug)
integer function, public crtm_irwatercoeff_destroy(Process_ID)
elemental logical function, public irwatercoeff_associated(self)