include header in f90 file using compaq visual fortran 
Author Message
 include header in f90 file using compaq visual fortran

Hello-

I'm running into an issue when I try to include a C header file in a
project that includes an .f90 file (free source format).  I'm working
on a project with a large number of subroutines/.f files, and there
was no issue with including the C header file until I changed one file
to .f90 to take advantage of the free source format.  Now, when I try
to include the header in the .f90 file, it seems the Compaq Visual
fortran is trying to compile the header file (and giving me messages
related to Fortran syntax errors).

I know the .f90 file is causing the error because when I comment out
the "include" line, and other files (.f fixed format files) in the
project still contain it, the project compiles correctly (as it
happens that particular file does not need to include the header, but
others do and I plan on updating them to .f90 eventually).

Does anyone know why this is happening?



Tue, 19 Jul 2011 00:51:12 GMT  
 include header in f90 file using compaq visual fortran

Quote:
> I'm running into an issue when I try to include a C header file in a
> project that includes an .f90 file (free source format).  I'm working
> on a project with a large number of subroutines/.f files, and there
> was no issue with including the C header file until I changed one file
> to .f90 to take advantage of the free source format.  Now, when I try
> to include the header in the .f90 file, it seems the Compaq Visual
> Fortran is trying to compile the header file (and giving me messages
> related to Fortran syntax errors).
> I know the .f90 file is causing the error because when I comment out
> the "include" line, and other files (.f fixed format files) in the
> project still contain it, the project compiles correctly (as it
> happens that particular file does not need to include the header, but
> others do and I plan on updating them to .f90 eventually).
> Does anyone know why this is happening?

As a quick fix, I would change the line:

include 'C_FILE.h'

to:

!DEC$ NOFREEFORM
include 'C_FILE.h'
!DEC$ FREEFORM

and see if that helps.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end



Tue, 19 Jul 2011 01:01:27 GMT  
 include header in f90 file using compaq visual fortran


Quote:


> > I'm running into an issue when I try to include a C header file in a
> > project that includes an .f90 file (free source format). ?I'm working
> > on a project with a large number of subroutines/.f files, and there
> > was no issue with including the C header file until I changed one file
> > to .f90 to take advantage of the free source format. ?Now, when I try
> > to include the header in the .f90 file, it seems the Compaq Visual
> > Fortran is trying to compile the header file (and giving me messages
> > related to Fortran syntax errors).
> > I know the .f90 file is causing the error because when I comment out
> > the "include" line, and other files (.f fixed format files) in the
> > project still contain it, the project compiles correctly (as it
> > happens that particular file does not need to include the header, but
> > others do and I plan on updating them to .f90 eventually).
> > Does anyone know why this is happening?

> As a quick fix, I would change the line:

> include 'C_FILE.h'

> to:

> !DEC$ NOFREEFORM
> include 'C_FILE.h'
> !DEC$ FREEFORM

> and see if that helps.

> --
> write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
> 6.0134700243160014d-154/),(/'x'/)); end

Thanks a lot, this worked!

I assumed it was something like this, the free form file was somehow
messing up the compiler when it tried to include the C file, but I
didn't know how to fix it.



Tue, 19 Jul 2011 01:15:30 GMT  
 include header in f90 file using compaq visual fortran
In article

Quote:

> Thanks a lot, this worked!

> I assumed it was something like this, the free form file was somehow
> messing up the compiler when it tried to include the C file, but I
> didn't know how to fix it.

Why are you including a C header file into your fortran program with a
fortran INCLUDE statement?  I don't know how this could possibly NOT
cause problems.  Are you sure that it is a C header file rather than a
file that contains fortran source code?  There must be something else
going on here.  I would be suspicious of the compiled code even though
the compiler itself did not complain after you removed the INCLUDE
statement.

$.02 -Ron Shepard



Tue, 19 Jul 2011 02:47:30 GMT  
 include header in f90 file using compaq visual fortran


Quote:
> In article


>> Thanks a lot, this worked!

>> I assumed it was something like this, the free form file was somehow
>> messing up the compiler when it tried to include the C file, but I
>> didn't know how to fix it.

> Why are you including a C header file into your fortran program with a
> fortran INCLUDE statement?  I don't know how this could possibly NOT
> cause problems.  Are you sure that it is a C header file rather than a
> file that contains fortran source code?  There must be something else
> going on here.  I would be suspicious of the compiled code even though
> the compiler itself did not complain after you removed the INCLUDE
> statement.

Probably the OP doesn't mean what you clearly think he means by the term
"C"...

--
Qolin

Email: my qname at domain dot com
Domain: qomputing



Tue, 19 Jul 2011 05:52:49 GMT  
 include header in f90 file using compaq visual fortran

Quote:



> > Why are you including a C header file into your fortran program with a
> > fortran INCLUDE statement?  I don't know how this could possibly NOT
> > cause problems.

