- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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...
! 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...
- Marcas:
- Intel® Fortran Compiler
Link copiado
4 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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.
However, Intel Fortran supports access='stream' and I suggest you use that.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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
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
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
If you are going to use cpp-style directives, you have to enable the preprocessor (/fpp from the command line).
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thanks and sorry for my ignorance
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora