Silverfrost Forums

Welcome to our forums

Opening file reading writing data

12 Mar 2012 7:56 #9793

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 ?

program test
implicit none 

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

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

stop

end program test 
12 Mar 2012 9:48 #9796

Ronan,

just add

close(11)

before the stop command.

Regards - Wilfried

12 Mar 2012 10:40 #9801

Or, simply, remove the 'stop' statement. END closes all files.

12 Mar 2012 10:46 #9802

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,

12 Mar 2012 10:53 #9803

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

12 Mar 2012 11:03 #9805

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

12 Mar 2012 1:29 #9809

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,

Please login to reply.