0

I have a number of output files from ArcGIS that consists of large elevation datasets.
I am trying to use FORTRAN to read and process these as the amount of data is very large.
I have a truncated example file below:

ncols         23

nrows         21

xllcorner     539204.730

yllcorner     3834204.851

cellsize      50

nodata_value  -9999

-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 
-9999 -9999 -9999 -9999 -9999 -9999 -9999 3.079 3.886 3.12 -
-9999 -9999 -9999 -9999 -9999 -9999 2.963 3.751 5.434 3.696 
-9999 -9999 -9999 -9999 -9999 1.927 1.509 1.358 1.897 1.402 
-9999 -9999 -9999 -9999 2.423 1.501 0.912 0.874 0.932 0.975 
-9999 -9999 -9999 2.994 2.563 1.613 0.781 0.401 0.598 0.815 
-9999 -9999 2.228 1.57 1.823 1.137 0.463 0.43 0.459 0.74 0.9
-9999 2.153 1.686 0.904 0.538 0.532 0.534 0.275 0.172 0.347 
-9999 1.532 0.935 0.416 0.365 0.575 0.493 0.28 0.17 0.251 0.
-9999 1.506 1.061 0.481 0.263 0.379 0.287 0.356 0.354 0.247 
-9999 1.793 1.823 1.032 0.349 0.43 0.406 0.437 0.473 0.337 0

I am trying to create an array of coordinates and elevation to perform some calculation.
I am very new to Fortran and am having trouble reading in this file and creating arrays.

BHF
  • 748
  • 7
  • 19
  • 3
    This seems to be a fairly straight-forward `READ(file_num,*)` exercise. Could you show us what you have tried? – Kyle Kanos Oct 11 '13 at 03:06

1 Answers1

0

Are the integer values left justified? Then I'd probably read those lines into a string and use list-directed IO to read the integers from a portion of the string. Something like:

character (len=80) :: line

read ( UnitNum, '(A)' )  line
read (line (14:50), * ) Ncols

Then skip blank lines by repeating the read of line.

Allocate the array to the correct dimensions, then just do:

read ( UnitNum, *) array

Let us know how far this gets you...

M. S. B.
  • 28,968
  • 2
  • 46
  • 73
  • 1
    Because Fortran stores arrays in column-major order the statement `read ( UnitNum, *) array` is likely to present the user with the transpose of what (s)he is expecting. – High Performance Mark Oct 11 '13 at 08:51