Fortran Fortran-write file to directory other than current

  • Thread starter Thread starter ign
  • Start date Start date
  • Tags Tags
    Current File
AI Thread Summary
To direct output files from a Fortran F90 program to a specific folder, users can declare a path variable that specifies the desired output directory. In this case, the path was set as CHARACTER*29 :: path='/home/.../output/'. By concatenating this path with the desired file name using the union slashes (//), the output files can be organized neatly in the specified folder. For example, the open statement was modified to open(unit=3, file=path//val(i,1)//'_Brutes_lowD.txt', status='unknown'). This approach effectively keeps the program directory clean and manages outputs efficiently.
ign
Messages
5
Reaction score
0
Hello,

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,:)
enddo
close(3)

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,
ign
 
Technology news on Phys.org
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')
 
Thanks. this solved my problem too :)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
9
Views
1K
Replies
1
Views
3K
Replies
5
Views
2K
Replies
8
Views
2K
Replies
3
Views
3K
Replies
1
Views
4K
Replies
19
Views
6K
Back
Top