Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

A Fortran file open oddity

michael_green
Beginner
1,061 Views

Hi All,

Here's a file open statement:

open(567,file=trim(fmis$private)//''//trim(SessionName)//'.ses', & status='replace',iostat=ios,err=1000)

it clearly specifies 'replace'. When I write to this file I can see, while debugging, that I am writing the correct data to it, and I get no errors. I close the file with:

close(567)

In Windows Explorer I see that the file has a new date and time, as I expect. But, the contents of the file are unchanged - they are still the old stuff from several days ago.

My workaround is to specifically delete and open the file 'new', but why should I have to do this? I'm using CVF 6.6c on Windows XP.

What's going on?

With many thanks

Mike

0 Kudos
2 Replies
anthonyrichards
New Contributor III
1,061 Views

I also use CVF 6.6C on WindowsXP. The OPEN(...REPLACE..) works fine for me. The following prog was tested:

program OPENREPLACE

implicit none
CHARACTER(100) FILENAME
INTEGER IOS

FILENAME='C:F90OPENREPLACEMYTEXT.SES'
OPEN(567,FILE=FILENAME,STATUS='UNKNOWN', FORM='FORMATTED')
WRITE(567,*) 'This is a new file'
WRITE(567,*) 'This is a new file'
WRITE(567,*) 'This is a new file'
close(567)

call sleepqq(60000)

OPEN(567,FILE=FILENAME, status='REPLACE', IOSTAT=IOS, ERR=1000)
WRITE(567,*) 'This is a REPLACEMENT in the new file'
WRITE(567,*) 'This is a REPLACEMENT in the new file'
CLOSE(567)
stop

1000print *, 'There was an error replacing the data in the file'

end program OPENREPLACE

The 60 second pause allowed me to inspect the contents of the new file which were as expected. After the pause, I inspected the file again and found thereplacement contents OK.

Ire-ran the program aftercommenting out the replacement WRITEs so that the file was just opened for replacement then CLOSEd, resulting in an empty file.

p.s. Are you running ZEMAX, btw? It uses .SES files....

I am at a loss to suggest what's wrong. More information is needed, I guess.

0 Kudos
michael_green
Beginner
1,061 Views

I never heard of ZEMAX, and I'm not running it as far as I know. I have used the 'replace' switch hundreds of times before and never had a problem with it, it's just this .ses file, and not just on my machine either - users get the same problem. I'll leave it at that for now because I have an adequate workaround, as mentioned, but I was amazed to see the problem.

Many thanks for your input on this,

Mike

0 Kudos
Reply