OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
mod_pr06od.f90
Go to the documentation of this file.
1  subroutine mod_pr06od( statistics, errorlevel)
2 
3 !-----------------------------------------------------------------------
4 !f90 mod_pr06od
5 !
6 !Description:
7 !
8 ! retrieve cloud optical and microphysical properties from MODIS radiation
9 ! measurements
10 !
11 !input parameters:
12 !
13 !output parameters:
14 !
15 !revision history:
16 !
17 ! v.1 July 2001 Initial work mag gray@climate.gsfc.nasa.gov
18 !
19 !team-unique header:
20 !
21 ! Cloud Retrieval Group, NASA GSFC, Greenbelt, Maryland, USA
22 !
23 !references and credits:
24 !
25 ! Mark Gray
26 ! gray@climate.gsfc.nasa.gov
27 ! EmergentIT
28 ! Code 913, NASA GSFC
29 ! Greenbelt, MD 20771
30 !
31 ! Nakajima, T. and M.D. King, 1990: determination of the
32 ! optical thickness and effective particle radius of
33 ! clouds from reflected solar radiation measurements
34 ! part i: theory. j. atmos. sci., 47, 1878-1893.
35 !
36 !design note:
37 !
38 !end
39 !----------------------------------------------------------------------
40 
41 
42  use generalauxtype
43  use core_arrays
47  use specific_other
48  use modis_io_module
51  use libraryarrays
54  use names
56 ! WDR use shared_io_module
57 ! WDR need transfer information
58  use ch_xfr
59 
60 #if VIIRS_INST
61  use mod06_run_settings, only: iff_yes, nasa_l1b
62 #endif
63 
64 #if AHI_INST
66 #endif
67 
68 #if !AMS_INST & !ASTER_INST & !AVIRIS_INST & !RSP_INST & !EPIC_INST & !SSFR_INST
69  use retrieval_irw
71 #endif
72 
73 #ifdef EMAS_INST
74  use modis_cirrus_module
75 #endif
76 
77  implicit none
78 
79 #if HAVE_MPI
80 ! include 'mpif.h'
81 #endif
82 
83 ! include "hdf.f90"
84 ! include "dffunc.f90"
85 
86  integer, parameter :: MODFILLEN = 10
87  real, intent(out) :: statistics(7)
88  integer, intent(out) :: errorlevel
89 
90  integer, dimension (2) :: start, edge, stride
91  integer, dimension (2) :: localstart, localedge, localstride
92 !WDR added
93  integer, dimension (2) :: l2_start
94  integer, dimension(2) :: meas_start, meas_edge
95 
96  integer :: status, tilesize
97  integer :: debug_start_iteration = 0, debug_stop_iteration = 0
98 
99  real :: threshold_solar_zenith, &
100  threshold_sensor_zenith, &
101  threshold_relative_azimuth
102 
103  integer :: l1b_filedata(set_number_of_bands), &
104  cloudmask_filedata(1), &
105  geolocation_filedata(1), &
106  mod06_filedata(2), &
107  angle_filedata(1)
108 
109  logical :: debug
110 
111  integer :: start_iteration
112 
113  integer :: file_id, var_id, err_code, mystart(2), mystride(2), myedge(2)
114 
115 ! integer*1, dimension(:,:), allocatable :: eco, snow, sfc
116 ! real, dimension(:,:), allocatable :: albedo
117 
118  integer :: start_time, end_time, crate, cmax, total_start, total_end
119  integer :: st1, et1, cr1, cm1, anc_filedata(2)
120 
121  integer :: start_iterationX, start_iterationY
122  integer :: granule_offset(2)
123 
124  integer :: mpi_stepX, mpi_stepY, mpi_index
125  integer :: mpi_rc, mpi_err
126 !WDR indicies
127  integer :: iwdr, jwdr
128 ! WDR need def here
129  integer, parameter :: fail= -1
130 
131 #if HAVE_MPI
132  call mpi_init(mpi_err)
133  if (mpi_err /= mpi_success) then
134  print *,'Error starting MPI program. Terminating.'
135  call mpi_abort(mpi_comm_world, mpi_rc, mpi_err)
136  end if
137 
138  call mpi_comm_rank(mpi_comm_world, mpi_rank, mpi_err)
139  call mpi_comm_size(mpi_comm_world, mpi_nprocs, mpi_err)
140 #else
141  mpi_rank = 0
142  mpi_nprocs = 1
143 #endif
144 
145 
146 ! call system_clock(total_start, crate, cmax)
147 ! print*, "system speed: ", crate, " cycles/sec"
148 
149 
150  im_cloudy_count = 0
153  im_undet_count = 0
154 
155  statistics_1km%retrieval_fraction = 0.
156  statistics_1km%land_fraction = 0.
157  statistics_1km%water_fraction = 0.
158  statistics_1km%snow_fraction = 0.
159  statistics_1km%cloud_fraction = 0.
160  statistics_1km%water_cloud_fraction = 0.
161  statistics_1km%ice_cloud_fraction = 0.
162  statistics_1km%mean_liquid_tau = 0.
163  statistics_1km%mean_ice_tau = 0.
164  statistics_1km%mean_liquid_re21 = 0.
165  statistics_1km%mean_ice_re21 = 0.
166  statistics_1km%ctp_liquid = 0.
167  statistics_1km%ctp_ice = 0.
168  statistics_1km%ctt_ice = 0.
169  statistics_1km%ctt_liquid = 0.
170  statistics_1km%ctp_undetermined = 0.
171  statistics_1km%ctt_undetermined = 0.
172 
173 
174  status = success
175  errorlevel = 0
176  statistics(:) = .0
177 
178 ! get runtime setup parameters, array sizes, lat/long-pixel limits
179  call initialize_run ( start, edge, stride, &
180  tilesize, &
181  threshold_solar_zenith, &
182  threshold_sensor_zenith, &
183  threshold_relative_azimuth,&
184  status )
185  if (status /= success) then
186  call local_message_handler('Problem reported in initialize_run. Check previous message/s', status,'mod_pr06od')
187  endif
188 
189 #ifndef SIM
190 ! check that all files exist and are openable
191 ! if not there is a complete algorithm failure
192  if( status == success) then
193  call check_datasources(status)
194 
195  if (status /= success) then
196  call local_message_handler('Problem reported in check_datasources. Check previous message/s', status,'mod_pr06od')
197  endif
198  endif
199 
200 
201 ! open core hdf files for reading and check
202 ! WDR not needed
203 ! if (status == success) then
204 ! call openclose_files ('open', &
205 ! l1b_filedata, &
206 ! cloudmask_filedata, &
207 ! geolocation_filedata,&
208 ! mod06_filedata, &
209 ! status)
210 ! if (status /= success) then
211 ! call local_message_handler('Problem reported in openclose_files . Check previous message/s', status,'mod_pr06od')
212 ! endif
213 ! endif
214 
215 
216 ! check the size of the array/s to be processed
217 ! if (status == success) then
218 ! WDR knock out l1b io
219 ! call check_datasize(l1b_filedata, start, stride, edge, status)
220 ! if (status /= success) then
221 ! call local_message_handler('Problem reported in check_datasize . Check previous message/s', status,'mod_pr06od')
222 ! endif
223 ! endif
224 
225 ! WDR try to insert the outside 'edge'
226 stride = (/1,1/)
227 edge(1) = c2_npix
228 edge(2) = c2_nlin
229 
230 #else
231  start = 0
232  stride = 1
233  edge(1) = 90
234  edge(2) = 10
235 
236  ! WDR to not call ftn IO mod06_filedata(1) = sfstart(Amod06_name, DFACC_WRITE)
237  l1b_filedata(1:4) = (/ 45, 46, 47, 48 /)
238 
239 #endif
240 
241 ! if the total number of lines to read is greater than the
242 ! tilesize (number of lines to process/ iteration) then
243 ! we need to iterate.
244 
245 ! read libraries in preparation for later interpolation
246  if (status == success ) then
247  call readlibraries_base(debug,status)
248  if (status /= success) then
249  call local_message_handler('Problem reported in readlibraries',status,'mod_pr06od')
250  endif
251  endif
252 
253 
254 #if !AMS_INST & !ASTER_INST & !AVIRIS_INST & !RSP_INST & !EPIC_INST & !SSFR_INST
255  call init_fascode
256  call init_irw
257 #endif
258 
259 ! for inventory metadata
260  total_number_of_pixels = edge(2)*edge(1)
261 
262  mystart = 0
263  mystride = 1
264  myedge(1) = edge(1)
265  myedge(2) = edge(2)
266 
267 
268 ! allocate(eco(edge(1), edge(2)), snow(edge(1), edge(2)), sfc(edge(1), edge(2)), albedo(edge(1), edge(2)))
269 
270  number_of_iterationsx = ceiling(real(edge(1)) / real(tilesize))
272 #if SEV_PR06OD || AHI_PR06OD || EPIC_OD
273 ! because of GEO angle space, it's not possible to retrieve a single data stripe
274 ! we have to use square blocks in order to keep the memory from going out of control
275  number_of_iterationsy = ceiling(real(edge(2)) / real(tilesize))
277 #else
279 #endif
280 
281  grids_are_read = .false.
282  nise_is_read = .false.
283  ! WDR move to mod_pr06od.f90 snow_stats_are_read = .false.
284 
285  debugprn = .false.
286 
287  anc_filedata(1) = mod06_filedata(1)
288  anc_filedata(2) = mod06_filedata(2) ! This may or may not be present, specific_ancillary module will figure that out.
289 
290  if (platform_name == "RSP" .or. platform_name == "SSFR" .or. platform_name == "EPIC" ) &
291  anc_filedata(1) = cloudmask_filedata(1)
292 
293 #if AHI_INST
294  granule_offset = (/ahi_start_i, ahi_start_j/)
295 #else
296  granule_offset = 0
297 #endif
298 
299 ! print*, "NUM_ITER: X, Y, total: ", number_of_iterationsX, number_of_iterationsY, &
300 ! number_of_iterationsX * number_of_iterationsY
301 
302 ! print*, edge
303 
304  mpi_stepx = mpi_nprocs
305  mpi_stepy = 1
306  start_iterationx = mpi_rank + 1 !1
307  start_iterationy = 1
308 
309 
310 ! stride is ALWAYS 1
311  localstride = stride
312 
313 ! open(unit=MY_UNIT_LUN, file = MY_TEXT_FILE)
314 
315 ! print*, "proc: ", mpi_rank, "domain: ", start_iterationX, number_of_iterationsX, mpi_stepX
316 
317  do iterationx = start_iterationx, number_of_iterationsx, mpi_stepx
318  do iterationy = start_iterationy, number_of_iterationsy
319 
320 
321 ! print*, "ITERATION X Y: ", iterationX, iterationY, "proc:", mpi_rank
322 
323  call system_clock(start_time, crate, cmax)
324 
325  localstart = start
326  localedge = edge
327 
328  meas_start = start
329  meas_edge = edge
330 
331 
332 ! we read one line more than we need on each side so that CSR can work correctly.
333 !WDR out with this as we use the entire line available
334 ! if (edge(1) > tilesize) then
335 ! if (iterationX == 1 ) then
336 ! localedge(1) = tilesize
337 ! meas_edge(1) = tilesize+1
338 ! else
339 ! localstart(1) = start(1) + (iterationX-1)*tilesize
340 ! meas_start(1) = start(1) + (iterationX-1)*tilesize-1
341 ! localedge(1) = tilesize
342 ! meas_edge(1) = tilesize+2
343 ! endif
344 ! endif
345 !! this works because just above we set the meas_start(1) to be one less.
346 ! if ( edge(1) - iterationX*tilesize <= 0 ) then
347 ! localedge(1) = edge(1) - (iterationX-1)*tilesize
348 ! meas_edge(1) = edge(1) - (iterationX-1)*tilesize+1
349 ! endif
350 !
351 !#if SEV_PR06OD || AHI_PR06OD || EPIC_OD
352 ! if (edge(2) > tilesize) then
353 ! if (iterationY == 1) then
354 ! localedge(2) = tilesize
355 ! else
356 ! localstart(2) = start(2) + (iterationY-1)*tilesize
357 ! localedge(2) = tilesize
358 ! endif
359 ! endif
360 !
361 ! if ( edge(2) - iterationY*tilesize < 0 ) then
362 ! localedge(2) = edge(2) - (iterationY-1)*tilesize
363 ! endif
364 !
365 !#endif
366 !
367 ! localstart = localstart + granule_offset
368 
369 ! these instruments do not currently do spatial variability, so there is no need to read the extra lines
370 !#if MAS_OD || SEV_PR06OD || MODIS_HKM || AMS_OD || ASTER_OD || AVIRIS_OD || RSP_OD || AHI_PR06OD || SIM || EPIC_OD || SSFR_OD
371 ! meas_start = localstart
372 ! meas_edge = localedge
373 !#endif
374 
375 
376 
377 
378 #ifndef GEOS5
379 ! if we're using GDAS, we need to know the model size beforehand, it's constant anyhow.
380  grid_xsize = 360
381  grid_ysize = 181
382 #endif
383 
384 !print*, __FILE__, __LINE__," WDR pre allocate_arrays"
385 !print*, "WDR localedge: ", localedge
386 !print*, "WDR meas_edge: ", meas_edge
387 
388 ! Setup and allocate all data arrays
389  if (status == success ) then
390  call allocate_arrays (localedge, &
391  meas_edge, &
392  start_iterationx, &
393  start_iterationy, &
394  status )
395  if (status /= success) then
396  call local_message_handler('Failure detected before allocate_modisarrays, check previous messages', &
397  status, &
398  'mod_pr06od')
399  endif
400  endif
401 
402  call init_qualitydata
403 ! print*, "allocate: " , status
404 
405  ! get data cube to be processed and ancillary data arrays
406 ! WDR make the change to start
407 ! orig WDR l2_start = (/ c2_st_samp - 1, c2_scan /)
408 l2_start = (/ c2_st_samp, c2_scan - c2_nlin / 2 /)
409 !print*, __FILE__,__LINE__, " WDR l2_start is: ", l2_start
410 ! WDR debug to see in/out sizes
411 !print*, __FILE__, __LINE__, " WDR debug localstart, localedge, localstride, meas_start, meas_edge"
412 !print*, localstart, localedge, localstride, meas_start, meas_edge
413  if (status == success ) then
414  call get_modis_data_cube (l1b_filedata, &
415  geolocation_filedata, &
416 ! WDR localstart, &
417  l2_start, &
418  localedge, &
419  localstride, &
420 ! WDR meas_start, &
421  l2_start, &
422  meas_edge, &
423  iterationx, &
424  debug, &
425  status )
426 
427  if (status /= success) then
428  call local_message_handler('Failure detected before get_modis_data_cube check previous messages',&
429  status, &
430  'mod_pr06od')
431  endif
432  endif
433 
434 ! print*, __FILE__, " ", __LINE__," WDR after get_modis_data_cube"
435 ! print*, "and .86, 2.1 um rad vals"
436 !! WDR for report the center line only
437 ! do jwdr = c2_nlin / 2 + 1, c2_nlin / 2 + 1
438 ! do iwdr = 1, c2_npix
439 ! write(*,"(i4,i4,f10.4,f10.4)"),iwdr,jwdr,band_measurements(iwdr, 2, jwdr), band_measurements(iwdr, 5, jwdr)
440 ! enddo
441 ! enddo
442 
443 ! print*, "read data" , status
444 ! if it's an empty iteration, then don't even bother wasting time doing anything else
445  if (no_valid_data == 1) then
446  print*, "no valid data"
447 ! WDR 1may19 don't think this is needed
448 ! call init_science_arrays
449 ! WDR no need to call any output
450 ! call output_retrieval( mod06_filedata, &
451 ! Amod06_name, &
452 ! iterationX, iterationY, &
453 ! number_of_iterationsX, number_of_iterationsY, &
454 ! localstart - granule_offset, localedge, localstride, &
455 ! status)
456 !
457  cycle
458 
459  endif
460 
461 
462 
463 
464 #ifdef GEOS5
465 
466 #ifdef MCARS
467  geos5_istart = localstart(1)
468  geos5_jstart = 0
469  geos5_iend = localstart(1) + localedge(1)-1
470  geos5_jend = localstart(2) + localedge(2)-1
471 #else
472  ! GEOS-5 is NC4, so it makes sense to read it in pieces
473  call find_geos5_bounds(geos5_istart, geos5_iend, geos5_jstart, geos5_jend, latitude, longitude)
474 #endif
475 
476  grid_xsize = geos5_iend - geos5_istart + 1
477  grid_ysize = geos5_jend - geos5_jstart + 1
478  print*, geos5_istart, geos5_iend, geos5_jstart, geos5_jend, grid_xsize, grid_ysize
479  call allocate_model(start_iterationx, start_iterationy, grid_xsize, grid_ysize)
480 #endif
481 
482 
483 ! get cloud decision info
484  if (status == success .and. no_valid_data == 0) then
485 ! print*, __FILE__, __LINE__," WDR l2_start for cloud processing is: ", l2_start
486 !
487 ! WDR 12oct18 Why I had the l2_start reduction below...
488 ! if (l2_start(2) <= 0) then
489 ! l2_start(2) = 1
490 ! endif
491  ! WDR change localstart to l2_start
492 !print*, __FILE__, __LINE__, " WDR localstart, localstride, localedge:", &
493 ! localstart, localstride, localedge
494 !
495 ! WDR call this conditionally to read the CM from the CM file or
496 ! take it from the l2 data
497  if ( cm_from_l2 .EQ. 0 ) then
498  ! call modis_cloudprocessing(cloudmask_filedata, mod06_filedata, &
499  ! WDR A lot of ftn I/O in this - will remove for now. Just look in
500  ! earlier versions of mod_pr06od.f90
501  print*, __file__, __line__," WDR Cloud mask option not available"
502  status = fail
503  ! iterationX, l2_start, localstride, localedge, debug, status)
504  ! if (status /= success) then
505  ! call local_message_handler('Failure detected before cloudprocessing. Check previous messages/s', &
506  ! status, &
507  ! 'mod_pr06od')
508  ! endif
509  else
510  ! WDR fill the cloudmask structure from transfer values
511  call make_cld_msk_str()
512  ! use the re-constituted modis_cloudprocessing
513  ! out for now call modis_cloudprocessing()
514  end if
515  endif
516 
517 ! print*, "cloud mask read: ", status
518 
519 ! get ancillary data, right now that means albedos
520  if (status == success .and. no_valid_data == 0 ) then
521  ! WDR change localstart to l2_start
522  ! print*, __FILE__, __LINE__, " WDR l2_start, localstride, localedge, localstart:", l2_start, localstride, localedge, localstart
523  call set_ancillary(agdas_name, agdas_name2, aozone_name, &
524  ancepice_name, &
525  anise_name, &
526  anc_filedata, &
530  l2_start, localstride, localedge, &
531  debug, &
532  status )
533  if (status /= success) then
534  call local_message_handler('Problem reported in set_ancillary. Check previous message/s', &
535  status, &
536  'mod_pr06od')
537  endif
538  endif
539 ! WDR print the line of result-read ancillary
540 !print*, __FILE__,__LINE__, " WDR p, l, cld P, T, Hgt meth, sfc T, IR phase"
541 ! for center line controlled by wdr_wr_ch_vars values
542 ! do jwdr = c2_nlin / 2 + 1, c2_nlin / 2 + 1
543 ! do iwdr = 1, c2_npix
544 ! write(*,"(i4,i4,f10.4,f10.4,i5,f10.4,i5)"),iwdr,jwdr,cloud_top_pressure(iwdr, jwdr), cloud_top_temperature(iwdr, jwdr), cloud_height_method(iwdr, jwdr), surface_temperature(iwdr, jwdr), cloud_phase_infrared(iwdr, jwdr)
545 ! enddo
546 ! enddo
547 
548 ! print*, "ancillary set", status
549 
550  if (status == 0 .and. no_valid_data == 0 ) then
551  call readlibraries_extra(debug,status)
552 
553  if (status /= success) then
554  call local_message_handler('Problem reported in readlibraries',status,'mod_pr06od')
555  endif
556  endif
557 
558 ! process modis data for cloud optical thickness and cloud top effective
559 ! particle radius
560 ! print*, "libraries read", status
561 
562 
563 ! Thin cirrus retrieval using water vapor absorption band(s)
564 ! This code massively segfaults when running old MAS.
565 #ifdef RETRIEVE_138
566 #if EMAS_INST
567  call science_module_cirrus_twochannel(mod06_filedata,localstart,localedge,localstride,number_of_iterationsx,l1b_filedata)
568 #else
569 ! For future implementation of a single channel 1.38µm cirrus retrieval
570 ! call science_module_cirrus(mod06_filedata,localstart,localedge,localstride)
571 #endif
572 #endif
573 
574  if (status == success .and. no_valid_data == 0 ) then
575  call scienceinterface( threshold_solar_zenith, &
576  threshold_sensor_zenith, &
577  threshold_relative_azimuth, &
578  debug, &
579  status)
580 
581  if (status /= success) then
582  call local_message_handler('Problem reported in scienceinterface',status,'mod_pr06od')
583  endif
584  endif
585 ! print*, "done retrieval", status
586 
587 ! eco(localstart(1)+1:localstart(1) + tilesize , &
588 ! localstart(2)+1:localstart(2) + localedge(2) ) = eco_out(:,:)
589 ! send output retrieval and qa data to a hdf file
590 ! print*, status, no_valid_data
591  if (status == success .and. no_valid_data == 0 ) then
592 ! WDR debug to see data sizes
593 !print*, "WDR debug look at the output chunk sizes"
594 !print*, "localstart - granule_offset, localedge, localstride"
595 !print*, localstart - granule_offset, localedge, localstride
596 !
597 !WDR write out the basic radius and optical depth values for the box
598 !if ( iterationX == 1 ) then
599 ! print*, __FILE__, " ", __LINE__," WDR FINAL TEST REGION VALUES"
600 ! print*, "Cloud_Effective_Radius = effective_radius_21_final"
601 ! print*, "and Cloud_Optical_Thickness = optical_thickness_final"
602 ! print*, "and .86, 2.1 um rad vals"
603 !!print*, "OFF FOR NOW"
604 !! WDR for report the center line only
605 ! do jwdr = c2_nlin / 2 + 1, c2_nlin / 2 + 1
606 ! !do iwdr = 1, c2_npix
607 ! do iwdr = 1,40
608 ! write(*,"(i4,i4,f10.4,f12.6,f10.4,f10.4)"),iwdr,jwdr,effective_radius_21_final(iwdr, jwdr), optical_thickness_final(iwdr, jwdr), band_measurements(iwdr, 2, jwdr), band_measurements(iwdr, 5, jwdr)
609 ! enddo
610 ! enddo
611 !! WDR same pattern as above but write the other rad/ thk
612 ! print*, "effective_radius and optical_thickness for 16, 37, 1621"
613 ! do jwdr = c2_nlin / 2 + 1, c2_nlin / 2 + 1
614 ! !do iwdr = 1, c2_npix
615 ! do iwdr = 1,40
616 ! write(*,"(i4,i4,f10.4,f12.6,f10.4,f12.6f10.4,f12.6)"),iwdr,jwdr,effective_radius_16_final(iwdr, jwdr),optical_thickness_16_final(iwdr, jwdr),effective_radius_37_final(iwdr, jwdr),optical_thickness_37_final(iwdr, jwdr),effective_radius_1621_final(iwdr, jwdr),optical_thickness_1621_final(iwdr, jwdr)
617 ! enddo
618 ! enddo
619 ! endif
620 !
621 ! WDR knock out the last data write
622 ! call output_retrieval( mod06_filedata, &
623 ! Amod06_name, &
624 ! iterationX, iterationY, &
625 ! number_of_iterationsX, number_of_iterationsY, &
626 ! localstart - granule_offset, localedge, localstride, &
627 ! status)
628 ! if (status /= success) then
629 ! call local_message_handler('Problem reported in output_retrieval',status,'mod_pr06od')
630 ! endif
631  endif
632 ! print*, "output_retrieval", status
633  call system_clock(end_time, crate, cmax)
634 
635 ! print*, "iteration_time: ", end_time - start_time
636 #if MODIS_INST & !MODIS_HKM & !SIM
638 #endif
639 
640  enddo
641  enddo
642 
643 !print*, "WDR commenting out the deallocate_cleanup for TEST"
644 
645 ! if (status == success) then
646 ! call deallocate_cleanup(status )
647 ! if (status /= success) then
648 ! call local_message_handler('Problem reported in deallocate_cleanup', status,'mod_pr06od')
649 ! endif
650 ! endif
651 
652 #ifndef HAVE_MPI
653 ! WDR call set_processing_attributes(mod06_filedata)
654 #endif
655 
656 #ifndef SIM
657 ! if (status == success) then
658 !
659 ! call openclose_files ('close', &
660 ! l1b_filedata, &
661 ! cloudmask_filedata, &
662 ! geolocation_filedata,&
663 ! mod06_filedata, &
664 ! status)
665 ! if (status /= success) then
666 ! call local_message_handler('Problem reported in openclose_files', status,'mod_pr06od')
667 ! endif
668 ! endif
669 #else
670 
671 ! status = sfend(mod06_filedata(1))
672 ! print*, status
673 
674 #endif
675 
676 ! here we do the final assignment of the Inventory metadata statistics
677 #ifndef MODIS_HKM
678 #if MODIS_INST & !SIM
679 
680  if (total_number_of_pixels > 0) then
681  statistics(2) = real(im_cloudy_count) / real(total_number_of_pixels) * 100.
682  statistics_1km%land_fraction = statistics_1km%land_fraction / real(total_number_of_pixels) * 100.
683  statistics_1km%water_fraction = statistics_1km%water_fraction / real(total_number_of_pixels) * 100.
684  statistics_1km%snow_fraction = statistics_1km%snow_fraction / real(total_number_of_pixels) * 100.
685  else
686  statistics(2) = -9999.
687  statistics_1km%land_fraction = -9999.
688  statistics_1km%water_fraction = -9999.
689  statistics_1km%snow_fraction = -9999.
690  endif
691 
692  if (im_cloudy_count > 0) then
693  statistics(1) = real(im_successful_retrieval_count) / real(im_cloudy_count) * 100.
694  statistics(3) = real(im_water_cloud_count) / real(im_cloudy_count) * 100.
695  statistics(4) = real(im_ice_cloud_count) / real(im_cloudy_count) * 100.
696  else
697  statistics(1) = -9999.
698  statistics(3:4) = -9999.
699  endif
700 
701 
702  statistics_1km%retrieval_fraction = statistics(1)
703  statistics_1km%cloud_fraction = statistics(2)
704  statistics_1km%water_cloud_fraction = statistics(3)
705  statistics_1km%ice_cloud_fraction = statistics(4)
706 
707  if (im_water_cloud_count > 0) then
708  statistics_1km%mean_liquid_tau = statistics_1km%mean_liquid_tau / real(im_water_cloud_count)
709  statistics_1km%mean_liquid_re21 = statistics_1km%mean_liquid_re21 / real(im_water_cloud_count)
710  statistics_1km%ctp_liquid = statistics_1km%ctp_liquid / real(im_water_cloud_count)
711  statistics_1km%ctt_liquid = statistics_1km%ctt_liquid / real(im_water_cloud_count)
712  else
713  statistics_1km%mean_liquid_tau = -9999.
714  statistics_1km%mean_liquid_re21 = -9999.
715  statistics_1km%ctp_liquid = -9999.
716  statistics_1km%ctt_liquid = -9999.
717  endif
718 
719  if (im_ice_cloud_count > 0) then
720  statistics_1km%mean_ice_tau = statistics_1km%mean_ice_tau / real(im_ice_cloud_count)
721  statistics_1km%mean_ice_re21 = statistics_1km%mean_ice_re21 / real(im_ice_cloud_count)
724  else
725  statistics_1km%mean_ice_tau = -9999.
726  statistics_1km%mean_ice_re21 = -9999.
727  statistics_1km%ctp_ice = -9999.
728  statistics_1km%ctt_ice = -9999.
729  endif
730 
731  if (im_undet_count > 0) then
732  statistics_1km%ctp_undetermined = statistics_1km%ctp_undetermined / real(im_undet_count)
733  statistics_1km%ctt_undetermined = statistics_1km%ctt_undetermined / real(im_undet_count)
734  else
735  statistics_1km%ctp_undetermined = -9999.
736  statistics_1km%ctt_undetermined = -9999.
737  endif
738 
739 ! WDR no outputs
740 ! call write_statistics(Amod06_name)
741 #endif
742 
743 #endif
744 
745 ! close (MY_UNIT_LUN)
746 
747 
748  call system_clock(total_end, crate, cmax)
749 ! print*, "Total Execution Time is: ", total_end - total_start, " cycles"
750 ! print*, "total execution time is: ", (total_end - total_start) / ( crate*1.0 ) / 60.0, " minutes"
751 
752 #if HAVE_MPI
753  call mpi_finalize(mpi_err)
754 #endif
755 
756 
757  end subroutine mod_pr06od
758 
759  subroutine make_cld_msk_str()
760 ! WDR this will set up the cloudmask structure
761  use core_arrays
762  use ch_xfr
763 !
764 ! I think cloudmask is already set up, so just transfer the stuff into
765 ! the structure
766 !
767 ! the logicals
768  cloudmask(:,:)%cloudmask_determined = .false.
769  cloudmask(:,:)%confident_cloudy = .false.
770  cloudmask(:,:)%probablyclear_66 = .false.
771  cloudmask(:,:)%probablyclear_95 = .false.
772  cloudmask(:,:)%probablyclear_99 = .false.
773  cloudmask(:,:)%snowice_surface = .false.
774  cloudmask(:,:)%water_surface = .false.
775  cloudmask(:,:)%coastal_surface = .false.
776  cloudmask(:,:)%desert_surface = .false.
777  cloudmask(:,:)%land_surface = .false.
778  !
779  do j = 1, c2_nlin
780  do i = 1, c2_npix
781  if ( c2_cld_det( i, j ) == 1 ) cloudmask(i,j)%cloudmask_determined = .true.
782  if ( c2_conf_cld( i, j ) == 1 ) cloudmask(i,j)%confident_cloudy = .true.
783  if ( c2_clr_66( i, j ) == 1 ) cloudmask(i,j)%probablyclear_66 = .true.
784  if ( c2_clr_95( i, j ) == 1 ) cloudmask(i,j)%probablyclear_95 = .true.
785  if ( c2_clr_99( i, j ) == 1 ) cloudmask(i,j)%probablyclear_99 = .true.
786  if ( c2_sno_sfc( i, j ) == 1 ) cloudmask(i,j)%snowice_surface = .true.
787  if ( c2_wtr_sfc( i, j ) == 1 ) cloudmask(i,j)%water_surface = .true.
788  if ( c2_coast_sfc( i, j ) == 1 ) cloudmask(i,j)%coastal_surface = .true.
789  if ( c2_desert_sfc( i, j ) == 1 ) cloudmask(i,j)%desert_surface = .true.
790  if ( c2_lnd_sfc( i, j ) == 1 ) cloudmask(i,j)%land_surface = .true.
791  end do
792  end do
793 !
794 ! the byte
795  cloudmask(:,:)%night = c2_night
796  cloudmask(:,:)%sunglint = c2_glint
797  cloudmask(:,:)%ocean_no_snow = c2_ocean_no_snow
798  cloudmask(:,:)%ocean_snow = c2_ocean_snow
799  cloudmask(:,:)%land_no_snow = c2_lnd_no_snow
800  cloudmask(:,:)%land_snow = c2_lnd_snow
801  cloudmask(:,:)%test_high_138 = c2_tst_h_138
802  cloudmask(:,:)%test_visiblereflectance = c2_tst_vis_refl
803  cloudmask(:,:)%test_visnirratio = c2_tst_vis_ratio
804  cloudmask(:,:)%visible_cloudtest_250m = c2_vis_cld_250
805  cloudmask(:,:)%applied_highcloud138 = c2_appl_hcld_138
806  cloudmask(:,:)%applied_visiblereflectance = c2_appl_vis_refl
807  cloudmask(:,:)%applied_visnirratio = c2_appl_vis_nir_ratio
808 !
809 ! and end
810  end subroutine make_cld_msk_str
Definition: ch_xfr.f90:1
integer *1, dimension(:,:), allocatable c2_wtr_sfc
Definition: ch_xfr.f90:29
integer *1, dimension(:,:), allocatable c2_clr_99
Definition: ch_xfr.f90:28
subroutine, public scienceinterface(threshold_solar_zenith, threshold_sensor_zenith, threshold_relative_azimuth, debug, status)
integer *1, dimension(:,:), allocatable c2_sno_sfc
Definition: ch_xfr.f90:29
type(cloudmask_type), dimension(:,:), allocatable cloudmask
integer *1, dimension(:,:), allocatable c2_appl_hcld_138
Definition: ch_xfr.f90:36
real(single), dimension(:,:), allocatable longitude
integer *1, dimension(:,:), allocatable c2_vis_cld_250
Definition: ch_xfr.f90:35
integer cm_from_l2
Definition: ch_xfr.f90:53
integer *1, dimension(:,:), allocatable c2_tst_h_138
Definition: ch_xfr.f90:34
subroutine mod_pr06od(statistics, errorlevel)
Definition: mod_pr06od.f90:2
integer *1, dimension(:,:), allocatable c2_ocean_snow
Definition: ch_xfr.f90:32
integer im_water_cloud_count
integer number_of_iterationsx
integer *1, dimension(:,:), allocatable c2_desert_sfc
Definition: ch_xfr.f90:30
real(single), dimension(:,:), allocatable latitude
subroutine, public check_datasources(status)
subroutine, public init_qualitydata
subroutine make_cld_msk_str()
Definition: mod_pr06od.f90:760
character *15 platform_name
#define real
Definition: DbAlgOcean.cpp:26
subroutine, public allocate_model(st_iterX, st_iterY, grid_wid, grid_ht)
integer *1, dimension(:,:), allocatable c2_night
Definition: ch_xfr.f90:31
integer c2_nlin
Definition: ch_xfr.f90:44
character(len=1000) asnowicealbedo_data_name
Definition: names.f90:37
subroutine, public init_irw
type(stat_type) statistics_1km
integer *1, dimension(:,:), allocatable c2_cld_det
Definition: ch_xfr.f90:27
subroutine, public set_ancillary(gdas_name, gdas_name2, ozone_name, ncepice_name, nise_name, mod06input_filedata, ecosystem_data_name, snowicealbedo_data_name, emissivity_name, mod06_start, mod06_stride, mod06_edge, debug, status)
integer *1, dimension(:,:), allocatable c2_appl_vis_refl
Definition: ch_xfr.f90:37
integer im_ice_cloud_count
integer c2_npix
Definition: ch_xfr.f90:44
integer *1, dimension(:,:), allocatable c2_tst_vis_refl
Definition: ch_xfr.f90:34
integer *1, dimension(:,:), allocatable c2_coast_sfc
Definition: ch_xfr.f90:30
integer *1, dimension(:,:), allocatable c2_glint
Definition: ch_xfr.f90:31
integer *1, dimension(:,:), allocatable c2_lnd_snow
Definition: ch_xfr.f90:33
subroutine, public allocate_arrays(edge, meas_edge, st_iterX, st_iterY, status)
integer *1, dimension(:,:), allocatable c2_lnd_sfc
Definition: ch_xfr.f90:31
subroutine, public readlibraries_extra(debug, status)
integer *1, dimension(:,:), allocatable c2_tst_vis_ratio
Definition: ch_xfr.f90:35
integer im_successful_retrieval_count
Definition: names.f90:1
integer *1, dimension(:,:), allocatable c2_appl_vis_nir_ratio
Definition: ch_xfr.f90:38
integer *1, dimension(:,:), allocatable c2_clr_95
Definition: ch_xfr.f90:28
integer c2_scan
Definition: ch_xfr.f90:44
integer number_of_iterationsy
integer *1, dimension(:,:), allocatable c2_lnd_no_snow
Definition: ch_xfr.f90:33
integer *1, dimension(:,:), allocatable c2_ocean_no_snow
Definition: ch_xfr.f90:32
character(len=500) aemissivity_name
Definition: names.f90:44
integer im_cloudy_count
character(len=1000) aecosystem_data_name
Definition: names.f90:37
integer *1, dimension(:,:), allocatable c2_clr_66
Definition: ch_xfr.f90:28
integer total_number_of_pixels
integer c2_st_samp
Definition: ch_xfr.f90:44
subroutine local_message_handler(message, severity, functionname)
subroutine, public readlibraries_base(debug, status)
subroutine, public initialize_run(start, edge, stride, tilesize, threshold_solar_zenith, threshold_sensor_zenith, threshold_relative_azimuth, status)
integer im_undet_count
subroutine aggregate_statistics_1km
subroutine, public get_modis_data_cube(level1b_filedata, geolocation_filedata, start, edge, stride, meas_start, meas_edge, scan_number, debug, status)
integer *1, dimension(:,:), allocatable c2_conf_cld
Definition: ch_xfr.f90:27