I was wondering very much the same thing.

Quote:
> Probably the OP doesn't mean what you clearly think he means by the term
> "C"...

Ah. I hadn't though of that, but now that you suggest it, that seems a
quite likely guess. As in perhaps "C header file" really means just
"header file", with the "C" part tacked on because that's where he heard
of header files and he has gotten used to describing them that way even
when they don't have anything to do with C. I could see that.

Somewhat like "ASCII text" used to describe text that has nothing to do
with ASCII. I've certainly seen that one, and I mean for things like
EBCDIC that have nothing to do with ASCII - not just ISO 10646 or other
things that are at least related.

--
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain



Tue, 19 Jul 2011 07:16:35 GMT  
 include header in f90 file using compaq visual fortran

Quote:



>> > Why are you including a C header file into your fortran program with a
>> > fortran INCLUDE statement?  I don't know how this could possibly NOT
>> > cause problems.
> I was wondering very much the same thing.

If you are careful with comments it might be possible to
write an include file that will work with both C and Fortran.

Even easier with the C preprocessor, as most C compilers define
some preprocessor variables.

#ifdef __STD_C__
   int i;
   struct { float a,b,c; } xyz;
#else
      INTEGER I
      COMMON /xyz/ A,B,C
#endif

Without the preprocessor:

char ignore_this; /*
      INTEGER I
      COMMON /xyz/ A,B,C
c  */ int i; /*
c  */ struct { float a,b,c; } xyz;

-- glen



Tue, 19 Jul 2011 08:05:14 GMT  
 include header in f90 file using compaq visual fortran


Quote:
> Without the preprocessor:

> char ignore_this; /*
>       INTEGER I
>       COMMON /xyz/ A,B,C
> c  */ int i; /*
> c  */ struct { float a,b,c; } xyz;

I have not seen this trick before.  Pretty neat!  However, and I hope
you don't take this the wrong way, I hope I never actually see this in
any code that I maintain. :-)

$.02 -Ron Shepard



Tue, 19 Jul 2011 12:04:57 GMT  
 include header in f90 file using compaq visual fortran
(snip, I wrote)

Quote:
>> char ignore_this; /*
>>       INTEGER I
>>       COMMON /xyz/ A,B,C
>> c  */?int i; /*
>> c  */ struct { float a,b,c; } xyz;
> I have not seen this trick before.  Pretty neat!  However, and I hope
> you don't take this the wrong way, I hope I never actually see this in
> any code that I maintain. :-)

I saw it done once with Fortran and PL/I (or maybe PL/S).
IBM PL/I compilers usually accept statements between
columns 2 and 72 (avoids accidental /* in column 1, the
JCL end-of-file marker.  Also, there is an option to use
column 1 as carriage control in the listing file.)

It is then easy to put C in column 1 and /* ... */ around
the Fortran source.

-- glen



Tue, 19 Jul 2011 12:29:05 GMT  
 include header in f90 file using compaq visual fortran

Quote:

>Somewhat like "ASCII text" used to describe text that has nothing to do
>with ASCII. I've certainly seen that one, and I mean for things like
>EBCDIC that have nothing to do with ASCII - not just ISO 10646 or other
>things that are at least related.

Yup.  When using FTP commands to and/or from EBCDIC systems, the
commands are still BINARY and ASCII :-)

Regards,
Nick Maclaren.



Tue, 19 Jul 2011 16:32:51 GMT  
 include header in f90 file using compaq visual fortran

Quote:



>>Somewhat like "ASCII text" used to describe text that has nothing to do
>>with ASCII. I've certainly seen that one, and I mean for things like
>>EBCDIC that have nothing to do with ASCII - not just ISO 10646 or other
>>things that are at least related.
> Yup.  When using FTP commands to and/or from EBCDIC systems, the
> commands are still BINARY and ASCII :-)

But in ASCII mode it is ASCII in the TCP data stream, isn't it?

The EBCDIC end is responsible for doing the conversion.

More fun is the effect of not having record markers on
most EBCDIC systems.  I once transfered some VB files an then
realized that no record marks were transfered.  (in binary mode)

-- glen



Tue, 19 Jul 2011 19:34:18 GMT  
 include header in f90 file using compaq visual fortran
On Thu, 29 Jan 2009 12:47:30 -0600, Ron Shepard

Quote:

>Why are you including a C header file into your fortran program with a
>fortran INCLUDE statement?

I understood this as "a Fortran include file with a .h file type".  I have
seen many programmers use .h as a "universal header" file type for both C and
Fortran.  You'll even see this codified in such libraries as OpenMP
(omp_lib.h),  MPICH2 (mpif.h) and IMSL (link_fnl_static.h).  It would not
astonish me that some might call this a "C header" even when it isn't.  Unlike
for C, there ;s no commonly accepted file type for Fortran include files.  I
have seen so many conventions over the years I have lost count.  .h is no
worse than the others, save for a possible bit of confusion as shown in this
thread.

