Multiple Read-file handling

Hi guys, I need a bit of suggestion on how to handle read from multiple files in a manner that best suits a program I am writing. The main idea of the program is to simulate, using a quite complex mathematical model, some biological process, and the results obtained for the dependent variable (in time) compared with the clinical results spanning several hundreds of datasets i have obtained from clinical trials, which are to be placed in a separate file.

Currently, I have 12 files, 8 of which contains a set of initial values of rate constants which will be constant throughout the program - These will be modified using some optimization methods but that is another matter entirely.

On 3 of the other 4 files, I have decided to have each line of text represent unique dataset, so that if I have, say

A|B|C.dat

1.0 1.5 1.44 1.5 0.23 0.45 // Dataset 1
1.120 1.35 1.34 1.43 0.33 0.45 // Dataset 2
1.130 1.25 1.44 1.23 0.13 0.45 // Dataset 3
.
.
.
.
1.80 1.95 1.544 13.5 5.23 3.45 // Dataset N



Then my program can read these values into the appropriate variables when it is time to solve for the dataset.

The last file holds the experimental results in time for the dependent variable, and I plan to get the outputs from my program at the same times as the ones in this input file so that I can make comparisons.

My problem now is that I have this all quite figured out in my head but can't seem to get it into code form. What I want to do algorithmically is

1. Open all the files
2. Read the all the inputs in the 8 rate constant files, which I have already done.
3. Read the first line of input from the subsequent 4 files into the appropriate variables
4. Perform the simulations
5. Flush the memory of the variables in 3
6. Read in next line of the files in 3
7. Do 4
8. Do 5
9. Goto 6

Currently, I have been able to achieve this with single lines of files (one data set) but I will like suggestions how to expand it to cover multiple lines for the four ".dat" files. Other suggestions are definitely welcome as well.

Thanks.

@Lastchance

Last edited on
Topic archived. No new replies allowed.