soccer jersey forums.silverfrost.com :: View topic - Finding files
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Finding files

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
tnaragan



Joined: 16 Apr 2009
Posts: 2

PostPosted: Fri Apr 17, 2009 2:41 pm    Post subject: Finding files Reply with quote

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
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2393
Location: Yateley, Hants, UK

PostPosted: Fri Apr 17, 2009 4:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
tnaragan



Joined: 16 Apr 2009
Posts: 2

PostPosted: Sun Apr 19, 2009 2:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2580
Location: Sydney

PostPosted: Mon Apr 20, 2009 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8011
Location: Salford, UK

PostPosted: Mon Apr 20, 2009 10:48 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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