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 

Opening file reading writing data

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



Joined: 27 Jun 2007
Posts: 19

PostPosted: Mon Mar 12, 2012 8:56 am    Post subject: Opening file reading writing data Reply with quote

hi all,

I observe very strange behaviour of Silverfrost fortran with file manipulating routines. I couldn't spot it whether it was due to my lack of knowledge or erratic behaviour of compiler. I run the following code and it suppose to create the new_file.dat under the folder of current project.

But actually it does nothing. What's wrong here ?


Code:
program test
implicit none

open(11,file='new_file.dat')

write(11, '(a15)') " The value"

stop

end program test
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Mon Mar 12, 2012 10:48 am    Post subject: Reply with quote

Ronan,

just add

Code:
close(11)


before the stop command.

Regards - Wilfried
Back to top
View user's profile Send private message
skeptic



Joined: 22 Mar 2009
Posts: 14

PostPosted: Mon Mar 12, 2012 11:40 am    Post subject: Reply with quote

Or, simply, remove the 'stop' statement. END closes all files.
Back to top
View user's profile Send private message
Ronan



Joined: 27 Jun 2007
Posts: 19

PostPosted: Mon Mar 12, 2012 11:46 am    Post subject: Reply with quote

I 've tried each of your option with possible variations. Interestingly it doesn't have any effect on file creation / manipulation, situation remains the same.

If I choose to print the values on the console window everything seems normal ( but I didn't verify it that produced results are correct with problem that I'm dealing with ).

Regards,
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Mar 12, 2012 11:53 am    Post subject: Reply with quote

I called your program test.f95, then used the command:
ftn95 test /lgo
It ran and produced the file with the text:" The value"
right justified for 15 characters.
Including a close or removing stop should not be required.
Not sure what the problem is ?
Are you running the program ?

John
Back to top
View user's profile Send private message
skeptic



Joined: 22 Mar 2009
Posts: 14

PostPosted: Mon Mar 12, 2012 12:03 pm    Post subject: Reply with quote

I don't know what you are doing, or not doing, but your
program works for me just as you listed it -

with and without any 'close' statement
with and without the 'stop' statement
Back to top
View user's profile Send private message
Ronan



Joined: 27 Jun 2007
Posts: 19

PostPosted: Mon Mar 12, 2012 2:29 pm    Post subject: Reply with quote

I see,

AFAIU nobody but me has encountered such a problem with fore-given code snippet. The intention is simply to open a file write something into it and exit the program. It seems that it's time change the computer.


One more thing , what actually would be to cause the compiler to raise and exception like :
"The program has terminated with an error code of 0"

Regards,
Back to top
View user's profile Send private message
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