Fortran77-- retrieve data from large source

In summary: CHEMA in all the files. That will help you get an idea of what you're working with.In summary, you need to input code to read data from a file that was generated by a simulation. The code may be in a language like Fortran, but it is not yet clear to you what you will do with the data. You should first try to understand the syntax of the language and the commands that are used to input and output data. You may also want to look for simpler tools that are available that may be easier to use.
  • #1
Carl Loomis-Anderson
6
1
I'm currently doing a chemical model of Titan's atmosphere and the simulation outputs several files (up to 1000) and I need to get an array of data out of them from a specific section labeled with a chemical name (i.e HC5N) that has an arbitrary number of values (usually above 100). I've seen this kind of question posted before however I'm new to programming and don't quite understand some of the jargon and the scope of previous posts that I've seen has been quite small.
 
Technology news on Phys.org
  • #2
You'll have to give more details about the structure of the file.
 
  • Like
Likes BvU
  • #3
The output file is as such:

CHEMA
0.000000D00 0.000000D00...

CHEMB
0.000000D00 0.000000D00...

there are a total of 459 different chemical species with 124 different points of data.
 
  • #4
Carl Loomis-Anderson said:
however I'm new to programming and don't quite understand some of the jargon
What you're calling "jargon" is probably the syntax of the language. A program that you write will need to open up to 1000 files generated by the simulation, and read the data from them. I suggest you do some research on the Fortran OPEN statement, as well as the READ statement and the FORMAT statement.

After you have done those things, see what you can come up with for code, and we'll take a look.
 
  • #5
Carl Loomis-Anderson said:
I'm currently doing a chemical model of Titan's atmosphere and the simulation outputs several files (up to 1000) and I need to get an array of data out of them from a specific section labeled with a chemical name (i.e HC5N) that has an arbitrary number of values (usually above 100).
So, the simulation code is in Fortran 77 and it produces those output files. It is not yet clear to me what you like to do with the arrays that you wish to extract. Do these arrays serve as input of other computational Fortran code or would you like to use them for visualization, for example?

The answer can be "both", of course, but I am just curious. If you like to use these arrays only for post-processing and visualization, there may be more modern and user friendly tools available.
 
  • #6
Carl Loomis-Anderson said:
CHEMA
0.000000D00 0.000000D00...

CHEMB
0.000000D00 0.000000D00...

there are a total of 459 different chemical species with 124 different points of data.

So each one of CHEMA, CHEMB, etc. has exactly 124 numbers on the next line?
 
  • #7
Put your problem on the back burner for a while and start with a simple file like:

mychema
1 2 3 4 5
mychemb
6 7 8 9 10
mychemc
11 12 13

Now type that in using Notepad (even better download Notepad++), save it as say myfile.txt. That's a start ok. Now, read up on the FORTRAN open and read commands and now put myfile.txt on the back burner with the other one. Now, instead, just work through the on-line examples I suspect they will have dealing with the open and read commands. Get those down, then apply what you've learned to then open and read myfile.txt. get to the point where you can read all of it, then use an if construct to pull out the mychemb record like (pseudo-code):

If (record=="mychemb")
{
mydata=read(myfile.txt)
}

Just get that much working where the data is in mydata. May need to process it further with type casting or whatever. The data may be in string format. Will need to know how to convert strings to numbers. Google that one as well. Just get the 6 7 8 9 10 working first then move on to your problem.
 
  • #8
Carl Loomis-Anderson said:
The output file is as such:

CHEMA
0.000000D00 0.000000D00...

CHEMB
0.000000D00 0.000000D00...

there are a total of 459 different chemical species with 124 different points of data.
There may be better tools than Fortran-77 for this.

Consider using something simple like $ grep -A 1 CHEMA file*.dat
 

FAQ: Fortran77-- retrieve data from large source

How do I retrieve data from a large source using Fortran77?

To retrieve data from a large source using Fortran77, you will need to use file input/output (I/O) operations. This involves opening the source file, reading the data, and storing it in appropriate variables. You can use the OPEN, READ, and CLOSE statements for this purpose.

Can Fortran77 handle large datasets?

Yes, Fortran77 is capable of handling large datasets. It has a fixed record length of 80 characters, which allows for efficient processing of large amounts of data. Additionally, Fortran77 also has features such as array operations and built-in functions that make it well-suited for handling large datasets.

How can I ensure that my Fortran77 program retrieves data accurately?

To ensure accuracy in retrieving data, it is important to have a thorough understanding of the data format and structure of the source file. This includes knowing the data type, record length, and any special characters or delimiters used. Additionally, proper error-handling techniques should be implemented to catch and handle any unexpected errors.

Are there any limitations to retrieving data from a large source using Fortran77?

While Fortran77 is capable of handling large datasets, it does have some limitations. One limitation is the fixed record length of 80 characters, which may not be suitable for all types of data. Additionally, Fortran77 does not have built-in support for modern data formats, such as XML or JSON, which may make it more difficult to retrieve data from certain sources.

How can I optimize my Fortran77 program for retrieving data from a large source?

To optimize your Fortran77 program for retrieving data from a large source, you can consider using features such as array operations and built-in functions, which can improve performance. Additionally, using efficient file I/O techniques, such as direct access instead of sequential access, can also improve the speed of data retrieval. It is also important to regularly review and optimize your code for any potential bottlenecks.

Similar threads

Replies
6
Views
1K
Replies
27
Views
6K
Replies
2
Views
3K
Replies
4
Views
16K
Replies
6
Views
3K
Replies
2
Views
3K
Replies
13
Views
4K
Replies
5
Views
2K
Replies
2
Views
18K
Back
Top