For Programmers: Free Programming Magazines  


Home > Archive > Fortran > February 2005 > PGI Preprocessor problems









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PGI Preprocessor problems
Berthold Höllmann

2005-02-07, 4:03 pm


Hello,

I have a project developed using the INTEL ifc compiler. Now I want to
test the code on a platform where I have to use the PGI FORTRAN
compiler. This leads to some problems with my code. Most of my source
code is using preprocessor directives. The problem is, that all
FORTRAN files are stored with .f extension in our version control
system. I found no command line switch to enforce the usage of the
FORTRAN preprocessor using PGI FORTAN. Is there really none or have I
overseen something?

Thanks
Berthold
--
hoel@GL-Group.com __ Address:
G / \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 35 P.O.Box 111606
fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg
Joe Hill

2005-02-07, 9:00 pm

Use the -Mpreprocess option to force the preprocessing of files. Let me know if
you have any problems or other questions. We use both PGI and Intel extensively
at Boeing.

BB
The Boeing Company

On Mon, 07 Feb 2005 13:01:04 +0100, hoel@gl-group.com (Berthold Höllmann) wrote:

>
>Hello,
>
>I have a project developed using the INTEL ifc compiler. Now I want to
>test the code on a platform where I have to use the PGI FORTRAN
>compiler. This leads to some problems with my code. Most of my source
>code is using preprocessor directives. The problem is, that all
>FORTRAN files are stored with .f extension in our version control
>system. I found no command line switch to enforce the usage of the
>FORTRAN preprocessor using PGI FORTAN. Is there really none or have I
>overseen something?
>
>Thanks
>Berthold


Berthold Höllmann

2005-02-11, 8:58 am

Paul Van Delst <paul.vandelst@noaa.gov> writes:

> Berthold Höllmann wrote:
>
> Hello,
>
> For files that need to be preprocessed, by default the PGI compiler
> looks for .F or .F90 files. They get processed and then the resulting
> .f or .f90 files are then compiled.
>
> Output from "man pgf90" :
>
> Suffixes of source file names indicate the type of processing to be
> done:
>
> .f fixed-format Fortran source; compile
> .F fixed-format Fortran source; preprocess, compile
> .f90 free-format Fortran source; preprocess, compile
> .F90 free-format Fortran source; preprocess, compile
> .for fixed-format Fortran source; compile
> .fpp fixed-format Fortran source; preprocess, compile
>


I found out that, but if you have a grown project, where you can't
change file names for various reasons, you have to force
preprocessing. I was unable to find the "-Mpreprocess" switch in the
PGI PDF documentation. I think I was searching for the term
"preprocessing" which brought up only unrelated chapers.

Thanks
Berthold
--
hoel@GL-Group.com __ Address:
G / \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 35 P.O.Box 111606
fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg
Joe Hill

2005-02-11, 8:58 pm

From the PGI FAQ :

pgf77/pgf90 do not handle #include "file" statements properly.

The statements

#include "filename"

include "filename"

are handled differently in pgf77 and pgf90. #include is a preprocessor
statement, while the indented 'include' statement is handled by the front end of
the compiler.

To handle files with #include statements, either rename the file from 'x.f' to
'x.F', or use the switch

-Mpreprocess

in your compile line.

Hope this helps.

BB
The Boeing Company


On Fri, 11 Feb 2005 11:25:51 +0100, hoel@gl-group.com (Berthold Höllmann) wrote:

>Paul Van Delst <paul.vandelst@noaa.gov> writes:
>
>
>I found out that, but if you have a grown project, where you can't
>change file names for various reasons, you have to force
>preprocessing. I was unable to find the "-Mpreprocess" switch in the
>PGI PDF documentation. I think I was searching for the term
>"preprocessing" which brought up only unrelated chapers.
>
>Thanks
>Berthold


Richard Maine

2005-02-12, 3:58 pm

Joe Hill <georgecostanz50@hotmail.com> writes:

> From the PGI FAQ :
>
> pgf77/pgf90 do not handle #include "file" statements properly.

....

I realize that you are just quoting the FAQ here, but I don't
understand the bit about "properly" here. I see nothing improper
about the elided description. Indeed, it sounds pretty typical
of many compilers to me.

One of the forms of include is part of the Fortran language.
The other is a widely used non-Fortran-specific preprocessor.

--
Richard Maine
email: my last name at domain
domain: summertriangle dot net
Berthold Höllmann

