Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problem with open statement

Zorrilla__David
Principiante
1.372 Visualizações
Hi all. I'm having a problem with open statement. I need to read a binary file and use this code

! If the compiler is other than INTEL's, uses the OPEN
! sentence for stream files according to Fortran 2003 standard
#if __INTEL_COMPILER
open (unit=iuni,file=s,form='binary',carriagecontrol='NONE')
#else
open (unit=iuni,file=s,form='unformatted',access='stream')
#endif

When I compile this code in linux with intel compiler or with gfortran compliler, all works fine. But when I try to compile in windows with CVF compliler I get an error because the statement access='stream' doesn't exist in CVF compiler.
I would like to know how can I modify the code to works in linux and windows and with intel compiler, gfortran and CVF.


Is there a statement like this:

#if __INTEL_COMPILER
open (unit=iuni,file=s,form='binary',carriagecontrol='NONE')
#elif __COMPAQ_COMPILER ------>something similar to this to work with CVF in windows
open (unit=iuni,file=s,form='binary',carriagecontrol='NONE')
#else
open (unit=iuni,file=s,form='unformatted',access='stream')
#endif

or other way to solve my problem?


Thanks in advanced...
0 Kudos
4 Respostas
Steven_L_Intel1
Funcionário
1.372 Visualizações
You can test for _WIN32 after eliminating Intel Fortran to do something for CVF. _DF_VERSION_ can also be tested to see if it is 660 or less, but a test on _WIN32 may be easier.

However, Intel Fortran supports access='stream' and I suggest you use that.
Zorrilla__David
Principiante
1.372 Visualizações
I have tried some combinations and I have the same warning and error with CVF6.6.
As you say, if intel manage access='stream', my last code is:

#if _WIN32
open (unit=iuni,file=s,form='binary',carriagecontrol='NONE')
#else
open (unit=iuni,file=s,form='unformatted',access='stream')
#endif

In linux, this code would work with intel and gfortran compilers, and in Windows with CVF, but I get this warnings and error:

Warning: Bad # preprocessor line
#if _WIN32

Warning: Bad # preprocessor line
#else

Warning: Bad # preprocessor line
#endif

Error: Not a valid value for the char-expr in this connect-spec. ['stream']
open (unit=iuni,file=s,form='unformatted',access='stream')

Thanks for your quick reply
Steven_L_Intel1
Funcionário
1.372 Visualizações
If you are going to use cpp-style directives, you have to enable the preprocessor (/fpp from the command line).
Zorrilla__David
Principiante
1.372 Visualizações
Thanks and sorry for my ignorance
Responder