Fortran Fortran 90 command to write only specific lines

AI Thread Summary
The discussion centers on a programming challenge involving the output of data files at specific intervals. The user seeks to generate files from a program that produces 3000 outputs, each 200MB in size, but wants to save storage by only writing every tenth file (e.g., 1.dat, 10.dat, 20.dat, etc.). Participants suggest using an if statement to control the output frequency, specifically recommending the use of the "mod" function to determine when to write files. A sample code snippet is provided, illustrating how to format output file names and write data conditionally, resulting in filenames formatted as 0000.dat, 0001.dat, up to 1000.dat. The conversation emphasizes practical coding solutions for efficient data management.
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:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
5
Views
3K
Replies
3
Views
4K
Replies
19
Views
6K
Replies
4
Views
2K
Replies
4
Views
6K
Replies
6
Views
16K
Replies
3
Views
4K
Replies
4
Views
4K
Back
Top