c============================================================================= c c NAME: multi_day_grid c c PURPOSE: Combines the daily max TB grids into longer time periods. c c INPUTS: (via multi_day grid.input) c period.......period of output grid (5, 15 or 30) c bday.........beginning julian69 day c eday.........end julian69 day c isat.........satellite id (number) c c INPUT DATA: c daily *.GRD files c c OUTPUT DATA: c Writes new multi-day grid file for 5-, 15- or 35-day period (*.GRD) c c EXTERNALS: c hirs1c.inc c init_grid.f c julian69_to_date.f c two_digit_year.f c c HISTORY: Darren Jackson ETL/CIRES April 2002 c c=============================================================================== program multi_day_grid implicit none include 'hirs1c.inc' integer iyr2,bday,eday,tday,isat,jd,i,j,k,l,period integer bday2,eday2,day,mon,n,two_digit_year,iyr4,jd1,jd2 integer biyr2,eiyr2 real igrid(nlon,nlat,ntim),ogrid(nlon,nlat,ntim,bs) real perc,xcnt,fpercent character dgrid_path*8,dgrid_file*50,mgrid_file*50 logical around external two_digit_year c data dgrid_path/'../grid/'/ c c* Choosing 45% indicates that I need at least 3 of 5 daily grids to make a pentad grid file c 2 of 3 pentad grids to make 15-day grid file c 4 of 7 15-day grids to make 35-day grid file data fpercent/45./ xcnt=0. c c* Input parameters c open(9,file='multi_day_grid.input') read(9,*) period read(9,*) bday read(9,*) eday read(9,*) isat close(9) c c* Double check period c if(period .ne. eday-bday+1) then write(*,*) 'Period does not correspond with bday and eday' write(*,*) 'bday = ',bday,' eday = ',eday,' Period = ',period write(*,*) 'Terminate program' stop endif c c* initialize grid c call init_grid(ogrid) c if(period .eq. 5) then do jd=bday,eday call julian69_to_date(1,jd,iyr4,mon,day) iyr2=two_digit_year(iyr4) write(dgrid_file,98) 'HIRS.N',isat,'.Y',iyr2,'.D',day, . '.V22.GD' 98 format(a6,i2.2,a2,i2.2,a2,i3.3,a7) inquire(file=dgrid_path//dgrid_file,exist=around) if(around) then open(unit=10,file=dgrid_path//dgrid_file, . access='direct',recl=nlon*nlat*ntim*4) do l=1,bs read(10,rec=l,err=100) igrid do i=1,nlon do j=1,nlat do k=1,ntim if(l .eq. 1) then ! Max Chn8 TBs ogrid(i,j,k,l)=amax1(igrid(i,j,k), . ogrid(i,j,k,l)) elseif(l .eq. 2) then ogrid(i,j,k,l)=amin1(igrid(i,j,k), ! Min chn20 refl. . ogrid(i,j,k,l)) elseif(l .gt. 2) then ! Sum and # obs TBs ogrid(i,j,k,l)=ogrid(i,j,k,l)+ . igrid(i,j,k) endif enddo enddo enddo enddo xcnt=xcnt+1. endif 100 close(10) enddo tday=5 elseif(period .eq. 15 .or. period .eq. 35) then if(eday .ne. bday+period-1) then write(*,*) 'bday,eday not correct for period = ',period write(*,*) 'bday = ',bday,' eday = ',eday write(*,*) 'Terminate multi_day_grid' stop endif if(period .eq. 15) tday=3 if(period .eq. 35) tday=7 do n=1,tday jd1=bday+(n-1)*5 jd2=jd1+4 call julian69_to_date(1,jd1,iyr4,mon,bday2) biyr2=two_digit_year(iyr4) call julian69_to_date(1,jd2,iyr4,mon,eday2) eiyr2=two_digit_year(iyr4) write(dgrid_file,99) 'HIRS.N',isat,'.Y',biyr2,'.B',bday2, . '.Y',eiyr2,'.E',eday2,'.V22.GD' inquire(file=dgrid_path//dgrid_file,exist=around) if(around) then open(unit=10,file=dgrid_path//dgrid_file, . access='direct',recl=nlon*nlat*ntim*4) do l=1,bs read(10,rec=l,err=101) igrid do i=1,nlon do j=1,nlat do k=1,ntim if(l .eq. 1) then ! Max Chn8 TBs ogrid(i,j,k,l)=amax1(igrid(i,j,k), . ogrid(i,j,k,l)) elseif(l .eq. 2) then ogrid(i,j,k,l)=amin1(igrid(i,j,k), ! Min chn20 refl. . ogrid(i,j,k,l)) elseif(l .gt. 2) then ! Sum and # obs TBs ogrid(i,j,k,l)=ogrid(i,j,k,l)+ . igrid(i,j,k) endif enddo enddo enddo enddo xcnt=xcnt+1. endif 101 close(10) enddo endif perc=xcnt/float(tday)*100. if(perc .gt. fpercent) then call julian69_to_date(1,bday,iyr4,mon,bday2) biyr2=two_digit_year(iyr4) call julian69_to_date(1,eday,iyr4,mon,eday2) eiyr2=two_digit_year(iyr4) write(mgrid_file,99) 'HIRS.N',isat,'.Y',biyr2,'.B', . bday2,'.Y',eiyr2,'.E',eday2,'.V22.GD' 99 format(a6,i2.2,a2,i2.2,a2,i3.3,a2,i2.2,a2,i3.3,a7) open(unit=20,file=dgrid_path//mgrid_file, . access='direct',recl=nlon*nlat*ntim*bs*4) write(20,rec=1) ogrid close(20) write(*,*) 'Multi-day grid file written' else write(*,*) 'Multi-day grid file not written' write(*,*) 'Percentage of days less than 45%' write(*,*) 'Percentage available = ',perc endif write(*,*) 'bday = ',bday,' Period = ',period write(*,*) ' ' end