Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran 90 command to write only specific lines

  1. Feb 17, 2015 #1
    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
     
  2. jcsd
  3. Feb 18, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

    I don't understand what is complicated here. Can't you simply use an if statement around the part where the output is done?
     
  4. Feb 18, 2015 #3
    well, yes, then write every 10th time through the loops...look into function "mod" to get you an idea.
     
  5. Mar 2, 2015 #4
    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: Mar 2, 2015
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran 90 command to write only specific lines
Loading...