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 :)
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

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