|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
tnaragan
Joined: 16 Apr 2009 Posts: 2
|
Posted: Fri Apr 17, 2009 2:41 pm Post subject: Finding files |
|
|
Hi,
This is clearly an issue of my not understanding how to tell Plato/Ftn95 where to find data and source files. In the test piece of code below, the file "test.dat" appears invisible. I created it using a test editor in the same directory as the .f95 file. When the open statement is reached the file "does not exist".
character*4 a
open(unit=10,file='test.dat',status='old')
read(10,'(a)') a
write(6,'(a)') a
stop
end
How do I associate filenames with unit numbers? Is there a way to tell Plato "find the file here"? Is there an equivalent of "ln -s test.dat fort.10' in Unix? Or is it done through env variables? How?
A (presumably) related problem is the debugger not finding the source code file. When I use the little green arrow to run the prog, the source code window is blank. I would appreciate advice on these...
Thanx, Travis |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Fri Apr 17, 2009 4:54 pm Post subject: |
|
|
Hi Travis,
Re "How do I associate filenames with Unit numbers?" - exactly as you have done. The problem is that test.dat must be in the current working directory for what you have done to work. Does Plato put your EXE in the same directory as the fortran source code and run it from there?
If the file isn't found, then the answer is clearly not.
I have in the past resorted to calling CURDIR@ to find which current directory I was in - see the FTN95 CHM helpfile library or the code fragment below.
Code: | program x
CHARACTER (LEN=256)::CURDIR@
PRINT *,'You are currently in ',CURDIR@()
END |
If you put a correct full path (such as 'c:\MyCode\Source\test.dat' then it would be found. If you don't want to do that, you can always hunt for the file and its directory (hint - again in FTN95.chm, look in the FTN95 library under "file manipulation routines" - there are several that might help you locate your data file). That might require a few lines of coding to sift out the right file, especially if its name is simple and therefore likely to match several files. (see DIRENT@, FILES@, FEXISTS@ etc).
I suspect that when you create a "project" in Plato, the EXE is put there, not in the source code directory (folder). I have to say that I have never been able to do anything meaningful with Plato, and I always run FTN95 from the command line (my editor can launch the command line app from its toolbar).
Should you then progress to writing a Windows application, there are various alternative procedures you have to follow, but reading between the lines of your request it looks as though you are just starting out with FTN95 and are simply running a "console application".
Regards
Eddie |
|
Back to top |
|
|
tnaragan
Joined: 16 Apr 2009 Posts: 2
|
Posted: Sun Apr 19, 2009 2:26 pm Post subject: |
|
|
Eddie, Thanks much. Yes there is no problem with finding the "open"ed files when programs are launched via the command line. SDBG, however, still has trouble with finding the source code file to display. Says something like " system error 2 occured, The system cannot find file specified file...". All relevant files are in the same directory, and the debugger is launced from there. Have I set any pointers incorrectly, is there a limit on path length strings, etc...
Thanx, Travis |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2580 Location: Sydney
|
Posted: Mon Apr 20, 2009 9:34 am Post subject: |
|
|
Travis,
Using Eddie's ideas, you could try the following to get a better idea of the error meaning.
For safety I only use unit numbers > 10.
I think this is mostly FTN77 compatible.
John
Code: |
character*40 a
integer*2 iostat
!
call Report_Current_Directory
!
open (unit=11,file='test.dat',status='old',iostat=iostat)
call report_iostat ('opening file test.dat', iostat)
read (11,1001,iostat=iostat) a
call report_iostat ('reading file test.dat', iostat)
if (iostat == 0) write (*,1001) a
stop
1001 format (a)
end
subroutine Report_Current_Directory
CHARACTER CURDIR@*256, location*256
external CURDIR@
!
location = CURDIR@ ()
PRINT *,'You are currently in ',trim(location)
END subroutine Report_Current_Directory
subroutine report_iostat (string, iostat)
integer*2 iostat
character string*(*), message*80
if (iostat /= 0) then
CALL FORTRAN_ERROR_MESSAGE@ (iostat, MESSAGE)
write (*,1000) ' Error ',string,' : ',iostat,' : ', trim (message)
end if
1000 format (a,a,a,i0,a,a) ! use I4 for F77
end subroutine report_iostat
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8011 Location: Salford, UK
|
Posted: Mon Apr 20, 2009 10:48 am Post subject: |
|
|
If you know where the file is then the simplest way is to provide its full path in your OPEN statement.
Alternatively, there is a good chance that the file will be found if it is located in a folder that is included in the PATH environment variable. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|