c======================================================================= c PROGRAM: globe_ssmi_dly_def_rain_v0711.lnx.f c c LANGUAGE: Fortran77 c c MACHINE: Any LINUX BOX c----------------------------------------------------------------------- c PURPOSE: to define GrADS formatted file of gridded daily ssmi data c----------------------------------------------------------------------- c USAGE: c----------------------------------------------------------------------- c INPUT FILES: Unit 10 == availability of SSM/I daily files c c OUTPUT FILES: Unit 50 == GrADS formatted daily SSM/I on 2.5deg lat/lon c----------------------------------------------------------------------- c SUBROUTINES USED: NONE c c FUNCTIONS USED: (all Standard Fortran 77 functions) c c----------------------------------------------------------------------- c INPUT VARIABLES: kyy == year of the target date c kmm == month of the target date c kdd == day of the target date c kjj == Julian Day c c LOCAL VARIABLES: kstatus == data availability c rain0 == SSMI precp estimates (one line, 0.25deg) c samp0 == SSMI sampling (one line, 0.25deg) c rain1 == SSMI precp estimates (0.25deg) c samp1 == number of pixels (0.25deg) c rain == SSMI precp estimates (2.5deg) c samp == number of pixels (2.5deg) c c----------------------------------------------------------------------- c DATE 2007-11-07 c----------------------------------------------------------------------- c MODIFICATIONS: c=====|==|=========|=========|=========|=========|=========|=========|== c program SSMI_def_dly_2_5deg implicit none integer NX0, NY0, NX, NY parameter( NX0=1440, NY0=720, NX=NX0/10, NY=NY0/10 ) character yyyymmdd*8, f_dly*54, f_num*32, f_rain*39 integer yyyy, mm, dd, days(12), yy, m, jjj, d real rain0(NX0,NY0), samp0(NX0,NY0) real rain1(NX0,NY0), samp1(NX0,NY0) real rain(NX,NY), samp(NX,NY) logical fd_there, fr_there, fn_there real s1, s2 integer ii, jj, i, j, i1, i2, j1, j2, is, js, nn data days / 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 / c----------------------------------------------------------------------- c----------------------------------------------------------------------- if( iargc().lt.1 ) then write(*, *) write(*, *) '#################################' write(*, *) '# #' write(*, *) '# parameter needed #' write(*, *) '# #' write(*, *) '#################################' write(*, *) stop endif c----------------------------------------------------------------------- c----------------------------------------------------------------------- call getarg(1, yyyymmdd) read(yyyymmdd, '(i4.4,2i2.2)') yyyy, mm, dd yy=mod(yyyy,100) c----------------------------------------------------------------------- c----------------------------------------------------------------------- if( mod(yyyy,4).eq.0 ) days(2)=29 if( mod(yyyy,100).eq.0 ) days(2)=28 if( mod(yyyy,400).eq.0 ) days(2)=29 c----------------------------------------------------------------------- c----------------------------------------------------------------------- jjj=dd do m=1, mm-1 jjj=jjj+days(m) enddo c----------------------------------------------------------------------- c----------------------------------------------------------------------- c------------>123456789|123456789|123456789|123456789|123456789|1234<-- f_dly ='../output/SSMI/yyyy/ppt/globe_dly_2.5deg_ssmi.lnx.yyyy' f_num ='../input/num_F13F14F15_yyjjj.dat' f_rain='../input/rain_daily_F13F14F15_yyjjj.dat' write(f_dly(16:19), '(i4.4)') yyyy write(f_dly(51:54), '(i4.4)') yyyy write(f_num(24:28), '(i2.2,i3.3)') yy, jjj write(f_rain(31:35), '(i2.2,i3.3)') yy, jjj c----------------------------------------------------------------------- c----------------------------------------------------------------------- inquire(file=f_dly, exist=fd_there) if( .not.fd_there ) then open(20, file=f_dly, access='direct', recl=NX*NY*4) do jj=1, NY do ii=1, NX rain(ii,jj)=-999.0 samp(ii,jj)=0.0 enddo enddo do d=1, 366 write(20, rec=(d-1)*2+1) rain write(20, rec=(d-1)*2+2) samp enddo close(20) endif c----------------------------------------------------------------------- c----------------------------------------------------------------------- inquire(file=f_num, exist=fn_there) inquire(file=f_rain, exist=fr_there) if( fn_there.and.fr_there ) then open(10, file=f_num, status='old', 1 access='direct', recl=NX0*NY0*4) open(11, file=f_rain, status='old', 1 access='direct', recl=NX0*NY0*4) read(10, rec=1) samp0 read(11, rec=1) rain0 close(10) close(11) write(*, *) ' <-- ', f_num write(*, *) ' <-- ', f_rain do jj=1, NY0 do ii=1, NX0 js=jj is=ii+NX0/2 if( is.gt.NX0 ) is=is-NX0 rain1(ii,jj)=rain0(is,js) samp1(ii,jj)=samp0(is,js) if( rain1(ii,jj).ge.0.0.and.samp1(ii,jj).gt.0.0 ) then rain1(ii,jj)=rain1(ii,jj)*24.0 else rain1(ii,jj)=-999.0 samp1(ii,jj)=0.0 endif enddo enddo do jj=1, NY do ii= 1, NX j1=(jj-1)*10+1 j2=j1+9 i1=(ii-1)*10+1 i2=i1+9 nn=0 s1=0.0 s2=0.0 do j=j1, j2 do i=i1, i2 if( rain1(i,j).ge.0.0.and.samp1(i,j).gt.0.0 ) then nn=nn+1 s1=s1+rain1(i,j) s2=s2+samp1(i,j) endif enddo enddo if( nn.gt.30 ) then rain(ii,jj)=s1/nn samp(ii,jj)=s2 else rain(ii,jj)=-999.0 samp(ii,jj)=0.0 endif enddo enddo open(20, file=f_dly, access='direct', recl=NX*NY*4) write(20, rec=(jjj-1)*2+1) rain write(20, rec=(jjj-1)*2+2) samp close(20) write(*,*) ' ==> ', f_dly else if( .not.fn_there ) then write(*, *) '## file missing: ', f_num endif if( .not.fr_there ) then write(*, *) '## file missing: ', f_rain endif endif stop end c c=====|==|=========|=========|=========|=========|=========|=========|==