--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
  http://software.intel.com/en-us/forums/
Intel Fortran Support
  http://support.intel.com/support/performancetools/fortran
My Fortran blog
  http://www.intel.com/software/drfortran



Tue, 19 Jul 2011 23:36:23 GMT  
 include header in f90 file using compaq visual fortran


Quote:

>I understood this as "a Fortran include file with a .h file type".  I have
>seen many programmers use .h as a "universal header" file type for both C and
>Fortran.  You'll even see this codified in such libraries as OpenMP
>(omp_lib.h),  MPICH2 (mpif.h) and IMSL (link_fnl_static.h).  It would not
>astonish me that some might call this a "C header" even when it isn't.  Unlike
>for C, there ;s no commonly accepted file type for Fortran include files.  I
>have seen so many conventions over the years I have lost count.  .h is no
>worse than the others, save for a possible bit of confusion as shown in this
>thread.

Indeed, an 8-bit counter would probably have overflowed :-)

I don't know how many current compilers use such this to control
whether to switch between fixed and free format (or vice versa),
and whether to pass the text through the C preprocessor, but a lot
used to.  Often unreliably, and all incompatibly.

One demented MVS compiler accepted either fixed or variable length
records for source text, but would accept include files only in
80-character fixed length.  This format was a file property and
had nothing to do with Fortran fixed and free format.

Doubtless other people have even weirder stories to tell.

Regards,
Nick Maclaren.



Tue, 19 Jul 2011 23:58:26 GMT  
 include header in f90 file using compaq visual fortran

Quote:

>I don't know how many current compilers use such this to control
>whether to switch between fixed and free format (or vice versa),
>and whether to pass the text through the C preprocessor, but a lot
>used to.  Often unreliably, and all incompatibly.

No compiler I have worked on has even looked at the file type named in an
INCLUDE statement.  For source files presented to the compiler directly, sure
- and yes, there are conventions for preprocessing or not (capital F or F90 or
lowercase, on operating systems that distinguish).

It certainly is a problem with INCLUDE files that they may be used from both
fixed and free-form source.  It is possible to write a file that is valid in
both source forms, and that's a good idea if you don't know how it will be
used.  Some compilers, Intel's being one, have directives that allow you to
switch source form mid-stream, mainly for the purpose of dealing with
mismatched source forms of INCLIDE files.  I would think poorly of a
programmer who used them for any other purpose.

Unfortunately, users assume that the conventions of compiler/OS A are
universal and get into trouble when compiler/OS B has different conventions.
--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
  http://software.intel.com/en-us/forums/
Intel Fortran Support
  http://support.intel.com/support/performancetools/fortran
My Fortran blog
  http://www.intel.com/software/drfortran



Wed, 20 Jul 2011 02:59:49 GMT  
 include header in f90 file using compaq visual fortran


Quote:

>>I don't know how many current compilers use such this to control
>>whether to switch between fixed and free format (or vice versa),
>>and whether to pass the text through the C preprocessor, but a lot
>>used to.  Often unreliably, and all incompatibly.

>No compiler I have worked on has even looked at the file type named in an
>INCLUDE statement.  For source files presented to the compiler directly, sure
>- and yes, there are conventions for preprocessing or not (capital F or F90 or
>lowercase, on operating systems that distinguish).

You are right that I overstated - I should have said "some" and not
"a lot".  I am pretty certain that I can remember one of the vendors,
but can no longer check and don't wish to damn them on the basis of
my failing memory.

Quote:
>Unfortunately, users assume that the conventions of compiler/OS A are
>universal and get into trouble when compiler/OS B has different conventions.

Sigh, yes :-(  And then some totally bone-headed idjits embed those
assumptions so deeply into the foulest sort of IDE, autoconfiguration
or gnottedmake files that porting the build mechanism to a system
with different conventions can take longer than porting the code ....

Regards,
Nick Maclaren.



Wed, 20 Jul 2011 04:51:05 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Creating - Fortran 77 dll for use in Visual Basic 6.0 (not using Compaq Visual Fortran)

2. Writing to mat (MATLAB) files using Compaq Visual Fortran compiler

3. Question on using Compaq Visual FORTRAN with Microsoft Visual C++ 6.0

4. External Header file xlib.h includes internal header file tkIntXlibDecls.h

5. Building DLLs with Compaq Visual Fortran and Intel Visual Fortran

6. Compaq Visual Fortran help: cannot save file

7. Compaq Visual Fortran 6.6 to read UNIX unformatted file

8. compaq visual fortran error while executing .exe file

9. Mixing Compaq Visual Fortran 6 with Microsoft Visual C++ .NET

10. Compaq Visual Fortran or Intel Fortran Compiler?

11. Compaq visual fortran and Watcom fortran

12. mex file in matlab using compaq fortran compiler

 

 
Powered by phpBB® Forum Software