NASA Logo
Ocean Color Science Software

ocssw V2022
modis_frontend_module.f90
Go to the documentation of this file.
2 
3  implicit none
4 
5  include 'netcdf.inc'
6 
7  private
8 
9  integer :: index_solarzenith, index_sensorzenith,&
10  index_relativeazimuth,index_solarzenith_flux
11 
12  real, dimension(:), allocatable :: solarzenith_all, sensorzenith_all, &
13  relativeazimuth_all, solarzenith_flux_all
14 
15 
19 
20  contains
21 
22  subroutine initialize_run( start, edge, stride, &
23  tilesize, &
24  threshold_solar_zenith, &
25  threshold_sensor_zenith, &
26  threshold_relative_azimuth, &
27  status )
28  ! WDR
29  ! tilesize O the size of the data block to process - in case of MODIS,
30  ! AVHRR, it is edge (1) the # pixels?
31  !
32  use core_arrays
35  use names
37  use specific_other
38  use ch_xfr, only : c2_sensor_id, oci_id, ocis_id
39 
40  implicit none
41 
42 
43  integer, intent (out) :: status, tilesize
44 
45  real, intent(out) :: threshold_solar_zenith, &
46  threshold_sensor_zenith, &
47  threshold_relative_azimuth
48 
49  integer, dimension (2), intent (out) :: start,edge,stride
50 
51  integer :: number_of_bands, index, file_version, localstatus
52 
53  ! function definitions
54  ! WDR integer get_platform_name
55  ! WDR external get_platform_name
56 
57  status = 0
58 
59  ! WDR only set the name to Aqua
60  platform_name = "Aqua"
61  ! WDR 13 jun 22, use c2_sensor_id to set to OCI if so
62  ! temp to test incrimentaly if( c2_sensor_id == OCI_ID ) platform_name = "OCI"
63  !localstatus = get_platform_name(Alevel1b_name(1), platform_name)
64 
65  call get_channels
66 
67  ! WDR remove these entirely
68  !if (platform_name == "RSP" .or. platform_name == "SSFR") then
69  ! call get_data_dims(Alevel1b_name(1), start, stride, edge)
70  !else
71  ! call get_data_dims(Amod06_name, start, stride, edge)
72  !endif
73 
74  threshold_solar_zenith = set_threshold_solar_zenith
75  threshold_sensor_zenith = set_threshold_sensor_zenith
76  threshold_relative_azimuth = set_threshold_relative_azimuth
77 
78  ! print*, size(Alevel1b_name)
79 
80 #ifdef VIIRS_INST
81  if (modis_mode) then
82  tilesize = set_tilesize_modis
83  number_of_bands = size(set_bands_modis)
84  allocate(bands(number_of_bands))
85  bands(:) = set_bands_modis(:)
86  channel_37um = set_bands_modis(band_0370)
87  channel_11um = set_bands_modis(band_1100)
88  channel_12um = set_bands_modis(band_1200)
89  else
90  tilesize = set_tilesize
91  number_of_bands = size(set_bands)
92  allocate(bands(number_of_bands))
93  bands(:) = set_bands(:)
97  endif
98 #else
99 
100  if (platform_name == "RSP" .or. platform_name == "SSFR") then
101  tilesize = edge(1)
102  else
103  tilesize = set_tilesize
104  endif
105  number_of_bands = size(set_bands)
106  ! WDR re-entrant
107  if( .not. allocated(bands) ) allocate(bands(number_of_bands))
108  bands(:) = set_bands(:)
109 
110 #endif
111 
112  end subroutine initialize_run
113 
114  subroutine check_datasources(status)
115 
117  use names
118  use ch_xfr, only : cm_from_l2
119  implicit none
120 
121  integer, intent(out) :: status
122  integer :: i, allstatus
123 
124  status = 0
125  allstatus = 0
126 
127 ! WDR remove this check
128 ! allstatus = checkfile(Alevel1b_name(1))
129 ! if (allstatus /= success) then
130 ! status = failure
131 ! call local_message_handler ('Error noted: level 1B file. Check input.' ,status, 'check_datasources')
132 ! return
133 ! endif
134 !
135 ! WDR only use work file if instructed
136 ! WDR out forever, I think
137 ! if ( cm_from_l2 .EQ. 0 ) THEN
138 ! allstatus = checkfile(Acloudmask_name)
139 ! if (allstatus /= success) then
140 ! status = failure
141 ! call local_message_handler ('Error noted: cloud mask file. Check input.', status,'check_datasources')
142 ! return
143 ! endif
144 ! END IF
145 ! WDR remove this check
146 ! allstatus = checkfile(Ageolocation_name)
147 ! if (allstatus /= success) then
148 ! status = failure
149 ! call local_message_handler ('Error noted: geolocation file. Check input.' ,status,'check_datasources')
150 ! return
151 ! endif
152 
153 #ifdef GEOS5
154 #ifndef SSFR_INST
155  allstatus = checkfile(ageos3d_name1)
156  if (allstatus /= success) then
157  status = failure
158  call local_message_handler ('Error noted: first GEOS5 3D file. Check input.' ,status, 'check_datasources')
159  return
160  endif
161  allstatus = checkfile(ageos3d_name2)
162  if (allstatus /= success) then
163  status = failure
164  call local_message_handler ('Error noted: second GEOS5 3D file. Check input.' ,status, 'check_datasources')
165  return
166  endif
167 
168  allstatus = checkfile(ageos2d_name1)
169  if (allstatus /= success) then
170  status = failure
171  call local_message_handler ('Error noted: first GEOS5 2D file. Check input.' ,status, 'check_datasources')
172  return
173  endif
174  allstatus = checkfile(ageos2d_name2)
175  if (allstatus /= success) then
176  status = failure
177  call local_message_handler ('Error noted: second GEOS5 2D file. Check input.' ,status, 'check_datasources')
178  return
179  endif
180 #endif
181 #else
182 ! WDR remove this check
183 ! allstatus = checkfile(Agdas_name)
184 ! if (allstatus /= success) then
185 ! status = failure
186 ! call local_message_handler ('Error noted: first GDAS file. Check input.' , status, 'check_datasources')
187 ! return
188 ! endif
189 ! WDR remove this check
190 ! allstatus = checkfile(Agdas_name2)
191 ! if (allstatus /= success) then
192 ! status = failure
193 ! call local_message_handler ('Error noted: second GDAS file. Check input.' ,status, 'check_datasources')
194 ! return
195 ! endif
196 #endif
197 
198 ! WDR remove this check
199 ! allstatus = checkfile(Ancepice_name)
200 ! if (allstatus /= success) then
201 ! status = failure
202 ! call local_message_handler ('Error noted: NCEP Ice file. Check input.' ,status, 'check_datasources')
203 ! return
204 ! endif
205 
206 #ifdef USE_TOAST
207  allstatus = checkfile(aozone_name)
208  if (allstatus /= success) then
209  status = failure
210  call local_message_handler ('Error noted: TOAST ozone file. Check input.' ,status, 'check_datasources')
211  return
212  endif
213 #endif
214 
215 ! WDR remove this check
216 ! allstatus = checkfile(Anise_name)
217 ! if (allstatus /= success) then
218 ! status = failure
219 ! call local_message_handler ('Error noted: NISE file. Check input.' , status, 'check_datasources')
220 ! return
221 ! endif
222 
223 ! WDR remove this check
224 ! allstatus = checkfile(Amod06_name)
225 ! if (allstatus /= success) then
226 ! status = failure
227 ! call local_message_handler ('Error noted: MOD06_L2 file. Check input.' , status, 'check_datasources')
228 ! return
229 ! endif
230  allstatus = checkfile(awater_library)
231  if (allstatus /= success) then
232  status = failure
233  call local_message_handler ('Error noted: Lambertian water library file. Check input.' , status, 'check_datasources')
234  return
235  endif
236 
237  allstatus = checkfile(aice_library)
238  if (allstatus /= success) then
239  status = failure
240  call local_message_handler ('Error noted: Lambertian ice library file. Check input.' ,status, 'check_datasources')
241  return
242  endif
243  allstatus = checkfile(atransmittance_library)
244  if (allstatus /= success) then
245  status = failure
246  call local_message_handler ('Error noted: transmittance file. Check input.' , status, 'check_datasources')
247  return
248  endif
249  allstatus = checkfile(aecosystem_data_name)
250  if (allstatus /= success) then
251  status = failure
252  call local_message_handler ('Error noted: IGBP Ecosystem file. Check input.' ,status, 'check_datasources')
253  return
254  endif
255  allstatus = checkfile(asnowicealbedo_data_name)
256  if (allstatus /= success) then
257  status = failure
258  call local_message_handler ('Error noted: Static SnowIce Albedo file. Check input.' ,status, 'check_datasources')
259  return
260  endif
261  allstatus = checkfile(aphase_library)
262  if (allstatus /= success) then
263  status = failure
264  call local_message_handler ('Error noted: phase library file. Check input.' ,status, 'check_datasources')
265  return
266  endif
267 
268  do i=1, 3
269  allstatus = checkfile(alibnames_water(i))
270  if (allstatus /= success) then
271  status = failure
272  call local_message_handler ('Error noted: Cox-Munk water library file. Check input.' , status, 'check_datasources')
273  return
274  endif
275  allstatus = checkfile(alibnames_water_sdev(i))
276  if (allstatus /= success) then
277  status = failure
278  call local_message_handler ('Error noted: Cox-Munk water sdev library file. Check input.' ,status, 'check_datasources')
279  return
280  endif
281  allstatus = checkfile(alibnames_ice(i))
282  if (allstatus /= success) then
283  status = failure
284  call local_message_handler ('Error noted: Cox-Munk ice library file. Check input.' ,status, 'check_datasources')
285  return
286  endif
287  allstatus = checkfile(alibnames_ice_sdev(i))
288  if (allstatus /= success) then
289  status = failure
290  call local_message_handler ('Error noted: Cox-Munk ice sdev library file. Check input.' ,status, 'check_datasources')
291  return
292  endif
293 
294  end do
295 
296  allstatus = checkfile(aemissivity_name)
297  if (allstatus /= success) then
298  status = failure
299  call local_message_handler ('Error noted: emissivity library file. Check input.' , status, 'check_datasources')
300  return
301  endif
302 
303 
304 ! if (Alevel1b_name(2) /= "none" ) then
305 ! allstatus = checkfile(Alevel1b_name(2))
306 ! if (allstatus /= success) then
307 ! status = failure
308 ! call local_message_handler ('Error noted: additional level 1B file. Check input.' , status, 'check_datasources')
309 ! return
310 ! endif
311 ! endif
312 
313  end subroutine check_datasources
314 
315  integer function checkfile(name)
316 
317  implicit none
318 
319  character(*), intent(in) :: name
320  logical :: exist
321  character(len=11) :: readability
322 
323  checkfile = 0
324 
325  inquire( file = name, &
326  exist= exist, &
327  read = readability)
328 
329  if (.not. exist) then
330  checkfile = 1
331  endif
332  if (readability == 'NO') then
333  checkfile = 2
334  endif
335  end function checkfile
336 
337 
338 
339 ! this subroutine returns the needed array bounds for a resized array
340  subroutine find_bounds(array, min_val, max_val, min_bnd, max_bnd)
341 
342  implicit none
343 
344  real, dimension(:), intent(in) :: array
345  real, intent(in) :: min_val, max_val
346  integer, intent(inout) :: min_bnd, max_bnd
347 
348  integer :: i, n
349 
350  n = size(array)
351 
352  do i=1, n
353  if (array(i) >= min_val) then
354  min_bnd = i-1
355  exit
356  endif
357  end do
358 
359  if (min_bnd < 1) min_bnd = 1
360  if (min_bnd > n) min_bnd = n
361 
362  do i=1, n
363  if (array(i) >= max_val) then
364  max_bnd = i
365  exit
366  endif
367  end do
368 
369  if (max_bnd >= n) max_bnd = n
370  if (max_bnd <= 1) max_bnd = 1
371 
372  end subroutine find_bounds
373 
374 !-----------------------------------------------------------------------
375 !f90 readlibraries
376 !
377 !Description:
378 !
379 ! Read bidirectional reflectance and flux library values for all
380 ! angles, as defined in a library description file. Library arrays
381 ! are allocated as required to read all library data.
382 !
383 !input parameters:
384 !
385 !output parameters:
386 !
387 !revision history:
388 !
389 ! v2.1 July 2002 arrays are now allocated to only include the angles
390 ! needed.
391 !
392 ! v2.0 June 2002 Changed the read routines to work with the HDF
393 ! version of the libraries. -- Gala. wind@climate.gsfc.nasa.gov
394 !
395 ! v1.0 November 2001 Initial work mag gray@climate.gsfc.nasa.gov
396 !
397 !team-unique header:
398 !
399 ! Cloud Retrieval Group, NASA GSFC, Greenbelt, Maryland, USA
400 !
401 !references and credits:
402 !
403 ! Mark Gray
404 ! gray@climate.gsfc.nasa.gov
405 ! EmergentIT
406 ! Code 913, NASA GSFC
407 ! Greenbelt, MD 20771
408 !
409 ! Gala Wind
410 ! wind@climate.gsfc.nasa.gov
411 ! L-3 Comm Analytics
412 ! all same, all same
413 !
414 !design note:
415 !
416 !end
417 !----------------------------------------------------------------------
418 
419  subroutine readlibraries_base(debug,status)
421  use libraryarrays
428  use ch_xfr, only: c2_sensor_id, oci_id, ocis_id
429  implicit none
430 
431  logical, intent(in) :: debug
432  integer,intent (out) :: status
433 
434  integer :: file_id, var_id, var_index,i, j
435  integer :: start(6), edge(6)
436  character(MAX_SDS_NAME_LEN) :: dummy_name
437  integer :: dummy_type, dummy_num_attr, dummy_rank
438  integer :: dim_sizes(6),dim_sizes4d(4)
439  integer :: idim, len, dimids(6)
440 
441  ! WDR I havd replaced the more extensive sf... HDF 4 I/O with calls to
442  ! fortran netcdf I/O (nf_...). The advantage is that they can also
443  ! read hdf 4 table files that were used originally
444  status = 0
445 
446  ! WDR try to read this only if the allocated array is not allocated
447  if( allocated( transmit_correction_table ) ) then
448  status = 0
449  return
450  endif
451 
452 ! read transmittance correction library
453 
454  !start = 0
455  start = 1 ! for netcdf
456 
457  status = nf_open( atransmittance_library, nf_nowrite, file_id )
458  call cld_fchk( status, __file__, __line__ )
459 
460  status = nf_inq_varid( file_id, "Transmittance", var_id )
461  call cld_fchk( status, __file__, __line__ )
462 
463  status = nf_inq_vardimid( file_id, var_id, dimids )
464  call cld_fchk( status, __file__, __line__ )
465  do idim = 1, 4
466  status = nf_inq_dimlen(file_id, dimids(idim), len )
467  call cld_fchk( status, __file__, __line__ )
468  dim_sizes(idim) = len
469  end do
470  ! WDR - if the OCI transmittance is read, it should have 8 bands
471  ! otherwise (Aqua) it has 7
472  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) ) then
473  if( dim_sizes(4) /= 8 ) then
474  print*, "Transmittance table has wrong # bands for OCI, ", &
475  __file__, __line__
476  stop 10
477  endif
478  else
479  if( dim_sizes(4) /= 7 ) then
480  print*, "Transmittance table has wrong # bands for Aqua, ", &
481  __file__, __line__
482  stop 10
483  endif
484  endif
485 
486  edge(1:4) = dim_sizes(1:4)
487 
488  allocate(transmit_correction_table(edge(1), edge(2), edge(3), edge(4)))
489  allocate(transmit_stddev_table(edge(1), edge(2), edge(3), edge(4)))
490 
491  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
493  call cld_fchk( status, __file__, __line__ )
494 
495  status = nf_inq_varid( file_id, "Standard_Deviation", var_id )
496  call cld_fchk( status, __file__, __line__ )
497 
498  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
500  call cld_fchk( status, __file__, __line__ )
501 
502  status = nf_close( file_id )
503  call cld_fchk( status, __file__, __line__ )
504 
505  ! we need to find angle range for the granule, so we can only read a
506  ! limited amount from the library
507  ! just enough to get the granule processed.
508 
509  ! from the find_granule_angle_range routine we know just how wide the
510  ! angle space we need.
511  ! it's fixed for sensor zenith and relative azimuth, but not for solar
512  ! angle. However for MAS<TER>
513  ! the relative azimuth space isn't fixed either and the sensor zenith
514  ! limits are different.
515 
516 
518 
519  ! start with the ice library first
520  status = nf_open( aice_library, nf_nowrite, file_id )
521  call cld_fchk( status, __file__, __line__ )
522 
523  ! get the number of wavelengths, we never use them, so we don't need
524  ! to actually read them.
525  status = nf_inq_varid( file_id, "Wavelengths", var_id )
526  call cld_fchk( status, __file__, __line__ )
527 
528  status = nf_inq_vardimid( file_id, var_id, dimids )
529  call cld_fchk( status, __file__, __line__ )
530 
531  status = nf_inq_dimlen(file_id, dimids(1), len )
532  call cld_fchk( status, __file__, __line__ )
533 
534  number_wavelengths = len
535 
536  start = 1
537 
538  ! get the radii
539  status = nf_inq_varid( file_id, "ParticleRadius", var_id )
540  call cld_fchk( status, __file__, __line__ )
541 
542  status = nf_inq_vardimid( file_id, var_id, dimids )
543  call cld_fchk( status, __file__, __line__ )
544 
545  status = nf_inq_dimlen(file_id, dimids(1), len )
546  call cld_fchk( status, __file__, __line__ )
547 
548  number_iceradii = len
549  allocate (ice_radii(number_iceradii))
550  edge(1) = number_iceradii
551 
552  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
553  ice_radii)
554  call cld_fchk( status, __file__, __line__ )
555 
556  ! get the taus
557  status = nf_inq_varid( file_id, "OpticalThickness", var_id )
558  call cld_fchk( status, __file__, __line__ )
559 
560  status = nf_inq_vardimid( file_id, var_id, dimids )
561  call cld_fchk( status, __file__, __line__ )
562  status = nf_inq_dimlen(file_id, dimids(1), len )
563  call cld_fchk( status, __file__, __line__ )
564 
565  number_taus = len
566  !number_taus = dim_sizes(1)
567  allocate (library_taus(number_taus))
568  edge(1) = number_taus
569  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
570  library_taus )
571  call cld_fchk( status, __file__, __line__ )
572 
573  ! get the full 1D angle arrays, they are small, we'll hang on to them
574  ! and do resizing after we read them
575  ! in the read_libraries_extra() subroutine
576 
577  ! now get the relative azimuth
578  status = nf_inq_varid( file_id, "ReflectanceRelativeAzimuth", var_id )
579  call cld_fchk( status, __file__, __line__ )
580 
581  status = nf_inq_vardimid( file_id, var_id, dimids )
582  call cld_fchk( status, __file__, __line__ )
583  status = nf_inq_dimlen(file_id, dimids(1), len )
584  call cld_fchk( status, __file__, __line__ )
585 
586  index_relativeazimuth = len
587 
588  allocate (relativeazimuth_all(index_relativeazimuth))
589  edge(1) = index_relativeazimuth
590  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
591  relativeazimuth_all )
592  call cld_fchk( status, __file__, __line__ )
593 
594  ! now get the solar zenith
595  status = nf_inq_varid( file_id, "ReflectanceSolarZenith", var_id )
596  call cld_fchk( status, __file__, __line__ )
597 
598  status = nf_inq_vardimid( file_id, var_id, dimids )
599  call cld_fchk( status, __file__, __line__ )
600  status = nf_inq_dimlen(file_id, dimids(1), len )
601  call cld_fchk( status, __file__, __line__ )
602  index_solarzenith = len
603 
604  allocate (solarzenith_all(index_solarzenith))
605  edge(1) = index_solarzenith
606 
607  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
608  solarzenith_all )
609  call cld_fchk( status, __file__, __line__ )
610 
611  ! now get the sensor zenith
612  status = nf_inq_varid( file_id, "ReflectanceSensorZenith", var_id )
613  call cld_fchk( status, __file__, __line__ )
614 
615  status = nf_inq_vardimid( file_id, var_id, dimids )
616  call cld_fchk( status, __file__, __line__ )
617  status = nf_inq_dimlen(file_id, dimids(1), len )
618  call cld_fchk( status, __file__, __line__ )
619 
620  index_sensorzenith = len
621  allocate (sensorzenith_all(index_sensorzenith))
622  edge(1) = index_sensorzenith
623  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
624  sensorzenith_all )
625  call cld_fchk( status, __file__, __line__ )
626 
627  ! now get the flux angle
628  status = nf_inq_varid( file_id, "FluxSolarZenith", var_id )
629  call cld_fchk( status, __file__, __line__ )
630 
631  status = nf_inq_vardimid( file_id, var_id, dimids );
632  call cld_fchk( status, __file__, __line__ )
633  status = nf_inq_dimlen(file_id, dimids(1), len )
634  call cld_fchk( status, __file__, __line__ )
635  index_solarzenith_flux = len
636 
637  allocate (solarzenith_flux_all(index_solarzenith))
638  edge(1) = index_solarzenith_flux
639  status = nf_get_vara_real( file_id, var_id,start(1:1), edge(1:1), &
640  solarzenith_flux_all )
641  call cld_fchk( status, __file__, __line__ )
642 
643  ! Read the 2D arrays
644 
645  start = 1
646  edge(1) = number_wavelengths
647  edge(2) = number_iceradii
648 
654 
655  status = nf_inq_varid( file_id, "ExtinctionCoefficient", var_id )
656  call cld_fchk( status, __file__, __line__ )
657 
658  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
660  call cld_fchk( status, __file__, __line__ )
661 
662  status = nf_inq_varid( file_id, "SingleScatterAlbedo", var_id )
663  call cld_fchk( status, __file__, __line__ )
664 
665  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
667  call cld_fchk( status, __file__, __line__ )
668 
669  status = nf_inq_varid( file_id, "Phase: AsymmetryParameter", var_id )
670  call cld_fchk( status, __file__, __line__ )
671 
672  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
673  asymmetry_ice )
674  call cld_fchk( status, __file__, __line__ )
675 
676  status = nf_inq_varid( file_id, "TruncationFactor", var_id )
677  call cld_fchk( status, __file__, __line__ )
678 
679  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
681  call cld_fchk( status, __file__, __line__ )
682 
683  status = nf_inq_varid( file_id, "PhaseFuncNormConstant", var_id )
684  call cld_fchk( status, __file__, __line__ )
685 
686  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
688  call cld_fchk( status, __file__, __line__ )
689 
690  ! Read the 3D arrays
691 
692  start = 1
693  edge(1) = number_taus
694  edge(2) = number_wavelengths
695  edge(3) = number_iceradii
696 
698  status = nf_inq_varid( file_id, "SphericalAlbedo", var_id )
699  call cld_fchk( status, __file__, __line__ )
700 
701  status = nf_get_vara_real( file_id, var_id, start(1:3), edge(1:3), &
703  call cld_fchk( status, __file__, __line__ )
704 
705  ! Read the 4D arrays
706  ! Now we finally read the 6D reflectance array
707 
708  status = nf_close( file_id )
709  call cld_fchk( status, __file__, __line__ )
710 
711  ! Now that we're done with ice, get started with water...
712  start = 1
713 
714  ! Read all the water stuff there is to read.
715  status = nf_open( awater_library, nf_nowrite, file_id )
716  call cld_fchk( status, __file__, __line__ )
717 
718  ! get the radii
719  status = nf_inq_varid( file_id, "ParticleRadius", var_id )
720  call cld_fchk( status, __file__, __line__ )
721 
722  status = nf_inq_vardimid( file_id, var_id, dimids )
723  call cld_fchk( status, __file__, __line__ )
724  status = nf_inq_dimlen(file_id, dimids(1), len )
725  call cld_fchk( status, __file__, __line__ )
726 
727  number_waterradii = len
728 
729  allocate (water_radii(number_waterradii))
730  edge(1) = number_waterradii
731  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
732  water_radii )
733  call cld_fchk( status, __file__, __line__ )
734 
735  ! Read the 2D arrays
736 
737  start = 1
738  edge(1) = number_wavelengths
739  edge(2) = number_waterradii
740 
746 
747  status = nf_inq_varid( file_id, "ExtinctionCoefficient", var_id )
748  call cld_fchk( status, __file__, __line__ )
749 
750  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
752  call cld_fchk( status, __file__, __line__ )
753 
754  status = nf_inq_varid( file_id, "SingleScatterAlbedo", var_id )
755  call cld_fchk( status, __file__, __line__ )
756 
757  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
759  call cld_fchk( status, __file__, __line__ )
760 
761  status = nf_inq_varid( file_id, "Phase: AsymmetryParameter", var_id )
762  call cld_fchk( status, __file__, __line__ )
763 
764  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
766  call cld_fchk( status, __file__, __line__ )
767 
768  status = nf_inq_varid( file_id, "TruncationFactor", var_id )
769  call cld_fchk( status, __file__, __line__ )
770 
771  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
773  call cld_fchk( status, __file__, __line__ )
774 
775  status = nf_inq_varid( file_id, "PhaseFuncNormConstant", var_id )
776  call cld_fchk( status, __file__, __line__ )
777 
778  status = nf_get_vara_real( file_id, var_id, start(1:2), edge(1:2), &
780  call cld_fchk( status, __file__, __line__ )
781 
782  ! Read the 3D arrays
783 
784 
785  start = 1
786  edge(1) = number_taus
787  edge(2) = number_wavelengths
788  edge(3) = number_waterradii
789 
792  status = nf_inq_varid( file_id, "SphericalAlbedo", var_id )
793  call cld_fchk( status, __file__, __line__ )
794 
795  status = nf_get_vara_real( file_id, var_id, start(1:3), edge(1:3), &
797  call cld_fchk( status, __file__, __line__ )
798 
799  status = nf_close( file_id )
800  call cld_fchk( status, __file__, __line__ )
801 
804 
807 
810 
813 
814 
821 
822  ! WDR re-entrant
823  if( .not. allocated(int_cloud_emissivity_water) ) &
826  if( .not. allocated(int_surface_emissivity_water) ) &
829 
830  if( .not. allocated(int_cloud_emissivity_water_sdev) ) &
833  if( .not. allocated(int_surface_emissivity_water_sdev) ) &
836 
841 
846 
847 
849  allocate(rayleigh_ice(number_iceradii))
850 
851  ! Now for the phase function information
852 
853  status = nf_open( aphase_library, nf_nowrite, file_id )
854  call cld_fchk( status, __file__, __line__ )
855 
856  start = 1
857 
858  ! get the ice phase func info
859  status = nf_inq_varid( file_id, "ScatAnglesIce", var_id )
860  call cld_fchk( status, __file__, __line__ )
861 
862  status = nf_inq_vardimid( file_id, var_id, dimids )
863  call cld_fchk( status, __file__, __line__ )
864  status = nf_inq_dimlen(file_id, dimids(1), len )
865  call cld_fchk( status, __file__, __line__ )
866 
869  edge(1) = number_phase_angles_ice
870 
871  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
873  call cld_fchk( status, __file__, __line__ )
874 
875  status = nf_inq_varid( file_id, "ScatAnglesWater", var_id )
876  call cld_fchk( status, __file__, __line__ )
877 
878  status = nf_inq_vardimid( file_id, var_id, dimids )
879  call cld_fchk( status, __file__, __line__ )
880  status = nf_inq_dimlen(file_id, dimids(1), len )
881  call cld_fchk( status, __file__, __line__ )
882 
885  edge(1) = number_phase_angles_water
886  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
888  call cld_fchk( status, __file__, __line__ )
889 
892 
893  start = 1
894  edge(1) = number_phase_angles_water
895  edge(2) = number_wavelengths
896  edge(3) = number_waterradii
897 
898  status = nf_inq_varid( file_id, "WaterPhaseFuncVals", var_id )
899  call cld_fchk( status, __file__, __line__ )
900 
901  status = nf_get_vara_real( file_id, var_id, start(1:3), edge(1:3), &
903  call cld_fchk( status, __file__, __line__ )
904 
905  edge(1) = number_phase_angles_ice
906  edge(2) = number_wavelengths
907  edge(3) = number_iceradii
908 
909  status = nf_inq_varid( file_id, "IcePhaseFuncVals", var_id )
910  call cld_fchk( status, __file__, __line__ )
911 
912  status = nf_get_vara_real( file_id, var_id, start(1:3), edge(1:3), &
914  call cld_fchk( status, __file__, __line__ )
915 
916  status = nf_close( file_id )
917  call cld_fchk( status, __file__, __line__ )
918 
919  ! now for the aerosol and rayleigh property information
920 
925 
926  status = nf_open( alibnames_ice(1), nf_nowrite, file_id )
927  call cld_fchk( status, __file__, __line__ )
928 
929  start = 1
930  edge(1) = number_wavelengths
931 
932  status = nf_inq_varid( file_id, "RayleighOpticalThickness", var_id )
933  call cld_fchk( status, __file__, __line__ )
934 
935  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
936  rayleigh_tau )
937  call cld_fchk( status, __file__, __line__ )
938 
939  status = nf_inq_varid( file_id, "AerosolOpticalThickness", var_id )
940  call cld_fchk( status, __file__, __line__ )
941 
942  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
943  aerosol_tau )
944  call cld_fchk( status, __file__, __line__ )
945 
946  status = nf_inq_varid( file_id, "AerosolAsymParameter", var_id )
947  call cld_fchk( status, __file__, __line__ )
948 
949  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
950  aerosol_asym )
951 
952  status = nf_inq_varid( file_id, "AerosolSSAlbedo", var_id )
953  call cld_fchk( status, __file__, __line__ )
954 
955  status = nf_get_vara_real( file_id, var_id, start(1:1), edge(1:1), &
956  aerosol_ssa )
957  call cld_fchk( status, __file__, __line__ )
958 
959  status = nf_close( file_id )
960  call cld_fchk( status, __file__, __line__ )
961 
962  call lib_init
963 
964  ! print*, water_radii
965  ! print*, ice_radii
966 
967  end subroutine readlibraries_base
968 
969 
970  subroutine readlibraries_extra(debug,status)
971 
972  use generalauxtype
973  use libraryarrays
979  use ch_xfr, only : c2_sensor_id, oci_id, ocis_id
980 
981  ! WDR try the setup for the call to mng_msl_init
982  use iso_c_binding
983  implicit none
984  interface
985  function mng_ms_init(fwl, fil, fww1, fww1sd, fiw1, fiw1sd, &
986  fww2, fww2sd, fiw2, fiw2sd, fww3, fww3sd, fiw3, fiw3sd )
987  import
988  character(kind=c_char), intent(in) :: fwl(*)
989  character(kind=c_char), intent(in) :: fil(*)
990  character(kind=c_char), intent(in) :: fww1(*)
991  character(kind=c_char), intent(in) :: fww1sd(*)
992  character(kind=c_char), intent(in) :: fiw1(*)
993  character(kind=c_char), intent(in) :: fiw1sd(*)
994  character(kind=c_char), intent(in) :: fww2(*)
995  character(kind=c_char), intent(in) :: fww2sd(*)
996  character(kind=c_char), intent(in) :: fiw2(*)
997  character(kind=c_char), intent(in) :: fiw2sd(*)
998  character(kind=c_char), intent(in) :: fww3(*)
999  character(kind=c_char), intent(in) :: fww3sd(*)
1000  character(kind=c_char), intent(in) :: fiw3(*)
1001  character(kind=c_char), intent(in) :: fiw3sd(*)
1002  end function mng_ms_init
1003  end interface
1004 
1005  logical, intent(in) :: debug
1006  integer,intent (out) :: status
1007 
1008  integer :: file_id, var_id, var_index,i, j
1009  integer :: start(6), edge(6)
1010  character(MAX_SDS_NAME_LEN) :: dummy_name
1011  integer :: dummy_type, dummy_num_attr, dummy_rank
1012  integer :: dim_sizes(6),dim_sizes4d(4)
1013 
1014  real, dimension(:,:,:,:), allocatable :: temp_emis
1015 
1016  integer :: max_bnd, min_bnd
1017  integer :: sensor_min, sensor_max, solar_min, solar_max, sza_min, &
1018  vza_min, ra_min
1019  real, dimension(:,:,:,:), allocatable :: temp_flux, temp_flux2
1020 
1021  integer :: start_time, end_time, crate, cmax
1022 
1023  real :: deg_to_rad, cos_vza_min, cos_vza_max, cos_sza_min, cos_sza_max
1024  integer :: i1, i2, i3, i4, i5, i6, nws
1025 
1026  ! WDR controls for limited reading of the ice... tables
1027  integer :: read_tables, ct_tbl_rd = 0
1028  real :: last_min_senz = -99999.
1029  real :: last_min_solz = -99999.
1030  real :: last_min_relaz = -99999.
1031  real :: last_max_senz = -99999.
1032  real :: last_max_solz = -99999.
1033  real :: last_max_relaz = -99999.
1034  real :: rng_margin_senz = 3.
1035  real :: rng_margin_solz = 5. ! rng_margin_relaz not needed - take full 0-180
1036  ! WDR guard to set up the large array manager only once
1037  integer :: guard_mng_ms = 0;
1038 
1039  status = 0
1040 
1041  deg_to_rad = d2r
1042 
1043  ! WDR init the large refl table reading
1044  if( guard_mng_ms == 0 ) then
1045  status = mng_ms_init( trim(awater_library), trim(aice_library), &
1052  guard_mng_ms = 1
1053  endif
1054 
1055  ! we need to find angle range for the granule, so we can only read a
1056  ! limited amount from the library just enough to get the granule processed.
1057 
1058  ! from the find_granule_angle_range routine we know just how wide the
1059  ! angle space we need. it's fixed for sensor zenith and relative azimuth,
1060  ! but not for solar angle. However for MAS<TER> the relative azimuth space
1061  ! isn't fixed either and the sensor zenith limits are different.
1062 
1063  !!!!!!!!!!! WDR this logic will set the range needed to read the tables
1064  ! just 1 time for test granule and also has refresh logic for test purposes
1065  !
1066  ! here we hard-code the ranges for init test
1067  ! TEMP
1068  min_rel_azimuth = 0.
1069  max_rel_azimuth = 180.
1070  !min_solar_zenith = 50. ! WDR these are out for table range with margin
1071  !max_solar_zenith = 80.
1072  !min_sensor_zenith = 0.
1073  !max_sensor_zenith = 66.
1074  !
1075  ! here is the logic to check to see if a table read is needed
1076  if( last_min_senz < -1000. ) then
1077  read_tables = 1
1078  else
1079  if( ( min_rel_azimuth < last_min_relaz ) .or. &
1080  ( max_rel_azimuth > last_max_relaz ) .or. &
1081  ( min_sensor_zenith < last_min_senz ) .or. &
1082  ( max_sensor_zenith > last_max_senz ) .or. &
1083  ( min_solar_zenith < last_min_solz ) .or. &
1084  ( max_solar_zenith > last_max_solz ) ) then
1085  read_tables = 1
1086  endif
1087  endif
1088 
1089  if( read_tables /= 1 ) then
1090  return
1091  endif
1092  print*, "Reading trans tables for this line"
1093 
1094  last_min_relaz = min_rel_azimuth
1095  min_rel_azimuth = last_min_relaz
1096  last_max_relaz = max_rel_azimuth
1097  max_rel_azimuth = last_max_relaz
1098  last_min_senz = min_sensor_zenith - rng_margin_senz
1099  min_sensor_zenith = last_min_senz
1100  last_max_senz = max_sensor_zenith + rng_margin_senz
1101  max_sensor_zenith = last_max_senz
1102  last_min_solz = min_solar_zenith - rng_margin_solz
1103  min_solar_zenith = last_min_solz
1104  last_max_solz = max_solar_zenith + rng_margin_solz
1105  max_solar_zenith = last_max_solz
1106  read_tables = 0
1107  ct_tbl_rd = ct_tbl_rd + 1
1108 
1109  print*, "Table update # ", ct_tbl_rd
1110  print*, "relaz range: ", min_rel_azimuth, max_rel_azimuth
1111  print*, "solz range: ", min_solar_zenith, max_solar_zenith
1112  print*, "senz range: ", min_sensor_zenith, max_sensor_zenith
1113 
1114  ! start with the ice library first
1115  status = nf_open( aice_library, nf_nowrite, file_id )
1116  call cld_fchk( status, __file__, __line__ )
1117 
1118  start = 1
1119 
1120  ! now get the relative azimuth and resize it as needed
1121  if (allocated(library_relative_azimuth)) deallocate(library_relative_azimuth)
1122  ! resize the array
1123  call find_bounds(relativeazimuth_all, min_rel_azimuth, max_rel_azimuth, &
1124  min_bnd, max_bnd)
1125  number_relazimuth = max_bnd - min_bnd + 1
1126 
1127  ra_min = min_bnd
1130  relativeazimuth_all(min_bnd : max_bnd)
1131 
1132  ! now get the solar zenith and resize it as needed
1133  if (allocated(library_solar_zenith)) deallocate(library_solar_zenith)
1134  ! resize the array
1135  cos_sza_max = cos(max_solar_zenith*deg_to_rad)
1136  cos_sza_min = cos(min_solar_zenith*deg_to_rad)
1137 
1138  call find_bounds(solarzenith_all, cos_sza_max, cos_sza_min, min_bnd, max_bnd)
1139  number_solarzenith = max_bnd - min_bnd + 1
1140 
1141  sza_min = min_bnd
1144  solarzenith_all(min_bnd : max_bnd)
1145 
1146  ! now get the sensor zenith and resize it as needed
1147  if (allocated(library_sensor_zenith)) deallocate(library_sensor_zenith)
1148  ! resize the array
1149  cos_vza_max = cos(max_sensor_zenith*deg_to_rad)
1150  cos_vza_min = cos(min_sensor_zenith*deg_to_rad)
1151 
1152  call find_bounds(sensorzenith_all, cos_vza_max, cos_vza_min, min_bnd, max_bnd)
1153 
1154  number_sensorzenith = max_bnd - min_bnd + 1
1155  vza_min = min_bnd
1158  sensorzenith_all(min_bnd : max_bnd)
1159 
1160  ! now get the flux angle and resize it as needed
1161  if (allocated(library_fluxsensorzenith)) deallocate(library_fluxsensorzenith)
1162  if (allocated(library_fluxsolarzenith)) deallocate(library_fluxsolarzenith)
1163  ! resize the array once for solar and once for sensor
1164  call find_bounds(solarzenith_flux_all, cos_vza_max, cos_vza_min, &
1165  min_bnd, max_bnd)
1166  number_fluxsensorzenith = max_bnd - min_bnd + 1
1167  sensor_min = min_bnd
1168  sensor_max = max_bnd
1171  solarzenith_flux_all(min_bnd : max_bnd)
1172 
1173  call find_bounds(solarzenith_flux_all, cos_sza_max, cos_sza_min, &
1174  min_bnd, max_bnd)
1175  number_fluxsolarzenith = max_bnd - min_bnd + 1
1176  solar_min = min_bnd
1177  solar_max = max_bnd
1180  solarzenith_flux_all(min_bnd : max_bnd)
1181 
1182  ! Read the 3D arrays
1183 
1184  ! Read the 4D arrays
1185 
1186  start = 1
1187 
1188  allocate(temp_flux2(number_iceradii, number_wavelengths, number_taus, &
1189  index_solarzenith_flux))
1190 
1191  if (allocated(flux_up_ice_solar)) deallocate(flux_up_ice_solar)
1192  if (allocated(flux_up_ice_sensor)) deallocate(flux_up_ice_sensor)
1193  if (allocated(flux_down_ice_solar)) deallocate(flux_down_ice_solar)
1194  if (allocated(flux_down_ice_sensor)) deallocate(flux_down_ice_sensor)
1195 
1200 
1201  edge(1) = number_iceradii
1202  edge(2) = number_wavelengths
1203  edge(3) = number_taus
1204  edge(4) = index_solarzenith_flux
1205 
1206 
1207 
1208  status = nf_inq_varid( file_id, "ReflectedFlux", var_id )
1209  call cld_fchk( status, __file__, __line__ )
1210 
1211  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1212  temp_flux2 )
1213  call cld_fchk( status, __file__, __line__ )
1214 
1215  allocate(temp_flux(index_solarzenith_flux, number_taus,number_wavelengths, &
1216  number_iceradii))
1217  do i1=1, index_solarzenith_flux
1218  do i2=1, number_taus
1219  do i3=1, number_wavelengths
1220  do i4=1, number_iceradii
1221 
1222  temp_flux(i1, i2, i3, i4) = temp_flux2(i4, i3, i2, i1)
1223 
1224  end do
1225  end do
1226  end do
1227  end do
1228 
1229 
1230  flux_up_ice_solar(:,:,:,:) = temp_flux(solar_min:solar_max, :,:,:)
1231  flux_up_ice_sensor(:,:,:,:) = temp_flux(sensor_min:sensor_max, :,:,:)
1232 
1233  status = nf_inq_varid( file_id, "TransmittedFlux", var_id )
1234  call cld_fchk( status, __file__, __line__ )
1235 
1236  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1237  temp_flux2 )
1238 
1239  do i1=1, index_solarzenith_flux
1240  do i2=1, number_taus
1241  do i3=1, number_wavelengths
1242  do i4=1, number_iceradii
1243 
1244  temp_flux(i1, i2, i3, i4) = temp_flux2(i4, i3, i2, i1)
1245 
1246  end do
1247  end do
1248  end do
1249  end do
1250 
1251 
1252  deallocate(temp_flux2)
1253 
1254  flux_down_ice_solar(:,:,:,:) = temp_flux(solar_min:solar_max, :,:,:)
1255  flux_down_ice_sensor(:,:,:,:) = temp_flux(sensor_min:sensor_max, :,:,:)
1256 
1257  deallocate(temp_flux)
1258 
1259  ! Now we finally read the 6D reflectance array
1260  ! but we don't read the 11um reflectance, as there sure isn't any.
1261  ! we do however need the 11um flux to do emissivity over land surfaces.
1262 
1263  status = nf_close( file_id )
1264  call cld_fchk( status, __file__, __line__ )
1265 
1266  if (allocated(cloud_emissivity_ice)) deallocate(cloud_emissivity_ice)
1267  if (allocated(surface_emissivity_ice)) deallocate(surface_emissivity_ice)
1268 
1273 
1274 
1275  if (allocated(cloud_emissivity_ice_sdev)) &
1276  deallocate(cloud_emissivity_ice_sdev)
1277  if (allocated(surface_emissivity_ice_sdev)) &
1278  deallocate(surface_emissivity_ice_sdev)
1279 
1280 
1285 
1286  ! wind speed 3
1287 
1288  allocate(temp_emis( number_iceradii, 2, number_taus + 1, &
1290 
1291  if (do_cox_munk) then ! DO_COX_MUNK
1292 
1293  do i=1, 3
1294 
1295  status = nf_open( alibnames_ice(i), nf_nowrite, file_id )
1296  call cld_fchk( status, __file__, __line__ )
1297 
1298  edge(4) = number_sensorzenith
1299  edge(3) = number_taus+1
1300  edge(2) = 2
1301  edge(1) = number_iceradii
1302 
1303  start = 1
1304  start(4) = vza_min
1305 
1306  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1307  ! WDR any emiss is not used
1308  status = nf_inq_varid( file_id, "CloudEmissivity", var_id )
1309  call cld_fchk( status, __file__, __line__ )
1310 
1311  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1312  temp_emis )
1313  call cld_fchk( status, __file__, __line__ )
1314  end if
1315 
1316  ! cloud_emissivity_ice(:,:,:,:,i) = temp_emis(:,:,:,:)
1317 
1318  do i1=1, number_sensorzenith
1319  do i4=1, number_taus+1
1320  do i5=1, 2
1321  do i6=1, number_iceradii
1322 
1323  cloud_emissivity_ice(i1, i4, i5, i6, i) = temp_emis(i6, i5, i4, i1)
1324 
1325  end do
1326  end do
1327  end do
1328  end do
1329 
1330  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1331  ! WDR any emiss is not used
1332  status = nf_inq_varid( file_id, "SurfaceEmissivity", var_id )
1333  call cld_fchk( status, __file__, __line__ )
1334 
1335  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1336  temp_emis )
1337  end if
1338 
1339  ! surface_emissivity_ice(:,:,:,:,i) = temp_emis(:,:,:,:)
1340 
1341  do i1=1, number_sensorzenith
1342  do i4=1, number_taus+1
1343  do i5=1, 2
1344  do i6=1, number_iceradii
1345 
1346  surface_emissivity_ice(i1, i4, i5, i6, i) = temp_emis(i6, i5, i4, i1)
1347 
1348  end do
1349  end do
1350  end do
1351  end do
1352 
1353 
1354 
1355  status = nf_close( file_id )
1356  call cld_fchk( status, __file__, __line__ )
1357 
1358  status = nf_open( alibnames_ice_sdev(i), nf_nowrite, file_id )
1359  call cld_fchk( status, __file__, __line__ )
1360 
1361  edge(4) = number_sensorzenith
1362  edge(3) = number_taus+1
1363  edge(2) = 2
1364  edge(1) = number_iceradii
1365 
1366  start = 1
1367  start(4) = vza_min
1368 
1369  ! The cloud folks used the wrong SD dataset namd, use
1370  ! StdDevCloudEmissivity instead
1371  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1372  ! WDR any emiss is not used
1373  status = nf_inq_varid( file_id, "StdDevCloudEmissivity", var_id )
1374  if( status .ne. 0 ) then
1375  status = nf_inq_varid( file_id, "CloudEmissivity", var_id )
1376  call cld_fchk( status, __file__, __line__ )
1377  endif
1378 
1379  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1380  temp_emis )
1381  end if
1382 
1383  ! cloud_emissivity_ice_sdev(:,:,:,:,i) = temp_emis(:,:,:,:)
1384 
1385  do i1=1, number_sensorzenith
1386  do i4=1, number_taus+1
1387  do i5=1, 2
1388  do i6=1, number_iceradii
1389 
1390  cloud_emissivity_ice_sdev(i1, i4, i5, i6, i) = &
1391  temp_emis(i6, i5, i4, i1)
1392 
1393  end do
1394  end do
1395  end do
1396  end do
1397 
1398  ! Same error here, use StdDevSurfaceEmissivity
1399  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1400  ! WDR any emiss is not used
1401  status = nf_inq_varid( file_id, "StdDevSurfaceEmissivity", var_id )
1402  if( status .ne. 0 ) then
1403  status = nf_inq_varid( file_id, "SurfaceEmissivity", var_id )
1404  call cld_fchk( status, __file__, __line__ )
1405  end if
1406 
1407  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1408  temp_emis )
1409  endif
1410 
1411  ! surface_emissivity_ice_sdev(:,:,:,:, i) = temp_emis(:,:,:,:)
1412 
1413  do i1=1, number_sensorzenith
1414  do i4=1, number_taus+1
1415  do i5=1, 2
1416  do i6=1, number_iceradii
1417 
1418  surface_emissivity_ice_sdev(i1, i4, i5, i6, i) = &
1419  temp_emis(i6, i5, i4, i1)
1420 
1421  end do
1422  end do
1423  end do
1424  end do
1425 
1426 
1427  status = nf_close( file_id )
1428  call cld_fchk( status, __file__, __line__ )
1429 
1430  end do
1431 
1432  endif ! DO_COX_MUNK
1433 
1434  deallocate(temp_emis)
1435 
1436  ! Now that we're done with ice, get started with water...
1437 
1438  ! Read all the water stuff there is to read.
1439  status = nf_open( awater_library, nf_nowrite, file_id )
1440  call cld_fchk( status, __file__, __line__ )
1441 
1442  ! Read the 3D arrays
1443 
1444  ! Read the 4D arrays
1445 
1446  start = 1
1447 
1448  allocate(temp_flux2(number_waterradii, number_wavelengths, number_taus, &
1449  index_solarzenith_flux))
1450 
1451  if (allocated(flux_up_water_solar)) deallocate(flux_up_water_solar)
1452  if (allocated(flux_up_water_sensor)) deallocate(flux_up_water_sensor)
1453  if (allocated(flux_down_water_solar)) deallocate(flux_down_water_solar)
1454  if (allocated(flux_down_water_sensor)) deallocate(flux_down_water_sensor)
1455 
1456 
1461 
1462  edge(1) = number_waterradii
1463  edge(2) = number_wavelengths
1464  edge(3) = number_taus
1465  edge(4) = index_solarzenith_flux
1466 
1467  allocate(temp_flux(index_solarzenith_flux, number_taus,number_wavelengths,number_waterradii))
1468 
1469  status = nf_inq_varid( file_id, "ReflectedFlux", var_id )
1470  call cld_fchk( status, __file__, __line__ )
1471 
1472  status = nf_get_vara_real( file_id, var_id, start(1:4),edge(1:4), &
1473  temp_flux2 )
1474  call cld_fchk( status, __file__, __line__ )
1475 
1476  do i1=1, index_solarzenith_flux
1477  do i2=1, number_taus
1478  do i3=1, number_wavelengths
1479  do i4=1, number_waterradii
1480 
1481  temp_flux(i1, i2, i3, i4) = temp_flux2(i4, i3, i2, i1)
1482 
1483  end do
1484  end do
1485  end do
1486  end do
1487 
1488  flux_up_water_solar(:,:,:,:) = temp_flux(solar_min:solar_max, :,:,:)
1489  flux_up_water_sensor(:,:,:,:) = temp_flux(sensor_min:sensor_max, :,:,:)
1490 
1491  status = nf_inq_varid( file_id, "TransmittedFlux", var_id )
1492  call cld_fchk( status, __file__, __line__ )
1493 
1494  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1495  temp_flux2 )
1496  call cld_fchk( status, __file__, __line__ )
1497 
1498  do i1=1, index_solarzenith_flux
1499  do i2=1, number_taus
1500  do i3=1, number_wavelengths
1501  do i4=1, number_waterradii
1502 
1503  temp_flux(i1, i2, i3, i4) = temp_flux2(i4, i3, i2, i1)
1504 
1505  end do
1506  end do
1507  end do
1508  end do
1509 
1510  deallocate(temp_flux2)
1511 
1512  flux_down_water_solar(:,:,:,:) = temp_flux(solar_min:solar_max, :,:,:)
1513  flux_down_water_sensor(:,:,:,:) = temp_flux(sensor_min:sensor_max, :,:,:)
1514 
1515  deallocate(temp_flux)
1516 
1517  ! Now we finally read the 6D reflectance array
1518  ! now, this is done on-demand by the dim_mgr
1519  status = nf_close( file_id )
1520  call cld_fchk( status, __file__, __line__ )
1521 
1522  if (allocated(cloud_emissivity_water)) deallocate(cloud_emissivity_water)
1523  if (allocated(surface_emissivity_water)) deallocate(surface_emissivity_water)
1524 
1529 
1530  if (allocated(cloud_emissivity_water_sdev)) &
1531  deallocate(cloud_emissivity_water_sdev)
1532  if (allocated(surface_emissivity_water_sdev)) &
1533  deallocate(surface_emissivity_water_sdev)
1538 
1539 
1540  ! wind speed 3
1541 
1542  allocate(temp_emis( number_waterradii, 2, number_taus + 1, &
1544 
1545  if (do_cox_munk) then ! DO_COX_MUNK
1546  do i=1, 3
1547 
1548  status = nf_open( alibnames_water(i), nf_nowrite, file_id )
1549  call cld_fchk( status, __file__, __line__ )
1550 
1551  edge(4) = number_sensorzenith
1552  edge(3) = number_taus+1
1553  edge(2) = 2
1554  edge(1) = number_waterradii
1555 
1556  start = 1
1557  start(4) = vza_min
1558 
1559  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1560  ! WDR any emiss is not used
1561  status = nf_inq_varid( file_id, "CloudEmissivity", var_id )
1562  call cld_fchk( status, __file__, __line__ )
1563 
1564  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1565  temp_emis )
1566  call cld_fchk( status, __file__, __line__ )
1567  end if
1568 
1569  ! cloud_emissivity_water(:,:,:,:, i) = temp_emis(:,:,:,:)
1570 
1571  do i1=1, number_sensorzenith
1572  do i4=1, number_taus+1
1573  do i5=1, 2
1574  do i6=1, number_waterradii
1575 
1576  cloud_emissivity_water(i1, i4, i5, i6, i) = temp_emis(i6, i5, i4, i1)
1577 
1578  end do
1579  end do
1580  end do
1581  end do
1582 
1583  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1584  ! WDR any emiss is not used
1585  status = nf_inq_varid( file_id, "SurfaceEmissivity", var_id )
1586  call cld_fchk( status, __file__, __line__ )
1587 
1588  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1589  temp_emis )
1590  call cld_fchk( status, __file__, __line__ )
1591  end if
1592 
1593  ! surface_emissivity_water(:,:,:,:, i) = temp_emis(:,:,:,:)
1594 
1595  do i1=1, number_sensorzenith
1596  do i4=1, number_taus+1
1597  do i5=1, 2
1598  do i6=1, number_waterradii
1599 
1600  surface_emissivity_water(i1, i4, i5, i6, i) = &
1601  temp_emis(i6, i5, i4, i1)
1602 
1603  end do
1604  end do
1605  end do
1606  end do
1607 
1608  status = nf_close( file_id )
1609  call cld_fchk( status, __file__, __line__ )
1610 
1611  status = nf_open( alibnames_water_sdev(i), nf_nowrite, file_id )
1612  call cld_fchk( status, __file__, __line__ )
1613 
1614  edge(4) = number_sensorzenith
1615  edge(3) = number_taus+1
1616  edge(2) = 2
1617  edge(1) = number_waterradii
1618 
1619  start = 1
1620  start(4) = vza_min
1621 
1622  ! WDR the cloud group put the SD data in SurfaceEmissivity, but the
1623  ! netcdf files need this as StdDevSurfaceEmissivity, so look for that
1624  ! first
1625  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1626  ! WDR any emiss is not used
1627  status = nf_inq_varid( file_id, "StdDevCloudEmissivity", var_id )
1628  if( status .ne. 0 ) then
1629  status = nf_inq_varid( file_id, "CloudEmissivity", var_id )
1630  call cld_fchk( status, __file__, __line__ )
1631  end if
1632 
1633  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1634  temp_emis )
1635  call cld_fchk( status, __file__, __line__ )
1636  endif
1637 
1638  ! cloud_emissivity_water_sdev(:,:,:,:,i) = temp_emis(:,:,:,:)
1639 
1640  do i1=1, number_sensorzenith
1641  do i4=1, number_taus+1
1642  do i5=1, 2
1643  do i6=1, number_waterradii
1644 
1645  cloud_emissivity_water_sdev(i1, i4, i5, i6, i) = &
1646  temp_emis(i6, i5, i4, i1)
1647 
1648  end do
1649  end do
1650  end do
1651  end do
1652 
1653  ! WDR the cloud group put the SD data in SurfaceEmissivity, but the
1654  ! netcdf files need this as StdDevSurfaceEmissivity, so look for that
1655  ! first
1656 
1657  if ( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
1658  ! WDR any emiss is not used
1659  status = nf_inq_varid( file_id, "StdDevSurfaceEmissivity,", var_id )
1660  if( status .ne. 0 ) then
1661  status = nf_inq_varid( file_id, "SurfaceEmissivity", var_id )
1662  call cld_fchk( status, __file__, __line__ )
1663  end if
1664 
1665  status = nf_get_vara_real( file_id, var_id, start(1:4), edge(1:4), &
1666  temp_emis )
1667  call cld_fchk( status, __file__, __line__ )
1668  endif
1669 
1670  ! surface_emissivity_water_sdev(:,:,:,:,i) = temp_emis(:,:,:,:)
1671 
1672  do i1=1, number_sensorzenith
1673  do i4=1, number_taus+1
1674  do i5=1, 2
1675  do i6=1, number_waterradii
1676 
1677  surface_emissivity_water_sdev(i1, i4, i5, i6, i) = &
1678  temp_emis(i6, i5, i4, i1)
1679 
1680  end do
1681  end do
1682  end do
1683  end do
1684 
1685  status = nf_close( file_id )
1686  call cld_fchk( status, __file__, __line__ )
1687 
1688  ! call system_clock(end_time, crate, cmax)
1689  ! print*, "time elapsed: ", end_time - start_time
1690 
1691  end do
1692  endif ! DO_COX_MUNK
1693 
1694 
1695  deallocate(temp_emis)
1696 
1697 
1698  ! print*, "lamb: ", library_reflectance_water( 1, 1, 1, :, 4, 8, 1)
1699  ! print*, "ws3: ",library_reflectance_water( 1, 1, 1, :, 4, 8, 2)
1700  ! print*, "ws7: ",library_reflectance_water( 1, 1, 1, :, 4, 8, 3)
1701  ! print*, "ws15: ",library_reflectance_water( 1, 1, 1, :, 4, 8, 4)
1702 
1703  ! print*, "lamb: ", library_reflectance_ice( 1, 1, 1, :, 4, 6, 1)
1704  ! print*, "ws3: ",library_reflectance_ice( 1, 1, 1, :, 4, 6, 2)
1705  ! print*, "ws7: ",library_reflectance_ice( 1, 1, 1, :, 4, 6, 3)
1706  ! print*, "ws15: ",library_reflectance_ice( 1, 1, 1, :, 4, 6, 4)
1707 
1708  end subroutine readlibraries_extra
1709 
1710  subroutine allocate_model(st_iterX, st_iterY, grid_wid, grid_ht)
1713  use science_parameters, only: model_levels
1714  use generalauxtype
1715 
1716  integer, intent(in) :: st_iterx, st_itery, grid_wid, grid_ht
1717  logical :: do_it
1718  integer :: i, j
1719 
1720 #ifdef GEOS5
1721  do_it = .true.
1722 #else
1723  do_it = .false.
1724  if (iterationx == st_iterx .and. iterationy == st_itery) do_it = .true.
1725 #endif
1726 
1727  if (do_it) then
1728  ! WDR
1729  ! no need to allocate c2_model_info except the contained arrays
1730  ! WDR re-entrant change
1731  if( .not. allocated( c2_model_info%mixr_profile ) ) then
1732  allocate( c2_model_info%mixr_profile(model_levels))
1733  allocate( c2_model_info%temp_profile(model_levels))
1734  allocate( c2_model_info%height_profile(model_levels))
1735  allocate( c2_model_info%pressure_profile(model_levels))
1736  allocate( c2_model_info%o3_profile(model_levels))
1737  endif
1738  if( .not. allocated( model_info ) ) then
1739  allocate(model_info(grid_wid, grid_ht))
1740  do i=1, grid_wid
1741  do j=1, grid_ht
1742 
1743  allocate(model_info(i,j)%mixr_profile(model_levels))
1744  allocate(model_info(i,j)%temp_profile(model_levels))
1745  allocate(model_info(i,j)%height_profile(model_levels))
1746  allocate(model_info(i,j)%pressure_profile(model_levels))
1747 
1748  end do
1749  end do
1750  end if
1751  end if
1752 
1753  end subroutine allocate_model
1754 
1755 
1756 
1757 
1758  subroutine allocate_arrays ( edge, meas_edge, st_iterX, st_iterY, status )
1760  use generalauxtype
1761  use core_arrays
1763  use libraryarrays
1764  use mod06_run_settings
1765  use science_parameters
1766  use specific_other
1767  use ch_xfr, only: oci_id, ocis_id, c2_sensor_id
1768 
1769  implicit none
1770 
1771  integer, dimension(:), intent(in) :: edge, meas_edge
1772  integer, intent (out) :: status
1773  integer, intent(in) :: st_iterx, st_itery
1774 
1775  integer :: checkvariable
1776  integer :: xdimension, meas_xdimension, ydimension, number_of_bands
1777 
1778  integer :: model_layers
1779  integer :: i, j
1780 
1781  logical :: allocation_status, array_size_change
1782 
1783  status = 0
1784  model_layers = model_levels
1785  number_of_bands = size(bands)
1786 
1787 
1788  meas_xdimension = meas_edge(1)
1789  xdimension = edge(1)
1790  ydimension = edge(2)
1791 
1792 ! Use optical_thickness array as a size/allocation test to save time.
1793  allocation_status = allocated(optical_thickness_16_final)
1794 
1795  array_size_change = .false.
1796 
1797  if (allocation_status) then
1798  if (size(optical_thickness_16_final,1) /= xdimension .or. &
1799  size(optical_thickness_16_final,2) /= ydimension .or. &
1800  size(band_measurements, 1) /= meas_xdimension) then
1801  array_size_change = .true.
1802  endif
1803  endif
1804 
1805 #ifdef GEOS5
1806  if (allocated(model_info)) then
1807 
1808  do i=1, grid_xsize
1809  do j=1, grid_ysize
1810 
1811  deallocate(model_info(i,j)%mixr_profile)
1812  deallocate(model_info(i,j)%temp_profile)
1813  deallocate(model_info(i,j)%height_profile)
1814  deallocate(model_info(i,j)%pressure_profile)
1815 
1816  end do
1817  end do
1818 
1819  deallocate(model_info)
1820  endif
1821 #endif
1822 
1823 #ifndef GEOS5
1824  call allocate_model(st_iterx, st_itery, grid_xsize, grid_ysize)
1825 #endif
1826 
1827 ! Core retrieval arrays
1828  if(array_size_change) then
1829 
1830  deallocate(snow_cover)
1831  deallocate(cloud_height_method)
1832  deallocate(irw_temperature)
1833  deallocate(optical_thickness_final, stat = checkvariable)
1834 
1835  deallocate(optical_thickness_1621_final, stat = checkvariable)
1836  deallocate(effective_radius_21_final, stat = checkvariable)
1837  deallocate(effective_radius_1621_final, stat = checkvariable)
1838  deallocate(liquid_water_path_1621, stat = checkvariable)
1839  deallocate(liquid_water_path, stat = checkvariable)
1840 
1841  deallocate(optical_thickness_final_pcl, stat = checkvariable)
1842  deallocate(optical_thickness_1621_final_pcl, stat = checkvariable)
1843  deallocate(effective_radius_21_final_pcl, stat = checkvariable)
1844  deallocate(effective_radius_1621_final_pcl, stat = checkvariable)
1845  deallocate(liquid_water_path_1621_pcl, stat = checkvariable)
1846  deallocate(liquid_water_path_pcl, stat = checkvariable)
1847 
1848  deallocate(optical_thickness_error, stat = checkvariable)
1849  deallocate(effective_radius_21_error, stat = checkvariable)
1850 
1851  deallocate(liquid_water_path_error, stat = checkvariable)
1852  deallocate(optical_thickness_1621_error, stat = checkvariable)
1853  deallocate(effective_radius_1621_error, stat = checkvariable)
1854  deallocate(liquid_water_path_1621_error, stat = checkvariable)
1855 
1856  ! WDR only do 2.2 um band if OCI
1857  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) ) then
1858  deallocate(optical_thickness_22_final, stat = checkvariable)
1859  deallocate(effective_radius_22_final, stat = checkvariable)
1860  deallocate(liquid_water_path_22, stat = checkvariable)
1861  deallocate(optical_thickness_22_final_pcl, stat = checkvariable)
1862  deallocate(effective_radius_22_final_pcl, stat = checkvariable)
1863  deallocate(liquid_water_path_22_pcl, stat = checkvariable)
1864  deallocate(optical_thickness_22_error, stat = checkvariable)
1865  deallocate(effective_radius_22_error, stat = checkvariable)
1866  deallocate(liquid_water_path_22_error, stat = checkvariable)
1867  deallocate(failure_metric_22, stat = checkvariable)
1868  endif
1869 
1870  deallocate(cloud_mask_spi, stat = checkvariable)
1871 
1872  deallocate(failure_metric, stat = checkvariable)
1873  deallocate(failure_metric_1621, stat = checkvariable)
1874 
1875  deallocate(atm_corr_refl, stat = checkvariable)
1876 
1877  deallocate(optical_thickness_16_final, stat = checkvariable)
1878  deallocate(optical_thickness_37_final, stat = checkvariable)
1879  deallocate(effective_radius_16_final, stat = checkvariable)
1880  deallocate(effective_radius_37_final, stat = checkvariable)
1881  deallocate(liquid_water_path_16, stat = checkvariable)
1882  deallocate(liquid_water_path_37, stat = checkvariable)
1883 
1884  deallocate(optical_thickness_16_final_pcl, stat = checkvariable)
1885  deallocate(optical_thickness_37_final_pcl, stat = checkvariable)
1886  deallocate(effective_radius_16_final_pcl, stat = checkvariable)
1887  deallocate(effective_radius_37_final_pcl, stat = checkvariable)
1888  deallocate(liquid_water_path_16_pcl, stat = checkvariable)
1889  deallocate(liquid_water_path_37_pcl, stat = checkvariable)
1890 
1891  deallocate(optical_thickness_16_error, stat = checkvariable)
1892  deallocate(optical_thickness_37_error, stat = checkvariable)
1893  deallocate(effective_radius_16_error, stat = checkvariable)
1894  deallocate(effective_radius_37_error, stat = checkvariable)
1895 
1896  deallocate(liquid_water_path_16_error, stat = checkvariable)
1897  deallocate(liquid_water_path_37_error, stat = checkvariable)
1898  deallocate(cloud_layer_flag, stat = checkvariable)
1899  deallocate(ml_test_flag, stat = checkvariable)
1900  deallocate(csr_flag_array, stat = checkvariable)
1901  deallocate(precip_water_094, stat = checkvariable)
1902 
1903 !******************
1904 ! deallocate(clear_sky_btemp)
1905 ! deallocate(clear_sky_rad)
1906 
1907  deallocate(latitude, stat = checkvariable)
1908  deallocate(longitude, stat = checkvariable)
1909  deallocate(sensor_zenith_angle, stat = checkvariable)
1910  deallocate(solar_zenith_angle, stat = checkvariable)
1911  deallocate(relative_azimuth_angle, stat = checkvariable)
1912  deallocate(band_measurements, stat = checkvariable)
1913  deallocate(band_uncertainty, stat = checkvariable)
1914  deallocate(sensor_azimuth_angle, stat = checkvariable)
1915  deallocate(solar_azimuth_angle, stat = checkvariable)
1916 
1917  deallocate(surface_albedo, stat = checkvariable)
1918  deallocate(surface_temperature, stat = checkvariable)
1919  deallocate(surface_emissivity_land, stat = checkvariable)
1920  deallocate(cloud_top_temperature, stat = checkvariable)
1921  deallocate(cloud_top_height, stat = checkvariable)
1922  deallocate(cloud_top_pressure, stat = checkvariable)
1923  deallocate(cloud_phase_infrared, stat = checkvariable)
1924  deallocate(abovecloud_watervapor, stat = checkvariable)
1925  deallocate(column_ozone, stat = checkvariable)
1926  deallocate(cloudmask, stat = checkvariable)
1927 
1928  deallocate(cloud_mask_spi, stat = checkvariable)
1929 
1930  deallocate(failure_metric_16, stat = checkvariable)
1931  deallocate(failure_metric_37, stat = checkvariable)
1932 
1933  deallocate(cloudsummary, stat = checkvariable)
1934 
1935 
1936  call deallocate_extra
1937  deallocate(processing_information, stat = checkvariable)
1938 
1939  endif
1940 
1941 
1942  if (.not. allocated(optical_thickness_final)) then
1943 
1944 
1945  allocate (optical_thickness_final(xdimension,ydimension), stat = checkvariable)
1946  allocate (optical_thickness_1621_final(xdimension,ydimension), stat = checkvariable)
1947  allocate (effective_radius_21_final(xdimension,ydimension), stat = checkvariable)
1948  allocate (effective_radius_1621_final(xdimension,ydimension), stat = checkvariable)
1949  allocate (liquid_water_path_1621(xdimension,ydimension), stat = checkvariable)
1950  allocate (liquid_water_path(xdimension,ydimension), stat = checkvariable)
1951 
1952  allocate (optical_thickness_final_pcl(xdimension,ydimension), stat = checkvariable)
1953  allocate (optical_thickness_1621_final_pcl(xdimension,ydimension), stat = checkvariable)
1954  allocate (effective_radius_21_final_pcl(xdimension,ydimension), stat = checkvariable)
1955  allocate (effective_radius_1621_final_pcl(xdimension,ydimension), stat = checkvariable)
1956  allocate (liquid_water_path_1621_pcl(xdimension,ydimension), stat = checkvariable)
1957  allocate (liquid_water_path_pcl(xdimension,ydimension), stat = checkvariable)
1958 
1959  allocate (optical_thickness_error(xdimension,ydimension), stat = checkvariable)
1960  allocate (effective_radius_21_error(xdimension,ydimension), stat = checkvariable)
1961  allocate (liquid_water_path_error(xdimension,ydimension), stat = checkvariable)
1962  allocate (optical_thickness_1621_error(xdimension,ydimension), stat = checkvariable)
1963  allocate (effective_radius_1621_error(xdimension,ydimension), stat = checkvariable)
1964  allocate (liquid_water_path_1621_error(xdimension,ydimension), stat = checkvariable)
1965 
1966  allocate(failure_metric(xdimension, ydimension), stat = checkvariable)
1967  allocate(failure_metric_1621(xdimension, ydimension), stat = checkvariable)
1968  ! WDR only do 2.2 um for OCI
1969  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) ) then
1970  allocate (optical_thickness_22_final(xdimension,ydimension), &
1971  stat = checkvariable)
1972  allocate (effective_radius_22_final(xdimension,ydimension), &
1973  stat = checkvariable)
1974  allocate (liquid_water_path_22(xdimension,ydimension), &
1975  stat = checkvariable)
1976  allocate (optical_thickness_22_final_pcl(xdimension,ydimension), &
1977  stat = checkvariable)
1978  allocate (effective_radius_22_final_pcl(xdimension,ydimension), &
1979  stat = checkvariable)
1980  allocate (liquid_water_path_22_pcl(xdimension,ydimension), &
1981  stat = checkvariable)
1982  allocate (optical_thickness_22_error(xdimension,ydimension), &
1983  stat = checkvariable)
1984  allocate (effective_radius_22_error(xdimension,ydimension), &
1985  stat = checkvariable)
1986  allocate (liquid_water_path_22_error(xdimension,ydimension), &
1987  stat = checkvariable)
1988  allocate(failure_metric_22(xdimension, ydimension), &
1989  stat = checkvariable)
1990  endif
1991 
1992  allocate(atm_corr_refl(set_albedo_bands, xdimension, ydimension), stat=checkvariable)
1993  allocate (cloud_mask_spi(2,xdimension,ydimension), stat = checkvariable)
1994  cloud_mask_spi = 0 ! WDR to set to a known
1995 
1996 
1997  allocate (optical_thickness_16_final(xdimension,ydimension), stat = checkvariable)
1998  allocate (optical_thickness_37_final(xdimension,ydimension), stat = checkvariable)
1999  allocate (effective_radius_16_final(xdimension,ydimension), stat = checkvariable)
2000  allocate (effective_radius_37_final(xdimension,ydimension), stat = checkvariable)
2001  allocate (liquid_water_path_16(xdimension,ydimension), stat = checkvariable)
2002  allocate (liquid_water_path_37(xdimension,ydimension), stat = checkvariable)
2003 
2004  allocate (optical_thickness_16_final_pcl(xdimension,ydimension), stat = checkvariable)
2005  allocate (optical_thickness_37_final_pcl(xdimension,ydimension), stat = checkvariable)
2006  allocate (effective_radius_16_final_pcl(xdimension,ydimension), stat = checkvariable)
2007  allocate (effective_radius_37_final_pcl(xdimension,ydimension), stat = checkvariable)
2008  allocate (liquid_water_path_16_pcl(xdimension,ydimension), stat = checkvariable)
2009  allocate (liquid_water_path_37_pcl(xdimension,ydimension), stat = checkvariable)
2010 
2011  allocate (optical_thickness_16_error(xdimension,ydimension), stat = checkvariable)
2012  allocate (optical_thickness_37_error(xdimension,ydimension), stat = checkvariable)
2013  allocate (effective_radius_16_error(xdimension,ydimension), stat = checkvariable)
2014  allocate (effective_radius_37_error(xdimension,ydimension), stat = checkvariable)
2015  allocate (liquid_water_path_16_error(xdimension,ydimension), stat = checkvariable)
2016  allocate (liquid_water_path_37_error(xdimension,ydimension), stat = checkvariable)
2017  allocate (cloud_layer_flag(xdimension,ydimension), stat = checkvariable)
2018  allocate (ml_test_flag(xdimension,ydimension), stat = checkvariable)
2019  allocate (csr_flag_array(xdimension,ydimension), stat = checkvariable)
2020  allocate(precip_water_094(xdimension,ydimension), stat = checkvariable)
2021  allocate(snow_cover(xdimension,ydimension), stat = checkvariable)
2022 
2023  allocate(failure_metric_16(xdimension, ydimension), stat = checkvariable)
2024  allocate(failure_metric_37(xdimension, ydimension), stat = checkvariable)
2025 
2026 
2027 ! Core input data arrays
2028 
2029  allocate (latitude(xdimension,ydimension), stat = checkvariable)
2030  allocate (longitude(xdimension,ydimension), stat = checkvariable)
2031  allocate (sensor_zenith_angle(xdimension,ydimension), stat = checkvariable)
2032  allocate (solar_zenith_angle(xdimension,ydimension), stat = checkvariable)
2033  allocate (sensor_azimuth_angle(xdimension,ydimension), stat = checkvariable)
2034  allocate (solar_azimuth_angle(xdimension,ydimension), stat = checkvariable)
2035  allocate (relative_azimuth_angle(xdimension,ydimension), stat = checkvariable)
2036 
2037  allocate (band_measurements(meas_xdimension,number_of_bands, ydimension), stat = checkvariable)
2038  allocate (band_uncertainty(meas_xdimension,set_albedo_bands, ydimension), stat = checkvariable)
2039 
2040 
2041 ! Ancillary data array
2042 
2043  allocate (surface_albedo(xdimension,ydimension,set_albedo_bands), stat = checkvariable)
2044  allocate (surface_temperature(xdimension,ydimension), stat = checkvariable)
2045  allocate (cloud_height_method(xdimension,ydimension), stat = checkvariable)
2046  allocate (cloud_phase_infrared(xdimension,ydimension), stat = checkvariable)
2047  allocate (irw_temperature(xdimension,ydimension), stat = checkvariable)
2048  allocate (surface_emissivity_land(xdimension,ydimension, 2), stat = checkvariable)
2049  allocate (cloud_top_temperature(xdimension,ydimension), stat = checkvariable)
2050  allocate (cloud_top_height(xdimension,ydimension), stat = checkvariable)
2051  allocate (cloud_top_pressure(xdimension,ydimension), stat = checkvariable)
2052  allocate (abovecloud_watervapor(xdimension,ydimension), stat = checkvariable)
2053  allocate (column_ozone(xdimension,ydimension), stat = checkvariable)
2054  column_ozone = 0 ! WDR-UIV
2055  allocate (cloudmask(xdimension,ydimension), stat = checkvariable)
2056  allocate (cloud_mask_spi(2,xdimension,ydimension), stat = checkvariable)
2057  cloud_mask_spi = 0 ! WDR to set to a known
2058 
2059 !******************
2060 ! allocate (clear_sky_btemp(xdimension, ydimension, 2))
2061 ! allocate (clear_sky_rad(xdimension, ydimension, 2))
2062 
2063 
2064 ! QA and Processing arrays
2065 
2066  allocate (cloudsummary(xdimension,ydimension), stat = checkvariable)
2067 
2068 ! atmospheric correction
2069 
2070 ! allocate (transmittance_stddev(xdimension,ydimension,7), stat = checkvariable)
2071 ! allocate (transmittance_twoway(xdimension,ydimension,7), stat = checkvariable)
2072 ! allocate (meandelta_trans(xdimension,ydimension,7), stat = checkvariable)
2073 ! allocate (thermal_correction_twoway(xdimension,ydimension,2), stat = checkvariable)
2074 ! allocate (thermal_correction_oneway(xdimension,ydimension,2), stat = checkvariable)
2075 ! allocate (thermal_correction_bands(2), stat = checkvariable)
2076 
2077  call allocate_extra(xdimension, ydimension)
2078 
2079  allocate (processing_information(xdimension,ydimension), stat = checkvariable)
2080 
2081 
2082  endif
2083 
2084 end subroutine allocate_arrays
2085 
2086 
2087 integer function findpoint( vector, value)
2089 
2090  implicit none
2091 
2092  real(single) ,intent(in) :: vector(:)
2093  real(single) ,intent(in) :: value
2094  integer ::temp(1)
2095 
2096  real(single) ,allocatable :: localvector(:)
2097 
2098  allocate(localvector(size(vector)))
2099 
2100  localvector = vector
2101  call realsingle_s_where_equal(localvector,value)
2102 
2103  temp = maxloc(localvector)
2104  findpoint = temp(1)
2105  deallocate(localvector)
2106 
2107 end function findpoint
2108 
2109 
2110 subroutine init_qualitydata
2113 
2114 ! product quality and retrieval processing QA flags
2115  processing_information(:,:)%optical_thickness_GC = 0_integer_onebyte
2116  processing_information(:,:)%optical_thickness_outofbounds = 0_integer_onebyte
2117  processing_information(:,:)%effective_radius_GC = 0_integer_onebyte
2118  processing_information(:,:)%water_path_GC = 0_integer_onebyte
2119  processing_information(:,:)%rayleigh_correction = 0_integer_onebyte
2120  processing_information(:,:)%path_and_outcome = 0_integer_onebyte
2121  processing_information(:,:)%path_and_outcome_1621 = 0_integer_onebyte
2122 
2123  processing_information(:,:)%path_and_outcome_16 = 0_integer_onebyte
2124  processing_information(:,:)%path_and_outcome_16_PCL = 0_integer_onebyte
2125 
2126  processing_information(:,:)%path_and_outcome_37 = 0_integer_onebyte
2127  processing_information(:,:)%path_and_outcome_37_PCL = 0_integer_onebyte
2128 
2129  processing_information(:,:)%path_and_outcome_22 = 0_integer_onebyte
2130  processing_information(:,:)%path_and_outcome_22_PCL = 0_integer_onebyte
2131 
2132  processing_information(:,:)%path_and_outcome_PCL = 0_integer_onebyte
2133  processing_information(:,:)%path_and_outcome_1621_PCL = 0_integer_onebyte
2134 
2135  processing_information(:,:)%band_used_for_optical_thickness = 0_integer_onebyte
2136  processing_information(:,:)%optical_thickness_1621_GC = 0_integer_onebyte
2137  processing_information(:,:)%effective_radius_1621_GC = 0_integer_onebyte
2138  processing_information(:,:)%water_path_1621_GC= 0_integer_onebyte
2139  processing_information(:,:)%multi_layer_cloud = 0_integer_onebyte
2140  processing_information(:,:)%CSR_flag = 0_integer_onebyte
2141  processing_information(:,:)%ml_test_mark = 0_integer_onebyte
2142 
2143 #ifdef SEVIRI_INST
2144  processing_information(:,:)%Tc_override = 0_integer_onebyte
2145 #endif
2146 
2147 end subroutine init_qualitydata
2148 
2149 subroutine deallocate_cleanup(status)
2151  use core_arrays
2152  use libraryarrays
2154  use specific_other
2156  use science_parameters
2157  use ch_xfr, only: oci_id, ocis_id, c2_sensor_id
2158 
2159  integer, intent(inout) :: status
2160  integer :: checkvariable
2161 
2162  integer :: i, j
2163 
2164  status = 0
2165 
2166  if (allocated(model_info)) then
2167 
2168  do i=1, grid_xsize
2169  do j=1, grid_ysize
2170 
2171  deallocate(model_info(i,j)%mixr_profile)
2172  deallocate(model_info(i,j)%temp_profile)
2173  deallocate(model_info(i,j)%height_profile)
2174  deallocate(model_info(i,j)%pressure_profile)
2175 
2176  end do
2177  end do
2178 
2179  deallocate(model_info)
2180 
2181  endif
2182 
2183  deallocate(optical_thickness_final, stat = checkvariable)
2184  deallocate(optical_thickness_1621_final, stat = checkvariable)
2185  deallocate(effective_radius_21_final, stat = checkvariable)
2186  deallocate(effective_radius_1621_final, stat = checkvariable)
2187  deallocate(liquid_water_path_1621, stat = checkvariable)
2188  deallocate(liquid_water_path, stat = checkvariable)
2189 
2190  deallocate(optical_thickness_final_pcl, stat = checkvariable)
2191  deallocate(optical_thickness_1621_final_pcl, stat = checkvariable)
2192  deallocate(effective_radius_21_final_pcl, stat = checkvariable)
2193  deallocate(effective_radius_1621_final_pcl, stat = checkvariable)
2194  deallocate(liquid_water_path_1621_pcl, stat = checkvariable)
2195  deallocate(liquid_water_path_pcl, stat = checkvariable)
2196 
2197  deallocate(optical_thickness_error, stat = checkvariable)
2198  deallocate(effective_radius_21_error, stat = checkvariable)
2199 
2200  deallocate(liquid_water_path_error, stat = checkvariable)
2201  deallocate(optical_thickness_1621_error, stat = checkvariable)
2202  deallocate(effective_radius_1621_error, stat = checkvariable)
2203  deallocate(liquid_water_path_1621_error, stat = checkvariable)
2204 
2205  deallocate(cloud_mask_spi, stat = checkvariable)
2206 
2207  deallocate(failure_metric, stat = checkvariable)
2208  deallocate(failure_metric_1621, stat = checkvariable)
2209 
2210  deallocate(atm_corr_refl, stat = checkvariable)
2211  ! WDR only for OCI
2212  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) )then
2213  deallocate(effective_radius_22_final, stat = checkvariable)
2214  deallocate(optical_thickness_22_final_pcl, stat = checkvariable)
2215  deallocate(effective_radius_22_final_pcl, stat = checkvariable)
2216  deallocate(liquid_water_path_22_pcl, stat = checkvariable)
2217  deallocate(optical_thickness_22_error, stat = checkvariable)
2218  deallocate(effective_radius_22_error, stat = checkvariable)
2219  deallocate(liquid_water_path_22_error, stat = checkvariable)
2220  deallocate(failure_metric_22, stat = checkvariable)
2221  endif
2222 
2223 ! Core retrieval arrays
2224 
2225  deallocate(optical_thickness_16_final, stat = checkvariable)
2226  deallocate(optical_thickness_37_final, stat = checkvariable)
2227  deallocate(effective_radius_16_final, stat = checkvariable)
2228  deallocate(effective_radius_37_final, stat = checkvariable)
2229 
2230  deallocate(liquid_water_path_16, stat = checkvariable)
2231  deallocate(liquid_water_path_37, stat = checkvariable)
2232 
2233 
2234  deallocate(optical_thickness_16_final_pcl, stat = checkvariable)
2235  deallocate(optical_thickness_37_final_pcl, stat = checkvariable)
2236  deallocate(effective_radius_16_final_pcl, stat = checkvariable)
2237  deallocate(effective_radius_37_final_pcl, stat = checkvariable)
2238  deallocate(liquid_water_path_16_pcl, stat = checkvariable)
2239  deallocate(liquid_water_path_37_pcl, stat = checkvariable)
2240 
2241 
2242 
2243  deallocate(optical_thickness_16_error, stat = checkvariable)
2244  deallocate(optical_thickness_37_error, stat = checkvariable)
2245  deallocate(effective_radius_16_error, stat = checkvariable)
2246  deallocate(effective_radius_37_error, stat = checkvariable)
2247  deallocate(liquid_water_path_16_error, stat = checkvariable)
2248  deallocate(liquid_water_path_37_error, stat = checkvariable)
2249 
2250  deallocate(cloud_layer_flag, stat = checkvariable)
2251  deallocate(ml_test_flag, stat = checkvariable)
2252  deallocate(csr_flag_array, stat = checkvariable)
2253  deallocate(precip_water_094, stat = checkvariable)
2254 
2255  deallocate(failure_metric_16, stat = checkvariable)
2256  deallocate(failure_metric_37, stat = checkvariable)
2257 
2258 ! Core input data arrays
2259  deallocate(latitude, stat = checkvariable)
2260  deallocate(longitude, stat = checkvariable)
2261  deallocate(sensor_zenith_angle, stat = checkvariable)
2262  deallocate(solar_zenith_angle, stat = checkvariable)
2263  deallocate(relative_azimuth_angle, stat = checkvariable)
2264  deallocate(band_measurements, stat = checkvariable)
2265  deallocate(band_uncertainty, stat = checkvariable)
2266  deallocate(sensor_azimuth_angle, stat = checkvariable)
2267  deallocate(solar_azimuth_angle, stat = checkvariable)
2268 
2269  deallocate(surface_albedo, stat = checkvariable)
2270  deallocate(surface_temperature, stat = checkvariable)
2271  deallocate(surface_emissivity_land, stat = checkvariable)
2272  deallocate(cloud_top_temperature, stat = checkvariable)
2273  deallocate(cloud_top_pressure, stat = checkvariable)
2274  deallocate(cloud_phase_infrared, stat = checkvariable)
2275  deallocate(abovecloud_watervapor, stat = checkvariable)
2276  deallocate(column_ozone, stat = checkvariable)
2277  deallocate(cloudmask, stat = checkvariable)
2278  deallocate(cloud_mask_spi, stat = checkvariable)
2279  deallocate(snow_cover, stat = checkvariable)
2280 ! deallocate(model_height_profile, stat = checkvariable)
2281 ! deallocate(model_temp_profile, stat = checkvariable)
2282 ! deallocate(model_water_profile, stat = checkvariable)
2283 
2284 
2285 !***********
2286 ! deallocate(clear_sky_btemp)
2287 ! deallocate(clear_sky_rad)
2288 
2289 ! QA and Processing arrays
2290  deallocate(cloudsummary, stat = checkvariable)
2291  deallocate(processing_information, stat = checkvariable)
2292 
2293 ! atmospheric correction
2294 
2295 ! deallocate(transmittance_stddev, stat = checkvariable)
2296 ! deallocate(transmittance_twoway, stat = checkvariable)
2297 ! deallocate(meandelta_trans, stat = checkvariable)
2298 ! deallocate(thermal_correction_twoway, stat = checkvariable)
2299 ! deallocate(thermal_correction_oneway, stat = checkvariable)
2300 ! deallocate(thermal_correction_bands, stat = checkvariable)
2301 
2302  deallocate(cloud_height_method)
2303  deallocate(irw_temperature)
2304 
2305 ! library arrays
2306 
2307  deallocate(transmit_correction_table)
2308  deallocate(transmit_stddev_table)
2309 
2310  deallocate(ice_radii)
2311  deallocate(library_taus)
2312  deallocate(water_radii)
2313 
2314 ! finally. Let's allocate the arrays we'll need later
2317  deallocate(spherical_albedo_water)
2318 
2319 ! ice arrays, library, not interpolated
2320 
2321 
2324  deallocate(spherical_albedo_ice)
2325 
2326 
2328 
2329 
2330 ! arrays for library interpolation
2335 
2338 
2339  deallocate(int_reflectance_water_wspeed)
2340  deallocate(int_reflectance_ice_wspeed)
2341  deallocate(int_refl_water_sdev_wspeed)
2342  deallocate(int_refl_ice_sdev_wspeed)
2343 
2346 
2347 
2348 
2351 
2352  deallocate(rayleigh_liq, rayleigh_ice)
2353 
2354 ! phase function information
2355  deallocate(phase_angles_water)
2356  deallocate(phase_angles_ice)
2357  deallocate(phase_funcs_water)
2358  deallocate(phase_funcs_ice)
2359 
2360  call deallocate_extra
2361  call lib_clean
2362 
2363  if (no_valid_data == 0) then
2364 
2365  deallocate(library_solar_zenith)
2366  deallocate(library_sensor_zenith)
2367  deallocate(library_relative_azimuth)
2368  deallocate(library_fluxsolarzenith)
2369  deallocate(library_fluxsensorzenith)
2370 
2371  deallocate( solarzenith_all, sensorzenith_all, &
2372  relativeazimuth_all, solarzenith_flux_all)
2373 
2376 
2379 
2382 
2385 
2386  endif
2387 
2388 end subroutine deallocate_cleanup
2389 
2390 
2391 end module modis_frontend_module
integer *2, dimension(:,:), allocatable optical_thickness_37_error
Definition: core_arrays.f90:76
Definition: ch_xfr.f90:1
integer *2, dimension(:,:), allocatable effective_radius_16_final_pcl
Definition: core_arrays.f90:54
type(failed_type), dimension(:,:), allocatable failure_metric_22
integer *2, dimension(:,:), allocatable optical_thickness_22_final_pcl
Definition: core_arrays.f90:50
integer number_wavelengths
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
subroutine allocate_extra(xdim, ydim)
real(single), dimension(:,:), allocatable liquid_water_path
Definition: core_arrays.f90:65
real(single), dimension(:,:,:,:,:), allocatable surface_emissivity_water
integer *2, dimension(:,:), allocatable effective_radius_1621_final_pcl
Definition: core_arrays.f90:58
integer *2, dimension(:,:), allocatable liquid_water_path_16_pcl
Definition: core_arrays.f90:61
subroutine, public deallocate_cleanup(status)
integer(integer_onebyte), dimension(:,:), allocatable cloud_layer_flag
Definition: core_arrays.f90:92
float * vector(long nl, long nh)
Definition: nrutil.c:15
real(single), dimension(:,:,:), allocatable int_surface_emissivity_water_sdev
integer *2, dimension(:,:), allocatable effective_radius_16_error
Definition: core_arrays.f90:80
integer, parameter band_1200
real(single), dimension(:,:,:,:,:), allocatable cloud_emissivity_ice
real(single), dimension(:,:), allocatable phase_fun_norm_constant_ice
integer ocis_id
Definition: ch_xfr.f90:51
integer *2, dimension(:,:), allocatable optical_thickness_22_error
Definition: core_arrays.f90:74
integer number_fluxsensorzenith
integer *2, dimension(:,:), allocatable liquid_water_path_16_error
Definition: core_arrays.f90:85
real(single), dimension(:,:,:,:,:), allocatable surface_emissivity_water_sdev
subroutine deallocate_extra
type(cloudmask_type), dimension(:,:), allocatable cloudmask
integer *2, dimension(:,:,:), allocatable cloud_mask_spi
real(single), dimension(:,:), allocatable optical_thickness_37_final
Definition: core_arrays.f90:41
real(single), dimension(:,:), allocatable longitude
integer *2, dimension(:,:), allocatable optical_thickness_37_final_pcl
Definition: core_arrays.f90:52
real(single), dimension(:,:), allocatable effective_radius_37_final
Definition: core_arrays.f90:46
real(single), dimension(:,:), allocatable cloud_top_pressure
real(single), dimension(:,:,:,:,:), allocatable surface_emissivity_ice
real(single), dimension(:,:,:,:), allocatable flux_up_water_solar
integer cm_from_l2
Definition: ch_xfr.f90:56
real(single), dimension(:,:,:,:), allocatable int_surface_emis_ice_wspeed
integer number_phase_angles_water
integer *2, dimension(:,:), allocatable effective_radius_21_final_pcl
Definition: core_arrays.f90:55
real(single), dimension(:,:,:,:), allocatable flux_down_ice_sensor
real(single), dimension(:), allocatable library_relative_azimuth
real(single), dimension(:,:), allocatable phase_fun_norm_constant_water
integer *2, dimension(:,:), allocatable optical_thickness_1621_error
Definition: core_arrays.f90:88
integer *2, dimension(:,:), allocatable liquid_water_path_pcl
Definition: core_arrays.f90:59
real(single), dimension(:,:,:), allocatable int_reflectance_ice
integer *2, dimension(:,:), allocatable effective_radius_22_error
Definition: core_arrays.f90:79
character(len=1000), dimension(3) alibnames_water_sdev
Definition: names.f90:36
real, dimension(:,:), allocatable irw_temperature
real(single), dimension(:,:), allocatable latitude
integer *2, dimension(:,:), allocatable optical_thickness_error
Definition: core_arrays.f90:73
subroutine, public check_datasources(status)
real(single), dimension(:,:,:,:), allocatable int_cloud_emis_water_wspeed
character(len=1000) aphase_library
Definition: names.f90:37
integer, parameter set_albedo_bands
real(single), dimension(:,:,:), allocatable int_fluxdownwater_solar
subroutine, public init_qualitydata
integer function findpoint(vector, value)
real(single), dimension(:,:,:,:), allocatable flux_down_water_solar
real, dimension(:,:,:), allocatable atm_corr_refl
character *15 platform_name
real, dimension(:,:), allocatable sensor_azimuth_angle
integer, parameter band_0370
real(4), parameter set_threshold_relative_azimuth
integer *1, dimension(:,:), allocatable cloud_phase_infrared
integer, parameter band_1100
real(single), dimension(:), allocatable library_solar_zenith
subroutine realsingle_s_where_equal(x, y)
character(len=1000) ageos2d_name1
Definition: names.f90:31
subroutine, public allocate_model(st_iterX, st_iterY, grid_wid, grid_ht)
character(len=1000), dimension(3) alibnames_ice
Definition: names.f90:35
type(failed_type), dimension(:,:), allocatable failure_metric_1621
integer *2, dimension(:,:), allocatable liquid_water_path_error
Definition: core_arrays.f90:83
real, dimension(:,:,:), allocatable surface_albedo
real(single), dimension(:,:), allocatable singlescattering_water
real(single), dimension(:,:,:,:,:), allocatable cloud_emissivity_water_sdev
real(single), dimension(:,:,:), allocatable int_cloud_emissivity_ice
character(len=1000), dimension(3) alibnames_ice_sdev
Definition: names.f90:35
real(single), dimension(:,:,:), allocatable int_cloud_emissivity_water
type(processflag), dimension(:,:), allocatable cloudsummary
real(single), dimension(:), allocatable water_radii
real(single), dimension(:), allocatable aerosol_ssa
real(single), dimension(:,:), allocatable cloud_top_height
integer *2, dimension(:,:), allocatable liquid_water_path_37_error
Definition: core_arrays.f90:86
real(single), dimension(:,:,:,:), allocatable flux_down_ice_solar
real(single), dimension(:), allocatable library_fluxsolarzenith
subroutine cld_fchk(status, file, line)
Definition: cld_fchk.f90:2
real(single), dimension(:), allocatable library_taus
real(single), dimension(:,:,:), allocatable int_reflectance_ice_sdev
integer, parameter single
real(single), dimension(:,:,:,:), allocatable int_cloud_emis_water_sdev_wspeed
real(4), parameter set_threshold_sensor_zenith
real(single), dimension(:,:), allocatable asymmetry_ice
real(single), dimension(:,:,:), allocatable int_reflectance_water_sdev
integer, parameter channel_37um
integer *2, dimension(:,:), allocatable optical_thickness_16_final_pcl
Definition: core_arrays.f90:51
character(len=1000) asnowicealbedo_data_name
Definition: names.f90:37
type(failed_type), dimension(:,:), allocatable failure_metric_16
integer number_relazimuth
character(len=1000) aice_library
Definition: names.f90:28
real(single), dimension(:,:,:), allocatable spherical_albedo_water
real(single), dimension(:,:,:,:), allocatable int_cloud_emis_ice_sdev_wspeed
integer(integer_onebyte), dimension(:,:), allocatable csr_flag_array
Definition: core_arrays.f90:93
real, dimension(:,:), allocatable solar_zenith_angle
Definition: core_arrays.f90:6
real(single), dimension(:,:,:,:,:), allocatable surface_emissivity_ice_sdev
real(single), dimension(:,:), allocatable liquid_water_path_37
Definition: core_arrays.f90:68
real(single), dimension(:,:,:), allocatable int_surface_emissivity_ice
real(single), dimension(:,:), allocatable column_ozone
real(single), dimension(:,:), allocatable singlescattering_ice
real(single), dimension(:,:), allocatable extinction_ice
real(single), dimension(:,:,:), allocatable int_fluxdownice_solar
real(single), dimension(:,:,:,:), allocatable int_refl_ice_sdev_wspeed
real(single), dimension(:,:), allocatable optical_thickness_final
Definition: core_arrays.f90:38
void print(std::ostream &stream, const char *format)
Definition: PrintDebug.hpp:38
character(len=1000) ageos2d_name2
Definition: names.f90:31
real(single), dimension(:,:), allocatable extinction_water
real(single), dimension(:), allocatable library_sensor_zenith
real(single), dimension(:,:,:), allocatable int_surface_emissivity_water
real(single), dimension(:,:,:), allocatable spherical_albedo_ice
real, dimension(:,:,:,:), allocatable transmit_stddev_table
integer *2, dimension(:,:), allocatable optical_thickness_final_pcl
Definition: core_arrays.f90:49
type(failed_type), dimension(:,:), allocatable failure_metric
real(single), dimension(:,:,:), allocatable phase_funcs_ice
real(single), dimension(:,:), allocatable optical_thickness_22_final
Definition: core_arrays.f90:39
real(single), dimension(:,:), allocatable liquid_water_path_1621
Definition: core_arrays.f90:69
real, dimension(:), allocatable rayleigh_liq
real(single), dimension(:), allocatable ice_radii
real, dimension(:,:), allocatable snow_cover
real(single), dimension(:), allocatable aerosol_asym
real(single), dimension(:,:,:,:), allocatable flux_up_water_sensor
real(single), dimension(:,:,:,:), allocatable int_surface_emis_water_wspeed
character(len=1000) ageos3d_name2
Definition: names.f90:31
integer *2, dimension(:,:), allocatable liquid_water_path_1621_error
Definition: core_arrays.f90:90
integer *2, dimension(:,:), allocatable effective_radius_37_final_pcl
Definition: core_arrays.f90:57
real(single), dimension(:,:,:,:), allocatable flux_down_water_sensor
integer *2, dimension(:,:), allocatable optical_thickness_1621_final_pcl
Definition: core_arrays.f90:53
integer function checkfile(name)
real(single), dimension(:,:,:), allocatable int_surface_emissivity_ice_sdev
type(ancillary_type), dimension(:,:), allocatable model_info
integer c2_sensor_id
Definition: ch_xfr.f90:50
integer, parameter set_tilesize
integer number_wind_speed
real(single), dimension(:), allocatable rayleigh_tau
subroutine, public allocate_arrays(edge, meas_edge, st_iterX, st_iterY, status)
character(len=1000) atransmittance_library
Definition: names.f90:37
real, dimension(:,:), allocatable precip_water_094
real(single), dimension(:,:), allocatable cloud_top_temperature
string & trim(string &s, const string &delimiters)
Definition: EnvsatUtil.cpp:29
real(single), dimension(:,:,:), allocatable surface_emissivity_land
integer number_phase_angles_ice
integer, dimension(set_number_of_bands), parameter set_bands
type(ancillary_type) c2_model_info
real(single), dimension(:,:,:), allocatable band_measurements
subroutine, public readlibraries_extra(debug, status)
real, dimension(:,:), allocatable sensor_zenith_angle
integer(integer_onebyte), dimension(:,:), allocatable ml_test_flag
Definition: core_arrays.f90:92
real(single), dimension(:,:), allocatable relative_azimuth_angle
real(single), dimension(:,:,:,:), allocatable int_surface_emis_water_sdev_wspeed
real(single), dimension(:,:,:), allocatable int_fluxupice_sensor
integer, parameter model_levels
real(single), dimension(:,:), allocatable surface_temperature
real(single), dimension(:,:,:), allocatable int_reflectance_water
integer *2, dimension(:,:), allocatable effective_radius_22_final_pcl
Definition: core_arrays.f90:56
integer number_waterradii
real(single), dimension(:,:), allocatable optical_thickness_1621_final
Definition: core_arrays.f90:42
Definition: names.f90:1
real(single), dimension(:,:,:,:), allocatable flux_up_ice_solar
instead the metadata field ProcessingEnvinronment is filled in from the output of a call to the POSIX compliant function uname from within the L1B code A small bug in L1B_Tables an incorrect comparison of RVS coefficients for TEBs to RVS coefficients for RSBs was being made This was replaced with a comparison between TEB coefficients This error never resulted in an incorrect RVS correction but did lead to recalculating the coefficients for each detector in a thermal band even if the coefficients were the same for all detectors To reduce to overall size of the reflective LUT HDF fill values were eliminated from all LUTs previously dimensioned where and where NUM_TIMES is the number of time dependent table pieces In Preprocess a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed This counter is internal only and is not yet used for any chiefly to casting of were added to make it LINUX compatible Output of code run on LINUX machines displays differences of at most scaled integer(SI) from output of code run on IRIX machines. 3. Checking for non-functioning detectors
integer number_solarzenith
integer, parameter channel_11um
real(single), dimension(:,:,:,:,:), allocatable cloud_emissivity_ice_sdev
integer *2, dimension(:,:), allocatable effective_radius_1621_error
Definition: core_arrays.f90:89
type(qualityanalysis), dimension(:,:), allocatable processing_information
integer *2, dimension(:,:), allocatable effective_radius_21_error
Definition: core_arrays.f90:78
integer, parameter channel_12um
real(single), dimension(:,:), allocatable liquid_water_path_16
Definition: core_arrays.f90:67
real(single), dimension(:,:,:), allocatable int_fluxdownwater_sensor
real(single), dimension(:,:), allocatable abovecloud_watervapor
real(single), dimension(:,:,:), allocatable int_cloud_emissivity_ice_sdev
real(single), dimension(:,:), allocatable truncation_factor_ice
type(failed_type), dimension(:,:), allocatable failure_metric_37
integer number_iceradii
real(single), dimension(:,:), allocatable effective_radius_22_final
Definition: core_arrays.f90:45
real(single), dimension(:,:), allocatable asymmetry_water
character(len=1000) ageos3d_name1
Definition: names.f90:31
integer *2, dimension(:,:), allocatable liquid_water_path_22_pcl
Definition: core_arrays.f90:60
real, dimension(:,:,:), allocatable band_uncertainty
real(single), dimension(:,:), allocatable liquid_water_path_22
Definition: core_arrays.f90:66
integer oci_id
Definition: ch_xfr.f90:52
real(single), dimension(:,:,:,:), allocatable int_cloud_emis_ice_wspeed
subroutine get_channels
real(single), dimension(:,:,:,:,:), allocatable cloud_emissivity_water
character(len=500) aemissivity_name
Definition: names.f90:44
real(single), dimension(:,:), allocatable optical_thickness_16_final
Definition: core_arrays.f90:40
character(len=1000), dimension(3) alibnames_water
Definition: names.f90:36
real(single), dimension(:,:), allocatable effective_radius_16_final
Definition: core_arrays.f90:43
real(4), parameter set_threshold_solar_zenith
real(single), dimension(:,:,:), allocatable phase_funcs_water
real, dimension(:), allocatable rayleigh_ice
character(len=1000) aecosystem_data_name
Definition: names.f90:37
real(single), dimension(:,:,:), allocatable int_fluxdownice_sensor
real, dimension(:,:), allocatable solar_azimuth_angle
real(single), dimension(:,:,:,:), allocatable int_surface_emis_ice_sdev_wspeed
integer *1, dimension(:,:), allocatable cloud_height_method
real(single), dimension(:,:,:,:), allocatable int_reflectance_water_wspeed
integer *2, dimension(:,:), allocatable optical_thickness_16_error
Definition: core_arrays.f90:75
real(single), dimension(:), allocatable phase_angles_water
real(single), dimension(:,:,:,:), allocatable flux_up_ice_sensor
real(single), dimension(:,:,:,:), allocatable int_refl_water_sdev_wspeed
subroutine local_message_handler(message, severity, functionname)
subroutine, public readlibraries_base(debug, status)
real(single), dimension(:), allocatable phase_angles_ice
real, dimension(:,:,:,:), allocatable transmit_correction_table
integer *2, dimension(:,:), allocatable effective_radius_37_error
Definition: core_arrays.f90:81
subroutine, public initialize_run(start, edge, stride, tilesize, threshold_solar_zenith, threshold_sensor_zenith, threshold_relative_azimuth, status)
character(len=1000) awater_library
Definition: names.f90:28
real(single), dimension(:,:), allocatable effective_radius_1621_final
Definition: core_arrays.f90:47
integer *2, dimension(:,:), allocatable liquid_water_path_37_pcl
Definition: core_arrays.f90:62
real(single), dimension(:,:,:,:), allocatable int_reflectance_ice_wspeed
real(single), dimension(:), allocatable library_fluxsensorzenith
logical, parameter do_cox_munk
integer *2, dimension(:,:), allocatable liquid_water_path_1621_pcl
Definition: core_arrays.f90:63
integer *2, dimension(:,:), allocatable liquid_water_path_22_error
Definition: core_arrays.f90:84
real(single), dimension(:), allocatable aerosol_tau
integer number_fluxsolarzenith
real(single), dimension(:,:), allocatable truncation_factor_water
real(single), dimension(:,:,:), allocatable int_cloud_emissivity_water_sdev
integer number_sensorzenith
real(single), dimension(:,:,:), allocatable int_fluxupwater_sensor
real(single), dimension(:,:), allocatable effective_radius_21_final
Definition: core_arrays.f90:44
integer number_taus