Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Designate path for output files?

Status
Not open for further replies.

crackah

Programmer
Jul 18, 2003
7
US
Hello,
I have a FORTRAN 95 program that creates about 20 files every time it runs. Currently, it just dumps the files into whatever directory the *.exe file is in. I would like to have the output files concentrated in a subdirectory. However, I often use the program on different computers, so I would like it to be general enough to make a new subdirectory in whatever folder the *.exe file resides.

Does anybody know how to set a path in the program that will do this?

Thanks,
Chad
 
1) Create a shortcut.
2) Open up the properties page.
3) Change the working directory.
 
Unfortunately, I'm a very new FORTRAN user, and I'm not sure how to do any of what you wrote. I'm running the program out of a DOS prompt. I'd like to make the alteration to the actual code.
 
How about something like

character (len=80): inputdir

write(*,*)'Input directory'
read(*,'(A80)') inputdir

And then use string concatenation to prepend (same as append but it comes in the front) it to the output filenames.
 
Does anybody else have some input on this one? I'm still at a loss here.
 
c Example program
character*80 outdir , filename
character * 160 fullname
write(*,*)'Output directory'
read(*,'(A80)') outdir
write(*,*)'Output file'
read(*,'(A)') filename
c Generate the path+ filename :
fullname = outdir(1:len_trim(outdir))//'\'//filename
c Write to screen , for check :
write(*,'(1h ,a80)')fullname
open(7,file=fullname)
c For example :
write(7,'(1h ,8htestdata)')
close (7)
end
 
OK, I'm following that. But instead of inputting the directory manually, is there any way for FORTRAN to recognize which directory the *.exe file is in, so I could set outdir equal to that plus a new subdirectory?

i.e.
outdir = (command returns "C:\currentdir") + (outfile directory)

Thanks again for the help. Sorry I'm a bit slow here! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top