program nvap_resize c*********************************************************************** c c this program takes the nvap-ng 1/2 degree data and averages up the c 4 grid boxes to create a 1 degree data set - for comparison with the c nvap dataset. Averaging is done since this is the process which c would create a 1 degree data set. c c written by dave randel stc/metsat c in august 2003 c c********************************************************************** real sa(360,180), rna(360,180), data2(360,180) character*80 flname,flout character*1 decc,dec logical ex c c--------common block which holds the data and header information--------- c real nvdata(720,360), headr(4), zindef cmy fix integer*2 headi(11), igrd cend fix character label*40 common /nvapdata/ nvdata, headr, zindef, headi, label c 1 format(a,$) 2 format(a) 3 format(i3) c**read input filename********** write(6,*)' NVAP-NG 1/2 degree to 1 degree routine' write(6,*) 5 write(6,*) write(6,1)' Input 1/2 degree NVAP-NG filename? : ' read(5,2) flname if(flname .eq. ' ') then pause stop endif c c**get output filename write(6,1)' Output 1 degree filename? : ' read(5,2) flout c**get field averaging information c write(6,*) write(6,1)' Resize all fields in file? (y/n) [y] : ' read(5,2) dec if(dec .eq. ' ') dec = 'y' if(dec.eq.'n' .or. dec.eq.'N') then write(6,1)' start with field number? : ' read(5,3) nstart write(6,1)' number of fields to resize? : ' read(5,3) nflds else nstart = 1 cmy fix nflds = 1000 cend fix endif c**start averaging/resizing process ioutfld = 0 do igrd = nstart,nstart+nflds-1 do j = 1,180 do i = 1,360 rna(i,j) = 0.0 sa(i,j) = 0.0 enddo enddo istat = 0 call nvap_read(flname, igrd, istat) !read 1/2 degree data if(istat .ne. 0) then write(6,*)'error reading grid ',igrd stop 10 else write(6,*)(headi(j),j=4,5) endif c do j = 1,360 do i = 1, 180 do k = 1,2 do m = 1,2 nk = (j-1)*2 + k nm = (i-1)*2 + m if(nvdata(nk,nm) .ne. zindef) then sa(j,i) = sa(j,i) + nvdata(nk,nm) rna(j,i) = rna(j,i) + 1. endif enddo enddo enddo enddo c do j = 1,360 !calc average do i = 1, 180 if(rna(j,i) .eq. 0) then nvdata(j,i) = zindef else nvdata(j,i) = sa(j,i) / rna(j,i) endif enddo enddo c ioutgrd = ioutgrd + 1 !write out headi(3)=3 headi(10) = 360 headi(11) = 180 headr(1) = 1.0 headr(2) = -1.0 headr(3) = 89.5 headr(4) = 0.5 call nvap_write(flout, ioutgrd,istat) if(istat .ne. 0) then write(6,*)' error writing data grid ' else write(6,*)' resized field written to: ',flout(1:40) endif enddo c write(6,1)' continue with another file? (y/n) [y] : ' read(5,2) decc if(decc .eq. ' ') decc = 'y' if(decc.eq.'y' .or. decc.eq.'Y') then go to 5 endif stop end