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

Fortran-write file to directory other than current

  1. Jun 15, 2009 #1


    User Avatar


    I am running a fortran f90 program and am writing outputs to several files,
    the thing is I would like them to be written to a specific folder to better manage outputs
    and so leaving the program directory clean.

    here's a sample write sentence:

    open(unit=3, file=val(i,1)//'_Brutes_lowV_thr_5_10_15.txt', status='replace')
    do h=1, size(pmv)
    write(3,*) YearList(h), pmv(h), lowV(h,:)

    where do I add instructions so that the file is written say in
    an output folder located on the desktop (/home/ign/desktop/output)?

    thank you in advance,
  2. jcsd
  3. Jun 15, 2009 #2


    User Avatar

    solved the problem!

    and to make it cleaner I declared a path

    CHARACTER*29 :: path='/home/....../output/'

    I then added path (followed by union slashes //) at the beginning of the file name

    open(unit=3, file=path//val(i,1)//'_Brutes_lowD.txt', status='unknown')
  4. Nov 30, 2009 #3
    Thanks. this solved my problem too :)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook