c ************************************************************************ c * c * Program Name: sortsummer.f (actaully harvey's sortsummer_a25.f) c * ------------ c * c * Description: c * ----------- c * This reads ascii rainfall files C * and averages all rain values C * for each geographic cell. C * A command file begins with the root of the ouput (bil and _c.bil) C * files, followed by a list of rain files. C * Rain is scaled up by a factor of 1000, which makes it microns/hour C * There are long lines here; compile with "F77 -e sortsummer.f" C * Edit the parameter line to change scale or stufy area. c * c * Date Author Name Change Description c * ----------- ------------ ------------------ c * 28-Mar-2002 harvey Created c * 22-Mar-2002 harvey Cleaned up for Drew c * c *********************************************************************** character*120 file_in, outfile, filelist INTEGER*4 n, row, col parameter (NROWS=36,NCOLS=20,XMIN=120,YMAX=25.4,RECL=NCOLS*2,CELL_PER_DEG=10) integer*2 count(NROWS,NCOLS),rainrow(NCOLS),countrow(NCOLS),one,dayl integer*4 ngood,nrain,nbad real*4 x, y, z, rain(NROWS,NCOLS) c Read input file name which should be in your local system c --------------------------------------------------------- print *, 'V. 1.05;Enter command filename (with double quotes) : ' read(5,*) filelist C! name of file containing output_filename, datafilenames, followed by END print*,'Opening ',filelist open(7,file=filelist) read(7,'(A)')outfile dayl = index(outfile,' ')-1 print*,'Output file ',outfile(:dayl)//'.bil' 50 read(7,'(A)',end=200) file_in if(file_in .eq. 'END')goto 200 write(6, '(A10,A60)') 'file_in = ', file_in c Open an input file c Then loop to read the data records. c --------------------------------------------------------------------- open(10,file=file_in,status='OLD') do 100 n=1,200000 read(10,*,end=150)one,x,y,z row = int((YMAX - y)*CELL_PER_DEG) + 1 ! north row is row 1 col = int((x - XMIN)*CELL_PER_DEG) + 1 if(row .le. 0 .or. row .gt. NROWS .or. col .le.0 .or. col .gt. NCOLS) then print*, x, y, col, row ! rounding error or real error goto 100 endif if(z .ge. 0) then ngood = ngood + 1 rain(row,col) = rain(row,col) + z count(row,col) = count(row,col) + 1 if (z .gt. 0)then nrain = nrain + 1 endif else nbad = nbad + 1 endif 100 continue 150 continue print*,'Read ',n,' records.' goto 50 ! read another file 200 continue open(11,file='../../bils/'//outfile(:dayl)//'.bil',ACCESS='DIRECT',RECL=RECL) open(12,file='../../bils/'//outfile(:dayl)//'_c.bil',ACCESS='DIRECT',RECL=RECL) do 400 row = 1,NROWS do 300 col = 1,NCOLS countrow(col) = count(row,col) if(countrow(col) .eq. 0)then C print*, 'NODATA at ',row,col rainrow(col) = -99 else C rain(row,col) = rain(row,col) / count(row,col) rainrow(col) = nint(1000.0 * rain(row,col) / real(countrow(col))) if(rainrow(col) .gt. 20000) then print*, '####row',row,'rainrow',col,'is',rainrow(col),countrow(col),rain(row,col),count(row,col) endif endif 300 continue write(11,rec=row)rainrow write(12,rec=row)countrow 400 continue print*,ngood," good records, ",nrain," rain records, ",nbad, " bad records." stop 500 write(6,*)'Hit end-of-file' stop 0 end