c This program reads binary grid file and c displays the header information on screen c It writes data in ascii to the specified output file. real val(2000) character*40, fin, fout integer nx, ny real xres,yres,xleft,xright,ytop,ybot vmin = 1.e6 vmax = -1.e6 print *, 'fin' read *, fin print *,'fout' read *, fout open(1, file=fin, form='unformatted') open(2, file=fout, form='formatted') read(1) nx,ny, xres,yres,xleft,xright,ytop,ybot c display header information to the screen write(*,101)nx,ny write(*,102)xleft write(*,103)xright write(*,104)ytop write(*,105)ybot write(*,106)xres write(*,107)yres c write header information to the output file write(2,101)nx,ny write(2,102)xleft write(2,103)xright write(2,104)ytop write(2,105)ybot write(2,106)xres write(2,107)yres 101 format('Grid Dimensions: ', i3,' X ', i3) 102 format('Left X Grid Point:' , f7.2) 103 format('Right X Grid Point:' , f8.2) 104 format('Top Y Grid Point:' ,f7.2) 105 format('Bottom Y Grid Point:' , f7.2) 106 format('Grid Resolution in X direction: ', f7.2) 107 format('Grid Resolution in Y direction: ', f7.2) n10 = nx/10 nls11 = mod(nx,10) yv = ytop do i = 1, ny c read one row of data read(1) (val(j),j=1,nx) do l = 1, nx if ( val(l) .gt. vmax) vmax = val(l) if ( val(l) .lt. vmin) vmin = val(l) enddo do k = 1, n10 ib = 10*(k-1) +1 ie = 10*k c write data in 10 columns write(2,111) (val(j),j=ib,ie) enddo c write the remaining data write(2,111) (val(j),j=ie+1,nx) yv = ytop + yres enddo print *, 'maximum data value: ', vmax print *, 'minimum data value: ', vmin 111 format(10(f6.2,2x)) close(1) stop end