For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2006 > How to read this random data from file in Fortran??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to read this random data from file in Fortran??
uday_kgiri

2006-04-19, 4:07 pm

Hi,

I have a data file in the following format:

-----------------------
*HEADING
*NODE,NSET=N0
609, 0.666667, -100.000000
1, 1.000000, -100.000000
*NODE,NSET=CT1-2
** x=51.000000, y=0.000000
3158, 51.026667, 0.000000
*ELEMENT,ELSET=B0,TYPE=CPE4R
1,609,1,17,604
2,1,2,18,17
-----------------------

This is only a part of the complete file which is very long. The problem is I want to read only those lines which have 3 numbers in a line. So in the above example, I want to read only (609, 0.666667, -100.000000), (1, 1.000000, -100.000000) and (3158, 51.026667, 0.000000). The format for such lines is: one integer followed by two floating points.

I am thinking I should read each line into a string and then count the number of data points in that line. But how to count the number of floating numbers or integers in each line?

Any suggestions?

Thankyou,
uday.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com