OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ancillary_module.f90
Go to the documentation of this file.
2 
5 ! WDR not required use general_array_io
6 
7  implicit none
8  private
9 
11 
12  real*8 :: pressures_source(model_levels)
13 
14 contains
15 
16 subroutine set_ancillary( &
17  gdas_name, &
18  gdas_name2, &
19  ozone_name, &
20  ncepice_name, &
21  nise_name, &
22  mod06input_filedata, &
23  ecosystem_data_name, &
24  snowicealbedo_data_name, &
25  emissivity_name, &
26  mod06_start, mod06_stride, mod06_edge, &
27  debug, &
28  status)
29 
31  use names
32  use generalauxtype
33  use core_arrays
36  ! WDR note that c2_scan only used to read in orig cloud top stuff
37 
39  use specific_other
41 
42  implicit none
43 
44  ! WDR include "hdf.f90"
45  ! WDR include "dffunc.f90"
46 
47  logical, intent(in) :: debug
48  integer, intent(inout),dimension(:) :: mod06_start, mod06_stride, mod06_edge,mod06input_filedata
49  character(*),intent(in) :: gdas_name, gdas_name2, ozone_name, ncepice_name, &
50  nise_name, &
51  ecosystem_data_name, &
52  snowicealbedo_data_name, emissivity_name
53 
54  integer, intent(out) :: status
55 
56  real,allocatable,dimension(:,:) :: icec
57  integer :: xsize, ysize, levels, i,j
58  integer, allocatable, dimension(:) :: mod06_edge_5km, mod06_stride_5km, mod06_start_5km
59 
60  character(len=200) :: pressure_sdsname, temperature_sdsname, ctm_sdsname, sfc_temp_sdsname, cpi_sdsname
61  logical :: execute_standard, replace_albedo
62  integer :: dim_size, do_cloud_top
63 
64  status = 0
65  levels = model_levels
66 
67  dim_size = size(mod06_edge)
68  allocate(mod06_edge_5km(dim_size))
69  allocate(mod06_stride_5km(dim_size))
70  allocate(mod06_start_5km(dim_size))
71 
72  xsize = size(latitude,1)
73  ysize = size(latitude,2)
74  allocate(icec(xsize, ysize))
75  status = 0
76  icec = 0 ! WDR-UIV
77 
78 
84 
85 
86 
87  call read_ancillary_grids( &
88  latitude, &
89  longitude, &
90  gdas_name, &
91  gdas_name2, &
92  ozone_name, &
93  ncepice_name, &
94  column_ozone, &
95  icec)
96 
97  ! WDR insert the ozone and ice concentration from l2gen
99  icec = c2_alt_icec
100 
101  execute_standard = .true.
102  replace_albedo = .false.
103 
104  mod06_start_5km = mod06_start
105  mod06_stride_5km = mod06_stride
106  mod06_edge_5km = mod06_edge
107 
108 ! WDR replace these reads with constants (from AVIRIS)
109 ! call get_specific_ancillary(mod06input_filedata, &
110 ! pressure_sdsname, &
111 ! temperature_sdsname, &
112 ! ctm_sdsname, &
113 ! sfc_temp_sdsname, &
114 ! cpi_sdsname, &
115 ! mod06_start_5km, &
116 ! mod06_stride_5km, &
117 ! mod06_edge_5km, EXECUTE_STANDARD, REPLACE_ALBEDO)
118 
119 ! call get_cloud_top_properties(mod06input_filedata, &
120 ! pressure_sdsname, &
121 ! temperature_sdsname, &
122 ! ctm_sdsname, &
123 ! sfc_temp_sdsname, &
124 ! cpi_sdsname, &
125 ! mod06_start_5km, &
126 ! mod06_stride_5km, &
127 ! mod06_edge_5km, &
128 ! mod06_start, &
129 ! mod06_edge, &
130 ! cloud_top_pressure, &
131 ! cloud_top_temperature, &
132 ! cloud_height_method, &
133 ! surface_temperature, &
134 ! cloud_phase_infrared, &
135 ! EXECUTE_STANDARD, &
136 ! status)
137 ! print*, status
138  !
139  ! The 3.7 um rad/thk is sensitive to these, so for the little test area,
140  ! use these nominal values
141  ! WDR go back to AVIRIS (Q on surface_temperature)
142  !cloud_top_pressure = 620.
143  !cloud_height_method = 6 ! (IR-window retrieval, band 31)
144  !cloud_phase_infrared = 1 ! (water cloud)
145  !cloud_top_temperature = 270.
146  !surface_temperature = 277.4
147 ! WDR for a try at compatibility, do a quick, dirty read of the cloud
148 ! top stuff
149 ! the rd_cloud_top() will cheat and read the cloud top info from the
150 ! chimaera L2 file, mainly for reproducibility to their product
151  if( c2_cloud_hgt_file(1:1) .ne. char(0) ) then
152  call rd_cloud_top( )
153  else
154  ! I've found that constant cold cloud tops get more retrievals than warm
155  ! From AVIRIS, but cold
156  ! cold cloud
157  !cloud_top_pressure = 480.
158  !cloud_top_temperature = 230.
159  ! Oct 2019 prev runs usually used 11 um - derived P,T
160  !
161  ! if you use a scimachy-derived average cloud height of 7.3 km
162  ! and run that through the standard atmos, you get:
163  !cloud_top_pressure = 240.
164  !cloud_top_temperature = 390.
165  ! this seems to leave out some large smooth cloud stretches
166  !
167  ! try a P more like before but with std atmos T (alt 5.8 km)
168  cloud_top_pressure = 480.
169  cloud_top_temperature = 250.
170  !
171  ! altitude of 3 km
172  !cloud_top_pressure = 700.
173  !cloud_top_temperature = 270.
174  !
175  ! altitude of .6 km
176  !cloud_top_pressure = 943.
177  !cloud_top_temperature = 284.
178  ! warm cloud
179  ! cloud_top_pressure = 950.
180  ! cloud_top_temperature = 270.
181  !
182  ! cloud_height_method = 6 ! (IR-window retrieval, band 31)
183  cloud_height_method = 1 ! ignore IR as I think ours is bad anyway and
184  ! we want to use the constant for now or
185  ! whatever is sent in
186  cloud_phase_infrared = 2 ! (ice cloud)
187  surface_temperature = 300.
188  endif
189 
191  longitude,&
192  nise_name, &
193  ecosystem_data_name, &
194  snowicealbedo_data_name, &
195  emissivity_name, &
196  debug, &
197  icec, &
198  surface_albedo, &
200  status)
201 
202 
203  if (replace_albedo) then
204  call set_albedo
205  endif
206 
207  if(platform_name == "SSFR") then
208  where(icec > 0.)
209  snow_cover = icec
210  end where
211  end if
212 
213 
214  deallocate( icec)
215  deallocate( mod06_start_5km, mod06_stride_5km, mod06_edge_5km)
216 
217 end subroutine set_ancillary
218 !
219 ! WDR temporary routine rd_cloud_top to get cloud top from 'output' file
220 subroutine rd_cloud_top()
222 use ch_xfr
224 
225 integer :: firsttime = 0
226 integer, dimension(2) :: start, stride, edge
227 integer :: fid, xdim, ydim, sds_id_p, stat
228 integer :: sds_id_t, sds_id_hgt_meth, sds_id_sfc_t, sds_id_phase_ir
229 integer :: DFACC_READ = 1
230 !character(*), parameter :: ct_file = "/accounts/wayne/src1/chimaera/mod_code_modis/inputs-2015005.2010/MYD06_L2.2015005.2010.hdf"
231 !character(*), parameter :: ct_file = "/accounts/wayne/data/satellite/aqua/A20161571845/MYD06_L2.A2016157.1845.061.2018059102814.hdf"
232 !character(*), parameter :: ct_file = "MYD06_L2.A2015005.2010.061.2018047161953.hdf"
233 
234 integer*2, dimension(:,:), allocatable :: i2_store
235 
236 integer c_sfstart
237 external c_sfstart
238 integer c_sfrdata
239 external c_sfrdata
240 integer c_sfselect
241 external c_sfselect
242 integer c_sfn2index
243 external c_sfn2index
244 
245 ! open the l2 cloud height (etc) file, currently the LAADS L2 cloud file
246 ! and set to the SDSes needed
247 if ( firsttime == 0 ) then
248  firsttime = 1
249  fid = c_sfstart( c2_cloud_hgt_file, dfacc_read)
250  if( fid == -1 ) then
251  print*, "Could not open the cloud height file: ", c2_cloud_hgt_file
252  call exit( -22 )
253  endif
254  xdim = SIZE( cloud_top_pressure, dim=1 )
255  ydim = SIZE( cloud_top_pressure, dim=2 )
256 
257  start(1) = 0
258  edge(1) = xdim
259  edge(2) = ydim
260  stride(1) = 1
261  stride(2) = 1
262  !
263  ! set up the SDSes for reading
264  sds_id_p = c_sfselect( fid, c_sfn2index( fid, "cloud_top_pressure_1km" ) )
265  sds_id_t = c_sfselect( fid, c_sfn2index( fid, "cloud_top_temperature_1km" ) )
266  sds_id_hgt_meth = c_sfselect( fid, c_sfn2index( fid, &
267  "cloud_top_method_1km" ) )
268  sds_id_sfc_t = c_sfselect( fid, c_sfn2index( fid, &
269  "surface_temperature_1km" ) )
270  sds_id_phase_ir = c_sfselect( fid, c_sfn2index( fid, &
271  "Cloud_Phase_Infrared_1km" ) )
272  allocate( i2_store( xdim, ydim ) )
273  end if
274 !
275 ! read the 5 arrays for the center scan
276 start(2) = c2_scan - 1
277 if ( c2_scan == 0 ) start(2) = 0
278 ! This is REAL souped up - a real treatment would find the actual size
279 ! of the data arrays and also the values of scale, offset
280 if ( c2_scan > 2029 ) start(2) = 2029 - ydim + 1
281 !
282 ! OK, the reading and scaling is done below
283 !
284 ! Cloud Top Pressure
285 stat = c_sfrdata( sds_id_p, start, stride, edge, i2_store )
286 cloud_top_pressure = i2_store * 0.1
287 where( i2_store == -999 ) cloud_top_pressure = fillvalue_real
288 !
289 ! Cloud Top Temperature
290 stat = c_sfrdata( sds_id_t, start, stride, edge, i2_store )
291 cloud_top_temperature = ( i2_store + 15000 ) * 0.01
292 where( i2_store == -999 ) cloud_top_temperature = fillvalue_real
293 !
294 ! cloud_height_method
295 stat = c_sfrdata( sds_id_hgt_meth, start, stride, edge, cloud_height_method )
296 !
297 ! surface_temperature
298 stat = c_sfrdata( sds_id_sfc_t, start, stride, edge, i2_store )
299 surface_temperature = ( i2_store + 15000 ) * 0.01
300 where( i2_store == -999 ) surface_temperature = fillvalue_real
301 !
302 ! cloud_phase_infrared
303 stat = c_sfrdata( sds_id_phase_ir, start, stride, edge, cloud_phase_infrared )
304 !
305 ! WDR, make the cloud mask values agree with cloud top
306 ! these are stored in cloudmask(i,j)
307 where( cloud_top_pressure < 0. ) ! no cloud
308  cloudmask%cloudmask_determined = .false.
309  cloudmask%confident_cloudy = .false.
310  cloudmask%probablyclear_66 = .true.
311  cloudmask%probablyclear_95 = .true.
312  cloudmask%probablyclear_99 = .true.
313 end where
314 
315 end subroutine rd_cloud_top
316 
317 !
318 !
319 ! subroutine get_bilinear_idx(lat, lon, i, j, idx_x, idx_y)
320 !
321 ! real, intent(in) :: lat, lon
322 ! integer, intent(in ) :: i,j
323 ! integer, intent(inout) :: idx_x(2), idx_y(2)
324 !
325 ! real :: x,y, x0, dx, y0, dy
326 !
327 ! x = min( max( lon, -179.99 ), 179.99 )
328 ! if( x > -999. .and. x < 0.0 ) x = lon+ 360.0
329 !
330 ! y = min( max( lat, -89.99 ), 89.99 )
331 ! y0 = 90.0
332 ! dy = -1.0
333 !
334 ! if ( x < (i*1.) ) then !+0.5) then
335 ! idx_x(1) = i-1
336 ! idx_x(2) = i
337 ! else
338 ! idx_x(1) = i
339 ! idx_x(2) = i+1
340 ! endif
341 !
342 ! if (idx_x(1) < 0 .or. idx_x(1) > 359) idx_x(1) = 0
343 ! if (idx_x(2) < 0 .or. idx_x(2) > 359) idx_x(2) = 0
344 !
345 ! if ( (y-y0)/dy < (j*1.) ) then !+0.5) then
346 ! idx_y(1) = j-1
347 ! idx_y(2) = j
348 ! else
349 ! idx_y(1) = j
350 ! idx_y(2) = j+1
351 ! endif
352 !
353 ! if (idx_y(1) < 0 ) idx_y(1) = 0
354 ! if (idx_y(1) > 180) idx_y(1) = 180
355 !
356 ! if (idx_y(2) < 0 ) idx_y(2) = 0
357 ! if (idx_y(2) > 180) idx_y(2) = 180
358 !
359 !
360 ! idx_x = idx_x + 1
361 ! idx_y = idx_y + 1
362 !
363 ! end subroutine get_bilinear_idx
364 
365 
366  subroutine given_p_get_t(P, model_point, T)
367 
369 
370  real, intent(in) :: p
371  real, intent(inout) :: t
372  type(ancillary_type) :: model_point
373 
374  integer :: k, lev_start
375  real :: factor
376 
377  lev_start = model_point%trop_level-2
378 
379  do k=lev_start, model_point%surface_level
380  if ( p < model_point%pressure_profile(k)) &
381  exit
382  end do
383 
384  if (k <= lev_start) then
385  t = model_point%temp_profile(lev_start)
386  elseif (k >= model_point%surface_level) then
387  t = model_point%temp_profile(model_point%surface_level)
388  else
389  t = model_point%temp_profile(k)
390  endif
391 
392  end subroutine given_p_get_t
393 
394 
395 
396 integer function find_trop(temp_prof, p_prof, sfc_lev)
397 
398  real, dimension(:), intent(in) :: temp_prof, p_prof
399  integer*1, intent(in) :: sfc_lev
400 
401  real :: xmin
402  integer :: ilev, imin
403  real, parameter :: ptop = 100.
404 
405  xmin = 999999.
406  imin = 1
407 
408  do ilev = 1, sfc_lev-5
409  if (temp_prof(ilev) < xmin .and. p_prof(ilev) > ptop) then
410  xmin = temp_prof(ilev)
411  imin = ilev
412  endif
413  end do
414 
415 
416 ! don't allow trop height > 400 mb (level 71)
417  find_trop = -99
418  do ilev = imin, 71
419 
420  if (temp_prof(ilev-1) >= temp_prof(ilev) .and. &
421  temp_prof(ilev+1) > temp_prof(ilev)) then
422  find_trop = ilev
423  exit
424  endif
425  end do
426 
427  if (find_trop == -99) find_trop = imin
428 
429 end function find_trop
430 
431 
432 subroutine read_ancillary_grids( lat, lon, ncepgdas_name,ncepgdas_name2, ozone_name, ice_name, &
433  ozone, icec )
434  use generalauxtype
441  use names, only: mytime, mymonth, atmp_dirname, myyear, myday, anise_name, frac_time
442 
443  ! WDR include "hdf.f90"
444  ! WDR include "dffunc.f90"
445 
446 ! include 'Atmos_AncData.f90.inc'
447 
448  !-----------------------------------------------------------------------
449  ! !f90
450  !
451  ! !description:
452  ! retrieve ancillary data items for a given set of
453  ! latitude and longitude pairs.
454  !
455  ! !input parameters:
456  ! lat latitude (degrees, -90s to +90.0n)
457  ! lon longitude (degrees, -180w to +180e, greenwich=0)
458  !
459  ! !output parameters:
460  ! pres array of pressure levels (hpa)
461  ! temp array of atmospheric temperatures (k) at pres(0:15)
462  ! mixr array of water vapor mixing ratios (g/kg) at pres(0:15)
463  ! land land mask (0=water, 1=land)
464  ! sfctmp surface temperature (k)
465  ! prmsl pressure (hpa) at mean sea level
466  ! pwat precipitable water (g/cm**2)
467  ! ugrd surface wind u component (m/s)
468  ! vgrd surface wind v component (m/s)
469  ! Ozone total column Ozone (dobson units)
470  ! icec ice concentration (fraction)
471  !
472  ! !notes
473  ! Modified from the MOD_PR06OD Collection 4 ReadNCEP.f algorithm written
474  ! by Liam Gumley and Jason Li.
475 
476  real(single), intent(in) :: lat(:,:),lon(:,:)
477  character(*), intent(in) :: ncepgdas_name, ncepgdas_name2, ozone_name, ice_name
478 
479  real(single), intent(inout) :: icec(:,:), ozone(:,:)
480 
481  ! ... parameter definitions
482  integer npoints_x, npoints_y
483  parameter( npoints_x = 360, npoints_y = 180 )
484 
485  real missing
486  parameter( missing = -999.0 )
487 
488  ! ... declaration of local variables and arrays
489  character*8 esdt_name_ncep, esdt_name_ozone, esdt_name
490  character*7 esdt_name_ice
491  character*160 errmsg
492  character*13 ncepgdastemp_name, ozonetemp_name
493  character*12 icetemp_name
494  character*400 temp_output_name, temp_input_name
495 
496 
497  integer header( 0:7 ), i, ios, j, k, level, lun, pcfnum, reclen, status, ii, jj
498 
499  integer data_xsize, data_ysize, grid_i, grid_j, kstart
500 
501  real(single) :: satmix, x, x0, xlon, dx, y, y0, dy
502 
503  real :: yy2(2), yy(2), xx(2)
504  integer :: idx_x(2), idx_y(2)
505 
506  real :: met_grid( 0:359, 0:180, 0:53 ), met_grid2( 0:359, 0:180, 0:53 )
507  integer, parameter :: num_gdas_vars = 54
508 
509  integer met_year, met_month, met_day, met_hour, &
510  ice_year, ice_month, ice_day, ice_hour, &
511  ozn_year, ozn_month, ozn_day, ozn_hour
512 
513  integer met_date(4), met_date2(4), ice_date(4), ozn_date(4)
514 
515  logical met_success, ice_success, ozn_success
516 
517 
518  real :: ts2m, w2m, pmsl, ts
519 
520  ! ... declaration of external functions
521  integer modis_grib_driver
522  external modis_grib_driver
523  integer make_profile_101
524  external make_profile_101
525 
526  integer profile_to_101
527  external profile_to_101
528 
529  integer height_profile
530  external height_profile
531 
532  real*8 :: model_lat
533  real*8 :: heights(model_levels)
534 
535  integer, parameter :: model_coarse = 27
536  integer, parameter :: wind_start = 47
537  integer, parameter :: rh_start = 6
538 
539  real :: a_factor
540  integer*1 :: sfc_level
541 
542  real*8 :: p(model_coarse), p_source(model_coarse)
543 
544  real*8 :: mixr(model_coarse), temp(model_coarse)
545 
546  real*8 :: pressures(model_levels), temp_hires(model_levels), mixr_hires(model_levels)
547 
548  real :: ts_forint(2,2), lat_set(2), lon_set(2)
549 
550  integer :: file_id(1), var_id, start(2), stride(2), edge(2), dummy
551 
552  character*30 :: name_tag
553  character*4 :: ttag
554  character*3 :: dtag
555  character(len=1) :: tag
556 
557  integer :: istart, iend, jstart, jend, model_wid, model_ht, model_i, model_j, &
558  err_code
559  real, dimension(:,:), allocatable :: geos_temp1
560 
561 
562  p_source = (/ 10., 20., 30., 50., 70., 100., 150., 200., 250., 300., 350., 400., 450., 500., &
563  550., 600., 650., 700., 750., 800., 850., 900., 925., 950., 975., 1000., 1100. /)
564 
565  !-----------------------------------------------------------------------
566  ! begin executable code
567  !-----------------------------------------------------------------------
568  ! ... read input data files if this is the first call
569 
570  lun = 222
571 
572 
573  data_xsize = size(lat,1)
574  data_ysize = size(lat,2)
575 
576  if(.not. grids_are_read) then
577  grids_are_read = .true.
578 
579  ! ..... set data ingest success/fail flags
580  met_success = .false.
581  ice_success = .false.
582  ozn_success = .false.
583 
584  do i = 1, 4
585  met_date( i ) = int( missing )
586  ice_date( i ) = int( missing )
587  ozn_date( i ) = int( missing )
588  end do
589 
590 
591  !-----------------------------------------------------------------------
592  ! get ncep meteorological data
593  !-----------------------------------------------------------------------
594  ! ... unpack grib met file and write to binary file
595 
596 ! errmsg = ' '
597 ! ESDT_name = 'GDAS_0ZF'
598 !
599 ! temp_input_name = trim(ncepgdas_name) // char(0)
600 ! write(tag, '(i1)') mpi_rank
601 ! temp_output_name = trim(ncepgdas_name) // "_" // tag // ".bin" // char(0)
602 !
603 ! status = success
604 ! status = modis_grib_driver( temp_input_name, temp_output_name, &
605 ! ESDT_name, errmsg, &
606 ! met_year, met_month, &
607 ! met_day, met_hour )
608 !
609 ! if ( status /= success ) then
610 ! status = failure
611 ! call local_message_handler ('error reported from grib driver, ncep read, Check PCF file', &
612 ! status, &
613 ! 'read_ancillary_grids')
614 !
615 ! ! .... open unpacked met file
616 ! else
617 !
618 ! reclen = 360*181*num_gdas_vars*4
619 !
620 ! open (unit = lun, file = temp_output_name, form = 'unformatted', &
621 ! access = 'direct', status = 'old', &
622 ! recl = reclen, iostat = ios )
623 !
624 ! if ( status /= 0 ) then
625 ! status = 2
626 ! call local_message_handler ('error reported from openr, ncep read, Check PCF file', &
627 ! status, &
628 ! 'read_ancillary_grids')
629 ! else
630 ! ! read the unpacked met file
631 ! if ( status == 0 ) then
632 ! ios= 0
633 ! read( lun, rec = 1, iostat = ios ) met_grid
634 !
635 !
636 ! if ( ios /= 0 ) then
637 ! level = 2
638 ! else
639 ! met_success = .true.
640 ! met_date( 1 ) = met_year
641 ! met_date( 2 ) = met_month
642 ! met_date( 3 ) = met_day
643 ! met_date( 4 ) = met_hour
644 !
645 ! endif
646 !
647 ! close(lun)
648 ! endif
649 !
650 ! endif
651 !
652 ! endif
653 !
654 ! errmsg = ' '
655 ! ESDT_name = 'GDAS_0ZF'
656 !
657 ! temp_input_name = trim(ncepgdas_name2) // char(0)
658 ! write(tag, '(i1)') mpi_rank
659 ! temp_output_name = trim(ncepgdas_name2) // "_" // tag // ".bin" // char(0)
660 !
661 ! status = success
662 ! status = modis_grib_driver( temp_input_name, temp_output_name, &
663 ! ESDT_name, errmsg, &
664 ! met_year, met_month, &
665 ! met_day, met_hour )
666 !
667 ! if ( status /= success ) then
668 ! status = failure
669 ! call local_message_handler ('error reported from grib driver, ncep read, Check PCF file', &
670 ! status, &
671 ! 'read_ancillary_grids')
672 !
673 ! ! .... open unpacked met file
674 ! else
675 !
676 ! reclen = 360*181*num_gdas_vars*4
677 ! open (unit = lun, file = temp_output_name, form = 'unformatted', &
678 ! access = 'direct', status = 'old', &
679 ! recl = reclen, iostat = ios )
680 !
681 ! if ( status /= 0 ) then
682 ! status = 2
683 ! call local_message_handler ('error reported from openr, ncep read, Check PCF file', &
684 ! status, &
685 ! 'read_ancillary_grids')
686 ! else
687 ! ! read the unpacked met file
688 ! if ( status == 0 ) then
689 ! ios= 0
690 ! read( lun, rec = 1, iostat = ios ) met_grid2
691 !
692 ! if ( ios /= 0 ) then
693 ! level = 2
694 ! else
695 ! met_success = .true.
696 ! met_date2( 1 ) = met_year
697 ! met_date2( 2 ) = met_month
698 ! met_date2( 3 ) = met_day
699 ! met_date2( 4 ) = met_hour
700 ! if (met_date2(4) == 0) met_date2(4) = 24
701 ! endif
702 !
703 ! close(lun)
704 ! endif
705 !
706 ! endif
707 !
708 ! endif
709 !
710 !! capture month of the granule
711 ! MYMONTH = met_date(2)
712 
713 !-----------------------------------------------------------------------
714 ! Get SSM/I sea ice concentration
715 !-----------------------------------------------------------------------
716 ! ... Unpack grib sea ice file and write to binary file
717 ! errmsg = ' '
718 ! ESDT_name = 'SEA_ICE'
719 !
720 ! temp_input_name = trim(ice_name) // char(0)
721 ! write(tag, '(i1)') mpi_rank
722 ! temp_output_name = trim(ice_name) // "_" // tag // ".bin" // char(0)
723 !
724 ! status = success
725 ! status = modis_grib_driver( temp_input_name, temp_output_name, &
726 ! ESDT_name, errmsg, &
727 ! ice_year, ice_month, &
728 ! ice_day, ice_hour )
729 ! if ( status /= success ) then
730 ! status = failure
731 ! call local_message_handler ('error reported from grib driver, NCEP sea ice read, Check PCF file', &
732 ! status, &
733 ! 'read_ancillary_grids')
734 ! else
735 !
736 !! Open unpacked ice file
737 ! reclen = 720*360*4
738 !
739 ! open (unit = lun, file = temp_output_name, form = 'unformatted', &
740 ! access = 'direct', status = 'old', &
741 ! recl = reclen, iostat = ios )
742 !
743 !
744 !
745 ! if ( status /= success ) then
746 ! status = failure
747 ! call local_message_handler ('error reported opening temp sea ice, Check PCF file', &
748 ! status, &
749 ! 'read_ancillary_grids')
750 ! else
751 !! Read the unpacked ice file
752 ! if ( status == 0 ) then
753 ! ios = 0
754 ! read( lun, rec = 1, iostat = ios )ice_grid
755 ! if ( ios /= success ) then
756 ! status = success
757 ! call local_message_handler ('error reported reading temp sea ice file, Check PCF file', &
758 ! status, &
759 ! 'read_ancillary_grids')
760 ! else
761 ! ice_success = .true.
762 ! ice_date( 1 ) = ice_year
763 ! ice_date( 2 ) = ice_month
764 ! ice_date( 3 ) = ice_day
765 ! ice_date( 4 ) = ice_hour
766 ! endif
767 ! close(lun)
768 ! endif
769 !
770 ! endif
771 ! endif
772 
773 ! xx(1) = met_date(4) * 1.0
774 ! xx(2) = met_date2(4) * 1.0
775 
776 ! frac_time = MYTIME / 100 + mod(MYTIME, 100) / 60.
777  ! calculate the pressure levels for the 101-level profile, courtesy UW-Madison
778  status = make_profile_101(pressures_source)
779 
780 ! do i=1, grid_xsize
781 ! ii = i-1
782 !
783 ! do j=1, grid_ysize
784 !
785 ! jj = j-1
786 !
787 ! p = p_source
788 ! pressures = pressures_source
789 !
790 ! model_lat = 89.5 - jj*1.0
791 !
792 ! yy(1) = met_grid(ii,jj,wind_start)
793 ! yy(2) = met_grid2(ii,jj, wind_start)
794 !
795 ! yy2(1) = met_grid(ii,jj,wind_start+1)
796 ! yy2(2) = met_grid2(ii,jj,wind_start+1)
797 !
798 ! model_info(i,j)%wind_speed = sqrt( linearinterpolation( xx, yy, frac_time) **2 + &
799 ! linearinterpolation( xx, yy2, frac_time) **2 )
800 !
801 !
802 ! kstart = 0
803 ! do k = 1, model_coarse-1
804 ! temp(k) = linearinterpolation( xx, &
805 ! (/ met_grid(ii,jj,kstart), met_grid2(ii,jj, kstart) /), frac_time) !met_grid( i, j, k )
806 ! kstart = kstart + 1
807 ! end do
808 !
809 ! kstart = model_coarse-1
810 ! do k = rh_start, model_coarse-1
811 ! mixr(k) = linearinterpolation( xx, &
812 ! (/ met_grid(ii,jj, kstart), met_grid2(ii,jj, kstart) /), frac_time) !met_grid( i, j, k + 16 )
813 ! if (mixr(k) < 0.) mixr(k) = 0.
814 ! kstart = kstart + 1
815 ! end do
816 !
817 !! convert relative humidity profile (%) to mixing ratio (g/kg)
818 !
819 ! do k = rh_start, model_coarse-1
820 ! mixr(k) = get_W (mixr(k), temp(k), p(k))
821 ! end do
822 !
823 !
824 !
825 !! extrapolate mixing ratio profile from 100 hPa to 10 hPa
826 ! do k = 1, 5
827 ! mixr(k) = max( mixr(6), 0.003d0 ) * ( p( k ) / 100.0 )**3 ! was 21
828 ! mixr(k) = max( mixr(k), 0.003d0 )
829 ! end do
830 !
831 !
832 ! model_info(i,j)%Ps = linearinterpolation( xx, (/ met_grid(ii,jj,wind_start+2), &
833 ! met_grid2(ii,jj, wind_start+2) /), frac_time) * 0.01 !met_grid( i, j, 76 )
834 !
835 !! get the surface parameters and convert the RH at 2m to mixing ratio
836 !! this Ts2m is really Ts, the surface temperature. Wisconsin switched to using TSFC instead of T2M
837 ! Ts2m = linearinterpolation( xx, (/ met_grid(ii,jj,wind_start+3), &
838 ! met_grid2(ii,jj, wind_start+3) /), frac_time)
839 !
840 !! if we have ECMWF this W2m is not an RH, but a dew point temperature.
841 ! W2m = linearinterpolation( xx, (/ met_grid(ii,jj,wind_start+4),&
842 ! met_grid2(ii,jj, wind_start+4) /), frac_time)
843 !
844 ! W2m = get_W(W2m*1.0d0, Ts2m*1.0d0, model_info(i,j)%Ps*1.0d0)
845 ! Pmsl = linearinterpolation( xx, (/ met_grid(ii,jj,52), met_grid2(ii,jj, 52) /), frac_time)* 0.01
846 !
847 ! if (model_info(i,j)%Ps > 0. .and. p(model_coarse-1) <= model_info(i,j)%Ps) then
848 ! model_info(i,j)%surface_level = model_coarse
849 ! else
850 ! model_info(i,j)%surface_level = 0
851 ! endif
852 !
853 ! model_info(i,j)%Ts = Ts2m
854 ! model_info(i,j)%col_o3 = linearinterpolation( xx, (/ met_grid(ii,jj,53), met_grid2(ii,jj, 53) /), frac_time)
855 !
856 !
857 ! kstart = model_coarse / 2
858 ! do k=kstart, model_coarse
859 !
860 ! if (model_info(i,j)%Ps > 0. .and. p(k) > model_info(i,j)%Ps) then
861 ! if (model_info(i,j)%surface_level == 0) then
862 !
863 ! model_info(i,j)%surface_level = k
864 ! temp(k) = Ts2m
865 ! if ( (model_info(i,j)%Ps - p(k-1)) < 5. .or. &
866 ! (p(k) - model_info(i,j)%Ps) < 5. ) then
867 ! p(k) = (p(k) + p(k-1)) / 2.
868 ! else
869 ! p(k) = model_info(i,j)%Ps
870 ! endif
871 ! mixr(k) = W2m
872 !
873 ! else
874 !
875 ! temp(k) = Ts2m
876 ! mixr(k) = W2m
877 ! p(k) = p_source(k-1)
878 !
879 ! endif
880 !
881 ! endif
882 !
883 ! end do
884 !
885 !! add the surface level into the coarse profile
886 ! if (model_info(i,j)%surface_level /= model_coarse) then
887 ! p(model_coarse) = p_source(model_coarse)
888 ! else
889 ! p(model_coarse) = model_info(i,j)%Ps
890 ! endif
891 ! temp(model_coarse) = Ts2m
892 ! mixr(model_coarse) = W2m
893 !
894 !
895 !
896 !! now we determine the lowest valid level of the new high-res profile
897 ! kstart = model_levels / 2
898 ! do k = kstart, model_levels
899 ! if (pressures(k) >= model_info(i,j)%Ps) then
900 ! model_info(i,j)%surface_level = k
901 ! exit
902 ! endif
903 ! end do
904 !
905 !! interpolate the profile to 101 levels, courtesy UW-Madison
906 !
907 ! status = profile_to_101(p, temp, mixr, model_coarse, model_lat, pressures, temp_hires, mixr_hires, 0)
908 !
909 !
910 !
911 ! sfc_level = model_info(i,j)%surface_level
912 ! a_factor = (model_info(i,j)%Ps - pressures(sfc_level-1)) / &
913 ! ( pressures(sfc_level) - pressures(sfc_level-1))
914 ! temp_hires(sfc_level) = temp_hires(sfc_level-1) + a_factor * (temp_hires(sfc_level) - temp_hires(sfc_level-1))
915 ! mixr_hires(sfc_level) = mixr_hires(sfc_level-1) + a_factor * (mixr_hires(sfc_level) - mixr_hires(sfc_level-1))
916 !
917 ! pressures(sfc_level) = model_info(i,j)%Ps
918 !
919 ! model_info(i,j)%temp_profile = temp_hires
920 ! model_info(i,j)%mixr_profile = mixr_hires
921 !
922 !! calculate the height profile, courtesy UW-Madison
923 !
924 ! status = height_profile(pressures, temp_hires, mixr_hires, &
925 ! heights, model_levels, Pmsl*1.0d0)
926 !
927 !
928 ! model_info(i,j)%height_profile = heights
929 ! model_info(i,j)%pressure_profile = pressures
930 !
931 !
932 !
933 ! model_info(i,j)%trop_level = find_trop (model_info(i,j)%temp_profile, &
934 ! model_info(i,j)%pressure_profile, sfc_level)
935 !
936 !
937 !
938 !
939 ! end do
940 ! end do
941 !
942  endif
943 
944 
945 
946 
947 ! get lat/long data from grids
948 
949 ! do grid_i = 1, data_xsize
950 ! do grid_j = 1, data_ysize
951 !
952 !! don't waste time processing and setting ancillary if there is no cloud. Why bother?
953 ! if (lon(grid_i,grid_j) <= -999. .or. lat(grid_i,grid_j) <= -999.0 &
954 ! .or. cloudmask(grid_i,grid_j)%probablyclear_95 .or. cloudmask(grid_i,grid_j)%probablyclear_99 ) then
955 !
956 ! icec(grid_i, grid_j) = -999.
957 ! ozone(grid_i, grid_j) = -999.
958 !
959 ! cycle
960 !
961 ! endif
962 !
963 ! call get_model_idx(lat(grid_i,grid_j), lon(grid_i,grid_j), i, j)
964 !
965 ! i = i-1
966 ! j = j-1
967 !
968 ! call get_bilinear_idx(lat(grid_i,grid_j), lon(grid_i,grid_j), i, j, idx_x, idx_y)
969 !
970 !
971 ! if (idx_x(1)-1 < 180) then
972 ! lon_set(1) = (idx_x(1) - 1) * 1.0 !+ 0.5
973 ! else
974 ! lon_set(1) = (idx_x(1) - 1) * 1.0 - 360. !+ 0.5
975 ! endif
976 !
977 ! if (idx_x(2)-1 < 180) then
978 ! lon_set(2) = (idx_x(2) - 1) * 1.0 !+ 0.5
979 ! else
980 ! lon_set(2) = (idx_x(2) - 1) * 1.0 - 360. !+ 0.5
981 ! endif
982 !
983 !
984 ! if (lon(grid_i, grid_j) > 179 ) then !.5) then
985 ! lon_set(1) = 179 !.5
986 ! lon_set(2) = 180 !.5
987 ! endif
988 !
989 ! if (lon(grid_i, grid_j) < -179 ) then !.5) then
990 ! lon_set(1) = -180 !.5
991 ! lon_set(2) = -179 !.5
992 ! endif
993 !
994 !
995 ! lat_set = 90-(idx_y-1)*1.0 ! - 0.5
996 ! if (lat(grid_i, grid_j) > 89 ) then !.5) then
997 ! lat_set(1) = 90.0
998 ! lat_set(2) = 89 !.5
999 ! endif
1000 !
1001 ! if (lat(grid_i, grid_j) < -89 ) then !.5) then
1002 ! lat_set(1) = -89. !.5
1003 ! lat_set(2) = -90.
1004 ! endif
1005 !
1006 ! Ts_forint(1,1) = model_info(idx_x(1), idx_y(1))%col_o3
1007 ! Ts_forint(1,2) = model_info(idx_x(1), idx_y(2))%col_o3
1008 ! Ts_forint(2,1) = model_info(idx_x(2), idx_y(1))%col_o3
1009 ! Ts_forint(2,2) = model_info(idx_x(2), idx_y(2))%col_o3
1010 !
1011 ! ozone(grid_i, grid_j) = bilinear_interpolation( lon_set, &
1012 ! lat_set, lon(grid_i, grid_j), lat(grid_i, grid_j), Ts_forint, 1)
1013 !
1014 !
1015 !! compute cell coordinates in ice grid and save ice data
1016 ! x = min( max( lon(grid_i,grid_j), -179.99 ), 179.99 )
1017 ! if( x .lt. 0.0 ) x = lon(grid_i,grid_j) + 360.0
1018 ! x0 = 0.25
1019 ! dx = 0.5
1020 ! i = int( ( x - x0 + 0.5*dx ) / dx )
1021 ! if( i .eq. 720 ) i = 0
1022 !
1023 ! y = min( max( lat(grid_i,grid_j), -89.99 ), 89.99 )
1024 ! y0 = 89.75
1025 ! dy = -0.5
1026 ! j = int( ( y - y0 + 0.5*dy ) / dy )
1027 !
1028 ! icec(grid_i, grid_j) = ice_grid( i, j, 1 )
1029 !
1030 ! enddo
1031 ! enddo
1032 
1033 
1034  end subroutine read_ancillary_grids
1035 
1036  subroutine get_surface_albedo(latitude, &
1037  longitude,&
1038  nise_filename, &
1039  IGBPfilename, &
1040  snowicealbedo_data_name, &
1041  emissivity_name, &
1042  debug, &
1043  icec, &
1044  surface_albedo, surface_emissivity, &
1045  status)
1046 !-----------------------------------------------------------------------
1047 !f90 modisretrieval
1048 !
1049 !Description:
1050 !
1051 ! get surface albedos for all required bands
1052 !
1053 !input parameters:
1054 !
1055 !output parameters:
1056 !
1057 !revision history:
1058 !
1059 !team-unique header:
1060 !
1061 ! Cloud Retrieval Group, NASA GSFC, Greenbelt, Maryland, USA
1062 !
1063 !references and credits:
1064 !
1065 ! Mark Gray
1066 ! gray@climate.gsfc.nasa.gov
1067 ! EmergentIT
1068 ! Code 913, NASA GSFC
1069 ! Greenbelt, MD 20771
1070 !
1071 !
1072 !design note:
1073 !
1074 !end
1075 !----------------------------------------------------------------------
1076 
1077 ! collection 4 albedo determination
1078  use generalauxtype
1081  use core_arrays, only: cloudsummary, cloudmask
1082  use names, only : myday
1083  use mod06_run_settings
1085 ! WDR use MOD06AlbedoEcoModule, only: init_NISE_processing
1086 
1087 
1088 ! include 'PGS_PC.f'
1089 ! include 'PGS_TD.f'
1090 ! include 'PGS_SMF.f'
1091 
1092  real, dimension(:,:), intent(in) :: latitude, longitude
1093  character(*),intent(in) :: IGBPfilename, &
1094  nise_filename, &
1095  snowicealbedo_data_name, emissivity_name
1096  logical, intent(in) :: debug
1097  real(single), dimension(:,:), intent(in) :: icec
1098  real, dimension(:,:,:), intent(out) :: surface_emissivity
1099  integer*2, dimension(:,:,:), intent(out) :: surface_albedo
1100  integer, intent(out) :: status
1101 
1102  integer (kind = integer_fourbyte), parameter :: MaxFileNameLength = 2025
1103  integer*1, &
1104  allocatable, dimension(:,:) :: ecosystem, sfc_info
1105  integer (integer_fourbyte) :: julianday,i,j,NumAlbWavelengths
1106 
1107  character (len = MaxFileNameLength) :: SnowAlbedoFN
1108  character(len = 10) :: wavelengthtext(set_albedo_bands)
1109  real :: Wavelength(set_albedo_bands)
1110  logical :: processlandalbedo(set_albedo_bands)
1111 
1112  !Timestamp variables:
1113  integer (kind = integer_fourbyte), parameter :: LUN_TimeStamp = 10258
1114  character (len = 40) :: dateTime_a, dateTime_b
1115  integer (kind = integer_fourbyte) :: PGS_PC_GetConfigData, &
1116  PGS_TD_asciitime_atob
1117  character (len = 3) :: DayOfYearString
1118 
1119  integer :: lat_wid, lat_ht, num_iter
1120 ! integer :: lat_start, lat_end
1121  integer :: use_eco ! WDR to easily use / disable getAlbedoEco output below
1122  ! and use the l2gen ice and land info
1123 
1124  lat_wid = size(latitude, 1)
1125  lat_ht = size(latitude, 2)
1126 
1127  allocate(ecosystem(lat_wid, lat_ht), sfc_info(lat_wid, lat_ht))
1128 
1129 
1130  numalbwavelengths = set_albedo_bands
1131 
1132  !Define the wavelengths:
1133 #if RETRIEVE
1134  wavelengthtext(1) = "0.659"
1135 #else
1136  wavelengthtext(1) = "0.555"
1137 #endif
1138 
1139  wavelengthtext(2) = "0.858"
1140 
1141 #if EPIC_INST
1142  wavelengthtext(3) = "0.659"
1143 #else
1144  wavelengthtext(3) = "1.24"
1145 #endif
1146 
1147  wavelengthtext(4) = "1.64"
1148  wavelengthtext(5) = "2.13"
1149  wavelengthtext(6) = "3.7"
1150 
1151  snowalbedofn = snowicealbedo_data_name
1152 
1153 
1154  ecosystem = -99
1155 
1156  !Determine the Julian Day by reading in the time stamp and converting:
1157  !Get the Time Stamp from the pcf file:
1158 ! Status = PGS_PC_GetConfigData(LUN_TimeStamp,dateTime_a)
1159 ! if (status /= PGS_S_SUCCESS) then
1160 ! call local_message_handler('Problem Reading in the PCF Time Stamp',status,'get_surface_albedo')
1161 ! endif
1162  !Convert to day of year string:
1163 ! Status = PGS_TD_asciitime_atob(dateTime_a,dateTime_b)
1164 ! if (status /= PGS_S_SUCCESS) then
1165 ! call local_message_handler('Problem converting time stamp to DOY',status,'get_surface_albedo')
1166 ! endif
1167  !Extract the Day of Year:
1168 ! DayOfYearString = dateTime_b(6:8)
1169  !Convert to integer:
1170 ! read(DayOfYearString, *) JulianDay
1171  !If not successful, set JulianDay to 1 so that it does not crash:
1172  julianday = myday
1173 
1174  if (julianday < 1 .or. julianday > 366) julianday = 1
1175 
1176  processlandalbedo(1) = .true.
1177  processlandalbedo(2) = .true.
1178  processlandalbedo(3) = .true.
1179 #if NOSWIR
1180  processlandalbedo(4) = .false.
1181  processlandalbedo(5) = .false.
1182  processlandalbedo(6) = .false.
1183 #else
1184  processlandalbedo(4) = .true.
1185  processlandalbedo(5) = .true.
1186  processlandalbedo(6) = .true.
1187 #endif
1188 
1189  if (.not. snow_stats_are_read) then
1190 !print*, '************* WDR initializing the snow stats again'
1191  call init_snow_stats(snowalbedofn, wavelengthtext)
1192  snow_stats_are_read = .true.
1193  endif
1194 
1195 ! WDR out for anc ice from outside
1196 !#ifdef GEOS5_SFC
1197 ! NISE_is_read = .true.
1198 !#else
1199 ! if (.not. NISE_is_read) then
1200 ! call init_NISE_processing(nise_filename)
1201 ! NISE_is_read = .true.
1202 ! endif
1203 !#endif
1204 
1205  num_iter = lat_ht / 100 + 1
1206 
1207  do i=1, num_iter
1208 
1209  lat_start = (i-1)*100 + 1
1210  if (lat_start > lat_ht) lat_start = lat_ht
1211 
1212  if (i==num_iter) then
1213  lat_end = lat_ht
1214  else
1215  lat_end = lat_start + 99
1216  endif
1217 
1218 
1219  call getalbedoeco (latitude(:, lat_start:lat_end), &
1220  longitude(:, lat_start:lat_end), &
1221  julianday, &
1222  igbpfilename, &
1223  emissivity_name, &
1224  debug, &
1225  wavelengthtext, &
1226  processlandalbedo, &
1227  icec(:, lat_start:lat_end), &
1228  surface_albedo(:, lat_start:lat_end, :), &
1229  surface_emissivity(:, lat_start:lat_end, :), &
1230  ecosystem(:, lat_start:lat_end), &
1231  status, sfc_info(:, lat_start:lat_end) )
1232 
1233  end do
1234 
1235  where (surface_albedo > 1000) surface_albedo = -9999
1236 
1237  do i = 1, lat_wid
1238  do j = 1, lat_ht
1239 
1240 ! WDR the use_eco will allow the getAlbedoEco land info to be used,
1241 ! else, the l2gen stuff is used (except the albedo)
1242  use_eco = 1
1243  if( use_eco == 1 ) then
1244  cloudmask(i,j)%ocean_no_snow = 0
1245  cloudmask(i,j)%ocean_snow = 0
1246  cloudmask(i,j)%land_no_snow = 0
1247  cloudmask(i,j)%land_snow = 0
1248 
1249  if (sfc_info(i,j) == 0) then
1250  cloudmask(i,j)%ocean_no_snow = 1
1251  else if (sfc_info(i,j) == 1) then
1252  cloudmask(i,j)%ocean_snow = 1
1253  else if (sfc_info(i,j) == 2) then
1254  cloudmask(i,j)%land_no_snow = 1
1255  else if (sfc_info(i,j) == 3) then
1256  cloudmask(i,j)%land_snow = 1
1257  endif
1258 
1259 
1260  if (ecosystem(i,j) == 0 )then
1261 
1262  cloudsummary(i,j)%land_surface = .false.
1263  cloudsummary(i,j)%ocean_surface = .true.
1264  cloudsummary(i,j)%coastal_surface = .false.
1265  cloudsummary(i,j)%desert_surface = .false.
1266  cloudsummary(i,j)%snowice_surface = .false.
1267  elseif (ecosystem(i,j) == 15) then
1268 
1269  cloudsummary(i,j)%land_surface = .false.
1270 
1271  cloudsummary(i,j)%ocean_surface = .false.
1272  cloudsummary(i,j)%coastal_surface = .false.
1273  cloudsummary(i,j)%desert_surface = .false.
1274  cloudsummary(i,j)%snowice_surface = .true.
1275  else
1276  cloudsummary(i,j)%land_surface = .true.
1277  cloudsummary(i,j)%ocean_surface = .false.
1278  cloudsummary(i,j)%coastal_surface = .false.
1279  cloudsummary(i,j)%desert_surface = .false.
1280  cloudsummary(i,j)%snowice_surface = .false.
1281  endif
1282  else
1283  ! WDR the cloudmask is set previously, just do the cloudsummary
1284  cloudsummary(i,j)%land_surface = .false.
1285  cloudsummary(i,j)%ocean_surface = .false.
1286  cloudsummary(i,j)%coastal_surface = .false.
1287  cloudsummary(i,j)%desert_surface = .false.
1288  cloudsummary(i,j)%snowice_surface = .false.
1289  if( cloudmask(i,j)%land_no_snow == 1 ) &
1290  cloudsummary(i,j)%land_surface = .true.
1291  if( ( cloudmask(i,j)%ocean_snow == 1 ) .or. &
1292  ( cloudmask(i,j)%land_snow == 1 ) ) &
1293  cloudsummary(i,j)%snowice_surface = .true.
1294  if( cloudmask(i,j)%ocean_no_snow == 1 ) &
1295  cloudsummary(i,j)%ocean_surface = .true.
1296  endif
1297 
1298  enddo
1299  enddo
1300  deallocate(ecosystem, sfc_info)
1301  if (status /= success) then
1302  call local_message_handler('Problem reported in get_surface_albedo, see earlier message/s',status,'get_surface_albedo')
1303  endif
1304  end subroutine get_surface_albedo
1305 
1306  subroutine get_above_cloud_properties( pprof, wprof, sfc_lev, &
1307  cloud_top_pressure, &
1308  abovecloud_watervapor, &
1309  status)
1312 
1313 
1314 
1315  real, intent(in), dimension(:) :: pprof, wprof
1316  integer*1, intent(in) :: sfc_lev
1317  real, intent(in) :: cloud_top_pressure
1318  real, intent(out) :: abovecloud_watervapor
1319  integer, intent(out) :: status
1320 
1321  integer :: level_index, k, num_levels
1322  real :: pw_layer, total_pw, slope, dummy
1323  real :: watervapor_lower, watervapor_upper
1324 
1325  abovecloud_watervapor = fillvalue_real
1326 
1327  if (cloud_top_pressure /= fillvalue_real) then
1328 
1329  num_levels = sfc_lev + 1
1330  k = 2
1331  total_pw = 0.
1332  do while ( pprof(k) < cloud_top_pressure .and. k < num_levels)
1333  pw_layer = ( pprof(k) - pprof(k-1) ) * &
1334  ( wprof(k-1) + wprof(k) ) * 0.5/ 980.616
1335 
1336  total_pw = total_pw + pw_layer
1337  k = k + 1
1338  enddo
1339 
1340 
1341  slope = ( wprof(k) - wprof(k-1) ) / &
1342  ( pprof(k) - pprof(k-1))
1343 
1344  watervapor_upper = wprof(k-1)
1345  watervapor_lower = slope * (cloud_top_pressure - pprof(k-1)) + &
1346  watervapor_upper
1347  pw_layer = (cloud_top_pressure - pprof(k-1)) * &
1348  (watervapor_upper + watervapor_lower) * 0.5/980.616
1349  abovecloud_watervapor = total_pw + pw_layer
1350 
1351  endif
1352 
1353  end subroutine get_above_cloud_properties
1354 
1355 
1356  end module ancillary_module
Definition: ch_xfr.f90:1
real, dimension(:,:), allocatable c2_alt_icec
Definition: ch_xfr.f90:20
subroutine get_surface_albedo(latitude, longitude, nise_filename, IGBPfilename, snowicealbedo_data_name, emissivity_name, debug, icec, surface_albedo, surface_emissivity, status)
subroutine, public init_snow_stats(SnowAlbedoFN, WavelengthText)
type(cloudmask_type), dimension(:,:), allocatable cloudmask
real(single), dimension(:,:), allocatable longitude
real(single), dimension(:,:), allocatable cloud_top_pressure
real function, public linearinterpolation(X, Y, XX)
real, dimension(:,:), allocatable irw_temperature
real(single), dimension(:,:), allocatable latitude
integer, parameter set_albedo_bands
character(len=500) atmp_dirname
Definition: names.f90:44
character *15 platform_name
#define real
Definition: DbAlgOcean.cpp:26
integer *1, dimension(:,:), allocatable cloud_phase_infrared
real, dimension(:,:,:), allocatable surface_albedo
subroutine set_albedo
type(processflag), dimension(:,:), allocatable cloudsummary
Definition: core_arrays.f90:87
integer, parameter single
subroutine, public get_above_cloud_properties(pprof, wprof, sfc_lev, cloud_top_pressure, abovecloud_watervapor, status)
README for MOD_PR03(V6.1.0) 2. POINTS OF CONTACT it can be either SDP Toolkit or MODIS Packet for Terra input files The orbit validation configuration parameter(LUN 600281) must be either "TRUE" or "FALSE". It needs to be "FALSE" when running in Near Real Time mode
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)
real(single), dimension(:,:), allocatable column_ozone
integer mytime
Definition: names.f90:9
real, dimension(:,:), allocatable snow_cover
character(len=500) c2_cloud_hgt_file
Definition: ch_xfr.f90:54
subroutine, public getalbedoeco(Lat, Long, JulianDay, EcosystemFN, emissivity_name, Debug, WavelengthText, ProcessLandAlbedo, icec, Albedo, emissivity, Ecosystem, Status, sfc_info)
type(ancillary_type), dimension(:,:), allocatable model_info
integer, public lat_start
integer myyear
Definition: names.f90:9
integer myday
Definition: names.f90:9
real(single), dimension(:,:), allocatable cloud_top_temperature
integer function find_trop(temp_prof, p_prof, sfc_lev)
real(single), dimension(:,:,:), allocatable surface_emissivity_land
real function, public bilinear_interpolation(X, Y, XX, YY, source, method)
integer, public lat_end
subroutine rd_cloud_top()
integer, parameter model_levels
integer mymonth
Definition: names.f90:9
real(single), dimension(:,:), allocatable surface_temperature
Definition: names.f90:1
integer c2_scan
Definition: ch_xfr.f90:44
real, dimension(:,:), allocatable c2_alt_o3
Definition: ch_xfr.f90:20
integer, parameter logical
real frac_time
Definition: names.f90:10
integer *1, dimension(:,:), allocatable cloud_height_method
subroutine, public given_p_get_t(P, model_point, T)
subroutine local_message_handler(message, severity, functionname)