2005-02-14, 8:59 am

Joe Hill <georgecostanz50@hotmail.com> writes:

> From the PGI FAQ :
>
> pgf77/pgf90 do not handle #include "file" statements properly.
>
> The statements
>
> #include "filename"
>
> include "filename"
>
> are handled differently in pgf77 and pgf90. #include is a
> preprocessor statement, while the indented 'include' statement is
> handled by the front end of the compiler.


I'm not shure whether it is a bug or a feature of the IFC, but PGI and
IFC do handle "include" statements differently. It seems IFC
interprets them in the preprocessing stage, so that preprocessor
statemets in "include"d files are processed, but PGI handels them in
the compiler front end, and you have to use "#include" if the included
file needs to preprocessd also. Is there an official standard for
preprocessing FORTRAN code?

Regards
Berthold
--
hoel@GL-Group.com __ Address:
G / \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 35 P.O.Box 111606
fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg
Richard Maine

2005-02-14, 8:59 pm

hoel@gl-group.com (Berthold Höllmann) writes:

> Is there an official standard for
> preprocessing FORTRAN code?


The include statement (not #include) is part of the Fortran standard
itself. Yes, that is an "official standard".

There is also CoCo, which is somewhat related, but not directly
in question here.

There is presumably an official standard for cpp (which is what the
#include stuff is). I couldn't off-hand name it (unless it is part
of the C standard), but there probably is one.

But there is *NO* standard, official or defacto,
for how cpp stuff interacts with Fortran. In particular, that means
that there is no standard covering the effects of intermixing
the Fortran include and the cpp #include mechanisms. The most
problematic such interaction is likely to be depending on #include
to work in included files. Since #include is often handled independently
of the Fortran compiler, while the include statement is often
handled in the compiler, it tends to be "too late" to do an #include
that appears in an include file.

Implementations vary in this; it might work in some, but you are asking
for portability "issues" if you count on it.

--
Richard Maine
email: my last name at domain
domain: summertriangle dot net
Greg Lindahl

2005-02-15, 4:02 am

In article <sfjld4g.fsf@pc047299.dhcp.germanlloyd.org>,
Berthold Höllmann <hoel@gl-group.com> wrote:

> Is there an official standard for preprocessing FORTRAN code?


Not that covers mixing the C pre-processor and other pre-processors,
no.

-- greg

Dave Thompson

2005-02-21, 3:59 am

On Mon, 14 Feb 2005 16:31:43 -0800, Richard Maine
<nospam@see.signature> wrote:
<snip>
> There is presumably an official standard for cpp (which is what the
> #include stuff is). I couldn't off-hand name it (unless it is part
> of the C standard), but there probably is one.
>

It is. C90 6.8, C99 6.10, and duplicated in C++98 16. Or rather
standard for the functionality of C or C++ preprocessing, usually
implemented as a separate program cpp but that's not required.

- David.Thompson1 at worldnet.att.net
Tim Prince

2005-02-21, 4:01 pm


"Dave Thompson" <david.thompson1@worldnet.att.net> wrote in message
news:013j11lsf2bnctdkpc51rgb3mg9dvej954@
4ax.com...
> On Mon, 14 Feb 2005 16:31:43 -0800, Richard Maine
> <nospam@see.signature> wrote:
> <snip>
> It is. C90 6.8, C99 6.10, and duplicated in C++98 16. Or rather
> standard for the functionality of C or C++ preprocessing, usually
> implemented as a separate program cpp but that's not required.
>

Yes, but then there is a de facto subset of cpp which is more useful for
Fortran pre-processing. The most common such version, evidently, is gnu
tradcpp
g77 -E file.f
gcc -traditional -E -x c file
(equivalent ways to run tradcpp)
The main difference being that tradcpp is Kernighan & Ritchie style, where
C90 would break Fortran (// is passed through untouched by tradcpp).


Greg Lindahl

2005-02-21, 8:59 pm

In article <GLmSd.3682$Pz7.1921@newssvr13.news.prodigy.com>,
Tim Prince <tprince@nospamcomputer.org> wrote:

>The main difference being that tradcpp is Kernighan & Ritchie style, where
>C90 would break Fortran (// is passed through untouched by tradcpp).


Tradcpp breaks Fortran a little, you're just used to it.

Hint: what happens when you're using fixed form and a substitution
runs off the end of a line?

-- greg

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com