Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help in reading and writing column data

Status
Not open for further replies.

vibhava

Programmer
Apr 20, 2008
19
US
hi,
I have two text files: file 1 is shown below.It has 50 columns each column having different number of datapoints
10 20 30 40
10 20 30 40
10 20 30 10
10 20 10 05
10 20 05
10
10
10
10
10

File 2 currently look like this:
45
45
10

Now what I want to do is
Step 1: Start a loop from n = 1 to 50 (1 run for each column)
Step 2: read column (n) of file 1
Step 3: delete whatever is previously stored in file 2
Step 4: write the column read from file 1 in step 2 to file 2.
Step 5: repeat the same process again eg. read column 2 from file 1 and replace it in file2 and so on.

the problem is that different columns in file 1 have different number of datapoints. I know ALLOCATABLE arrays can be used to solve this problem but I am new in FORTRAN programming and unable to figure out how to read column data and allocate memory to array accordingly.

Any help would be appreciated. Solving this problem is very important for my research.

Thanks

Vibhava
 
Someone had a similar problem about a year ago. If you look through the previous postings, you will probably find the answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top