Hello,
I have a simple program that reads a datafile in scanline format and writes out an XYZ file (longitude, latitude and value). Everything is set fine and the input and output files are read fine. I have modified existing code to read the Gravsoft data format.
However, I would like to make the dimension statement generic, so that the user can input a new value if the input file has a larger dimension (eg more columns).
If I put Implicit none in, then I have to define nn, ne, i, j, and row as integer. The code compiles but a run-time error is generated, so this is left out to make it work.
Any pointers how to streamline the code and make it more efficient would be helpful.
What I am looking to achieve is a generic Gravsoft reader, e.g.:
Enter input data: Enter output data: Enter row dimension:
Program Gravsoft
dimension row(4320)
real :: rlat,rlat1,rlat2,rlon,rlon1,rlon2,dlat,dlon
character(len=128) :: infile, outfile
print *, 'Enter input data file:'
read (*,'(A40)') infile
open(10, file=infile, status='old')
print *, 'Enter output data file:'
read (*,'(A40)') outfile
open(11, file=outfile, status='new')
read(10,*) rlat1,rlat2,rlon1,rlon2,dlat,dlon
nn = (rlat2-rlat1)/dlat+1.5
ne = (rlon2-rlon1)/dlon+1.5
rlat = rlat2
do i = 1, nn
read(10,*) (row(j),j=1,ne)
rlon = rlon1
do j = 1,ne
if (rlon .gt. 360) rlon = rlon1
write(11,*) rlat, rlon, row(j)
rlon = rlon + dlon
enddo
rlat = rlat - dlat
enddo
close (10)
close (11)
end program
Thanks
Lester