31 afwa_snow_global_file, &
34 afwa_lsmask_nh_file, &
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
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
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(:,:)
95 data kgds_afwa_nh_8th/5,2*512,-20826,145000,8,-80000,2*47625,0, &
97 data kgds_afwa_sh_8th/5,2*512,20826,-125000,8,-80000,2*47625,128, &
122 type(gribfield
) :: gfld
124 integer :: iret, j, k, lugb, lugi
125 integer :: jdisc, jgdtn, jpdtn
126 integer :: jids(200), jgdt(200), jpdt(200)
130 use_autosnow = .true.
132 if ( len_trim(autosnow_file) == 0 )
then
133 print*,
"- WILL NOT USE AUTOSNOW DATA."
134 use_autosnow = .false.
138 print*,
"- OPEN AND READ AUTOSNOW FILE ", trim(autosnow_file)
141 call baopenr(lugb,autosnow_file,iret)
144 print*,
'- FATAL ERROR: BAD OPEN OF FILE, IRET IS ', iret
145 call w3tage(
'SNOW2MDL')
163 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
164 unpack, k, gfld, iret)
167 print*,
'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
168 call w3tage(
'SNOW2MDL')
172 print*,
"- DATA VALID AT (YYYYMMDDHH): ", gfld%idsect(6),gfld%idsect(7), &
173 gfld%idsect(8),gfld%idsect(9)
175 call baclose(lugb, iret)
182 call
gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_autosnow, &
183 iautosnow, jautosnow, autosnow_res)
185 allocate (bitmap_autosnow(iautosnow,jautosnow))
186 bitmap_autosnow = reshape(gfld%bmap , (/iautosnow,jautosnow/) )
188 allocate (snow_cvr_autosnow(iautosnow,jautosnow))
189 snow_cvr_autosnow = reshape(gfld%fld , (/iautosnow,jautosnow/) )
227 integer,
parameter :: iunit = 13
228 integer,
parameter :: iunit2 = 43
230 integer*4,
allocatable :: dummy4(:,:)
236 integer,
parameter :: lugi = 0
237 integer :: jdisc, jgdtn, jpdtn, k
238 integer :: jids(200), jgdt(200), jpdt(200)
241 integer :: message_num
248 real,
allocatable :: dummy(:,:)
251 type(gribfield
) :: gfld
255 if ( len_trim(nesdis_snow_file) == 0 )
then
256 print*,
"- WILL NOT USE NESDIS/IMS DATA."
261 print*,
"- OPEN AND READ NESDIS/IMS SNOW FILE ", trim(nesdis_snow_file)
266 print*,
'- FATAL ERROR: IMS FILE MUST BE GRIB 1 OR GRIB2 FORMAT'
267 call w3tage(
'SNOW2MDL')
271 call baopenr(iunit, nesdis_snow_file, iret)
274 print*,
'- FATAL ERROR: BAD OPEN OF FILE, IRET IS ', iret
275 call w3tage(
'SNOW2MDL')
292 print*,
"- GET GRIB HEADER"
294 call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
295 numpts, message_num, kpds, kgds, iret)
298 print*,
"- FATAL ERROR: BAD DEGRIB OF HEADER. IRET IS ", iret
299 call w3tage(
'SNOW2MDL')
307 mesh_nesdis = inesdis / 64
308 nesdis_res = 381. / float(mesh_nesdis)
310 print*,
"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
312 allocate (dummy(inesdis,jnesdis))
313 allocate (sea_ice_nesdis(inesdis,jnesdis))
314 allocate (bitmap_nesdis(inesdis,jnesdis))
316 print*,
"- DEGRIB SEA ICE."
318 call getgb(iunit, lugi, (inesdis*jnesdis), lskip, jpds, jgds, &
319 numpts, lskip, kpds, kgds, bitmap_nesdis, dummy, iret)
322 print*,
"- FATAL ERROR: BAD DEGRIB OF DATA. IRET IS ", iret
323 call w3tage(
'SNOW2MDL')
327 sea_ice_nesdis = nint(dummy)
337 allocate (snow_cvr_nesdis(inesdis,jnesdis))
339 print*,
"- DEGRIB SNOW COVER."
341 call getgb(iunit, lugi, (inesdis*jnesdis), lskip, jpds, jgds, &
342 numpts, lskip, kpds, kgds, bitmap_nesdis, snow_cvr_nesdis, iret)
345 print*,
"- FATAL ERROR: BAD DEGRIB OF DATA. IRET IS ", iret
346 call w3tage(
'SNOW2MDL')
350 elseif (isgrib==2)
then
352 print*,
"- DEGRIB SNOW COVER."
367 call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
368 unpack, k, gfld, iret)
371 print*,
'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
372 call w3tage(
'SNOW2MDL')
376 print*,
"- DATA VALID AT (YYYYMMDDHH): ", gfld%idsect(6),gfld%idsect(7), &
377 gfld%idsect(8),gfld%idsect(9)
384 call
gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_nesdis, &
385 inesdis, jnesdis, dum)
387 mesh_nesdis = inesdis / 64
388 nesdis_res = 381. / float(mesh_nesdis)
390 if (mesh_nesdis==16) kgds_nesdis(6)=136
395 allocate (snow_cvr_nesdis(inesdis,jnesdis))
396 allocate (sea_ice_nesdis(inesdis,jnesdis))
397 allocate (bitmap_nesdis(inesdis,jnesdis))
399 bitmap_nesdis = reshape(gfld%bmap , (/inesdis,jnesdis/) )
400 snow_cvr_nesdis = reshape(gfld%fld , (/inesdis,jnesdis/) )
404 print*,
"- DEGRIB SEA ICE."
417 call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
418 unpack, k, gfld, iret)
421 print*,
'- FATAL ERROR: BAD DEGRIB OF FILE, IRET IS ', iret
422 call w3tage(
'SNOW2MDL')
426 sea_ice_nesdis = reshape(gfld%fld , (/inesdis,jnesdis/) )
432 call baclose(iunit,iret)
440 if (mesh_nesdis == 16)
then
442 print*,
"- OPEN NESDIS/IMS 16TH MESH LAND MASK: ", trim(nesdis_lsmask_file)
444 open(iunit2, file=trim(nesdis_lsmask_file), form=
"formatted", &
448 print*,
"- FATAL ERROR OPENING NESDIS/IMS LAND MASK FILE. ISTAT IS: ", iret
452 print*,
"- READ NESDIS/IMS 16TH MESH LAND MASK."
454 allocate (dummy4(inesdis,jnesdis))
457 read(iunit2, 123, iostat=iret) (dummy4(i,j),i=1,1024)
459 print*,
"- FATAL ERROR READING NESDIS/IMS LAND MASK FILE. ISTAT IS: ", iret
471 bitmap_nesdis=.false.
474 if (dummy4(i,j) == 1) bitmap_nesdis(i,j) = .true.
485 call
nh_climo_check(kgds_nesdis,snow_cvr_nesdis,bitmap_nesdis,inesdis,jnesdis,2,bad_nesdis)
498 print*,
'- FATAL ERROR: NESDIS/IMS DATA BAD, DO NOT USE.'
499 print*,
'- DONT RUN PROGRAM.'
501 call w3tage(
'SNOW2MDL')
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)
545 type(gribfield
) :: gfld
549 bad_afwa_global=.false.
551 use_global_afwa=.true.
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.
569 if ( len_trim(afwa_snow_global_file) > 0 )
then
571 print*,
"- OPEN AND READ global AFWA SNOW FILE ", trim(afwa_snow_global_file)
572 call baopenr(iunit, afwa_snow_global_file, istat)
574 print*,
'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
575 call w3tage(
'SNOW2MDL')
594 call getgb2(iunit, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
595 unpack, k, gfld, istat)
598 print*,
"- FATAL ERROR: BAD DEGRIB OF GLOBAL DATA. ISTAT IS ", istat
599 call w3tage(
'SNOW2MDL')
603 print*,
"- DATA VALID AT (YYMMDDHH): ", gfld%idsect(6:9)
604 print*,
"- DEGRIB SNOW DEPTH."
606 call
gdt_to_gds(gfld%igdtnum, gfld%igdtmpl, gfld%igdtlen, kgds_afwa_global, &
607 iafwa, jafwa, afwa_res)
609 allocate(bitmap_afwa_global(iafwa,jafwa))
610 allocate(snow_dep_afwa_global(iafwa,jafwa))
612 snow_dep_afwa_global = reshape(gfld%fld, (/iafwa,jafwa/))
613 bitmap_afwa_global = reshape(gfld%bmap, (/iafwa,jafwa/))
615 call baclose(iunit, istat)
617 call
nh_climo_check(kgds_afwa_global,snow_dep_afwa_global,bitmap_afwa_global,iafwa,jafwa,1,bad_afwa_global)
619 if (bad_afwa_global)
then
620 print*,
'- WARNING: AFWA DATA BAD, DO NOT USE.'
621 use_global_afwa = .false.
631 use_global_afwa=.false.
635 if ( len_trim(afwa_snow_nh_file) > 0 )
then
644 kgds_afwa_nh = kgds_afwa_nh_8th
646 allocate (snow_dep_afwa_nh(iafwa,jafwa))
649 allocate (bitmap_afwa_nh(iafwa,jafwa))
654 print*,
"- OPEN AND READ AFWA SNOW FILE ", trim(afwa_snow_nh_file)
656 call baopenr(iunit, afwa_snow_nh_file, istat)
659 print*,
'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
660 call w3tage(
'SNOW2MDL')
676 print*,
"- GET GRIB HEADER"
677 call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
678 numpts, message_num, kpds, kgds, istat)
681 print*,
"- FATAL ERROR: BAD DEGRIB OF HEADER. ISTAT IS ", istat
682 call w3tage(
'SNOW2MDL')
688 afwa_res = float(kgds(8))*0.001
690 print*,
"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
692 print*,
"- DEGRIB SNOW DEPTH."
694 allocate(bitmap_afwa_nh(iafwa,jafwa))
695 allocate(snow_dep_afwa_nh(iafwa,jafwa))
697 call getgb(iunit, lugi, (iafwa*jafwa), lskip, jpds, jgds, &
698 numpts, lskip, kpds, kgds, bitmap_afwa_nh, snow_dep_afwa_nh, istat)
701 print*,
"- FATAL ERROR: BAD DEGRIB OF DATA. ISTAT IS ", istat
702 call w3tage(
'SNOW2MDL')
708 kgds_afwa_nh(7) = -80000
711 call baclose(iunit, istat)
715 call
nh_climo_check(kgds_afwa_nh,snow_dep_afwa_nh,bitmap_afwa_nh,iafwa,jafwa,1,bad_afwa_nh)
727 if ( len_trim(afwa_snow_sh_file) > 0 )
then
736 kgds_afwa_sh = kgds_afwa_sh_8th
738 allocate (snow_dep_afwa_sh(iafwa,jafwa))
741 allocate (bitmap_afwa_sh(iafwa,jafwa))
746 print*,
"- OPEN AND READ AFWA SNOW FILE ", trim(afwa_snow_sh_file)
748 call baopenr(iunit, afwa_snow_sh_file, istat)
751 print*,
'- FATAL ERROR: BAD OPEN OF FILE, ISTAT IS ', istat
752 call w3tage(
'SNOW2MDL')
768 print*,
"- GET GRIB HEADER"
769 call getgbh(iunit, lugi, lskip, jpds, jgds, numbytes, &
770 numpts, message_num, kpds, kgds, istat)
773 print*,
"- FATAL ERROR: BAD DEGRIB OF HEADER. ISTAT IS ", istat
774 call w3tage(
'SNOW2MDL')
780 afwa_res = float(kgds(8))*0.001
782 print*,
"- DATA VALID AT (YYMMDDHH): ", kpds(8:11)
784 print*,
"- DEGRIB SNOW DEPTH."
786 allocate(bitmap_afwa_sh(iafwa,jafwa))
787 allocate(snow_dep_afwa_sh(iafwa,jafwa))
789 call getgb(iunit, lugi, (iafwa*jafwa), lskip, jpds, jgds, &
790 numpts, lskip, kpds, kgds, bitmap_afwa_sh, snow_dep_afwa_sh, istat)
793 print*,
"- FATAL ERROR: BAD DEGRIB OF DATA. ISTAT IS ", istat
794 call w3tage(
'SNOW2MDL')
800 kgds_afwa_sh(7) = -80000
803 call baclose(iunit, istat)
811 use_sh_afwa = .false.
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.
858 grib_year, grib_month, grib_day, &
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.
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)
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
886 logical*1,
allocatable :: bitmap_clim(:,:)
889 real,
allocatable :: climo(:,:)
890 real :: fill, percent, x, y
891 real,
allocatable :: xpts(:,:),ypts(:,:),rlon_data(:,:),rlat_data(:,:)
892 real :: thresh_gross, thresh
894 type(gribfield
) :: gfld
897 if (len_trim(climo_qc_file)==0)
return
899 print*,
"- QC SNOW DATA IN NH."
903 elseif (isrc==2)
then
908 allocate(xpts(idata,jdata))
909 allocate(ypts(idata,jdata))
910 allocate(rlon_data(idata,jdata))
911 allocate(rlat_data(idata,jdata))
919 print*,
"- CALC LAT/LONS OF SOURCE POINTS."
920 call gdswzd(kgds_data,1,(idata*jdata),fill,xpts,ypts,rlon_data,rlat_data,nret)
922 deallocate(xpts,ypts)
924 if (nret /= (idata*jdata))
then
925 print*,
"- WARNING: CALC FAILED. WILL NOT PERFORM QC."
926 deallocate (rlon_data,rlat_data)
930 count_grosschk_data=0
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
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)
948 print*,
"- QC DATA SOURCE AGAINST CLIMO."
949 print*,
"- OPEN CLIMO SNOW COVER FILE ",trim(climo_qc_file)
951 call baopenr(lugb,climo_qc_file,iret)
954 print*,
"- WARNING: BAD OPEN, WILL NOT PERFORM QC ", iret
955 deallocate (rlon_data,rlat_data)
964 if (grib_year == 100)
then
965 century = grib_century
967 century = grib_century-1
970 year = century*100 + grib_year
977 call w3doxdat(idat,jdow,jdoy,jday)
981 week = nint((jdoy+3.)/7.)
985 print*,
"- READ CLIMO FOR WEEK ",week
1000 jgdt(12) = nint(lat11_clim * 1e6)
1001 jgdt(13) = nint(abs(lon11_clim) * 1e6)
1008 call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
1009 unpack, k, gfld, iret)
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)
1019 call baclose(lugb,iret)
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/) )
1041 count_nosnow_climo=0
1048 elseif (isrc==2)
then
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
1060 if (jj>jclim) jj=jclim
1062 if (ii<1) ii=ii+iclim
1063 if (ii>iclim) ii=ii-iclim
1064 if (bitmap_clim(ii,jj))
then
1065 if (climo(ii,jj) <1.0)
then
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
1071 if (climo(ii,jj) > 99.)
then
1072 count_snow_climo=count_snow_climo+1
1073 if (snow_data(i,j) >thresh)
then
1074 count_snow_data=count_snow_data+1
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), &
1088 200
format(1x,a45,1x,i10)
1089 201
format(1x,a45,1x,i10,1x,a2,1x,f6.2,a1)
1091 if (percent>50.0)
then
1092 print*,
"- WARNING: PERCENTAGE OF BARE GROUND POINTS EXCEEDS ACCEPTABLE LEVEL."
1093 print*,
"- WILL NOT USE SOURCE DATA."
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), &
1103 202
format(1x,a51,1x,i10)
1104 203
format(1x,a34,1x,i10,1x,a2,1x,f6.2,a1)
1106 if (percent>20.0)
then
1107 print*,
"- WARNING: PERCENTAGE OF POINTS WITH SNOW EXCEEDS ACCEPTABLE LEVEL."
1108 print*,
"- WILL NOT USE SOURCE DATA."
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)
1130 integer,
intent(in) :: hemi
1131 integer :: kgds(200), nret
1132 integer,
parameter :: npts=1
1134 real :: fill, xpts(npts), ypts(npts)
1135 real :: rlon(npts), rlat(npts)
1141 print*,
'- QC DATA IN NH.'
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.'
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.'
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.'
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.'
1178 print*,
'- QC DATA IN SH.'
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.'
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.'
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.'
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.'
1237 character*8 :: afwa_file_info(2)
1238 character*(*),
intent(in) :: file_name
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
1246 real,
intent(out) :: snow_dep_afwa(iafwa,jafwa)
1248 print*,
"- OPEN AFWA BINARY FILE ", trim(file_name)
1249 open (iunit, file=trim(file_name), access=
"direct", recl=iafwa*2, iostat=istat)
1251 if (istat /= 0)
then
1252 print*,
'- FATAL ERROR: BAD OPEN. ISTAT IS ',istat
1253 call w3tage(
'SNOW2MDL')
1257 print*,
"- READ AFWA BINARY FILE ", trim(file_name)
1258 read(iunit, rec=2, iostat = istat) afwa_file_info
1260 if (istat /= 0)
then
1261 print*,
'- FATAL ERROR: BAD READ. ISTAT IS ',istat
1262 call w3tage(
'SNOW2MDL')
1266 print*,
"- AFWA DATA IS ", afwa_file_info(1),
" AT TIME ", afwa_file_info(2)(2:7)
1268 allocate(dummy(iafwa,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')
1285 where (dummy == 4090) dummy = 0
1287 snow_dep_afwa = float(dummy)
1294 snow_dep_afwa = snow_dep_afwa * 2.54 / 1000.0
1319 character*(*),
intent(in) :: file_name
1321 integer,
parameter :: iunit=11
1322 integer,
parameter :: iafwa = 512
1323 integer,
parameter :: jafwa = 512
1324 integer :: i, j, istat
1325 integer*4,
allocatable :: dummy4(:,:)
1327 logical*1,
intent(out) :: bitmap_afwa(iafwa,jafwa)
1329 allocate (dummy4(iafwa,jafwa))
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)
1335 if (istat /= 0)
then
1336 print*,
'- FATAL ERROR: BAD OPEN. ISTAT IS ', istat
1337 call w3tage(
'SNOW2MDL')
1341 print*,
'- READ AFWA MASK FILE ', trim(file_name)
1342 read(iunit, rec=1, iostat=istat) dummy4
1344 if (istat /= 0)
then
1345 print*,
'- FATAL ERROR: BAD READ. ISTAT IS ', istat
1346 call w3tage(
'SNOW2MDL')
1356 bitmap_afwa = .false.
1360 if (dummy4(i,j) > 1)
then
1361 bitmap_afwa(i,j) = .true.
subroutine read_afwa_binary(file_name, snow_dep_afwa)
Read afwa binary snow depth file.
subroutine grib2_null(gfld)
Nullify the grib2 gribfield pointers.
subroutine readafwa
Read snow depth data and masks.
subroutine readnesdis
Read nesdis/ims snow cover/ice data.
subroutine nh_climo_check(kgds_data, snow_data, bitmap_data, idata, jdata, isrc, bad)
Check for corrupt nh snow cover data.
Read in data defining the model grid.
subroutine read_afwa_mask(file_name, bitmap_afwa)
Read afwa land mask file to get a bitmap.
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.
subroutine grib2_free(gfld)
Deallocate the grib2 gribfield pointers.
This module reads in data from the program's configuration namelist.
subroutine afwa_check(hemi)
Check for corrupt afwa data.
Read and qc afwa, nesdis/ims and autosnow snow data.
subroutine grib_check(file_name, isgrib)
Determine whether file is grib or not.
subroutine readautosnow
Read autosnow snow cover.