OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
deepblue_config.f95
Go to the documentation of this file.
2  !
3  ! deepblue_config.f95
4  !
5  ! Description: Configuration module for Deep Blue aerosol retrievals.
6  !
7  ! Modules: None
8  !
9  ! Author: Corey Bettenhausen
10  ! Science Systems and Applications, Inc.
11  ! NASA Goddard Space Flight Center
12  ! corey_bettenhausen@ssaihq.com
13  !
14  ! Last Changed:
15  !
16  ! History: 2012-08 Original version
17  !
18  !------------------------------------------------------------------------------
19  implicit none
20 
21  ! Restrict access to module components.
22  private
23 
24  public :: load_viirs_config
25  public :: viirs_config_type
26 
27  type :: viirs_config_type
28  integer :: year
29  integer :: month
30  integer :: day
31  integer :: hour
32  integer :: minute
33  integer :: second
34  character(len=255) :: lut_nc4
35  character(len=255) :: aerosol_land_file
36  character(len=255) :: aerosol_dust_file
37  character(len=255) :: aerosol_ocean_dust_file
38  character(len=255) :: aerosol_ocean_fine_file
39  character(len=255) :: aerosol_ocean_mari_file
40  character(len=255) :: aerosol_ocean_mix_file
41  character(len=255) :: bathymetry_lut_file
42  character(len=255) :: chl_lut_file
43  character(len=255) :: ler_lut_file
44  character(len=255) :: landcover_file
45  character(len=255) :: surfpressure_file
46  character(len=255) :: geozone_file
47  character(len=255) :: seasonal_deserts_file
48  character(len=255) :: brdfbase_file
49  character(len=255) :: modis_surfdb_file
50  character(len=255) :: viirs_surfdb_file
51  character(len=255) :: surfcoeffs_file
52  character(len=255) :: swir_vis_surfcoeffs_file
53  character(len=255) :: veg_landcover_file
54  character(len=255) :: veg_sfc21_file
55 
56  character(len=255) :: rayl412_file
57  character(len=255) :: rayl488_file
58  character(len=255) :: rayl670_file
59  character(len=255) :: xcal412_file
60  character(len=255) :: xcal488_file
61  character(len=255) :: xcal670_file
62 
63  character(len=255) :: gmtco_file
64  character(len=255) :: iicmo_file
65  character(len=255) :: svm01_file
66  character(len=255) :: svm02_file
67  character(len=255) :: svm03_file
68  character(len=255) :: svm04_file
69  character(len=255) :: svm05_file
70  character(len=255) :: svm07_file
71  character(len=255) :: svm08_file
72  character(len=255) :: svm09_file
73  character(len=255) :: svm10_file
74  character(len=255) :: svm11_file
75  character(len=255) :: svm14_file
76  character(len=255) :: svm15_file
77  character(len=255) :: svm16_file
78  character(len=255) :: gdas_file1
79  character(len=255) :: gdas_file2
80 
81  character(len=255) :: l1b_m
82  character(len=255) :: geo_m
83 
84  character(len=255) :: output_l2
85 
86 
87  end type viirs_config_type
88 
89 contains
90 
91  !
92  ! load_viirs_config()
93  !
94  ! Loads configuration file, config_file, into viirs_config object.
95  !
96  !-------------------------------------------------------------------
97  type(viirs_config_type) function load_viirs_config(config_file, status) result(vcfg)
98  implicit none
99 
100  character(len=255), intent(in) :: config_file
101  integer, intent(inout) :: status
102 
103  character(255) :: c_line, var, val
104  integer :: eq_index
105 
106  ! -- initialize our config variables.
107  vcfg%year = 1900
108  vcfg%month = 1
109  vcfg%day = 1
110  vcfg%hour = 0
111  vcfg%minute = 0
112  vcfg%second = 0
113 
114  vcfg%lut_nc4 = ''
115  vcfg%aerosol_land_file = ''
116  vcfg%aerosol_dust_file = ''
117  vcfg%aerosol_ocean_dust_file = ''
118  vcfg%aerosol_ocean_fine_file = ''
119  vcfg%aerosol_ocean_mari_file = ''
120  vcfg%aerosol_ocean_mix_file = ''
121  vcfg%bathymetry_lut_file = ''
122  vcfg%chl_lut_file = ''
123  vcfg%ler_lut_file = ''
124  vcfg%landcover_file = ''
125  vcfg%surfpressure_file = ''
126  vcfg%geozone_file = ''
127  vcfg%seasonal_deserts_file = ''
128  vcfg%brdfbase_file = ''
129  vcfg%modis_surfdb_file = ''
130  vcfg%viirs_surfdb_file = ''
131  vcfg%surfcoeffs_file = ''
132  vcfg%swir_vis_surfcoeffs_file = ''
133  vcfg%veg_landcover_file = ''
134  vcfg%veg_sfc21_file = ''
135 
136  vcfg%gmtco_file = ''
137  vcfg%svm01_file = ''
138  vcfg%svm02_file = ''
139  vcfg%svm03_file = ''
140  vcfg%svm04_file = ''
141  vcfg%svm05_file = ''
142  vcfg%svm07_file = ''
143  vcfg%svm08_file = ''
144  vcfg%svm09_file = ''
145  vcfg%svm10_file = ''
146  vcfg%svm11_file = ''
147  vcfg%svm14_file = ''
148  vcfg%svm15_file = ''
149  vcfg%svm16_file = ''
150  vcfg%iicmo_file = ''
151 
152  vcfg%l1b_m = ''
153  vcfg%geo_m = ''
154 
155  vcfg%gdas_file1 = ''
156  vcfg%gdas_file2 = ''
157 
158  vcfg%rayl412_file = ''
159  vcfg%rayl488_file = ''
160  vcfg%rayl670_file = ''
161  vcfg%xcal412_file = ''
162  vcfg%xcal488_file = ''
163  vcfg%xcal670_file = ''
164  vcfg%output_l2 = ''
165 
166  open(100, file=trim(config_file), status='OLD', form='FORMATTED', action='READ', iostat=status)
167  if (status /= 0) then
168  print *, 'ERROR: failed to open configuration file: ', status
169  return
170  end if
171 
172  do
173  ! Read a line from the config file. Die on error.
174  read(100, fmt='(A)', iostat=status) c_line
175  if (status /= 0) then
176  if (status < 0) then
177  status = 0
178  return
179  else if (status > 0) then
180  print *, "ERROR: Failed to read configuration file: ", status
181  status = -1
182  return
183  end if
184  end if
185 
186  ! Clean up whitespace.
187  c_line =rm_whitespace(c_line)
188 
189  ! Detect comment lines or empty lines and skip.
190  if (index(c_line, '!') /= 0) then
191  cycle
192  end if
193 
194  if (len_trim(c_line) == 0) then
195  cycle
196  end if
197 
198  ! Begin parsing for variable and value.
199  ! If no '=' is detected, we have a funky line, cycle.
200  eq_index = index(c_line,'=')
201  if (eq_index /= 0) then
202  var = c_line(1:eq_index-1)
203  val = c_line(eq_index+1:len(c_line))
204 
205  select case (trim(var))
206  case ('lut_nc4_db')
207  vcfg%lut_nc4 = trim(val)
208  case ('year')
209  read(val, fmt='(I4)') vcfg%year
210  case ('month')
211  read(val, fmt='(I2)') vcfg%month
212  case ('day')
213  read(val, fmt='(I2)') vcfg%day
214  case ('hour')
215  read(val, fmt='(I2)') vcfg%hour
216  case ('minute')
217  read(val, fmt='(I2)') vcfg%minute
218  case ('second')
219  read(val, fmt='(I2)') vcfg%second
220  case ('ofile')
221  vcfg%output_l2 = trim(val)
222  case ('lut_aero_land_fine')
223  vcfg%aerosol_land_file = trim(val)
224  case ('lut_aero_land_dust')
225  vcfg%aerosol_dust_file = trim(val)
226  case ('lut_aero_ocean_dust')
227  vcfg%aerosol_ocean_dust_file = trim(val)
228  case ('lut_aero_ocean_fine')
229  vcfg%aerosol_ocean_fine_file = trim(val)
230  case ('lut_aero_ocean_mari')
231  vcfg%aerosol_ocean_mari_file = trim(val)
232  case ('lut_aero_ocean_mix')
233  vcfg%aerosol_ocean_mix_file = trim(val)
234  case ('lut_bathymetry')
235  vcfg%bathymetry_lut_file = trim(val)
236  case ('lut_chl')
237  vcfg%chl_lut_file = trim(val)
238  case ('lut_ler_table')
239  vcfg%ler_lut_file = trim(val)
240  case ('lut_landcover')
241  vcfg%landcover_file = trim(val)
242  case ('lut_geozone')
243  vcfg%geozone_file = trim(val)
244  case ('lut_seasonal_deserts')
245  vcfg%seasonal_deserts_file = trim(val)
246  case ('lut_brdf')
247  vcfg%brdfbase_file = trim(val)
248  case ('lut_modis_surfdb')
249  vcfg%modis_surfdb_file = trim(val)
250  case ('lut_viirs_surfdb')
251  vcfg%viirs_surfdb_file = trim(val)
252  case ('lut_surfcoeff')
253  vcfg%surfcoeffs_file = trim(val)
254  case ('lut_swir')
255  vcfg%swir_vis_surfcoeffs_file = trim(val)
256  case ('lut_veg_landcover')
257  vcfg%veg_landcover_file = trim(val)
258  case ('lut_veg_21sfc')
259  vcfg%veg_sfc21_file = trim(val)
260 
261  case ('lut_rayl_412')
262  vcfg%rayl412_file = trim(val)
263  case ('lut_rayl_488')
264  vcfg%rayl488_file = trim(val)
265  case ('lut_rayl_670')
266  vcfg%rayl670_file = trim(val)
267  case ('lut_viirs_xcal_412')
268  vcfg%xcal412_file = trim(val)
269  case ('lut_viirs_xcal_488')
270  vcfg%xcal488_file = trim(val)
271  case ('lut_viirs_xcal_670')
272  vcfg%xcal670_file = trim(val)
273 
274  case ('gmtco')
275  vcfg%gmtco_file = trim(val)
276  case ('iicmo')
277  vcfg%iicmo_file = trim(val)
278  case ('svm01')
279  vcfg%svm01_file = trim(val)
280  case ('svm02')
281  vcfg%svm02_file = trim(val)
282  case ('svm03')
283  vcfg%svm03_file = trim(val)
284  case ('svm04')
285  vcfg%svm04_file = trim(val)
286  case ('svm05')
287  vcfg%svm05_file = trim(val)
288  case ('svm07')
289  vcfg%svm07_file = trim(val)
290  case ('svm08')
291  vcfg%svm08_file = trim(val)
292  case ('svm09')
293  vcfg%svm09_file = trim(val)
294  case ('svm10')
295  vcfg%svm10_file = trim(val)
296  case ('svm11')
297  vcfg%svm11_file = trim(val)
298  case ('svm14')
299  vcfg%svm14_file = trim(val)
300  case ('svm15')
301  vcfg%svm15_file = trim(val)
302  case ('svm16')
303  vcfg%svm16_file = trim(val)
304  case ('gdas1')
305  vcfg%gdas_file1 = trim(val)
306  case ('gdas2')
307  vcfg%gdas_file2 = trim(val)
308  case ('ifile')
309  vcfg%l1b_m = trim(val)
310  case ('geofile')
311  vcfg%geo_m = trim(val)
312  case default
313  cycle
314  end select
315  else
316  cycle
317  end if
318 
319 
320  end do
321 
322  return
323 
324  end function load_viirs_config
325 
326  !
327  ! rm_whitespace()
328  !
329  ! Removes whitespace from a specified string.
330  !
331  ! Inputs: input_string string to be cleared of whitespace
332  ! Outputs: Returns character array cleared of all whitespace.
333  ! Side effects: None
334  !
335  !----------------------------------------------------------------------
336  function rm_whitespace(input_string)
337  implicit none
338 
339  character(len=255), intent(in) :: input_string
340 
341  character(len=len(input_string)) :: rm_whitespace
342  integer :: space_index, end_index
343 
344  rm_whitespace = input_string
345 
346  ! Empty string?
347  if (len_trim(rm_whitespace) == 0) then
348  return
349  end if
350 
351  ! Remove frontal spaces.
352  do
353  space_index = index(rm_whitespace,' ')
354  if ( space_index == 1) then
355  rm_whitespace = rm_whitespace(2:len(rm_whitespace))
356  else
357  exit
358  end if
359  end do
360 
361  ! Remove any internal spaces
362  do
363  space_index = index(rm_whitespace,' ')
364  end_index = len_trim(rm_whitespace)
365  if (space_index > 0 .AND. space_index < end_index) then
366  rm_whitespace = rm_whitespace(1:space_index-1) // &
367  & rm_whitespace(space_index+1:end_index)
368  else
369  exit
370  end if
371  end do
372 
373  return
374  end function rm_whitespace
375 
376 end module deepblue_config
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
type(viirs_config_type) function, public load_viirs_config(config_file, status)
string & trim(string &s, const string &delimiters)
Definition: EnvsatUtil.cpp:29