Fortran 90 command to write only specific lines

Click For Summary

Discussion Overview

The discussion centers around how to modify a Fortran 90 program to selectively write output files, specifically to save storage by only writing every tenth output file from a larger dataset. Participants explore various programming techniques and approaches to achieve this goal.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant seeks a method to write output files named 1.dat, 10.dat, 20.dat, etc., from a program that generates a large number of output files.
  • Another participant suggests using an if statement to control when the output occurs, implying that this could simplify the process.
  • A different participant recommends using the "mod" function to determine when to write the output, indicating a mathematical approach to the problem.
  • One participant provides a sample code snippet that demonstrates how to format output file names, but it does not address the specific requirement of writing every tenth file.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the best approach to the problem, as various methods and interpretations are suggested without agreement on a single solution.

Contextual Notes

Some assumptions about the program's structure and the specific requirements for output file naming and selection may not be fully articulated, leading to potential misunderstandings in the proposed solutions.

Who May Find This Useful

Individuals working with Fortran 90 who need to manage large output datasets efficiently, particularly in scientific computing or data analysis contexts.

s_hy
Messages
57
Reaction score
0
Hi all. I did search in internet but couldn't find the specific answer for my specific problem.I need to run a program with a datafile in 3000 time step and the output will 1.dat to 3000.dat, which is every single data output size 200Mb. To safe the storage, I would like to write only every tenth of file, in example 1.dat,10.dat,20.dat,30.dat,40.dat,...., 2970.dat,2980.dat,2990.dat,3000.dat. How I can write in write statement for this purpose?

thank you in advance
 
Technology news on Phys.org
I don't understand what is complicated here. Can't you simply use an if statement around the part where the output is done?
 
well, yes, then write every 10th time through the loops...look into function "mod" to get you an idea.
 
What's your specific question? Did you mean the output name or big size data generate?
If you mean the output name :

program main
implicit none
integer i
real vars
character(len=255) output_name

do i=1,1000
write(output_name,100) i,"dat"
write(10,file=trim(output_name)) vars
end do

100 FORMAT(I4.4,A3)
end program

The result would be: 0000.dat, 0001.dat, 0002.dat ... 1000.dat
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 6 ·
Replies
6
Views
16K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K