NASA Logo
Ocean Color Science Software

ocssw V2022
modis_science_module.f90
Go to the documentation of this file.
2 
3 implicit none
4 
5 private
6 
7 public:: scienceinterface
8 
9 
10 
11 contains
12 
13 subroutine scienceinterface(threshold_solar_zenith, &
14  threshold_sensor_zenith, &
15  threshold_relative_azimuth, &
16  debug, &
17  status)
18 
61  ! for the 2.2 um band
62  optical_thickness_22_final,effective_radius_22_final, &
63  optical_thickness_22_error, effective_radius_22_error, &
64  liquid_water_path_22_error, optical_thickness_22_error, &
65  failure_metric_22, liquid_water_path_22, &
66  effective_radius_22_ice, effective_radius_22_liquid, &
67  optical_thickness_22_ice, optical_thickness_22_liquid
68 
72  int_reflectance_water, im_cloudy_count, im_ice_cloud_count, &
73  im_successful_retrieval_count, im_undet_count, im_water_cloud_count, &
74  iterationx, number_of_iterationsx, pi, pixx, pixy
75  !use science_parameters
91  use retrieval_prep_logic, only:color_first_time, cox_munk, d2r, delta_pc, &
92  delta_ts, last_2way_angle, last_cox_munk, lastinterp_relative_azimuth, &
93  lastinterp_scat_angle, lastinterp_scat_angle_ss, &
94  lastinterp_sensor_zenith, lastinterp_solar_zenith, lastinterp_wind_speed,&
95  retr_scale_factor, solar_constant_37, solar_zenith_threshold, swir_error,&
96  unc_scale_factor, vnir_error, watervapor_error, uncertain_sf, &
97  uncertain_sf, spec_uncertain, init_retrieval, cleanup_retrieval
103  use cloud_phase, only:clouddecision
106  use names, only: my_unit_lun
111  use planck_functions, only: modis_planck
113 !WDR for the new routine
114 ! out in this vers use wdr_wr_ch_vars, only: wr_ch_vars
115 
116  implicit none
117 
118  logical, intent(in) :: debug
119  real, intent(in) :: threshold_solar_zenith, &
120  threshold_sensor_zenith, &
121  threshold_relative_azimuth
122 
123  integer, intent(out) :: status
124 
125 
126  integer :: xdimension, ydimension,i,j, k,jj,count_interpolations, &
127  retrievalcount
128  integer :: retrieval_failcount, library_failcount, cloud_failcount, atmoscorr_failcount
129  integer :: cloudstatus, retrievalstatus, librarystatus, atmoscorrstatus,cloudiness_degree_250m
130  real :: diff_solar_zenith, &
131  diff_sensor_zenith, &
132  diff_relative_azimuth
133 
134  real :: scattering_angle, dscat, diff_scat_angle, diff_scat_angle_ss
135  real :: dsol, dsen, drel, diff_wind_speed
136  real :: cur_wind_speed
137  real :: cloud_top_temperature_water, cloud_top_temperature_ice, ctt_1km
138 
139  integer :: istart, iend, jstart, jend, myrad
140 
141  logical :: ldebug, sunglint_dust_test, lowvariability_confidence_test, put_back_cloud
142  logical :: ir_cloudphase_1km_watercloud, ir_cloudphase_1km_icecloud
143  integer :: model_i, model_j
144  integer :: uncertain_start
145 
146  integer :: na_band_used, r1r2wavelengthidx(2), absorbingband_index, uncertainty_nonabsorbing_1621
147  real:: corr_meas(set_number_of_bands), temp_meas(set_number_of_bands), alb_meas(set_albedo_bands)
148  character(10) :: phase
149  real :: cloud_reflectance(2),delta_reflectance(2), albedo_holder(2) , &
150  delta_transmittance(2), tauregimethreshold(2), unc_reflectance(2)
151 
152  integer :: start_time, end_time, cmax, crate
153 
154  integer :: cnt_sza, cnt_vza, cnt_raz, cnt_cm_switch, cnt_wspeed, cnt_scat, cnt_wspeed_only
155  logical :: wind_speed_only, interp_ms, interp_ss
156  real :: irw_pressure
157  real :: tc_liquid, tc_ice, pc_liquid, pc_ice, pw_liquid, pw_ice
158  real :: rad_clr(2), bt_clr(2)
159  integer :: ice_near(4), liq_near(4), nearest_used(4)
160  real :: rss_ice(4), rss_liq(4), rss_final(4)
161 
162  real :: unc_tau_real, unc_tau_1621_real, unc_tau16_real, unc_tau37_real
163  real :: unc_re21_real, unc_re16_real, unc_re37_real, unc_re1621_real
164  real :: unc_lwp21_real, unc_lwp16_real, unc_lwp37_real, unc_lwp1621_real
165  real :: unc_re22_real, unc_lwp22_real, unc_tau22_real
166 
167  real :: emission_pw(20), emission_tc(20), sigma_r37_pw(20)
168 
169  real :: alt_ray_liq, alt_ray_ice, temp_pres
170  real :: aod550, irw_dummy
171 
172  integer :: re_idx_low, re_idx_hi
173  integer :: clin ! WDR for directed processing
174 
175  real, dimension(:,:), allocatable :: aod550_store
176 
177  logical :: vis1km_test ! KGM 3-4-13
178  type(cloudphase) :: ir_cloudphase
179 
180  logical :: do_retrievals_liq(4), do_retrievals_ice(4)
181  logical :: finalize_liq(4), finalize_ice(4)
182  logical :: set_near(4)
183  real :: zzz_test ! WDR just for testing
184 
185  unc_re16_real = 0 ! WDR-UIV
186  unc_tau16_real = 0 ! WDR-UIV
187  unc_tau_1621_real = 0 ! WDR-UIV
188  unc_re1621_real = 0 ! WDR-UIV
189  unc_lwp1621_real = 0 ! WDR-UIV
190  unc_re22_real = 0
191  unc_lwp22_real = 0
192  unc_re21_real = 0 ! WDR-UIV
193  unc_lwp21_real = 0 ! WDR-UIV
194  unc_tau37_real = 0 ! WDR-UIV
195  unc_re37_real = 0 ! WDR-UIV
196  unc_lwp37_real = 0 ! WDR-UIV
197  unc_tau_real = 0 ! WDR-UIV
198 
199  re_idx_low = 0 ! WDR-UIV
200  re_idx_hi = 0 ! WDR-UIV
201 
202  status = 0
203 
204  xdimension = size(optical_thickness_final, 1)
205  ydimension = size(optical_thickness_final, 2)
206 
207 
208  lastinterp_solar_zenith = fillvalue_real
209  lastinterp_sensor_zenith = fillvalue_real
210  lastinterp_relative_azimuth = fillvalue_real
211  lastinterp_scat_angle = fillvalue_real
212  lastinterp_wind_speed = fillvalue_real
213  lastinterp_scat_angle_ss = fillvalue_real
214  count_interpolations = 0
215  retrievalcount = 0
216  retrieval_failcount = 0
217  library_failcount = 0
218  cloud_failcount = 0
219  atmoscorr_failcount = 0
220 
221 
222  cnt_sza = 0
223  cnt_vza = 0
224  cnt_raz = 0
225  cnt_cm_switch = 0
226  cnt_wspeed = 0
227  cnt_scat = 0
228  cnt_wspeed_only = 0
229 
231 
232  call init_rtm_vars
233  call init_half_radii
234 
235  cox_munk = .false.
236  last_cox_munk = .false.
237  wind_speed_only = .false.
238  interp_ms = .false.
239  interp_ss = .false.
240 
241  color_first_time = .true.
242  last_2way_angle = fillvalue_real
243 
244 
245  call set_drel(threshold_relative_azimuth, drel)
246 
248 
249 #ifndef RETRIEVE
250  allocate(aod550_store(xdimension, ydimension))
251  aod550_store = fillvalue_real
252  cloudsummary(:,:)%cloudobserved = .true.
253 #endif
254 ! WDR export the data needed for a small test
255 ! out in this vers call wr_ch_vars
256 
257  do i = 1, xdimension
258 ! do i=40, 40
259 
260 ! do not process lines 1 and 1354 of the data because there are issues with cloud mask, particularly for the last line
261 ! of the data
262  if (iterationx == 1 .and. i==1 .or. iterationx == number_of_iterationsx .and. i==xdimension ) then
263  cloudsummary(i,:)%cloudobserved = .false.
264 ! aod550_store(i,:) = fillvalue_real
265  do j=1, ydimension
266  call assign_retrieval_error(i,j)
267  retrieval_failcount = retrieval_failcount + 1
268  end do
269  cycle
270  endif
271 
272  !WDR try only the center line do j=1, ydimension
273  ! (this makes the center line a cloud edge somehow and missing data goes
274  ! there, so don't do for now
275  ! clin = ydimension / 2 + 1
276  ! do j=clin, clin
277  ! WDR switch to scn_loop_st,scn_loop_en do j=1,ydimension
279 ! do j=665, 665
280 ! WDR to see all lines, pix: print*, __FILE__, __LINE__," Doing pixel ", i, " line ", j
281 ! WDR set up the single-point model_info at chunk point i, j
282 ! (fills c2_model_info)
283  call fill_c2_mdl( i, j )
284  zzz_test = effective_radius_22_final(231,2)
285 
286 #ifndef RETRIEVE
287 
288  if (surface_albedo(i,j,1) >= 300 .or. (cloudmask(i,j)%sunglint == 1 .and. &
289  cloudmask(i,j)%water_surface) ) then
290  aod550_store(i,j) = fillvalue_real
291  cycle
292  endif
293 
294 
295 #endif
296 
297 
298  pixx = i
299  pixy = j
300 
301  cloudsummary(i,j)%cloudmask_determined = .false.
302  cloudsummary(i,j)%cloudobserved = .false.
303  cloudsummary(i,j)%watercloud = .false.
304  cloudsummary(i,j)%icecloud = .false.
305  cloudsummary(i,j)%unknowncloud = .false.
306  csr_flag_array(i,j) = 0
307 
308  liq_near = 0
309  ice_near = 0
310 
317 
318 ! can't retrieve, sun too low or no cloud top
319  if (solar_zenith_angle(i,j) > solar_zenith_threshold &
320  .or. solar_zenith_angle(i,j) < 0. &
321  .or. cloud_top_pressure(i,j) < 0. &
322  .or. cloud_top_temperature(i,j) < 0. ) then
323  retrievalstatus = 1
324  call assign_retrieval_error(i,j)
325  retrieval_failcount = retrieval_failcount + 1
326  ! This should get clear areas have a 'no cloud' in phase
327  if (cloudmask(i,j)%cloudmask_determined) &
328  cloudsummary(i,j)%cloudmask_determined = .true.
329  cycle
330  endif
331 
332 
334  lowvariability_confidence_test = .false.
335  na_band_used = 0
336 
337 
338 ! we have to set cloudy/not cloudy and surface type outside the cloud phase call so the retrieval actually works.
339  if (cloudmask(i,j)%cloudmask_determined) cloudsummary(i,j)%cloudmask_determined = .true.
340 
341  if (cloudmask(i,j)%confident_cloudy .or. cloudmask(i,j)%probablyclear_66) &
342  cloudsummary(i,j)%cloudobserved = .true.
343 
344  if (cloudmask(i,j)%snowice_surface) then
345  if (cloudmask(i,j)%land_surface) cloudsummary(i,j)%land_surface = .true.
346  if (cloudmask(i,j)%water_surface) cloudsummary(i,j)%ocean_surface = .true.
347  if (cloudmask(i,j)%desert_surface) cloudsummary(i,j)%desert_surface = .true.
348  if (cloudmask(i,j)%coastal_surface) cloudsummary(i,j)%coastal_surface = .true.
349  endif
350  if (cloudmask(i,j)%land_surface .or. cloudmask(i,j)%coastal_surface .or. cloudmask(i,j)%desert_surface) then
351  if (cloudsummary(i,j)%ocean_surface) then
352  cloudsummary(i,j)%coastal_surface= .true.
353  cloudsummary(i,j)%ocean_surface = .false.
354  endif
355  endif
356 
357 
358  corr_meas = fillvalue_real
359 
360 
361 
362 ! We have a cloud, now we can attempt retrieval
363  if (cloudsummary(i,j)%cloudobserved .and. cloud_top_pressure(i,j) > 0.) then
364 
365 
366 
367  if (iterationx == 1) then
368  temp_meas = band_measurements(i, :, j)
369  corr_meas = band_measurements(i, :, j)
370  else
371  temp_meas = band_measurements(i+1, :, j)
372  corr_meas = band_measurements(i+1, :, j)
373  endif
374 
375 ! DO_COX_MUNK is a model control flag. Set/unset this in mod06_run_settings.f90
376  if (cloudsummary(i,j)%ocean_surface .and. .not. cloudsummary(i,j)%snowice_surface &
377  .and. temp_meas(2) > 0. .and. do_cox_munk) then
378  cox_munk = .true.
379  else
380  cox_munk = .false.
381  endif
382 
383 
384  const_c = pi / ( cos(solar_zenith_angle(i,j)*d2r) * solar_constant_37)
385 
386 
387 #ifdef GEOS5
388 
389 #ifdef MCARS
390  model_i = i
391  model_j = j
392 #else
393  call get_model_idx_geos5(geos5_istart, geos5_jstart, latitude(i,j), longitude(i,j), model_i, model_j)
394 #endif
395 
396 #else
397  call get_model_idx(latitude(i,j), longitude(i,j), model_i, model_j)
398 #endif
399  ! WDR cur_wind_speed = model_info(model_i, model_j)%wind_speed
400  cur_wind_speed = c2_model_info%wind_speed
401 
402  call set_interp_controls(i,j, scattering_angle, cur_wind_speed, drel, &
403  threshold_solar_zenith, &
404  threshold_sensor_zenith, &
405  wind_speed_only, interp_ss, interp_ms )
406 
407 ! do k=1, model_levels
408 
409 ! print*, model_info(model_i, model_j)%pressure_profile(k), &
410 ! model_info(model_i, model_j)%temp_profile(k), &
411 ! model_info(model_i, model_j)%mixr_profile(k)
412 ! print*, c2_model_inf%pressure_profile(k), &
413 ! c2_model_info%temp_profile(k), &
414 ! c2_model_info%mixr_profile(k)
415 
416 ! end do
417 
418 
419 #ifdef RETRIEVE
420  if( librarystatus == 5 ) then ! not sure if this is best way, but
421  ! keep trying till librarystatus is not 5
422  ! for being outside the table WDR
423  interp_ms = .true.
424  interp_ss = .true.
425  endif
427  sensor_zenith_angle(i,j), &
428  relative_azimuth_angle(i,j), &
429  scattering_angle, &
430  cur_wind_speed, &
431  wind_speed_only, interp_ms, interp_ss, &
432  debug, &
433  librarystatus, i, j)
434  if( librarystatus == 5 ) then
435  call assign_retrieval_error(i,j)
436  cycle
437  endif
438 #endif
439 
440  ctt_1km = cloud_top_temperature(i,j) !(save 1km ctt for to pass to clouddecision)
441 
442 ! do the IRW retrieval
443 #ifndef RETRIEVE
444 
445  ! WDRcloud_top_pressure(i,j) = model_info(model_i, model_j)%&
446  !pressure_profile(model_info(model_i, model_j)%surface_level-6)
447  !WDR cloud_top_temperature(i,j) = model_info(model_i, model_j)%&
448  !temp_profile(model_info(model_i, model_j)%surface_level-6)
449  cloud_top_pressure(i,j) = &
450  c2_model_info%pressure_profile(c2_model_info%surface_level-6)
451  cloud_top_temperature(i,j) = &
452  c2_model_info%temp_profile(c2_model_info%surface_level-6)
453 
454 #else
455 
457  !
458  ! WDR 15 jun 22 route around this, seems to be only for IR bands
459  if( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) ) then
460  if (cox_munk) then
463  sensor_zenith_angle(i,j), solar_zenith_angle(i,j), model_i, &
464  model_j, i, j)
465  else
467  surface_emissivity_land(i,j,:), &
468  sensor_zenith_angle(i,j), solar_zenith_angle(i,j), model_i, &
469  model_j, i, j)
470  endif
471  endif
472 
473 ! print*, i,j, model_i, model_j
474 ! do k=1, model_levels
475 ! print*, k, model_info(model_i,model_j)%pressure_profile(k), &
476 ! model_info(model_i,model_j)%temp_profile(k), &
477 ! model_info(model_i,model_j)%mixr_profile(k)
478 ! end do
479 
480  if (cloud_height_method(i,j) == 6) then
481  ! retrieve regular temperature
482  call retrieve_irw_temp(i,j, temp_meas(band_1100), &
483  model_i, model_j, rtm_rad_atm_clr, rtm_trans_atm_clr, &
484  rtm_cloud_prof, irw_temperature(i,j), irw_pressure, irw_dummy)
486  cloud_top_pressure(i,j) = irw_pressure
487  !
488  ! now do the stuff for uncertainty
489  call retrieve_irw_temp(i,j, temp_meas(band_1100), &
490  model_i, model_j, rtm_rad_atm_clr_low, rtm_trans_atm_clr_low, &
491  rtm_cloud_prof_low , tc_low_for_delta, temp_pres, irw_dummy )
492  call retrieve_irw_temp(i,j, temp_meas(band_1100), &
493  model_i, model_j, rtm_rad_atm_clr_high, rtm_trans_atm_clr_high, &
494  rtm_cloud_prof_high, tc_high_for_delta, temp_pres, irw_dummy )
495  !
496  else if (cloud_height_method(i,j) > 0 .and. &
497  cloud_height_method(i,j) < 6) then
499  ! for uncertainty we need to find the temperature that fits a
500  ! delta_P of 50 mb
501  ! WDR call given_P_get_T(cloud_top_pressure(i,j)-delta_Pc, &
502  ! model_info(model_i, model_j), Tc_low_for_delta)
503  call given_p_get_t(cloud_top_pressure(i,j)-delta_pc, c2_model_info, &
505  ! WDR if (cloud_top_pressure(i,j) + delta_Pc > &
506  ! model_info(model_i, model_j)%Ps) then
507  if (cloud_top_pressure(i,j) + delta_pc > c2_model_info%Ps) then
509  else
510  ! WDR call given_P_get_T(cloud_top_pressure(i,j)+delta_Pc, &
511  ! model_info(model_i, model_j), Tc_high_for_delta)
512  call given_p_get_t(cloud_top_pressure(i,j)+delta_pc, c2_model_info, &
514  endif
515  endif
516 
517  ! WDR if (cloud_top_pressure(i,j) < 0. .or. cloud_top_pressure(i,j) &
518  ! > model_info(model_i, model_j)%Ps) then
519  if (cloud_top_pressure(i,j) < 0. .or. &
520  cloud_top_pressure(i,j) > c2_model_info%Ps) then
521  ! WDR cloud_top_pressure(i,j) = model_info(model_i, model_j)%Ps
524  endif
525 #endif
526 
527 ! get above-cloud water vapor
528  ! WDR call get_above_cloud_properties(model_info(model_i,model_j)%pressure_profile(:),&
529  ! model_info(model_i,model_j)%mixr_profile(:), &
530  ! model_info(model_i,model_j)%surface_level, &
531  call get_above_cloud_properties(c2_model_info%pressure_profile(:),&
532  c2_model_info%mixr_profile(:), &
533  c2_model_info%surface_level, &
534  cloud_top_pressure(i,j), &
535  abovecloud_watervapor(i,j), &
536  status )
537 
538  tc_liquid = fillvalue_real
539  tc_ice = fillvalue_real
540 
541 
542 
543 
544 ! do atmospheric correction
545 
546  ! WDR call atmospheric_correction(i,j, iterationX, corr_meas, model_info(model_i,model_j), &
547  call atmospheric_correction(i,j, iterationx, corr_meas, c2_model_info, &
548  debug, atmoscorrstatus)
549 
550 
551 ! now we need to compute derivatives that we'll hang on to in the uncertainty calculations
552  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) )then
553  bprime_tc = 0
554  bprime_ts = 0
555  else
556  bprime_tc = &
559  (abovecloud_watervapor(i,j)*(2.*watervapor_error))
560 
561  bprime_ts = &
563  delta_ts, channel_37um, 1) - &
565  delta_ts, channel_37um, 1)) / (2.0*delta_ts)
566  endif
567 
569  (abovecloud_watervapor(i,j)*(2.*watervapor_error))
571  (abovecloud_watervapor(i,j)*(2.*watervapor_error))
572 
573 
574 
576  if (cox_munk) albedo_real4 = 0.
577 
578  rss_ice = -999.
579  rss_liq = -999.
582  alt_ray_liq = fillvalue_real
583  alt_ray_ice = fillvalue_real
584  liq_near = 0
585  ice_near = 0
586 
595 
604 
605  optical_thickness_22_liquid = fillvalue_real
606  effective_radius_22_liquid = fillvalue_real
607  optical_thickness_22_ice = fillvalue_real
608  effective_radius_22_ice = fillvalue_real
609 
610  nearest_used = 0
611  rss_final = fillvalue_real
612 
613 #ifdef RETRIEVE
614 
615  ! 1.6 2.1 3.7|2.2 1.6-2.1
616  do_retrievals_liq = (/ .true., .true., .true., .true. /)
617  do_retrievals_ice = (/ .true., .true., .true., .true. /)
618 ! WDR the 3rd do_retrievals_... is for 3.7 for MODIS and 2.2 for OCI
619 
620  call corescience (i, j, cloudsummary(i,j), corr_meas, &
621  tc_liquid, tc_ice, &
622  debug, na_band_used, liq_near, ice_near, &
623  rss_liq, rss_ice, alt_ray_liq, alt_ray_ice, &
624  do_retrievals_liq, do_retrievals_ice, retrievalstatus)
625 
626 
627  if (allocated(tau_liquid)) then
628 
629  if (optical_thickness_liquid > 0.) then
630  tau_liquid(i,j) = nint(optical_thickness_liquid / retr_scale_factor)
631  else
633  endif
634 
635  if (optical_thickness_ice > 0.) then
636  tau_ice(i,j) = nint(optical_thickness_ice / retr_scale_factor)
637  else
638  tau_ice(i,j) = fillvalue_int2
639  endif
640 
641  if (effective_radius_21_liquid > 0.) then
642  re21_liquid(i,j) = nint(effective_radius_21_liquid / retr_scale_factor)
643  else
645  endif
646 
647  if (effective_radius_21_ice > 0.) then
648  re21_ice(i,j) = nint(effective_radius_21_ice / retr_scale_factor)
649  else
650  re21_ice(i,j) = fillvalue_int2
651  endif
652 
653  endif
654 
655 
656 #endif
657 
658 
659  if (cox_munk) &
661 
662 
663 
664  if (retrievalstatus == 0 ) retrievalcount = retrievalcount+1
665  if (retrieval_failcount /= 0) retrieval_failcount = retrieval_failcount +1
666 
667 
668 ! there was no cloud
669  else
670  ! failure before retrieval
671  retrievalstatus = 1
672  call assign_retrieval_error(i,j)
673  retrieval_failcount = retrieval_failcount + 1
674  endif
675 
676 
677 
678 ! now we do cloud phase
679  cloudsummary(i,j)%cloudmask_determined = .true.
680  cloudsummary(i,j)%cloudobserved = .false.
681  cloudsummary(i,j)%watercloud = .false.
682  cloudsummary(i,j)%icecloud = .false.
683  cloudsummary(i,j)%unknowncloud = .false.
684 
685 ! set the baum phase according to the "Cloud_Phase_Infrared_1km" SDS (to pass to cloud phase and multi-layer alg.)
686 
687  ir_cloudphase%icecloud = 0
688  ir_cloudphase%watercloud = 0
689  ir_cloudphase%unknowncloud = 1
690  if (cloud_phase_infrared(i,j) == 1) ir_cloudphase%watercloud = 1
691  if (cloud_phase_infrared(i,j) == 2) ir_cloudphase%icecloud = 1
692  if (cloud_phase_infrared(i,j) == 1 .or. cloud_phase_infrared(i,j) == 2) ir_cloudphase%unknowncloud = 0
693 
695  cloudmask(i,j), &
696  corr_meas, &
697  rss_liq, &
698  rss_ice, &
707  ctt_1km, &
708  cloud_mask_spi(2,i,j)*0.01, &
709  cloud_height_method(i,j), &
710  ir_cloudphase, &
711  processing_information(i,j)%band_used_for_optical_thickness, &
712  cloudsummary(i,j), &
713  ldebug, &
714  cloudstatus, i,j)
715 
716 ! Normally, FORCE_ICE, FORCE_WATER are false and the cloud decision
717 ! above sets the cloudsummary water or ice state
718 ! force phase to ice ( Yes, for some reason, they set the contrary state and
719 ! set the right state for cloudsummary(i,j)%icecloud, watercloud)
720  if (force_ice .and. cloudsummary(i,j)%cloudobserved) then
721  cloudsummary(i,j)%watercloud = .false.
722  cloudsummary(i,j)%icecloud = .false.
723  cloudsummary(i,j)%unknowncloud = .false.
724  cloudsummary(i,j)%icecloud = .true.
725  endif
726 ! force phase to water
727  if (force_water .and. cloudsummary(i,j)%cloudobserved) then
728  cloudsummary(i,j)%watercloud = .false.
729  cloudsummary(i,j)%icecloud = .false.
730  cloudsummary(i,j)%unknowncloud = .false.
731  cloudsummary(i,j)%watercloud = .true.
732  endif
733 
734 #ifndef RETRIEVE
735  cloudsummary(i,j)%cloudobserved = .true.
736 #endif
737 
738  if (cloudsummary(i,j)%cloudobserved) then
739  ! the channels get set regardless of phase, however
740  ! 0.65um gets overwritten if rayleigh is applied later
741  atm_corr_refl(band_0065,i,j) = corr_meas(band_0065)
742  atm_corr_refl(band_0086,i,j) = corr_meas(band_0086)
743  atm_corr_refl(band_0124,i,j) = corr_meas(band_0124)
744  atm_corr_refl(band_0163,i,j) = corr_meas(band_0163)
745  atm_corr_refl(band_0213,i,j) = corr_meas(band_0213)
746  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) ) then
747  atm_corr_refl(band_0226-1,i,j) = corr_meas(band_0226)
748  else
750  endif
751 
752 
753 
754 ! set the answers based on final phase decision and do the remaining science here
755 ! we need to compute water path, multilayer and uncertainty and set the tau_out_of_bounds QA bit
756 
757 
758  if (cloudsummary(i,j)%watercloud .or. cloudsummary(i,j)%unknowncloud) then
759 
760 ! set the liquid water answers
769  if (tc_liquid > 0.) then
770  irw_temperature(i,j) = tc_liquid
771  cloud_top_temperature(i,j) = tc_liquid
772  endif
773  if( ( c2_sensor_id == oci_id ) .or. &
774  ( c2_sensor_id == ocis_id ) ) then
775  optical_thickness_22_final(i,j) = optical_thickness_22_liquid
776  effective_radius_22_final(i,j) = effective_radius_22_liquid
777  endif
778 
779  nearest_used = liq_near
780  rss_final = rss_liq
781  emission_pw = emission_uncertainty_pw_liq
782  emission_tc = emission_uncertainty_tc_liq
783  sigma_r37_pw = sigma_r37_pw_liq
784 
785 ! set the rayleigh refl here
786  if (.not. cox_munk) then
787  if (alt_ray_liq > 0.) then
788  atm_corr_refl(band_0065, i,j) = alt_ray_liq
789  else
791  re_idx_low,re_idx_hi)
792  if (rayleigh_liq(re_idx_low) > 0. .and. rayleigh_liq(re_idx_hi) > 0.) then
793  atm_corr_refl(band_0065, i,j) = &
794  linearinterpolation( (/water_radii(re_idx_low), water_radii(re_idx_hi) /), &
795  (/rayleigh_liq(re_idx_low), rayleigh_liq(re_idx_hi)/), &
797  endif
798  endif
799  endif
800 ! set the tau out of bounds bit
801 
802  if (optical_thickness_final(i,j) > 150.) then!{
803  optical_thickness_final(i,j) = 150.
804  processing_information(i,j)%optical_thickness_outofbounds = 2
805  else!}{
806  processing_information(i,j)%optical_thickness_outofbounds = 0
807  endif!}
808 
809 
810  if (optical_thickness_16_final(i,j) > 150.) &
811  optical_thickness_16_final(i,j) = 150.
812 
813  if( ( c2_sensor_id == oci_id ) .or. &
814  ( c2_sensor_id == ocis_id ) )then
815  if( ( optical_thickness_22_final(i,j) > 150.) ) &
816  optical_thickness_22_final(i,j) = 150.
817  else
818  if (optical_thickness_37_final(i,j) > 150.) &
819  optical_thickness_37_final(i,j) = 150.
820  endif
821 
822  if (optical_thickness_1621_final(i,j) > 150.) &
823  optical_thickness_1621_final(i,j) = 150.
824 
825  finalize_liq = .false.
826  finalize_ice = .false.
827  if (optical_thickness_16_final(i,j) > 0. .and. &
828  effective_radius_16_final(i,j) > 0.) &
829  finalize_liq(1) = .true.
830 
831  if (optical_thickness_final(i,j) > 0. .and. &
832  effective_radius_21_final(i,j) > 0.) &
833  finalize_liq(2) = .true.
834 
835  if( ( c2_sensor_id == oci_id ) .or. &
836  ( c2_sensor_id == ocis_id ) )then
837  if( optical_thickness_22_final(i,j) > 0. .and. &
838  effective_radius_22_final(i,j) > 0.) &
839  finalize_liq(3) = .true.
840  else
841  if (optical_thickness_37_final(i,j) > 0. .and. &
842  effective_radius_37_final(i,j) > 0.) &
843  finalize_liq(3) = .true.
844  endif
845 
846  if (optical_thickness_1621_final(i,j) > 0. .and. &
847  effective_radius_1621_final(i,j) > 0.) &
848  finalize_liq(4) = .true.
849 
850  else if(cloudsummary(i,j)%icecloud) then
851 
852 ! set the ice cloud answers
859 
860  if( ( c2_sensor_id == oci_id ) .or. &
861  ( c2_sensor_id == ocis_id ) )then
862  optical_thickness_22_final(i,j) = optical_thickness_22_ice
863  effective_radius_22_final(i,j) = effective_radius_22_ice
864  else
867  endif
868 
869  if (tc_ice > 0.) then
870  irw_temperature(i,j) = tc_ice
871  cloud_top_temperature(i,j) = tc_ice
872  endif
873 
874  nearest_used = ice_near
875  rss_final = rss_ice
876  emission_pw = emission_uncertainty_pw_ice
877  emission_tc = emission_uncertainty_tc_ice
878  sigma_r37_pw = sigma_r37_pw_ice
879 
880  if (.not. cox_munk) then
881  if (alt_ray_ice > 0.) then
882  atm_corr_refl(band_0065, i,j) = alt_ray_ice
883  else
885  re_idx_low,re_idx_hi)
886  if (rayleigh_ice(re_idx_low) > 0. .and. rayleigh_ice(re_idx_hi) > 0.) then
887  atm_corr_refl(band_0065, i,j) = &
888  linearinterpolation( (/ice_radii(re_idx_low), ice_radii(re_idx_hi) /), &
889  (/rayleigh_ice(re_idx_low), rayleigh_ice(re_idx_hi)/), &
891  endif
892  endif
893  endif
894 
895 ! set the tau out of bounds bit
896 ! the new setting indicates flagging of tau only if it's more than 150. All others are considered perfectly valid
897 
898  if (optical_thickness_final(i,j) > 150.) then!{
899  optical_thickness_final(i,j) = 150.
900  processing_information(i,j)%optical_thickness_outofbounds = 2
901  else!}{
902  processing_information(i,j)%optical_thickness_outofbounds = 0
903  endif!}
904 
905 
906  if (optical_thickness_16_final(i,j) > 150.) &
907  optical_thickness_16_final(i,j) = 150.
908 
909  if( ( c2_sensor_id == oci_id ) .or. &
910  ( c2_sensor_id == ocis_id ) ) then
911  if( optical_thickness_22_final(i,j) > 150. ) &
912  optical_thickness_22_final(i,j) = 150.
913  else
914  if( optical_thickness_37_final(i,j) > 150. ) &
915  optical_thickness_37_final(i,j) = 150.
916  endif
917 
918  if (optical_thickness_1621_final(i,j) > 150.) &
919  optical_thickness_1621_final(i,j) = 150.
920 
921 
922  finalize_liq = .false.
923  finalize_ice = .false.
924  if (optical_thickness_16_final(i,j) > 0. .and. effective_radius_16_final(i,j) > 0.) &
925  finalize_ice(1) = .true.
926  if (optical_thickness_final(i,j) > 0. .and. effective_radius_21_final(i,j) > 0.) &
927  finalize_ice(2) = .true.
928 
929  if( ( c2_sensor_id == oci_id ) .or. &
930  ( c2_sensor_id == ocis_id ) )then
931  if( optical_thickness_22_final(i,j) > 0. .and. &
932  effective_radius_22_final(i,j) > 0.) &
933  finalize_ice(3) = .true.
934  else
935  if (optical_thickness_37_final(i,j) > 0. .and. &
936  effective_radius_37_final(i,j) > 0.) &
937  finalize_ice(3) = .true.
938  endif
939 
940  if (optical_thickness_1621_final(i,j) > 0. .and. effective_radius_1621_final(i,j) > 0.) &
941  finalize_ice(4) = .true.
942 
943  endif
944 
945  call set_water_path_answers(i,j, finalize_liq, finalize_ice)
946 
947  if (optical_thickness_final(i,j) > 0. .and. effective_radius_21_final(i,j) > 0.) then
948  im_successful_retrieval_count = im_successful_retrieval_count + 1
949  endif
950 
951 ! assign the failure metric here:
952 
953 ! nearest_used and RSS_final
954  set_near = .false.
955  if (nearest_used(re16) == 1 .and. &
957  .and. effective_radius_16_final(i,j) /= fillvalue_real))) then
958  set_near(re16) = .true.
959  endif
960 
961  if (nearest_used(re21) == 1 .and. &
962  (.not. (optical_thickness_final(i,j) == max_tau_rtrieved &
963  .and. effective_radius_21_final(i,j) /= fillvalue_real))) then
964  set_near(re21) = .true.
965  endif
966 
967  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) ) then
968  if( nearest_used(re22) == 1 .and. &
969  (.not. (optical_thickness_22_final(i,j) == max_tau_rtrieved &
970  .and. effective_radius_22_final(i,j) /= fillvalue_real))) then
971  set_near(re22) = .true.
972  endif
973  else
974  if (nearest_used(re37) == 1 .and. &
976  .and. effective_radius_37_final(i,j) /= fillvalue_real))) then
977  set_near(re37) = .true.
978  endif
979  endif
980 
981  if (nearest_used(re1621) == 1) then
982  set_near(re1621) = .true.
983  endif
984 
985  call set_failure_answers(i,j,rss_final, set_near)
986 
987 ! compute multilayer
988  if ( (optical_thickness_final(i,j) > 0.) .and. &
989  ( c2_cmp_there(band_0935) == 1) .and. &
990  ( c2_cmp_there(band_1100) == 1) ) then
991 
994  temp_meas, &
995  cloudsummary(i,j), &
996  ir_cloudphase, &
997  ! WDR model_info(model_i,model_j)%pressure_profile,&
998  ! model_info(model_i,model_j)%mixr_profile(:), &
999  ! model_info(model_i,model_j)%temp_profile(:), &
1000  ! model_info(model_i,model_j)%surface_level, &
1001  c2_model_info%pressure_profile,&
1002  c2_model_info%mixr_profile(:), &
1003  c2_model_info%temp_profile(:), &
1004  c2_model_info%surface_level, &
1005  cloud_top_pressure(i,j), &
1006  abovecloud_watervapor(i,j), &
1007  sensor_zenith_angle(i,j), &
1008  solar_zenith_angle(i,j), &
1009  relative_azimuth_angle(i,j), &
1012  i, j, &
1013  cloud_layer_flag(i,j), ml_test_flag(i,j))
1014 
1015  else
1016  cloud_layer_flag(i,j) = 0
1017  ml_test_flag(i,j) = 0
1018  endif
1019 
1020 
1021 
1022 
1023 
1024 ! *** ATTENTION ****
1025 ! to do the 3.7um uncertainty, it is not enough to replace the re and tau with the 3.7um values. It is also
1026 ! necessary to set the absorbingband_index to be 3.7um to feed the libraries in. In addition to that
1027 ! the albedo_holder and R1R2wavelengthIdx arrays MUST be fed with absorbingband_index-1 !!
1028 ! If you fail to do so, you will end up with a royal mess and not know why the numbers don't make sense.
1029 ! -- G. Wind 7.5.2006
1030 
1031 
1032 ! get retrieval uncertainty estimate
1033 
1034  if ( cloudsummary(i,j)%icecloud ) then!{
1035  phase = 'ice'
1036  else!}{
1037  phase = 'water'
1038  endif!}
1039 
1040 
1041 
1042 ! if ((nearest_used(re21) == 0 .or. (nearest_used(re21) == 1 .and. optical_thickness_final(i,j) == MAX_TAU_RTRIEVED ))&
1043 ! .and. (optical_thickness_final(i,j) .ge. 0.01) .and. (effective_radius_21_final(i,j) .ge. 0.01) .and. &
1044 ! (cloudsummary(i,j)%icecloud .or. cloudsummary(i,j)%watercloud .or. cloudsummary(i,j)%unknowncloud)) then!{
1045 
1046  ! WDR - I'm keeping original 'if' decision logic above but
1047  ! cleaning it up and adding a test for na_band_used
1048  if( ( nearest_used(re21) == 0 .or. ( nearest_used(re21) == 1 &
1049  .and. optical_thickness_final(i,j) == max_tau_rtrieved ) ) &
1050  .and. ( optical_thickness_final(i,j) .ge. 0.01 ) &
1051  .and. ( effective_radius_21_final(i,j) .ge. 0.01 ) &
1052  .and. ( cloudsummary(i,j)%icecloud &
1053  .or. cloudsummary(i,j)%watercloud &
1054  .or. cloudsummary(i,j)%unknowncloud ) &
1055  .and. ( na_band_used > 0 ) ) then!{
1056 
1057 
1058  absorbingband_index = band_0213
1059 
1060 !if ( na_band_used <= 0 ) then
1061 ! print*, __FILE__, __LINE__," WDR BAD condition, na_band_used = ", &
1062 ! na_band_used
1063 !endif
1064  albedo_holder = (/albedo_real4(na_band_used), &
1065  albedo_real4(absorbingband_index)/)
1066  cloud_reflectance = (/corr_meas(na_band_used), &
1067  corr_meas(absorbingband_index)/)
1068  r1r2wavelengthidx = (/na_band_used, absorbingband_index/)
1069 
1070  if (iterationx == 1) then
1071  uncertain_start = i
1072  else
1073  uncertain_start = i+1
1074  endif
1075 
1076  unc_reflectance(1) = spec_uncertain(na_band_used) * &
1077  exp(band_uncertainty(uncertain_start,na_band_used, j)*1.0 / uncertain_sf(na_band_used)) * 0.01
1078  unc_reflectance(2) = spec_uncertain(absorbingband_index) * &
1079  exp(band_uncertainty(uncertain_start,absorbingband_index, j)*1.0 / uncertain_sf(absorbingband_index)) * 0.01
1080 
1081 
1082  if (set_bands(na_band_used) < set_bands(band_0124)) unc_reflectance(1) = max(vnir_error, unc_reflectance(1))
1083  if (set_bands(na_band_used) >= set_bands(band_0124)) unc_reflectance(1) = max(swir_error, unc_reflectance(1))
1084  if (set_bands(absorbingband_index) >= set_bands(band_0124)) unc_reflectance(2) = max(swir_error, unc_reflectance(2))
1085 
1086 
1087 
1088 ! FIVE PERCENT
1089 ! unc_reflectance = 0.05
1090 ! UNC_REFL + 2%
1091 ! unc_reflectance = sqrt ( unc_reflectance**2 + 0.02**2 )
1092 
1095  liquid_water_path(i,j), &
1096  phase, &
1097  r1r2wavelengthidx, &
1098  unc_reflectance, &
1099  albedo_holder, &
1100  transmittance_twoway(na_band_used), &
1101  transmittance_twoway(absorbingband_index), &
1102  meandelta_trans(na_band_used), &
1103  meandelta_trans(absorbingband_index), &
1104  transmittance_stddev(na_band_used), &
1105  transmittance_stddev(absorbingband_index), &
1106  emission_pw, emission_tc, sigma_r37_pw, &
1107  unc_tau_real , &
1108  unc_re21_real, &
1109  unc_lwp21_real, i, j)
1110 
1111  optical_thickness_error(i, j) = nint(unc_tau_real / unc_scale_factor)
1112  effective_radius_21_error(i, j) = nint(unc_re21_real / unc_scale_factor)
1113  liquid_water_path_error(i,j) = nint(unc_lwp21_real / unc_scale_factor)
1114 
1115 
1116  else!}{
1120  endif!}
1121 
1122  if ( unc_tau_real .lt. epsilon(unc_tau_real) .or. &
1123  unc_re21_real .lt. epsilon(unc_re21_real) .or. &
1124  unc_lwp21_real .lt. epsilon(unc_lwp21_real)) then!{
1125 
1129  endif!}
1130 
1131 
1132 
1133 
1134 ! get uncertainty estimate for 1.6um retrieval
1135  if ((nearest_used(re16) == 0 .or. (nearest_used(re16) == 1 .and. optical_thickness_16_final(i,j) == max_tau_rtrieved ))&
1136  .and. (optical_thickness_16_final(i,j) .ge. 0.01) .and. (effective_radius_16_final(i,j) .ge. 0.01) .and. &
1137  (cloudsummary(i,j)%icecloud .or. cloudsummary(i,j)%watercloud .or. cloudsummary(i,j)%unknowncloud) &
1138  .and. ( na_band_used > 0 ) ) then!{
1139 
1140 
1141 
1142  absorbingband_index = band_0163
1143 
1144  albedo_holder = (/albedo_real4(na_band_used), &
1145  albedo_real4(absorbingband_index)/)
1146  cloud_reflectance = (/corr_meas(na_band_used), &
1147  corr_meas(absorbingband_index)/)
1148  r1r2wavelengthidx = (/na_band_used, absorbingband_index/)
1149 
1150  if (iterationx == 1) then
1151  uncertain_start = i
1152  else
1153  uncertain_start = i+1
1154  endif
1155 
1156  unc_reflectance(1) = spec_uncertain(na_band_used) * &
1157  exp(band_uncertainty(uncertain_start,na_band_used, j)*1.0 / uncertain_sf(na_band_used)) * 0.01
1158  unc_reflectance(2) = spec_uncertain(absorbingband_index) * &
1159  exp(band_uncertainty(uncertain_start,absorbingband_index, j)*1.0 / uncertain_sf(absorbingband_index)) * 0.01
1160 
1161  if (set_bands(na_band_used) < set_bands(band_0124)) unc_reflectance(1) = max(vnir_error, unc_reflectance(1))
1162  if (set_bands(na_band_used) >= set_bands(band_0124)) unc_reflectance(1) = max(swir_error, unc_reflectance(1))
1163  if (set_bands(absorbingband_index) >= set_bands(band_0124)) unc_reflectance(2) = max(swir_error, unc_reflectance(2))
1164 
1167  liquid_water_path_16(i,j), &
1168  phase, &
1169  r1r2wavelengthidx, &
1170  unc_reflectance, &
1171  albedo_holder, &
1172  transmittance_twoway(na_band_used), &
1173  transmittance_twoway(absorbingband_index), &
1174  meandelta_trans(na_band_used), &
1175  meandelta_trans(absorbingband_index), &
1176  transmittance_stddev(na_band_used), &
1177  transmittance_stddev(absorbingband_index), &
1178  emission_pw, emission_tc, sigma_r37_pw, &
1179  unc_tau16_real , &
1180  unc_re16_real, &
1181  unc_lwp16_real, i, j)
1182 
1183  optical_thickness_16_error(i, j) = nint(unc_tau16_real / unc_scale_factor)
1184  effective_radius_16_error(i, j) = nint(unc_re16_real / unc_scale_factor)
1185  liquid_water_path_16_error(i, j) = nint(unc_lwp16_real / unc_scale_factor)
1186 
1187  else!}{
1191  endif!}
1192 
1193  if ( unc_tau16_real .lt. epsilon(unc_tau16_real) .or. &
1194  unc_re16_real .lt. epsilon(unc_re16_real) .or. &
1195  unc_lwp16_real .lt. epsilon(unc_lwp16_real) ) then!{
1199  endif!}
1200 
1201  ! WDR uncertainty for 2.2? we have no re uncertainty in so why bother
1202 
1203  if( ( c2_sensor_id /= oci_id ) .and. ( c2_sensor_id /= ocis_id ) )then
1204 ! get uncertainty estimate for 3.7um retrieval
1205 ! this is the initial part, without any emission uncertainty
1206 ! we are not using the transmittance table to do the atmospheric correction here, so
1207 ! for the moment uncertainty due to PW table for 3.7um is set to be 0.0
1208  if ((nearest_used(re37) == 0 .or. (nearest_used(re37) == 1 .and. optical_thickness_37_final(i,j) == max_tau_rtrieved ))&
1209  .and. (optical_thickness_37_final(i,j) .ge. 0.01) .and. (effective_radius_37_final(i,j) .ge. 0.01) .and. &
1210  (cloudsummary(i,j)%icecloud .or. cloudsummary(i,j)%watercloud .or. cloudsummary(i,j)%unknowncloud) &
1211  .and. ( na_band_used > 0 ) ) then!{
1212 
1213 
1214  absorbingband_index = band_0370
1215 
1216 
1217  albedo_holder = (/albedo_real4(na_band_used), &
1218  albedo_real4(absorbingband_index-1)/)
1219  cloud_reflectance = (/corr_meas(na_band_used), &
1220  corr_meas(absorbingband_index)/)
1221  r1r2wavelengthidx = (/na_band_used, absorbingband_index-1/)
1222 
1223  if (iterationx == 1) then
1224  uncertain_start = i
1225  else
1226  uncertain_start = i+1
1227  endif
1228 
1229  unc_reflectance(1) = spec_uncertain(na_band_used) * &
1230  exp(band_uncertainty(uncertain_start,na_band_used, j)*1.0 / uncertain_sf(na_band_used)) * 0.01
1231  unc_reflectance(2) = spec_uncertain(absorbingband_index-1) * &
1232  exp(band_uncertainty(uncertain_start,absorbingband_index-1, j)*1.0 / &
1233  uncertain_sf(absorbingband_index-1)) * 0.01
1234 
1235  if (set_bands(na_band_used) < set_bands(band_0124)) unc_reflectance(1) = max(vnir_error, unc_reflectance(1))
1236  if (set_bands(na_band_used) >= set_bands(band_0124)) unc_reflectance(1) = max(swir_error, unc_reflectance(1))
1237  if (set_bands(absorbingband_index) >= set_bands(band_0124) .and. set_bands(absorbingband_index) <= set_bands(band_0213)) &
1238  unc_reflectance(2) = max(swir_error, unc_reflectance(2))
1239 
1242  liquid_water_path_37(i,j), &
1243  phase, &
1244  r1r2wavelengthidx, &
1245  unc_reflectance, &
1246  albedo_holder, &
1247  transmittance_twoway(na_band_used), &
1248  transmittance_twoway(absorbingband_index), &
1249  meandelta_trans(na_band_used), &
1250  meandelta_trans(absorbingband_index), &
1251  transmittance_stddev(na_band_used), &
1252  transmittance_stddev(absorbingband_index), &
1253  emission_pw, emission_tc, sigma_r37_pw,&
1254  unc_tau37_real , &
1255  unc_re37_real, &
1256  unc_lwp37_real, i, j)
1257 
1258  optical_thickness_37_error(i, j) = nint(unc_tau37_real / unc_scale_factor)
1259  effective_radius_37_error(i, j) = nint(unc_re37_real / unc_scale_factor)
1260  liquid_water_path_37_error(i, j) = nint(unc_lwp37_real / unc_scale_factor)
1261 
1262  else!}{
1266  endif!}
1267 
1268  if ( unc_tau37_real .lt. epsilon(unc_tau37_real) .or. &
1269  unc_re37_real .lt. epsilon(unc_re37_real) .or. &
1270  unc_lwp37_real .lt. epsilon(unc_lwp37_real) ) then!{
1274  endif!}
1275  endif ! WDR guard this in the OCI case
1276 
1277 
1278 ! get 1621 retrieval uncertainty estimate
1279  if ((nearest_used(re1621) == 0 .or. (nearest_used(re1621) == 1 .and. optical_thickness_1621_final(i,j) == max_tau_rtrieved ))&
1280  .and. (optical_thickness_1621_final(i,j) .ge. 0.01) .and. (effective_radius_1621_final(i,j) .ge. 0.01) .and. &
1281  (cloudsummary(i,j)%icecloud .or. cloudsummary(i,j)%watercloud .or. cloudsummary(i,j)%unknowncloud) &
1282  .and. ( na_band_used > 0 ) ) then!{
1283 
1284 
1285  uncertainty_nonabsorbing_1621 = band_0163
1286  absorbingband_index = band_0213
1287 
1288 
1289  albedo_holder = (/albedo_real4(uncertainty_nonabsorbing_1621), &
1290  albedo_real4(absorbingband_index)/)
1291  cloud_reflectance = (/corr_meas(uncertainty_nonabsorbing_1621), &
1292  corr_meas(absorbingband_index)/)
1293  r1r2wavelengthidx = (/uncertainty_nonabsorbing_1621, absorbingband_index/)
1294 
1295 
1296  if (iterationx == 1) then
1297  uncertain_start = i
1298  else
1299  uncertain_start = i+1
1300  endif
1301 
1302  unc_reflectance(1) = spec_uncertain(uncertainty_nonabsorbing_1621) * &
1303  exp(band_uncertainty(uncertain_start,uncertainty_nonabsorbing_1621, j)*1.0 / &
1304  uncertain_sf(uncertainty_nonabsorbing_1621)) * 0.01
1305  unc_reflectance(2) = spec_uncertain(absorbingband_index) * &
1306  exp(band_uncertainty(uncertain_start,absorbingband_index, j)*1.0 / uncertain_sf(absorbingband_index)) * 0.01
1307 
1308  if (set_bands(uncertainty_nonabsorbing_1621) < set_bands(band_0124)) unc_reflectance(1) = max(vnir_error, unc_reflectance(1))
1309  if (set_bands(uncertainty_nonabsorbing_1621) >= set_bands(band_0124)) unc_reflectance(1) = max(swir_error, unc_reflectance(1))
1310  if (set_bands(absorbingband_index) >= set_bands(band_0124)) unc_reflectance(2) = max(swir_error, unc_reflectance(2))
1311 
1314  liquid_water_path_1621(i,j), &
1315  phase, &
1316  r1r2wavelengthidx, &
1317  unc_reflectance, &
1318  albedo_holder, &
1319  transmittance_twoway(uncertainty_nonabsorbing_1621), &
1320  transmittance_twoway(absorbingband_index), &
1321  meandelta_trans(uncertainty_nonabsorbing_1621), &
1322  meandelta_trans(absorbingband_index), &
1323  transmittance_stddev(uncertainty_nonabsorbing_1621), &
1324  transmittance_stddev(absorbingband_index), &
1325  emission_pw, emission_tc, sigma_r37_pw,&
1326  unc_tau_1621_real , &
1327  unc_re1621_real, &
1328  unc_lwp1621_real, i, j)
1329 
1330 
1331 
1332  optical_thickness_1621_error(i, j) = nint(unc_tau_1621_real / unc_scale_factor)
1333  effective_radius_1621_error(i, j) = nint(unc_re1621_real / unc_scale_factor)
1334  liquid_water_path_1621_error(i,j) = nint(unc_lwp1621_real / unc_scale_factor)
1335 
1336  else!}{
1340  endif!}
1341 
1342  if ( unc_tau_1621_real .lt. epsilon(unc_tau_1621_real) .or. &
1343  unc_re1621_real .lt. epsilon(unc_re1621_real) .or. &
1344  unc_lwp1621_real .lt. epsilon(unc_lwp1621_real)) then!{
1345 
1349  endif!}
1350 
1351  ! WDR HA! the 2.2 uncertainty would go here. Seeing as
1352  ! we could naver make uncertainty (no refl uncertainty) I'll
1353  ! leave this as a placeholder for when it can be done
1354 
1355  if (do_csr) then
1356 
1357 ! let us remember that band measurements are being overscanned
1358  if (iterationx == 1) then
1359  if (i==1) then
1360  istart = i
1361  iend = i+1
1362  endif
1363  else
1364  if (i==1) then
1365  istart = i
1366  iend = i+2
1367  endif
1368  endif
1369 
1370  if (i > 1 .and. i < xdimension) then
1371  istart = i-1
1372  iend = i+1
1373  endif
1374 
1375  if (iterationx < number_of_iterationsx) then
1376  if (i == xdimension) then
1377  istart = i-1
1378  iend = i+1
1379  endif
1380  else
1381  if (i == xdimension) then
1382  istart = i-1
1383  iend = i
1384  endif
1385  endif
1386 
1387 
1388  if (j == 1) then
1389  jstart = j
1390  jend = j+1
1391  endif
1392  if (j >=2 .and. j <= (ydimension-1)) then
1393  jstart = j-1
1394  jend = j+1
1395  endif
1396  if (j == ydimension) then
1397  jstart = j-1
1398  jend = j
1399  endif
1400 
1401  ! Check if 1km visible reflectance threshold or VIS/NIR ratio tests are applied and cloudy. Clear sky restoral
1402  ! Part V (CSR=3) test will only be applied over ocean if vis1km_test = .true. (i.e., either one of visible
1403  ! reflectance or VIS/NIR ratio tests are applied and cloudy).
1404  ! KGM 3-4-13
1405  vis1km_test = .false.
1406  if ((cloudmask(i,j)%applied_visiblereflectance==1 .and. cloudmask(i,j)%test_visiblereflectance==1) .or. &
1407  (cloudmask(i,j)%applied_visnirratio==1 .and. cloudmask(i,j)%test_visnirratio==1) ) vis1km_test = .true.
1408 
1409  call cloudiness_test (cloudmask(i,j), &
1410  cloudsummary(i,j), &
1411  temp_meas, &
1412  band_measurements(istart:iend,:,jstart:jend), &
1413  sunglint_dust_test, &
1414  lowvariability_confidence_test, &
1415  csr_flag_array(i,j), latitude(i,j), &
1416  cloud_height_method(i,j), vis1km_test) ! KGM 3-4-13 GW 3.28.13
1417 
1418  if (csr_flag_array(i,j) == 2 .and. cloudsummary(i,j)%ocean_surface) then
1419 #ifdef RETRIEVE
1420  call compute_aod(i, j, scattering_angle, corr_meas, cur_wind_speed, aod550)
1421 
1422  ! if the aerosol optical depth is too much then it's probably a cloud
1423  ! and we can keep the retrieval, however we will mark it as a potentially
1424  ! problematic cloud.
1425  if (aod550 > 0.95) then ! aod550 is a ln(aod+0.01) quantity
1426  csr_flag_array(i,j) = 0
1427  endif
1428 #endif
1429  endif
1430 
1431  endif
1432 
1433 #ifndef RETRIEVE
1434 
1435 
1436 
1437  if (surface_albedo(i,j,1) < 300 .and. .not. cloudmask(i,j)%desert_surface .and. &
1438  .not. cloudsummary(i,j)%snowice_surface ) then
1439 
1440 
1441 
1442  call compute_aod(i, j, scattering_angle, corr_meas, cur_wind_speed, aod550)
1443  aod550_store(i,j) = (exp(aod550) - 0.01) ! that's so it can be stored in a good way in an RE sds
1444  if (aod550_store(i,j) < 0.) aod550_store(i,j) = 0.01
1445 
1446  else
1447  aod550_store(i,j) = fillvalue_real
1448  endif
1449 
1450 #endif
1451 
1452  else
1453  retrievalstatus = 1
1454  call assign_retrieval_error(i,j)
1455  retrieval_failcount = retrieval_failcount + 1
1456  endif
1457 
1458  enddo
1459 enddo
1460 ! end of loop over the data blob
1461 
1462 ! WDR capture the working arrays before modification
1463  call capture_arrays
1464 
1465  call cleanup_retrieval
1466 
1467 ! print*, "NUM_INTERP:", count_interpolations
1468 
1469 ! print*, "num_sza: ", cnt_sza
1470 ! print*, "num_vza: ", cnt_vza
1471 ! print*, "num_raz: ", cnt_raz
1472 ! print*, "num_scat: ", cnt_scat
1473 ! print*, "num_cm_switch: ", cnt_cm_switch
1474 ! print*, "num_wspeed: ", cnt_wspeed
1475 ! print*, "** wind speed only: ", cnt_wspeed_only
1476 
1477 ! Now that we've done the clear sky restoral, we remove the edges of the clouds (ED)
1478 ! WDR temp to set so no remove done
1479  if (do_csr) then !{
1480 
1482  csr_flag_array, &
1483  xdimension, ydimension, &
1484  status)
1485 
1486 
1487 ! reset cloudsummary variables for pixels "cleared" by CSR or ED, this
1488 ! step necessary
1489 ! so that "cleared" pixels in cloud optical properties SDS get set to
1490 ! clear, and
1491 ! so that pertainent QA can be properly identified when set GTA 6/7/05
1492 
1493 ! endif
1494 
1495  where(csr_flag_array == 2)
1496  cloudsummary%cloudobserved = .false.
1497  cloudsummary%watercloud = .false.
1498  cloudsummary%icecloud = .false.
1499  cloudsummary%unknowncloud = .false.
1500 
1520  cloud_layer_flag = 0
1521  ml_test_flag = 0
1527 
1531 
1535 
1539 
1543 
1546  end where
1547 
1548  if( ( c2_sensor_id == oci_id ) .or. ( c2_sensor_id == ocis_id ) )then
1549  where(csr_flag_array == 2)
1550  optical_thickness_22_final = fillvalue_real
1551  effective_radius_22_final = fillvalue_real
1552  liquid_water_path_22 = fillvalue_real
1553  effective_radius_22_error = fillvalue_int2
1554  liquid_water_path_22_error = fillvalue_int2
1555  optical_thickness_22_error = fillvalue_int2
1556  failure_metric_22%tau = fillvalue_int2
1557  failure_metric_22%re = fillvalue_int2
1558  failure_metric_22%RSS = fillvalue_int2
1559  end where
1560  endif
1561 
1562 ! Now split off the PCL retrievals
1563 ! if it's an edge pixel or a 250m variable pixels then
1564 ! split off the retrieval to the PCL storage and get rid of the value in
1565 ! main retrieval arrays
1566  call split_pcl(xdimension, ydimension)
1567 
1568  endif !}
1569 
1570 
1571 
1572 
1573 ! now we need to compute the inventory metadata that relates to the cloudiness percentage
1574 ! water cloud percentage and ice cloud percentage. We need to aggregate the little suckers
1575 
1576  do i=1, xdimension
1577  do j = 1, ydimension
1578 
1579 ! first of all we need to make sure that we have a cloud
1580  if (solar_zenith_angle(i,j) <= solar_zenith_threshold .and. &
1581  cloudsummary(i,j)%cloudobserved) then
1582  im_cloudy_count = im_cloudy_count + 1
1583 
1584 ! now that we're sure, we can count the ice and water cloud pixels
1585  if (cloudsummary(i,j)%watercloud) then
1586  im_water_cloud_count = im_water_cloud_count + 1
1587  endif
1588  if (cloudsummary(i,j)%icecloud) then
1589  im_ice_cloud_count = im_ice_cloud_count + 1
1590  endif
1591 
1592  if (cloudsummary(i,j)%unknowncloud) then
1593  im_undet_count = im_undet_count + 1
1594  endif
1595 
1596  endif
1597 
1598  end do
1599  end do
1600 
1601 
1602 ! optical_thickness_final = abovecloud_watervapor
1603 ! effective_radius_16_final = cloud_top_pressure
1604 
1605 #ifndef RETRIEVE
1606  effective_radius_21_final(:,:) = aod550_store(:,:)
1607  deallocate(aod550_store)
1608 #endif
1609 
1610 ! print*, abovecloud_watervapor(14,884), cloud_top_pressure(14,884), surface_temperature(14,884)
1611 
1612 ! WDR complete the processing_information setup with call to set_quality_data
1613  call set_quality_data( xdimension, ydimension )
1614 
1615 ! print*, optical_thickness_final(19, 1992)
1616 ! print*, effective_radius_16_final (19, 1992)
1617 ! print*, effective_radius_21_final (19, 1992)
1618 ! print*, effective_radius_37_final(19, 1992)
1619 
1620  end subroutine scienceinterface
1621 
1622 subroutine compute_aod(x, y, scat_ang, corr_meas, ws, aod550)
1624  use core_arrays
1625  use mod06_run_settings
1626  use science_parameters, only: d2r
1629 
1630  integer, intent(in) :: x, y
1631  real, intent(in) :: scat_ang, ws
1632  real, intent(inout) :: aod550
1633  real, dimension(:), intent(in) :: corr_meas
1634 
1635  external ffnet_terra, ffnet_aqua, ffnet_aqua_land, ffnet_terra_land
1636 
1637  real*8 :: input(15), output(1), input_land(14)
1638  real*8 :: ga, sza, vza, saz, vaz, raz, sca
1639  real :: check_val, temp_16
1640  integer :: i
1641 
1642  sza = solar_zenith_angle(x,y)
1643  vza = sensor_zenith_angle(x,y)
1644  saz = solar_azimuth_angle(x,y)
1645  vaz = sensor_azimuth_angle(x,y)
1646  raz = relative_azimuth_angle(x,y)
1647 
1648  ga = cos(sza*d2r) * cos(vza*d2r) + sin(sza*d2r) * sin(vza*d2r) * cos(raz*d2r)
1649 
1650  sca = cos(scat_ang*d2r)*1.0d0
1651  saz = cos(saz*d2r)*1.0d0
1652  sza = cos(sza*d2r)*1.0d0
1653  vaz = cos(vaz*d2r)*1.0d0
1654  vza = cos(vza*d2r)*1.0d0
1655 
1656 !tbsS'InputNames ocean'
1657 !S'mRef470'
1658 !aS'mRef550'
1659 !aS'mRef660'
1660 !aS'mRef870'
1661 !aS'mRef1200'
1662 !aS'mRef1600'
1663 !aS'mRef2100'
1664 !aS'ScatteringAngle'
1665 !aS'GlintAngle'
1666 !aS'SolarAzimuth'
1667 !aS'SolarZenith'
1668 !aS'SensorAzimuth'
1669 !aS'SensorZenith'
1670 !aS'cloud'
1671 !aS'wind'
1672 
1673 
1674  if (cloudsummary(x,y)%ocean_surface) then
1675 
1676  input = (/ corr_meas(band_0047)*1.0d0, &
1677  corr_meas(band_0055)*1.0d0, &
1678  corr_meas(band_0065)*1.0d0, &
1679  corr_meas(band_0086)*1.0d0, &
1680  corr_meas(band_0124)*1.0d0, &
1681  corr_meas(band_0163)*1.0d0, &
1682  corr_meas(band_0213)*1.0d0, &
1683  sca, ga, saz, sza, vaz, vza, 0.0d0, &
1684  ws*1.0d0 /)
1685 
1686  if ( corr_meas(band_0163) < 0.) then
1687 
1688  temp_16 = linearinterpolation( (/1.24, 2.13/), (/corr_meas(band_0124), corr_meas(band_0213)/), 1.63)
1689  input(6) = temp_16*1.0d0
1690 
1691  endif
1692 
1693  if (platform_name(1:4) == "Aqua") call ffnet_aqua(input, output)
1694  if (platform_name(1:5) == "Terra") call ffnet_terra(input, output)
1695  else
1696 
1697 
1698  input_land = (/ corr_meas(band_0055)*1.0d0, &
1699  corr_meas(band_0047)*1.0d0, &
1700  corr_meas(band_0065)*1.0d0, &
1701  corr_meas(band_0086)*1.0d0, &
1702  corr_meas(band_0124)*1.0d0, &
1703  corr_meas(band_0163)*1.0d0, &
1704  corr_meas(band_0213)*1.0d0, &
1705  sca, saz, sza, vaz, vza, 0.0d0, albedo_real4(band_0065)*1.0d0 /) ! this is really a 550nm albedo
1706  ! look at ancillary module and see
1707 
1708  if ( corr_meas(band_0163) < 0.) then
1709 
1710  temp_16 = linearinterpolation( (/1.24, 2.13/), (/corr_meas(band_0124), corr_meas(band_0213)/), 1.63)
1711  input(6) = temp_16*1.0d0
1712 
1713  endif
1714 
1715  if (platform_name(1:4) == "Aqua") call ffnet_aqua_land(input_land, output)
1716  if (platform_name(1:5) == "Terra") call ffnet_terra_land(input_land, output)
1717  endif
1718 
1719  aod550 = output(1) ! ln(aod+0.01)
1720 
1721 end subroutine compute_aod
1722 
1723 subroutine fill_c2_mdl( i, j )
1724  !
1725  ! WDR fill_c2_mdl will make a 'ancillary_type' structure like model_info
1726  ! has but for just 1 point of interest
1727  !
1728  ! i, j pixel, line, coordinates in the current granule chunk
1729  !
1730  ! WDR 27 Nov 2018
1731  !
1732  use core_arrays, only: c2_model_info
1736 
1737  integer, intent(in) :: i, j
1738 
1739  c2_model_info%mixr_profile = c2_prof_mixr( i, j, : )
1740  c2_model_info%temp_profile = c2_prof_t( i, j, : )
1741  c2_model_info%height_profile = c2_prof_hgt( i, j, : )
1742  c2_model_info%pressure_profile = c2_prof_p( i, j, : )
1743  ! c2_model_info%o3_profile - not used, I think
1744  c2_model_info%o3_profile = 0
1745  c2_model_info%Ts = c2_tsfc( i, j )
1746  c2_model_info%Ps = c2_psfc( i, j )
1747  c2_model_info%wind_speed = c2_wind( i, j )
1748  c2_model_info%col_o3 = c2_tot_o3( i, j )
1749  c2_model_info%seaice_fraction = c2_ice_frac( i, j )
1750  c2_model_info%snow_fraction = c2_snow_frac( i, j )
1751  c2_model_info%surface_level = c2_sfc_lvl( i, j )
1752  c2_model_info%trop_level = c2_trop_lvl( i, j )
1753  ! c2_model_info%LSM = Not sure if used again
1754  c2_model_info%LSM = 0
1755 
1756 end subroutine fill_c2_mdl
1757 
1758 end module modis_science_module
1759 
Definition: ch_xfr.f90:1
integer *2, dimension(:,:), allocatable optical_thickness_37_error
Definition: core_arrays.f90:76
real, dimension(:,:), allocatable c2_alt_icec
Definition: ch_xfr.f90:20
integer *1, dimension(:,:), allocatable c2_trop_lvl
Definition: ch_xfr.f90:26
real, dimension(:,:), allocatable c2_psfc
Definition: ch_xfr.f90:17
real, dimension(nchan, model_levels), public rtm_trans_atm_clr
Definition: rtm_support.f90:47
integer, parameter re21
real optical_thickness_16_liquid
Definition: core_arrays.f90:24
integer, dimension(:,:), allocatable c2_alt_snowice
Definition: ch_xfr.f90:27
real, dimension(nchan, model_levels), public rtm_rad_atm_clr_low
Definition: rtm_support.f90:59
real(single), dimension(:,:), allocatable liquid_water_path
Definition: core_arrays.f90:65
integer, parameter band_0124
subroutine, public scienceinterface(threshold_solar_zenith, threshold_sensor_zenith, threshold_relative_azimuth, debug, status)
integer(integer_onebyte), dimension(:,:), allocatable cloud_layer_flag
Definition: core_arrays.f90:92
real, dimension(:,:,:), allocatable c2_prof_hgt
Definition: ch_xfr.f90:16
integer *2, dimension(:,:), allocatable effective_radius_16_error
Definition: core_arrays.f90:80
real, dimension(nchan, model_levels), public rtm_trans_atm_clr_low
Definition: rtm_support.f90:58
real, dimension(2) thermal_correction_oneway_high
real, dimension(set_number_of_bands) meandelta_trans
integer ocis_id
Definition: ch_xfr.f90:51
real, dimension(2) thermal_correction_twoway_high
real, dimension(20) sigma_r37_pw_liq
subroutine set_quality_data(xsize, ysize)
integer *2, dimension(:,:), allocatable liquid_water_path_16_error
Definition: core_arrays.f90:85
subroutine set_interp_controls(i, j, scattering_angle, cur_wind_speed, drel, threshold_solar_zenith, threshold_sensor_zenith, wind_speed_only, interp_SS, interp_MS)
subroutine get_model_idx_geos5(grid_xstart, grid_ystart, lat, lon, model_i, model_j)
type(cloudmask_type), dimension(:,:), allocatable cloudmask
integer *2, dimension(:,:,:), allocatable cloud_mask_spi
real optical_thickness_1621_ice
Definition: core_arrays.f90:26
real(single), dimension(:,:), allocatable optical_thickness_37_final
Definition: core_arrays.f90:41
real(single), dimension(:,:), allocatable longitude
real, dimension(20) sigma_r37_pw_ice
real(single), dimension(:,:), allocatable effective_radius_37_final
Definition: core_arrays.f90:46
real(single), dimension(:,:), allocatable cloud_top_pressure
real effective_radius_21_ice
Definition: core_arrays.f90:27
integer, parameter band_0047
integer, parameter re37
subroutine assign_retrieval_error(xpoint, ypoint)
integer *2, dimension(:,:), allocatable optical_thickness_1621_error
Definition: core_arrays.f90:88
real function, public linearinterpolation(X, Y, XX)
real function, public scatangle(solarAng, viewAng, relAzm)
integer *2, dimension(:,:), allocatable tau_liquid
Definition: core_arrays.f90:34
real, dimension(:,:), allocatable irw_temperature
real(single), dimension(:,:), allocatable latitude
integer *2, dimension(:,:), allocatable optical_thickness_error
Definition: core_arrays.f90:73
subroutine get_model_idx(lat, lon, i, j)
real optical_thickness_ice
Definition: core_arrays.f90:23
real effective_radius_21_liquid
Definition: core_arrays.f90:27
subroutine, public libraryinterpolate(local_solarzenith, local_sensorzenith, local_relativeazimuth, local_scatangle, local_wind_speed, wind_speed_only, interp_MS, interp_SS, debug, status, i, j)
real, dimension(set_number_of_bands) transmittance_twoway
real, dimension(nchan, model_levels), public rtm_cloud_prof_high
Definition: rtm_support.f90:65
real, dimension(:,:,:), allocatable c2_prof_mixr
Definition: ch_xfr.f90:15
integer, parameter set_albedo_bands
integer *2, parameter fillvalue_int2
real, dimension(:,:,:), allocatable atm_corr_refl
character *15 platform_name
real, dimension(:,:), allocatable sensor_azimuth_angle
integer, parameter band_0370
real optical_thickness_16_ice
Definition: core_arrays.f90:24
#define real
Definition: DbAlgOcean.cpp:26
integer *1, dimension(:,:), allocatable cloud_phase_infrared
subroutine, public init_rtm_vars()
Definition: rtm_support.f90:89
integer, parameter band_1100
real effective_radius_1621_ice
Definition: core_arrays.f90:31
subroutine ffnet_aqua_land(input, output)
integer, parameter band_0226
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
integer, parameter band_0086
subroutine split_pcl(xdim, ydim)
integer, parameter band_0213
real effective_radius_37_liquid
Definition: core_arrays.f90:32
type(processflag), dimension(:,:), allocatable cloudsummary
real(single), dimension(:), allocatable water_radii
integer *2, dimension(:,:), allocatable liquid_water_path_37_error
Definition: core_arrays.f90:86
real, parameter albedo_fac
real, dimension(nchan, model_levels), public rtm_trans_atm_clr_high
Definition: rtm_support.f90:63
real(single), dimension(:), allocatable library_taus
real, dimension(:,:), allocatable c2_tsfc
Definition: ch_xfr.f90:17
real, dimension(20) emission_uncertainty_tc_liq
real, dimension(nchan, model_levels), public rtm_rad_atm_clr
Definition: rtm_support.f90:48
subroutine, public get_above_cloud_properties(pprof, wprof, sfc_lev, cloud_top_pressure, abovecloud_watervapor, status)
real optical_thickness_37_liquid
Definition: core_arrays.f90:25
integer, parameter channel_37um
real optical_thickness_1621_liquid
Definition: core_arrays.f90:26
subroutine set_cox_munk_albedo(albedo, lib_albedo)
type(failed_type), dimension(:,:), allocatable failure_metric_16
real tc_low_for_delta
subroutine set_water_path_answers(i, j, finalize_liq, finalize_ice)
subroutine, public getuncertainties(thickness, re, water_path, phase, R1R2wavelengthIdx, meas_error, surface_albedo, transmittance_w1, transmittance_w2, delta_transmittance_w1, delta_transmittance_w2, transmittance_stddev_w1, transmittance_stddev_w2, emission_pw, emission_Tc, sigma_R37_pw, uTau, uRe, uWaterPath, xpoint, ypoint)
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 liquid_water_path_37
Definition: core_arrays.f90:68
real, dimension(nchan, model_levels), public rtm_cloud_prof_low
Definition: rtm_support.f90:60
logical, parameter force_water
real(single), dimension(:,:), allocatable optical_thickness_final
Definition: core_arrays.f90:38
integer scn_loop_en
real(single), dimension(:,:,:), allocatable int_surface_emissivity_water
#define max(A, B)
Definition: main_biosmap.c:61
real, dimension(:,:), allocatable c2_ice_frac
Definition: ch_xfr.f90:19
real optical_thickness_37_ice
Definition: core_arrays.f90:25
endif() set(LIBS $
Definition: CMakeLists.txt:6
real optical_thickness_liquid
Definition: core_arrays.f90:23
real, dimension(nchan, model_levels), public rtm_cloud_prof
Definition: rtm_support.f90:49
type(failed_type), dimension(:,:), allocatable failure_metric
real function, public modis_planck(platform_name, TEMP, BAND, UNITS)
real(single), dimension(:,:), allocatable liquid_water_path_1621
Definition: core_arrays.f90:69
real, dimension(:), allocatable rayleigh_liq
integer, parameter re22
subroutine set_failure_answers(i, j, RSS_final, set_near)
real(single), dimension(:), allocatable ice_radii
integer *2, dimension(:,:), allocatable liquid_water_path_1621_error
Definition: core_arrays.f90:90
integer scn_loop_st
subroutine, public cloudiness_test(cloudmask, process_summary, measurement, reflectance_box, not_cloud, lowvariability_confidence_test, CSR_QA, latitude, chm, vis1km_test)
subroutine, public get_rtm_parameters(platform, surface_emissivity, view_zenith, sun_zenith, i, j, x, y)
real, dimension(20) emission_uncertainty_pw_liq
type(ancillary_type), dimension(:,:), allocatable model_info
integer, parameter band_0163
real effective_radius_37_ice
Definition: core_arrays.f90:32
integer c2_sensor_id
Definition: ch_xfr.f90:50
logical, parameter do_csr
subroutine init_retrieval(library_taus)
integer *2, dimension(:,:), allocatable re21_liquid
Definition: core_arrays.f90:34
real, dimension(:,:,:), allocatable c2_prof_p
Definition: ch_xfr.f90:16
real, dimension(:,:), allocatable precip_water_094
real(single), dimension(:,:), allocatable cloud_top_temperature
real(single), dimension(:,:,:), allocatable surface_emissivity_land
subroutine set_drel(threshold_relative_azimuth, drel)
subroutine, public atmospheric_correction(xpoint, ypoint, iteration, meas_out, model, debug, status)
integer, dimension(set_number_of_bands), parameter set_bands
type(ancillary_type) c2_model_info
#define pi
Definition: vincenty.c:23
integer, parameter my_unit_lun
Definition: names.f90:47
real(single), dimension(:,:,:), allocatable band_measurements
real effective_radius_16_liquid
Definition: core_arrays.f90:30
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 surface_temperature
subroutine ffnet_terra(input, output)
real(single), dimension(:,:,:), allocatable int_reflectance_water
integer, parameter band_0065
real(single), dimension(:,:), allocatable optical_thickness_1621_final
Definition: core_arrays.f90:42
Definition: names.f90:1
real tc_high_for_delta
subroutine phase
Definition: phase.f:2
subroutine, public corescience(xpoint, ypoint, process, measurements, Tc_liquid, Tc_ice, debug, na_band_used, nearest_liq, nearest_ice, RSS_liq, RSS_ice, alt_ray_liq, alt_ray_ice, do_retrievals_liq, do_retrievals_ice, status)
integer *2, dimension(:,:), allocatable re21_ice
Definition: core_arrays.f90:35
subroutine, public retrieve_irw_temp(x, y, I11_meas, idx_i, idx_j, clear_rad_table, clear_trans_table, cloud_prof, irw_temp, irw_pressure, irw_height)
integer *2, dimension(:,:), allocatable effective_radius_1621_error
Definition: core_arrays.f90:89
real effective_radius_16_ice
Definition: core_arrays.f90:30
integer c2_scan
Definition: ch_xfr.f90:46
type(qualityanalysis), dimension(:,:), allocatable processing_information
integer *2, dimension(:,:), allocatable effective_radius_21_error
Definition: core_arrays.f90:78
integer, parameter band_0935
integer, parameter band_0055
real(single), dimension(:,:), allocatable liquid_water_path_16
Definition: core_arrays.f90:67
integer, parameter set_number_of_bands
real(single), dimension(:,:), allocatable abovecloud_watervapor
integer *1, dimension(:,:), allocatable c2_sfc_lvl
Definition: ch_xfr.f90:26
type(failed_type), dimension(:,:), allocatable failure_metric_37
real, dimension(20) emission_uncertainty_pw_ice
real, dimension(:,:,:), allocatable band_uncertainty
integer oci_id
Definition: ch_xfr.f90:52
real, dimension(:,:), allocatable c2_alt_o3
Definition: ch_xfr.f90:20
real(single), dimension(:,:), allocatable optical_thickness_16_final
Definition: core_arrays.f90:40
real(single), dimension(:,:), allocatable effective_radius_16_final
Definition: core_arrays.f90:43
real, dimension(set_number_of_bands) transmittance_stddev
real, dimension(:), allocatable rayleigh_ice
subroutine, public bisectionsearch(xx, x, jlo, jhi)
real, dimension(:,:), allocatable solar_azimuth_angle
real, dimension(nchan, model_levels), public rtm_rad_atm_clr_high
Definition: rtm_support.f90:64
integer *1, dimension(:,:), allocatable cloud_height_method
subroutine, public given_p_get_t(P, model_point, T)
real, dimension(2) thermal_correction_oneway_low
real, dimension(2) thermal_correction_twoway_low
integer *2, dimension(:,:), allocatable optical_thickness_16_error
Definition: core_arrays.f90:75
real transprime_1way
subroutine ffnet_terra_land(input, output)
subroutine ffnet_aqua(input, output)
real, dimension(:,:), allocatable c2_snow_frac
Definition: ch_xfr.f90:19
real, dimension(:,:), allocatable c2_wind
Definition: ch_xfr.f90:18
subroutine, public compute_multilayer_map(platform_name, BigTransTable, measurements, cloud_phase, Baum_phase, p_ncep, mixR_ncep, t_ncep, surface, MOD06_Pc, MOD06_PW, sat_zen, sol_zen, rel_az, tau, tau1621, xpoint, ypoint, mlayer, mlayer_test)
real, dimension(set_albedo_bands) albedo_real4
integer *2, dimension(:,:), allocatable tau_ice
Definition: core_arrays.f90:34
subroutine clouddecision(platform_name, cloudmask, measurements, RSSLiq, RSSIce, optical_thickness_liquid, optical_thickness_ice, effective_radius_16_liquid, effective_radius_21_liquid, effective_radius_37_liquid, effective_radius_16_ice, effective_radius_21_ice, effective_radius_37_ice, cloud_top_temperature_1km, cloud_mask_SPI, cloudHeightMethod, ir_phase, procflag_band_used_ot, cloudsummary, debug, status, i, j)
Definition: cloud_phase.f90:27
real, dimension(:,:,:,:), allocatable transmit_correction_table
integer *2, dimension(:,:), allocatable effective_radius_37_error
Definition: core_arrays.f90:81
logical, parameter force_ice
real, dimension(:,:,:), allocatable c2_prof_t
Definition: ch_xfr.f90:15
real(single), dimension(:,:), allocatable effective_radius_1621_final
Definition: core_arrays.f90:47
subroutine remove_edge_scenes(cloudmask, CSR_results, xsize, ysize, status)
real transprime_2way
logical, parameter do_cox_munk
integer, parameter re1621
real, dimension(:,:), allocatable c2_tot_o3
Definition: ch_xfr.f90:17
integer *1, dimension(:), allocatable c2_cmp_there
Definition: ch_xfr.f90:43
subroutine compute_aod(x, y, scat_ang, corr_meas, ws, aod550)
real, dimension(20) emission_uncertainty_tc_ice
integer, parameter re16
real effective_radius_1621_liquid
Definition: core_arrays.f90:31
real(single), dimension(:,:), allocatable effective_radius_21_final
Definition: core_arrays.f90:44