View previous topic :: View next topic |
Author |
Message |
Ronan
Joined: 27 Jun 2007 Posts: 19
|
Posted: Mon Mar 12, 2012 8:56 am Post subject: Opening file reading writing data |
|
|
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 |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Mon Mar 12, 2012 10:48 am Post subject: |
|
|
Ronan,
just add
before the stop command.
Regards - Wilfried |
|
Back to top |
|
|
skeptic
Joined: 22 Mar 2009 Posts: 14
|
Posted: Mon Mar 12, 2012 11:40 am Post subject: |
|
|
Or, simply, remove the 'stop' statement. END closes all files. |
|
Back to top |
|
|
Ronan
Joined: 27 Jun 2007 Posts: 19
|
Posted: Mon Mar 12, 2012 11:46 am Post subject: |
|
|
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 |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon Mar 12, 2012 11:53 am Post subject: |
|
|
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 |
|
|
skeptic
Joined: 22 Mar 2009 Posts: 14
|
Posted: Mon Mar 12, 2012 12:03 pm Post subject: |
|
|
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 |
|
|
Ronan
Joined: 27 Jun 2007 Posts: 19
|
Posted: Mon Mar 12, 2012 2:29 pm Post subject: |
|
|
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 |
|
|
|