I've been given a data file laid out as such:(adsbygoogle = window.adsbygoogle || []).push({});

heading1 heading2 heading3

x1 y1 z1

x2 y2 z2

x3 y3 z3

.etc.

where x=integer, y,z=real

I need to count the number of lines to allocate x, y and z their sizes. My first attempt looked like:

...

OPEN(21, FILE='data.dat', STATUS=OLD)

counter=1

ok=.FALSE.

DO WHILE (.NOT. ok)

READ(21,'\,1X,I1') first

counter=counter+1

IF (first .EQ. ' ') THEN

numberoflines=counter-1

ok=.TRUE.

ELSE CONTINUE

END IF

END DO

...

This runs into the problem that i don't know what type to make "first" as it'll be looking at integers until the last line.

If anyone can help it'd be much appreciated!

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fortran read from file problems

Loading...

Similar Threads for Fortran read file |
---|

Fortran Successive Over Relaxation Method in FORTRAN |

If statement for Monte Carlo integration |

C/++/# How to use C++ in studying calculus |

Fortran How to buy Fortran Programming Software Commersial License |

**Physics Forums | Science Articles, Homework Help, Discussion**