emcsfc_snow2mdl  1.13.0
snowdat.F90
Go to the documentation of this file.
1 
4 
26  module snowdat
27 
28  use program_setup, only : autosnow_file, &
36 
37  use model_grid, only : imdl, &
38  jmdl
39 
40  integer :: iafwa
41  integer :: iautosnow
42  integer :: inesdis
43  integer :: jafwa
44  integer :: jautosnow
45  integer :: jnesdis
46  integer :: kgds_afwa_global(200)
48  integer :: kgds_afwa_nh(200)
50  integer :: kgds_afwa_nh_8th(200)
52  integer :: kgds_afwa_sh(200)
54  integer :: kgds_afwa_sh_8th(200)
56  integer :: kgds_autosnow(200)
57  integer :: kgds_nesdis(200)
58  integer :: mesh_nesdis
59  integer*1, allocatable :: sea_ice_nesdis(:,:)
60  logical :: bad_afwa_nh
62  logical :: bad_afwa_sh
64  logical :: bad_nesdis
66  logical :: bad_afwa_global
68  logical*1, allocatable :: bitmap_afwa_global(:,:)
70  logical*1, allocatable :: bitmap_afwa_nh(:,:)
72  logical*1, allocatable :: bitmap_afwa_sh(:,:)
74  logical*1, allocatable :: bitmap_nesdis(:,:)
75  logical*1, allocatable :: bitmap_autosnow(:,:)
77  logical :: use_nh_afwa
78  logical :: use_sh_afwa
79  logical :: use_global_afwa
80  logical :: use_autosnow
81  logical :: use_nesdis
82 
83  real :: autosnow_res
84  real :: afwa_res
85  real :: nesdis_res
86  real, allocatable :: snow_cvr_nesdis(:,:)
87  real, allocatable :: snow_cvr_autosnow(:,:)
88  real, allocatable :: snow_dep_afwa_global(:,:)
89  real, allocatable :: snow_dep_afwa_nh(:,:)
90  real, allocatable :: snow_dep_afwa_sh(:,:)
91 
92 ! the afwa 8th mesh binary data has no grib header, so set it from these
93 ! data statements. needed for ipolates routines.
94 
95  data kgds_afwa_nh_8th/5,2*512,-20826,145000,8,-80000,2*47625,0, &
96  9*0,255,180*0/
97  data kgds_afwa_sh_8th/5,2*512,20826,-125000,8,-80000,2*47625,128, &
98  9*0,255,180*0/
99  contains
117  subroutine readautosnow
118  use grib_mod ! grib 2 libraries
119 
120  implicit none
121 
122  type(gribfield) :: gfld
123 
124  integer :: iret, j, k, lugb, lugi
125  integer :: jdisc, jgdtn, jpdtn
126  integer :: jids(200), jgdt(200), jpdt(200)
127 
128  logical :: unpack
129 
130  use_autosnow = .true.
131 
132  if ( len_trim(autosnow_file) == 0 ) then
133  print*,"- WILL NOT USE AUTOSNOW DATA."
134  use_autosnow = .false.
135  return
136  end if
137 
138  print*,"- OPEN AND READ AUTOSNOW FILE ", trim(autosnow_file)
139 
140  lugb=12
141  call baopenr(lugb,autosnow_file,iret)
142 
143  if (iret /= 0) then
144  print*,'- FATAL ERROR: BAD OPEN OF FILE, IRET IS ', iret
145  call w3tage('SNOW2MDL')
146  call errexit(74)
147  endif
148 
149  call grib2_null(gfld)
150 
151  j = 0 ! search at beginning of file
152  lugi = 0 ! no grib index file
153  jdisc = 0 ! search for discipline; 0 - meteorological products
154  jpdtn = 30 ! search for product definition template number; 30 - satellite product
155  jgdtn = 0 ! search for grid definition template number; 0 - lat/lon grid
156  jids = -9999 ! array of values in identification section, set to wildcard
157  jgdt = -9999 ! array of values in grid definiation template 3.m
158  jpdt = -9999 ! array of values in product definition template 4.n
159  jpdt(1) = 1 ! search for parameter category - moisture
160  jpdt(2) = 42 ! search for parameter number - snow cover in percent.
161  unpack = .true. ! unpack data
162 
163  call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
164  unpack, k, gfld, iret)
165 
166  if (iret /=0) then
167  print*,'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
168  call w3tage('SNOW2MDL')
169  call errexit(75)
170  endif
171 
172  print*,"- DATA VALID AT (YYYYMMDDHH): ", gfld%idsect(6),gfld%idsect(7), &
173  gfld%idsect(8),gfld%idsect(9)
174 
175  call baclose (lugb, iret)
176 
177 !-----------------------------------------------------------------------
178 ! set the grib1 kgds array from the g2 grid definition template array.
179 ! the kgds array is used by ipolates.
180 !-----------------------------------------------------------------------
181 
182  call gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_autosnow, &
184 
186  bitmap_autosnow = reshape(gfld%bmap , (/iautosnow,jautosnow/) )
187 
189  snow_cvr_autosnow = reshape(gfld%fld , (/iautosnow,jautosnow/) )
190 
191  call grib2_free(gfld)
192 
193  end subroutine readautosnow
194 
222  subroutine readnesdis
223  use grib_mod
224 
225  implicit none
226 
227  integer, parameter :: iunit = 13 ! input grib file unit number
228  integer, parameter :: iunit2 = 43 ! input landmask file unit number
229 
230  integer*4, allocatable :: dummy4(:,:)
231  integer :: i, j
232  integer :: iret
233  integer :: jgds(200)
234  integer :: jpds(200)
235  integer :: lskip
236  integer, parameter :: lugi = 0 ! grib index file unit number - not used
237  integer :: jdisc, jgdtn, jpdtn, k
238  integer :: jids(200), jgdt(200), jpdt(200)
239  integer :: kgds(200)
240  integer :: kpds(200)
241  integer :: message_num
242  integer :: numbytes
243  integer :: numpts
244  integer :: isgrib
245 
246  logical :: unpack
247 
248  real, allocatable :: dummy(:,:)
249  real :: dum
250 
251  type(gribfield) :: gfld
252 
253  use_nesdis = .true.
254 
255  if ( len_trim(nesdis_snow_file) == 0 ) then
256  print*,"- WILL NOT USE NESDIS/IMS DATA."
257  use_nesdis = .false.
258  return
259  end if
260 
261  print*,"- OPEN AND READ NESDIS/IMS SNOW FILE ", trim(nesdis_snow_file)
262 
263  call grib_check(nesdis_snow_file, isgrib)
264 
265  if (isgrib==0) then
266  print*,'- FATAL ERROR: IMS FILE MUST BE GRIB 1 OR GRIB2 FORMAT'
267  call w3tage('SNOW2MDL')
268  call errexit(41)
269  end if
270 
271  call baopenr (iunit, nesdis_snow_file, iret)
272 
273  if (iret /= 0) then
274  print*,'- FATAL ERROR: BAD OPEN OF FILE, IRET IS ', iret
275  call w3tage('SNOW2MDL')
276  call errexit(73)
277  end if
278 
279  if (isgrib==1) then ! grib 1 format
280 
281 !-----------------------------------------------------------------------
282 ! tell degribber to look for requested data.
283 !-----------------------------------------------------------------------
284 
285  lskip = -1
286  jpds = -1
287  jgds = -1
288  jpds(5) = 91 ! ice cover
289  kpds = jpds
290  kgds = jgds
291 
292  print*,"- GET GRIB HEADER"
293 
294  call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
295  numpts, message_num, kpds, kgds, iret)
296 
297  if (iret /= 0) then
298  print*,"- FATAL ERROR: BAD DEGRIB OF HEADER. IRET IS ", iret
299  call w3tage('SNOW2MDL')
300  call errexit(72)
301  end if
302 
303  kgds_nesdis = kgds
304  inesdis = kgds(2)
305  jnesdis = kgds(3)
306 
307  mesh_nesdis = inesdis / 64
308  nesdis_res = 381. / float(mesh_nesdis) ! in km
309 
310  print*,"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
311 
312  allocate (dummy(inesdis,jnesdis))
313  allocate (sea_ice_nesdis(inesdis,jnesdis))
314  allocate (bitmap_nesdis(inesdis,jnesdis))
315 
316  print*,"- DEGRIB SEA ICE."
317 
318  call getgb(iunit, lugi, (inesdis*jnesdis), lskip, jpds, jgds, &
319  numpts, lskip, kpds, kgds, bitmap_nesdis, dummy, iret)
320 
321  if (iret /= 0) then
322  print*,"- FATAL ERROR: BAD DEGRIB OF DATA. IRET IS ", iret
323  call w3tage('SNOW2MDL')
324  call errexit(71)
325  end if
326 
327  sea_ice_nesdis = nint(dummy) ! only needed as yes/no flag
328  deallocate (dummy)
329 
330  lskip = -1
331  jpds = -1
332  jgds = -1
333  jpds(5) = 238 ! snow cover
334  kpds = jpds
335  kgds = jgds
336 
337  allocate (snow_cvr_nesdis(inesdis,jnesdis))
338 
339  print*,"- DEGRIB SNOW COVER."
340 
341  call getgb(iunit, lugi, (inesdis*jnesdis), lskip, jpds, jgds, &
342  numpts, lskip, kpds, kgds, bitmap_nesdis, snow_cvr_nesdis, iret)
343 
344  if (iret /= 0) then
345  print*,"- FATAL ERROR: BAD DEGRIB OF DATA. IRET IS ", iret
346  call w3tage('SNOW2MDL')
347  call errexit(70)
348  end if
349 
350  elseif (isgrib==2) then ! grib 2 format
351 
352  print*,"- DEGRIB SNOW COVER."
353 
354  j = 0 ! search at beginning of file
355  jdisc = 0 ! search for discipline; 0 - meteorological products
356  jpdtn = 0 ! search for product definition template number; 0 - analysis at one level
357  jgdtn = 20 ! search for grid definition template number; 20 - polar stereographic grid
358  jids = -9999 ! array of values in identification section, set to wildcard
359  jgdt = -9999 ! array of values in grid definition template 3.m
360  jpdt = -9999 ! array of values in product definition template 4.n
361  jpdt(1) = 1 ! search for parameter category - moisture
362  jpdt(2) = 201 ! search for parameter number - snow cover in percent.
363  unpack = .true. ! unpack data
364 
365  call grib2_null(gfld)
366 
367  call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
368  unpack, k, gfld, iret)
369 
370  if (iret /=0) then
371  print*,'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
372  call w3tage('SNOW2MDL')
373  call errexit(70)
374  endif
375 
376  print*,"- DATA VALID AT (YYYYMMDDHH): ", gfld%idsect(6),gfld%idsect(7), &
377  gfld%idsect(8),gfld%idsect(9)
378 
379 !-----------------------------------------------------------------------
380 ! set the grib1 kgds array from the g2 grid definition template array.
381 ! the kgds array is used by ipolates.
382 !-----------------------------------------------------------------------
383 
384  call gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_nesdis, &
385  inesdis, jnesdis, dum)
386 
387  mesh_nesdis = inesdis / 64
388  nesdis_res = 381. / float(mesh_nesdis) ! in km
389 
390  if (mesh_nesdis==16) kgds_nesdis(6)=136 ! the ims 16th mesh grib2 data
391  ! is gribbed with an elliptical
392  ! earth. that is wrong. hardwire
393  ! a fix here.
394 
395  allocate (snow_cvr_nesdis(inesdis,jnesdis))
396  allocate (sea_ice_nesdis(inesdis,jnesdis))
397  allocate (bitmap_nesdis(inesdis,jnesdis))
398 
399  bitmap_nesdis = reshape(gfld%bmap , (/inesdis,jnesdis/) )
400  snow_cvr_nesdis = reshape(gfld%fld , (/inesdis,jnesdis/) )
401 
402  call grib2_free(gfld)
403 
404  print*,"- DEGRIB SEA ICE."
405 
406  j = 0 ! search at beginning of file
407  jdisc = 10 ! search for discipline; 10 - ocean products
408  jpdtn = 0 ! search for product definition template number; 0 - analysis at one level
409  jgdtn = 20 ! search for grid definition template number; 20 - polar stereographic grid
410  jids = -9999 ! array of values in identification section, set to wildcard
411  jgdt = -9999 ! array of values in grid definition template 3.m
412  jpdt = -9999 ! array of values in product definition template 4.n
413  jpdt(1) = 2 ! search for parameter category - ice
414  jpdt(2) = 0 ! search for parameter number - ice cover in percent.
415  unpack = .true. ! unpack data
416 
417  call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
418  unpack, k, gfld, iret)
419 
420  if (iret /=0) then
421  print*,'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
422  call w3tage('SNOW2MDL')
423  call errexit(71)
424  endif
425 
426  sea_ice_nesdis = reshape(gfld%fld , (/inesdis,jnesdis/) )
427 
428  call grib2_free(gfld)
429 
430  end if
431 
432  call baclose(iunit,iret)
433 
434 !-----------------------------------------------------------------------
435 ! the 16th mesh nesdis/ims grib data does not have a proper
436 ! bitmap section. therefore, need to read in the mask
437 ! from file. but the 96th mesh data has a proper bitmap, so use it.
438 !-----------------------------------------------------------------------
439 
440  if (mesh_nesdis == 16) then
441 
442  print*,"- OPEN NESDIS/IMS 16TH MESH LAND MASK: ", trim(nesdis_lsmask_file)
443 
444  open(iunit2, file=trim(nesdis_lsmask_file), form="formatted", &
445  iostat = iret)
446 
447  if (iret /= 0) then
448  print*,"- FATAL ERROR OPENING NESDIS/IMS LAND MASK FILE. ISTAT IS: ", iret
449  call errexit(87)
450  end if
451 
452  print*,"- READ NESDIS/IMS 16TH MESH LAND MASK."
453 
454  allocate (dummy4(inesdis,jnesdis))
455 
456  do j = 1, 1024
457  read(iunit2, 123, iostat=iret) (dummy4(i,j),i=1,1024)
458  if (iret /= 0) then
459  print*,"- FATAL ERROR READING NESDIS/IMS LAND MASK FILE. ISTAT IS: ", iret
460  call errexit(88)
461  end if
462  enddo
463 
464  close (iunit2)
465 
466 !-----------------------------------------------------------------------
467 ! the file has 0-sea, 1-land, 9-off hemi. this code expects
468 ! 0-non-land (or don't use data), 1-land (use data).
469 !-----------------------------------------------------------------------
470 
471  bitmap_nesdis=.false.
472  do j = 1, 1024
473  do i = 1, 1024
474  if (dummy4(i,j) == 1) bitmap_nesdis(i,j) = .true.
475  enddo
476  enddo
477 
478  deallocate(dummy4)
479 
480 123 FORMAT(80i1)
481 
482  endif ! is nesdis/ims data 16th mesh?
483 
484  bad_nesdis=.false.
486 
487 !-----------------------------------------------------------------------
488 ! for the 2009 nmm-b implementation, it was decided to not run with
489 ! afwa only. so even if afwa data is current and not corrupt,
490 ! but the ims is bad, then abort program. exception, if ims is very old
491 ! (there is a catastropic outage) then program will run with afwa
492 ! only. this is done by setting the nesdis_snow_file variable to
493 ! a zero length string (i.e., ims data not selected). this variable
494 ! setting is accomplished in the run script.
495 !-----------------------------------------------------------------------
496 
497  if (bad_nesdis) then
498  print*,'- FATAL ERROR: NESDIS/IMS DATA BAD, DO NOT USE.'
499  print*,'- DONT RUN PROGRAM.'
500  use_nesdis=.false.
501  call w3tage('SNOW2MDL')
502  call errexit(53)
503  stop
504  endif
505 
506  return
507 
508  end subroutine readnesdis
509 
531  subroutine readafwa
532  use grib_mod
533 
534  implicit none
535 
536  integer, parameter :: iunit=17
537  integer :: jgds(200), jpds(200), kgds(200), kpds(200)
538  integer :: istat, isgrib
539  integer :: lugi, lskip, numbytes, numpts, message_num
540  integer :: j, k, jdisc, jpdtn, jgdtn
541  integer :: jpdt(200), jgdt(200), jids(200)
542 
543  logical :: unpack
544 
545  type(gribfield) :: gfld
546 
547  bad_afwa_nh=.false.
548  bad_afwa_sh=.false.
549  bad_afwa_global=.false.
550 
551  use_global_afwa=.true.
552  use_nh_afwa = .true.
553  use_sh_afwa = .true.
554 
555  if (len_trim(afwa_snow_nh_file) == 0 .and. &
556  len_trim(afwa_snow_sh_file) == 0 .and. &
557  len_trim(afwa_snow_global_file) == 0) then
558  print*,"- WILL NOT USE AFWA DATA."
559  use_nh_afwa = .false.
560  use_sh_afwa = .false.
561  use_global_afwa = .false.
562  return
563  end if
564 
565 !-----------------------------------------------------------------------
566 ! If chosen, read global AFWA GRIB2 file.
567 !-----------------------------------------------------------------------
568 
569  if ( len_trim(afwa_snow_global_file) > 0 ) then
570 
571  print*,"- OPEN AND READ global AFWA SNOW FILE ", trim(afwa_snow_global_file)
572  call baopenr (iunit, afwa_snow_global_file, istat)
573  if (istat /= 0) then
574  print*,'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
575  call w3tage('SNOW2MDL')
576  call errexit(60)
577  end if
578 
579  call grib2_null(gfld)
580 
581  jdisc = 0 ! Search for discipline; 0 - meteorological products
582  j = 0 ! Search at beginning of file.
583  lugi = 0 ! No grib index file.
584  jids = -9999 ! Identification section, set to wildcard.
585  jgdt = -9999 ! Grid definition template, set to wildcard.
586  jgdtn = -1 ! Grid definition template number, set to wildcard.
587  jpdtn = 0 ! Search for product definition template number 0 - analysis or forecast
588  jpdt = -9999 ! Product definition template (Sec 4), initialize to wildcard.
589  jpdt(1) = 1 ! Search for parameter category 1 (Sec 4 oct 10) -
590  ! moisture.
591  jpdt(2) = 11 ! Search for parameter 11 (Sec 4 oct 11) - snow depth.
592  unpack = .true. ! Unpack data.
593 
594  call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
595  unpack, k, gfld, istat)
596 
597  if (istat /= 0) then
598  print*,"- FATAL ERROR: BAD DEGRIB OF GLOBAL DATA. ISTAT IS ", istat
599  call w3tage('SNOW2MDL')
600  call errexit(61)
601  end if
602 
603  print*,"- DATA VALID AT (YYMMDDHH): ", gfld%idsect(6:9)
604  print*,"- DEGRIB SNOW DEPTH."
605 
606  call gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_afwa_global, &
607  iafwa, jafwa, afwa_res)
608 
609  allocate(bitmap_afwa_global(iafwa,jafwa))
610  allocate(snow_dep_afwa_global(iafwa,jafwa))
611 
612  snow_dep_afwa_global = reshape(gfld%fld, (/iafwa,jafwa/))
613  bitmap_afwa_global = reshape(gfld%bmap, (/iafwa,jafwa/))
614 
615  call baclose(iunit, istat)
616 
618 
619  if (bad_afwa_global) then
620  print*,'- WARNING: AFWA DATA BAD, DO NOT USE.'
621  use_global_afwa = .false.
622  endif
623 
624  use_nh_afwa=.false. ! Use global or hemispheric files. not both.
625  use_sh_afwa=.false.
626 
627  return ! Use global or hemispheric files. not both.
628 
629  else
630 
631  use_global_afwa=.false.
632 
633  endif
634 
635  if ( len_trim(afwa_snow_nh_file) > 0 ) then ! afwa nh data selected
636 
637  call grib_check(afwa_snow_nh_file, isgrib)
638 
639  if (isgrib==0) then ! old ncep binary format
640 
641  iafwa = 512
642  jafwa = 512
643  afwa_res = 47.625 ! in kilometers
645 
646  allocate (snow_dep_afwa_nh(iafwa,jafwa))
648 
649  allocate (bitmap_afwa_nh(iafwa,jafwa))
651 
652  else ! afwa data is grib
653 
654  print*,"- OPEN AND READ AFWA SNOW FILE ", trim(afwa_snow_nh_file)
655 
656  call baopenr (iunit, afwa_snow_nh_file, istat)
657 
658  if (istat /= 0) then
659  print*,'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
660  call w3tage('SNOW2MDL')
661  call errexit(60)
662  end if
663 
664 !-----------------------------------------------------------------------
665 ! tell degribber to look for requested data.
666 !-----------------------------------------------------------------------
667 
668  lugi = 0
669  lskip = -1
670  jpds = -1
671  jgds = -1
672  jpds(5) = 66 ! snow depth
673  kpds = jpds
674  kgds = jgds
675 
676  print*,"- GET GRIB HEADER"
677  call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
678  numpts, message_num, kpds, kgds, istat)
679 
680  if (istat /= 0) then
681  print*,"- FATAL ERROR: BAD DEGRIB OF HEADER. ISTAT IS ", istat
682  call w3tage('SNOW2MDL')
683  call errexit(61)
684  end if
685 
686  iafwa = kgds(2)
687  jafwa = kgds(3)
688  afwa_res = float(kgds(8))*0.001 ! in km.
689 
690  print*,"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
691 
692  print*,"- DEGRIB SNOW DEPTH."
693 
694  allocate(bitmap_afwa_nh(iafwa,jafwa))
695  allocate(snow_dep_afwa_nh(iafwa,jafwa))
696 
697  call getgb(iunit, lugi, (iafwa*jafwa), lskip, jpds, jgds, &
698  numpts, lskip, kpds, kgds, bitmap_afwa_nh, snow_dep_afwa_nh, istat)
699 
700  if (istat /= 0) then
701  print*,"- FATAL ERROR: BAD DEGRIB OF DATA. ISTAT IS ", istat
702  call w3tage('SNOW2MDL')
703  call errexit(61)
704  end if
705 
706  kgds_afwa_nh = kgds
707 
708  kgds_afwa_nh(7) = -80000 ! ipolates definition of orientation angle is
709  ! 180 degrees off from grib standard.
710 
711  call baclose(iunit, istat)
712 
713  endif ! is nh afwa data grib?
714 
716 
717  else
718 
719  use_nh_afwa=.false.
720 
721  endif
722 
723 !-----------------------------------------------------------------------
724 ! now, read southern hemisphere data.
725 !-----------------------------------------------------------------------
726 
727  if ( len_trim(afwa_snow_sh_file) > 0 ) then
728 
729  call grib_check(afwa_snow_sh_file, isgrib)
730 
731  if (isgrib==0) then ! old ncep binary format
732 
733  iafwa = 512
734  jafwa = 512
735  afwa_res = 47.625
737 
738  allocate (snow_dep_afwa_sh(iafwa,jafwa))
740 
741  allocate (bitmap_afwa_sh(iafwa,jafwa))
743 
744  else ! sh afwa data is grib
745 
746  print*,"- OPEN AND READ AFWA SNOW FILE ", trim(afwa_snow_sh_file)
747 
748  call baopenr (iunit, afwa_snow_sh_file, istat)
749 
750  if (istat /= 0) then
751  print*,'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
752  call w3tage('SNOW2MDL')
753  call errexit(60)
754  end if
755 
756 !-----------------------------------------------------------------------
757 ! tell degribber to look for requested data.
758 !-----------------------------------------------------------------------
759 
760  lugi = 0
761  lskip = -1
762  jpds = -1
763  jgds = -1
764  jpds(5) = 66 ! snow cover
765  kpds = jpds
766  kgds = jgds
767 
768  print*,"- GET GRIB HEADER"
769  call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
770  numpts, message_num, kpds, kgds, istat)
771 
772  if (istat /= 0) then
773  print*,"- FATAL ERROR: BAD DEGRIB OF HEADER. ISTAT IS ", istat
774  call w3tage('SNOW2MDL')
775  call errexit(61)
776  end if
777 
778  iafwa = kgds(2)
779  jafwa = kgds(3)
780  afwa_res = float(kgds(8))*0.001 ! in km.
781 
782  print*,"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
783 
784  print*,"- DEGRIB SNOW DEPTH."
785 
786  allocate(bitmap_afwa_sh(iafwa,jafwa))
787  allocate(snow_dep_afwa_sh(iafwa,jafwa))
788 
789  call getgb(iunit, lugi, (iafwa*jafwa), lskip, jpds, jgds, &
790  numpts, lskip, kpds, kgds, bitmap_afwa_sh, snow_dep_afwa_sh, istat)
791 
792  if (istat /= 0) then
793  print*,"- FATAL ERROR: BAD DEGRIB OF DATA. ISTAT IS ", istat
794  call w3tage('SNOW2MDL')
795  call errexit(61)
796  end if
797 
798  kgds_afwa_sh = kgds
799 
800  kgds_afwa_sh(7) = -80000 ! ipolates definition of orientation angle is
801  ! 180 degrees off from grib standard.
802 
803  call baclose(iunit, istat)
804 
805  endif ! is sh afwa data grib or not?
806 
807  call afwa_check(2)
808 
809  else
810 
811  use_sh_afwa = .false.
812 
813  endif
814 
815 !-------------------------------------------------------------------
816 !if either hemisphere is bad, don't trust all hemispheres
817 !-------------------------------------------------------------------
818 
819  if (bad_afwa_nh .or. bad_afwa_sh) then
820  print*,'- WARNING: AFWA DATA BAD, DO NOT USE.'
821  use_nh_afwa = .false.
822  use_sh_afwa = .false.
823  endif
824 
825  return
826 
827  end subroutine readafwa
828 
854  subroutine nh_climo_check(kgds_data,snow_data,bitmap_data,idata,jdata,isrc,bad)
855  use gdswzd_mod
856 
857  use program_setup, only : climo_qc_file, &
860 
861  use grib_mod ! for grib2 library
862 
863  implicit none
864 
865 ! describes the climo data grid.
866  integer, parameter :: iclim = 1080
867  integer, parameter :: jclim = 270
868  real, parameter :: lat11_clim = 90.0
869  real, parameter :: lon11_clim = -180.0
870  real, parameter :: dx_clim = 1./3.
871  real, parameter :: dy_clim = 1./3.
872 
873  integer, intent(in) :: idata, jdata, kgds_data(200), isrc
874  logical*1, intent(in) :: bitmap_data(idata,jdata)
875  logical, intent(out) :: bad
876  real, intent(in) :: snow_data(idata,jdata)
877 
878 ! local variables
879  integer :: idat(8), jdow, jdoy, jday
880  integer :: century, year, week, iret, lugb, i, j, ii, jj
881  integer :: lugi, jdisc, jpdtn, jgdtn, k, nret
882  integer :: jids(200), jgdt(200), jpdt(200)
883  integer :: count_nosnow_climo, count_nosnow_data
884  integer :: count_snow_climo, count_snow_data, count_grosschk_data
885 
886  logical*1, allocatable :: bitmap_clim(:,:)
887  logical :: unpack
888 
889  real, allocatable :: climo(:,:)
890  real :: fill, percent, x, y
891  real, allocatable :: xpts(:,:),ypts(:,:),rlon_data(:,:),rlat_data(:,:)
892  real :: thresh_gross, thresh
893 
894  type(gribfield) :: gfld
895 
896  bad=.false.
897  if (len_trim(climo_qc_file)==0) return
898 
899  print*,"- QC SNOW DATA IN NH."
900 
901  if (isrc==1) then
902  thresh_gross=50.0 ! afwa data is depth in meters
903  elseif (isrc==2) then
904  thresh_gross=100.0 ! nesdis/ims data is coverage in percent
905  endif
906 
907  fill=999.
908  allocate(xpts(idata,jdata))
909  allocate(ypts(idata,jdata))
910  allocate(rlon_data(idata,jdata))
911  allocate(rlat_data(idata,jdata))
912  do j=1,jdata
913  do i=1,idata
914  xpts(i,j)=i
915  ypts(i,j)=j
916  enddo
917  enddo
918 
919  print*,"- CALC LAT/LONS OF SOURCE POINTS."
920  call gdswzd(kgds_data,1,(idata*jdata),fill,xpts,ypts,rlon_data,rlat_data,nret)
921 
922  deallocate(xpts,ypts)
923 
924  if (nret /= (idata*jdata)) then
925  print*,"- WARNING: CALC FAILED. WILL NOT PERFORM QC."
926  deallocate (rlon_data,rlat_data)
927  return
928  endif
929 
930  count_grosschk_data=0
931  do j=1,jdata
932  do i=1,idata
933  if (rlat_data(i,j)>0.0 .and. bitmap_data(i,j)) then
934  if (snow_data(i,j) < 0.0 .or. snow_data(i,j) > thresh_gross) then
935  count_grosschk_data=count_grosschk_data+1
936  endif
937  endif
938  enddo
939  enddo
940 
941  if (count_grosschk_data > 1) then
942  print*,'- NUMBER OF DATA POINTS THAT FAIL GROSS CHECK ',count_grosschk_data
943  deallocate (rlon_data,rlat_data)
944  bad=.true.
945  return
946  endif
947 
948  print*,"- QC DATA SOURCE AGAINST CLIMO."
949  print*,"- OPEN CLIMO SNOW COVER FILE ",trim(climo_qc_file)
950  lugb=11
951  call baopenr(lugb,climo_qc_file,iret)
952 
953  if (iret /= 0) then
954  print*,"- WARNING: BAD OPEN, WILL NOT PERFORM QC ", iret
955  deallocate (rlon_data,rlat_data)
956  return
957  endif
958 
959 !---------------------------------------------------------------
960 ! climo file is weekly. so calculate the current week
961 ! then read that record from the climo file.
962 !---------------------------------------------------------------
963 
964  if (grib_year == 100) then
965  century = grib_century
966  else
967  century = grib_century-1
968  endif
969 
970  year = century*100 + grib_year
971 
972  idat=0
973  idat(1)=year
974  idat(2)=grib_month
975  idat(3)=grib_day
976 
977  call w3doxdat(idat,jdow,jdoy,jday)
978 
979 ! the climo file date is the beginning of the 7 day period
980 
981  week = nint((jdoy+3.)/7.)
982  if (week==0) week=52
983  if (week==53) week=1
984 
985  print*,"- READ CLIMO FOR WEEK ",week
986 
987  call grib2_null(gfld)
988 
989  j = week-1 ! search for specific week (# records to skip)
990  lugi = 0 ! no grib index file
991  jdisc = 0 ! search for discipline; 0 - meteorological products
992  jpdtn = 8 ! search for product definition template number; 8 - average
993  jgdtn = 0 ! search for grid definition template number; 0 - lat/lon grid
994  jids = -9999 ! array of values in identification section, set to wildcard
995 
996  jgdt = -9999 ! array of values in grid definition template 3.m
997  jgdt(8) = iclim ! search for assumed grid specs - i/j dimensions and corner
998  ! point lat/lons must match.
999  jgdt(9) = jclim
1000  jgdt(12) = nint(lat11_clim * 1e6)
1001  jgdt(13) = nint(abs(lon11_clim) * 1e6)
1002 
1003  jpdt = -9999 ! array of values in product definition template 4.n
1004  jpdt(1) = 1 ! search for parameter category - moisture
1005  jpdt(2) = 201 ! search for parameter number - snow cover in percent.
1006  unpack = .true. ! unpack data
1007 
1008  call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1009  unpack, k, gfld, iret)
1010 
1011  if (iret /= 0) then
1012  print*,"- WARNING: PROBLEM READING GRIB FILE ", iret
1013  print*,"- WILL NOT PERFORM QC."
1014  deallocate(rlon_data,rlat_data)
1015  call baclose(lugb,iret)
1016  return
1017  endif
1018 
1019  call baclose(lugb,iret)
1020 
1021  allocate(climo(iclim,jclim))
1022  climo = reshape(gfld%fld , (/iclim,jclim/) )
1023  allocate(bitmap_clim(iclim,jclim))
1024  bitmap_clim = reshape(gfld%bmap , (/iclim,jclim/) )
1025 
1026  call grib2_free(gfld)
1027 
1028 !---------------------------------------------------------------
1029 ! loop over all data points in nh. gross check data.
1030 ! afwa is a depth in meters, ims is % coverage. there should be
1031 ! no neg values or very large values. if point passes gross check,
1032 ! then check against climatology. find the
1033 ! nearest point on the climo snow cover grid. if
1034 ! climo indicates snow is likely (100% coverage), then
1035 ! check if afwa/ims has snow. if climo indicates snow is
1036 ! impossible (0% coverage), then check if afwa/ims has no snow. if
1037 ! afwa/ims differs from climo too much, then afwa/ims is
1038 ! considered suspect and will not be used.
1039 !---------------------------------------------------------------
1040 
1041  count_nosnow_climo=0
1042  count_nosnow_data=0
1043  count_snow_data=0
1044  count_snow_climo=0
1045 
1046  if (isrc==1) then
1047  thresh=.005
1048  elseif (isrc==2) then
1049  thresh=50.0
1050  endif
1051 
1052  do j=1,jdata
1053  do i=1,idata
1054  if (rlat_data(i,j)>0.0 .and. bitmap_data(i,j)) then
1055  y = (lat11_clim-rlat_data(i,j))/dy_clim + 1.0
1056  if (rlon_data(i,j)>180.0) rlon_data(i,j)=rlon_data(i,j)-360.0
1057  x = (rlon_data(i,j)-lon11_clim)/dx_clim + 1.0
1058  jj=nint(y)
1059  if (jj<1) jj=1
1060  if (jj>jclim) jj=jclim
1061  ii=nint(x)
1062  if (ii<1) ii=ii+iclim
1063  if (ii>iclim) ii=ii-iclim
1064  if (bitmap_clim(ii,jj)) then ! climo point is land
1065  if (climo(ii,jj) <1.0) then ! climo point is snow impossible
1066  count_nosnow_climo=count_nosnow_climo+1
1067  if (snow_data(i,j) == 0.0) then
1068  count_nosnow_data=count_nosnow_data+1
1069  endif
1070  endif
1071  if (climo(ii,jj) > 99.) then ! climo point is snow likely
1072  count_snow_climo=count_snow_climo+1
1073  if (snow_data(i,j) >thresh) then
1074  count_snow_data=count_snow_data+1
1075  endif
1076  endif
1077  endif
1078  endif
1079  enddo
1080  enddo
1081 
1082  percent = float(count_snow_climo-count_snow_data) / float(count_snow_climo)
1083  percent = percent*100.
1084  write(6,200) '- NUMBER OF DATA POINTS THAT SHOULD HAVE SNOW',count_snow_climo
1085  write(6,201) '- NUMBER OF THESE POINTS THAT ARE BARE GROUND',(count_snow_climo-count_snow_data), &
1086  'OR', percent, '%'
1087 
1088  200 format(1x,a45,1x,i10)
1089  201 format(1x,a45,1x,i10,1x,a2,1x,f6.2,a1)
1090 
1091  if (percent>50.0) then
1092  print*,"- WARNING: PERCENTAGE OF BARE GROUND POINTS EXCEEDS ACCEPTABLE LEVEL."
1093  print*,"- WILL NOT USE SOURCE DATA."
1094  bad=.true.
1095  endif
1096 
1097  percent = float(count_nosnow_climo-count_nosnow_data) / float(count_nosnow_climo)
1098  percent = percent*100.
1099  write(6,202) '- NUMBER OF DATA POINTS THAT SHOULD *NOT* HAVE SNOW',count_nosnow_climo
1100  write(6,203) '- NUMBER OF THESE POINTS WITH SNOW',(count_nosnow_climo-count_nosnow_data), &
1101  'OR', percent, '%'
1102 
1103  202 format(1x,a51,1x,i10)
1104  203 format(1x,a34,1x,i10,1x,a2,1x,f6.2,a1)
1105 
1106  if (percent>20.0) then
1107  print*,"- WARNING: PERCENTAGE OF POINTS WITH SNOW EXCEEDS ACCEPTABLE LEVEL."
1108  print*,"- WILL NOT USE SOURCE DATA."
1109  bad=.true.
1110  endif
1111 
1112  if (allocated(rlat_data)) deallocate (rlat_data)
1113  if (allocated(rlon_data)) deallocate (rlon_data)
1114  if (allocated(climo)) deallocate (climo)
1115  if (allocated(bitmap_clim)) deallocate (bitmap_clim)
1116 
1117  return
1118 
1119  end subroutine nh_climo_check
1120 
1125  subroutine afwa_check(hemi)
1126  use gdswzd_mod
1127 
1128  implicit none
1129 
1130  integer, intent(in) :: hemi
1131  integer :: kgds(200), nret
1132  integer, parameter :: npts=1
1133 
1134  real :: fill, xpts(npts), ypts(npts)
1135  real :: rlon(npts), rlat(npts)
1136 
1137  kgds=0
1138  fill=9999.
1139 
1140  if (hemi==1) then
1141  print*,'- QC DATA IN NH.'
1142  kgds=kgds_afwa_nh
1143  rlat=75.0
1144  rlon=-40.
1145  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1146  if (snow_dep_afwa_nh(nint(xpts(1)),nint(ypts(1))) < 0.001) then
1147  print*,'- WARNING: NO SNOW IN GREENLAND: ',snow_dep_afwa_nh(nint(xpts),nint(ypts))
1148  print*,'- DONT USE AFWA DATA.'
1149  bad_afwa_nh=.true.
1150  endif
1151  rlat=3.0
1152  rlon=-60.
1153  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1154  if (snow_dep_afwa_nh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1155  print*,'- WARNING: SNOW IN S AMERICA: ',snow_dep_afwa_nh(nint(xpts),nint(ypts))
1156  print*,'- DONT USE AFWA DATA.'
1157  bad_afwa_nh=.true.
1158  endif
1159  rlat=23.0
1160  rlon=10.
1161  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1162  if (snow_dep_afwa_nh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1163  print*,'- WARNING: SNOW IN SAHARA: ',snow_dep_afwa_nh(nint(xpts),nint(ypts))
1164  print*,'- DONT USE AFWA DATA.'
1165  bad_afwa_nh=.true.
1166  endif
1167  rlat=15.0
1168  rlon=10.
1169  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1170  if (snow_dep_afwa_nh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1171  print*,'- WARNING: SNOW IN S INDIA: ',snow_dep_afwa_nh(nint(xpts),nint(ypts))
1172  print*,'- DONT USE AFWA DATA.'
1173  bad_afwa_nh=.true.
1174  endif
1175  endif
1176 
1177  if (hemi==2) then
1178  print*,'- QC DATA IN SH.'
1179  kgds=kgds_afwa_sh
1180  rlat=-88.0
1181  rlon=0.
1182  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1183  if (snow_dep_afwa_sh(nint(xpts(1)),nint(ypts(1))) < 0.001) then
1184  print*,'- WARNING: NO SNOW IN ANTARCTICA: ',snow_dep_afwa_sh(nint(xpts),nint(ypts))
1185  print*,'- DONT USE AFWA DATA.'
1186  bad_afwa_sh=.true.
1187  endif
1188  rlat=-10.
1189  rlon=-45.
1190  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1191  if (snow_dep_afwa_sh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1192  print*,'- WARNING: SNOW IN SOUTH AMERICA: ',snow_dep_afwa_sh(nint(xpts),nint(ypts))
1193  print*,'- DONT USE AFWA DATA.'
1194  bad_afwa_sh=.true.
1195  endif
1196  rlat=-20.0
1197  rlon=130.
1198  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1199  if (snow_dep_afwa_sh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1200  print*,'- WARNING: SNOW IN AUSTRALIA: ',snow_dep_afwa_sh(nint(xpts),nint(ypts))
1201  print*,'- DONT USE AFWA DATA.'
1202  bad_afwa_sh=.true.
1203  endif
1204  rlat=-9.0
1205  rlon=25.
1206  call gdswzd(kgds,(-1),npts,fill,xpts,ypts,rlon,rlat,nret)
1207  if (snow_dep_afwa_sh(nint(xpts(1)),nint(ypts(1))) > 0.0) then
1208  print*,'- WARNING: SNOW IN AFRICA: ',snow_dep_afwa_sh(nint(xpts),nint(ypts))
1209  print*,'- DONT USE AFWA DATA.'
1210  bad_afwa_sh=.true.
1211  endif
1212  endif
1213 
1214  end subroutine afwa_check
1215 
1233  subroutine read_afwa_binary(file_name, snow_dep_afwa)
1235  implicit none
1236 
1237  character*8 :: afwa_file_info(2)
1238  character*(*), intent(in) :: file_name
1239 
1240  integer*2, allocatable :: dummy(:,:)
1241  integer :: i,j, istat
1242  integer, parameter :: iafwa = 512
1243  integer, parameter :: jafwa = 512
1244  integer, parameter :: iunit=11 ! input afwa data file
1245 
1246  real, intent(out) :: snow_dep_afwa(iafwa,jafwa)
1247 
1248  print*,"- OPEN AFWA BINARY FILE ", trim(file_name)
1249  open (iunit, file=trim(file_name), access="direct", recl=iafwa*2, iostat=istat)
1250 
1251  if (istat /= 0) then
1252  print*,'- FATAL ERROR: BAD OPEN. ISTAT IS ',istat
1253  call w3tage('SNOW2MDL')
1254  call errexit(60)
1255  end if
1256 
1257  print*,"- READ AFWA BINARY FILE ", trim(file_name)
1258  read(iunit, rec=2, iostat = istat) afwa_file_info
1259 
1260  if (istat /= 0) then
1261  print*,'- FATAL ERROR: BAD READ. ISTAT IS ',istat
1262  call w3tage('SNOW2MDL')
1263  call errexit(61)
1264  end if
1265 
1266  print*,"- AFWA DATA IS ", afwa_file_info(1), " AT TIME ", afwa_file_info(2)(2:7)
1267 
1268  allocate(dummy(iafwa,jafwa))
1269 
1270  do j = 1, jafwa
1271  read(iunit, rec=j+2, iostat=istat) (dummy(i,j),i=1,iafwa)
1272  if (istat /= 0) then
1273  print*,'- FATAL ERROR: BAD READ. ISTAT IS ',istat
1274  call w3tage('SNOW2MDL')
1275  call errexit(61)
1276  end if
1277  enddo
1278 
1279  close(iunit)
1280 
1281 !-----------------------------------------------------------------------
1282 ! "4090" is the sea ice flag. we don't use the afwa sea ice.
1283 !-----------------------------------------------------------------------
1284 
1285  where (dummy == 4090) dummy = 0
1286 
1287  snow_dep_afwa = float(dummy)
1288 
1289 !---------------------------------------------------------------------
1290 ! afwa data is a snow depth in units of tenths of inches.
1291 ! convert this to meters.
1292 !---------------------------------------------------------------------
1293 
1294  snow_dep_afwa = snow_dep_afwa * 2.54 / 1000.0
1295 
1296  deallocate (dummy)
1297 
1298  return
1299 
1300  end subroutine read_afwa_binary
1301 
1316  subroutine read_afwa_mask(file_name, bitmap_afwa)
1317  implicit none
1318 
1319  character*(*), intent(in) :: file_name
1320 
1321  integer, parameter :: iunit=11 ! input mask file
1322  integer, parameter :: iafwa = 512
1323  integer, parameter :: jafwa = 512
1324  integer :: i, j, istat
1325  integer*4, allocatable :: dummy4(:,:)
1326 
1327  logical*1, intent(out) :: bitmap_afwa(iafwa,jafwa)
1328 
1329  allocate (dummy4(iafwa,jafwa))
1330 
1331  print*,'- OPEN AFWA MASK FILE ', trim(file_name)
1332  open(iunit, file=trim(file_name), access='direct', &
1333  recl=iafwa*jafwa*4, iostat=istat)
1334 
1335  if (istat /= 0) then
1336  print*,'- FATAL ERROR: BAD OPEN. ISTAT IS ', istat
1337  call w3tage('SNOW2MDL')
1338  call errexit(62)
1339  end if
1340 
1341  print*,'- READ AFWA MASK FILE ', trim(file_name)
1342  read(iunit, rec=1, iostat=istat) dummy4
1343 
1344  if (istat /= 0) then
1345  print*,'- FATAL ERROR: BAD READ. ISTAT IS ', istat
1346  call w3tage('SNOW2MDL')
1347  call errexit(63)
1348  end if
1349 
1350  close(iunit)
1351 
1352 !-----------------------------------------------------------------------
1353 ! here -1-offhemi, 1-ocean, 2-land, 4-coast.
1354 !-----------------------------------------------------------------------
1355 
1356  bitmap_afwa = .false.
1357 
1358  do j = 1, jafwa
1359  do i = 1, iafwa
1360  if (dummy4(i,j) > 1) then
1361  bitmap_afwa(i,j) = .true.
1362  endif
1363  enddo
1364  enddo
1365 
1366  deallocate (dummy4)
1367 
1368  end subroutine read_afwa_mask
1369 
1370 
1371  end module snowdat
integer, dimension(200) kgds_afwa_sh_8th
grib1 grid description section for southern hemisphere 8th mesh afwa data.
Definition: snowdat.F90:54
real, dimension(:,:), allocatable snow_dep_afwa_sh
Southern hemisphere afwa snow depth.
Definition: snowdat.F90:90
This module reads in data from the program&#39;s configuration namelist.
logical bad_afwa_sh
When true, the southern hemisphere afwa data failed its quality control check.
Definition: snowdat.F90:62
integer mesh_nesdis
nesdis/ims data is 96th mesh (or bediant)
Definition: snowdat.F90:58
integer, dimension(200) kgds_afwa_nh
grib1 grid description section for northern hemisphere 16th mesh afwa data.
Definition: snowdat.F90:48
real, dimension(:,:), allocatable snow_cvr_autosnow
autosnow snow cover flag (0-no, 100-yes)
Definition: snowdat.F90:87
integer *1, dimension(:,:), allocatable sea_ice_nesdis
nesdis/ims sea ice flag (0-open water, 1-ice)
Definition: snowdat.F90:59
real, dimension(:,:), allocatable snow_dep_afwa_global
The global afwa snow depth.
Definition: snowdat.F90:88
subroutine grib2_null(gfld)
Nullify the grib2 gribfield pointers.
Definition: grib_utils.F90:611
integer, public grib_century
date of the final merged snow product that will be placed in grib header.
integer jmdl
j-dimension of model grid
Definition: model_grid.F90:28
integer, dimension(200) kgds_nesdis
nesdis/ims grid description section (grib section 2)
Definition: snowdat.F90:57
logical *1, dimension(:,:), allocatable bitmap_nesdis
nesdis data grib bitmap (false-non land, true-land).
Definition: snowdat.F90:74
real afwa_res
Resolution of afwa data in km.
Definition: snowdat.F90:84
logical bad_afwa_global
When true, the global afwa data failed its quality control check.
Definition: snowdat.F90:66
integer, dimension(200) kgds_afwa_global
grib1 grid description section for global afwa data.
Definition: snowdat.F90:46
Read in data defining the model grid.
Definition: model_grid.F90:19
subroutine read_afwa_mask(file_name, bitmap_afwa)
Read afwa land mask file to get a bitmap.
Definition: snowdat.F90:1317
integer, dimension(200) kgds_autosnow
autosnow grid description section (grib section 2)
Definition: snowdat.F90:56
integer, dimension(200) kgds_afwa_nh_8th
grib1 grid description section for northern hemisphere 8th mesh afwa data.
Definition: snowdat.F90:50
integer jafwa
j-dimension of afwa grid
Definition: snowdat.F90:43
integer iautosnow
i-dimension of autosnow grid
Definition: snowdat.F90:41
Read and qc afwa, nesdis/ims and autosnow snow data.
Definition: snowdat.F90:26
integer iafwa
i-dimension of afwa grid
Definition: snowdat.F90:40
subroutine read_afwa_binary(file_name, snow_dep_afwa)
Read afwa binary snow depth file.
Definition: snowdat.F90:1234
logical *1, dimension(:,:), allocatable bitmap_autosnow
autosnow data grib bitmap (false-non land, true-land).
Definition: snowdat.F90:75
real nesdis_res
Resolution of the nesdis data in km.
Definition: snowdat.F90:85
integer, public grib_month
date of the final merged snow product that will be placed in grib header.
logical *1, dimension(:,:), allocatable bitmap_afwa_sh
The southern hemisphere afwa data grib bitmap.
Definition: snowdat.F90:72
subroutine afwa_check(hemi)
Check for corrupt afwa data.
Definition: snowdat.F90:1126
real, dimension(:,:), allocatable snow_dep_afwa_nh
Northern hemisphere afwa snow depth.
Definition: snowdat.F90:89
character *200, public climo_qc_file
Climatological snow cover file.
logical use_sh_afwa
True if southern hemisphere afwa data to be used.
Definition: snowdat.F90:78
character *200, public nesdis_lsmask_file
nesdis/ims land mask file
subroutine gdt_to_gds(igdtnum, igdstmpl, igdtlen, kgds, ni, nj, res)
Convert from the grib2 grid description template array used by the ncep grib2 library, to the grib1 grid description section array used by ncep ipolates library.
Definition: grib_utils.F90:140
character *200, public afwa_lsmask_nh_file
path/name afwa n hemis land/sea mask
subroutine readafwa
Read snow depth data and masks.
Definition: snowdat.F90:532
character *200, public afwa_lsmask_sh_file
path/name afwa s hemis land/sea mask
character *200, public autosnow_file
path/name s hemis autosnow file
character *200, public afwa_snow_sh_file
path/name afwa s hemis snow depth
integer inesdis
i-dimension of nesdis grid
Definition: snowdat.F90:42
integer imdl
i-dimension of model grid
Definition: model_grid.F90:27
integer, public grib_day
date of the final merged snow product that will be placed in grib header.
subroutine grib2_free(gfld)
Deallocate the grib2 gribfield pointers.
Definition: grib_utils.F90:636
integer jautosnow
j-dimension of autosnow grid
Definition: snowdat.F90:44
character *200, public nesdis_snow_file
nesdis/ims snow file
logical use_nh_afwa
True if northern hemisphere afwa data to be used.
Definition: snowdat.F90:77
logical use_nesdis
True if nesdis/ims data to be used.
Definition: snowdat.F90:81
subroutine readnesdis
Read nesdis/ims snow cover/ice data.
Definition: snowdat.F90:223
character *200, public afwa_snow_global_file
global afwa snow file.
logical use_autosnow
True if autosnow data to be used.
Definition: snowdat.F90:80
character *200, public afwa_snow_nh_file
path/name afwa n hemis snow depth
logical *1, dimension(:,:), allocatable bitmap_afwa_global
The global afwa data grib bitmap.
Definition: snowdat.F90:68
logical bad_nesdis
When true, the nesdis data failed its quality control check.
Definition: snowdat.F90:64
integer, public grib_year
date of the final merged snow product that will be placed in grib header.
integer jnesdis
j-dimension of nesdis grid
Definition: snowdat.F90:45
subroutine nh_climo_check(kgds_data, snow_data, bitmap_data, idata, jdata, isrc, bad)
Check for corrupt nh snow cover data.
Definition: snowdat.F90:855
logical bad_afwa_nh
When true, the northern hemisphere afwa data failed its quality control check.
Definition: snowdat.F90:60
integer, dimension(200) kgds_afwa_sh
grib1 grid description section for southern hemisphere 16th mesh afwa data.
Definition: snowdat.F90:52
subroutine readautosnow
Read autosnow snow cover.
Definition: snowdat.F90:118
real autosnow_res
Resolution of autosnow in km.
Definition: snowdat.F90:83
logical *1, dimension(:,:), allocatable bitmap_afwa_nh
The northern hemisphere afwa data grib bitmap.
Definition: snowdat.F90:70
subroutine grib_check(file_name, isgrib)
Determine whether file is grib or not.
Definition: grib_utils.F90:24
logical use_global_afwa
True if global hemisphere afwa data to be used.
Definition: snowdat.F90:79
real, dimension(:,:), allocatable snow_cvr_nesdis
nesdis/ims snow cover flag (0-no, 100-yes)
Definition: snowdat.F90:86