c decimate matrix subroutine c This subroutine decimates the input matrix by depth in mulitples of the c input resolution, created 9/96 c subroutine decimate_matrix(grid,grerror,nx,ny,xres,yres, 1 xleft,xright,ytop,ybot) parameter (ngx=1000,ngy=700) character*1, quest integer nx,ny,ifactor,i,j,k real xres,yres,xleft,xright,ytop,ybot real grid(ngy,ngx),newgrid(ngy,ngx) real grerror(ngy,ngx),newgriderr(ngy,ngx) c Ask user if they want to decimate print *,'Input matrix pressure resolution is: ',yres print *,' ' print *,"Do you want to decimate this matrix in pressure? (y/n)" read *,quest c if the user says 'yes' if (quest .eq. "y") then c ask user for the decimation ifactor iyres = int(yres) print *,'Enter output vertical resolution in multiples of ',iyres read *,nyres ifactor = nyres/iyres if ((ifactor .lt. 1) .or. (ifactor .ge. (ybot/yres))) then print *,'error: no decimation' return endif c c create a new, vertically decimated grid i = 0 dy = float(ifactor)*yres c print *,'ifactor ',ifactor,nyres,iyres,dy ybnew = ytop c do while (((i*ifactor)+1) .lt. (ybot/yres)) do while (((i*ifactor)) .le. (ybot/yres)) do j = 1, nx newgrid(i+1,j)=grid((ifactor*i)+1,j) newgriderr(i+1,j)=grerror((ifactor*i)+1,j) enddo i = i + 1 ybnew = ybnew + dy enddo c end-of-while c c replace the old grid with the new grid do j = 1, i do k = 1, nx grid(j,k)=newgrid(j,k) grerror(j,k)=newgriderr(j,k) enddo enddo c set the new y dimension, yres and also ybot if necessary ny = i yres = dy ybot = ybnew - dy c print *,'new ',ybot,yres c end if return end