Fortran77-- retrieve data from large source

  • Context: Fortran 
  • Thread starter Thread starter Carl Loomis-Anderson
  • Start date Start date
  • Tags Tags
    Data Fortran77 Source
Click For Summary

Discussion Overview

The discussion revolves around retrieving data from multiple output files generated by a Fortran 77 simulation related to a chemical model of Titan's atmosphere. Participants are exploring methods to extract specific data arrays associated with chemical names from these files, which contain a significant amount of numerical data.

Discussion Character

  • Technical explanation
  • Homework-related
  • Exploratory

Main Points Raised

  • One participant describes the need to extract an array of values for specific chemical names from up to 1000 output files, indicating a lack of familiarity with programming concepts.
  • Another participant requests more details about the structure of the output files to provide better assistance.
  • A participant outlines the format of the output files, specifying that there are 459 chemical species, each with 124 data points.
  • There is a suggestion that the original poster research Fortran commands such as OPEN, READ, and FORMAT to facilitate data extraction.
  • One participant inquires about the intended use of the extracted arrays, suggesting that if they are solely for visualization, more modern tools might be preferable.
  • Another participant proposes starting with a simpler example file to practice the Fortran commands before tackling the larger problem.
  • There is a mention of using command-line tools like grep as an alternative to Fortran for data extraction.

Areas of Agreement / Disagreement

Participants express varying levels of familiarity with programming and Fortran, and there is no consensus on the best approach to extract the data. Some suggest using Fortran, while others propose alternative methods.

Contextual Notes

Participants have not fully resolved the specifics of the file structure or the best programming practices for data extraction. There are also indications of differing opinions on the appropriateness of using Fortran 77 versus other tools.

Carl Loomis-Anderson
Messages
6
Reaction score
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
You'll have to give more details about the structure of the file.
 
  • Like
Likes   Reactions: BvU
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.
 
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.
 
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.
 
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?
 
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.
 
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
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 27 ·
Replies
27
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 4 ·
Replies
4
Views
17K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
18K