NASA Logo
Ocean Color Science Software

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