25 public :: viirs_config_type
27 type :: viirs_config_type
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
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
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
81 character(len=255) :: l1b_m
82 character(len=255) :: geo_m
84 character(len=255) :: output_l2
87 end type viirs_config_type
97 type(viirs_config_type) function load_viirs_config(config_file, status) result(vcfg)
100 character(len=255),
intent(in) :: config_file
101 integer,
intent(inout) :: status
103 character(255) :: c_line, var, val
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 =
''
158 vcfg%rayl412_file =
''
159 vcfg%rayl488_file =
''
160 vcfg%rayl670_file =
''
161 vcfg%xcal412_file =
''
162 vcfg%xcal488_file =
''
163 vcfg%xcal670_file =
''
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
174 read(100, fmt=
'(A)', iostat=status) c_line
175 if (status /= 0)
then
179 else if (status > 0)
then
180 print *,
"ERROR: Failed to read configuration file: ", status
187 c_line =rm_whitespace(c_line)
190 if (
index(c_line,
'!') /= 0)
then
194 if (len_trim(c_line) == 0)
then
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))
205 select case (
trim(var))
207 vcfg%lut_nc4 =
trim(val)
209 read(val, fmt=
'(I4)') vcfg%year
211 read(val, fmt=
'(I2)') vcfg%month
213 read(val, fmt=
'(I2)') vcfg%day
215 read(val, fmt=
'(I2)') vcfg%hour
217 read(val, fmt=
'(I2)') vcfg%minute
219 read(val, fmt=
'(I2)') vcfg%second
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)
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)
243 vcfg%geozone_file =
trim(val)
244 case (
'lut_seasonal_deserts')
245 vcfg%seasonal_deserts_file =
trim(val)
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)
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)
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)
275 vcfg%gmtco_file =
trim(val)
277 vcfg%iicmo_file =
trim(val)
279 vcfg%svm01_file =
trim(val)
281 vcfg%svm02_file =
trim(val)
283 vcfg%svm03_file =
trim(val)
285 vcfg%svm04_file =
trim(val)
287 vcfg%svm05_file =
trim(val)
289 vcfg%svm07_file =
trim(val)
291 vcfg%svm08_file =
trim(val)
293 vcfg%svm09_file =
trim(val)
295 vcfg%svm10_file =
trim(val)
297 vcfg%svm11_file =
trim(val)
299 vcfg%svm14_file =
trim(val)
301 vcfg%svm15_file =
trim(val)
303 vcfg%svm16_file =
trim(val)
305 vcfg%gdas_file1 =
trim(val)
307 vcfg%gdas_file2 =
trim(val)
309 vcfg%l1b_m =
trim(val)
311 vcfg%geo_m =
trim(val)
336 function rm_whitespace(input_string)
339 character(len=255),
intent(in) :: input_string
341 character(len=len(input_string)) :: rm_whitespace
342 integer :: space_index, end_index
344 rm_whitespace = input_string
347 if (len_trim(rm_whitespace) == 0)
then
353 space_index =
index(rm_whitespace,
' ')
354 if ( space_index == 1)
then
355 rm_whitespace = rm_whitespace(2:len(rm_whitespace))
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)
374 end function rm_whitespace