Fortran 90 command to write only specific lines

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
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
 
Physics 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: