PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Preprocessing a Fortran file with C preprocessor directives

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Toki



Joined: 22 Feb 2006
Posts: 3

PostPosted: Mon Feb 27, 2006 6:26 pm    Post subject: Preprocessing a Fortran file with C preprocessor directives Reply with quote

I'm trying to compile a Fortran source file containing C preprocessor directives. Actually, the lines of preprocessor directives are in a header file and included using #include directive in Fortran file. The original contents of header file is shown below (1. ...).

However, it seems that preprocessing is not working well. When I checked the preprocessed file, the lines corresponding to the header file were apparently reduced as shown below (2. ...).

I'd appreciate any comments and suggestions.


1. Header file containing C preprocessor directives

------------------------------------------------


#ifndef _sprngf_h_

#define SPRNG_DEFAULT 0
#define CRAYLCG 0
#define DRAND48 1
#define FISH1 2
#define FISH2 3
#define FISH3 4
#define FISH4 5
#define FISH5 6
#define LECU1 0
#define LECU2 1
#define LECU3 2
#define LAG1279 0
#define LAG17 1
#define LAG31 2
#define LAG55 3
#define LAG63 4
#define LAG127 5
#define LAG521 6
#define LAG521B 7
#define LAG607 8
#define LAG607B 9
#define LAG1279B 10

#ifdef CHECK_POINTERS
#define CHECK 1
#else
#define CHECK 0
#endif /* ifdef CHECK_POINTERS */

#define MAX_PACKED_LENGTH 24000

#ifdef POINTER_SIZE
#if POINTER_SIZE == 8
#define SPRNG_POINTER integer*8
#else
#define SPRNG_POINTER integer*4
#endif
#else
#define SPRNG_POINTER integer*4
#endif /* ifdef POINTER_SIZE */

#ifdef USE_MPI
#define make_sprng_seed fseed_mpi
#else
#define make_sprng_seed fmake_new_seed
#endif

#endif /* ifdef _sprng_h */

#ifdef USE_MPI
external fseed_mpi
integer fseed_mpi
#else
external fmake_new_seed
integer fmake_new_seed
#endif

#ifndef DEFAULTINT
#define DEFAULTINT
#endif
#ifndef FLOAT_GEN
#define DBLGEN
#endif

#if defined(SIMPLE_SPRNG)
#undef DEFAULTINT

#ifndef _sprngf_h_
#define pack_sprng fpack_rng_simple
#define unpack_sprng funpack_rng_simple
#ifdef USE_MPI
#define isprng fget_rn_int_simmpi
#define init_sprng finit_rng_simmpi
#else
#define isprng fget_rn_int_sim
#define init_sprng finit_rng_sim
#endif /* ifdef USE_MPI */
#define print_sprng fprint_rng_simple

#if defined(FLOAT_GEN) && defined(USE_MPI)
#define sprng fget_rn_flt_simmpi
#endif
#if defined(FLOAT_GEN) && !defined(USE_MPI)
#define sprng fget_rn_flt_sim
#endif
#if defined(DBLGEN) && defined(USE_MPI)
#define sprng fget_rn_dbl_simmpi
#endif
#if defined(DBLGEN) && !defined(USE_MPI)
#define sprng fget_rn_dbl_sim
#endif

#endif /* ifdef _sprng_h */
external isprng
external fget_rn_dbl_sim, fget_rn_flt_sim
external init_sprng, fpack_rng_simple
external funpack_rng_simple, fprint_rng_simple
#ifdef USE_MPI
external fget_rn_flt_simmpi, fget_rn_dbl_simmpi
real*4 fget_rn_flt_simmpi
real*8 fget_rn_dbl_simmpi
#endif
integer isprng,fpack_rng_simple,fprint_rng_simple
SPRNG_POINTER init_sprng, funpack_rng_simple
real*4 fget_rn_flt_sim
real*8 fget_rn_dbl_sim
#endif

#if defined(CHECK_POINTERS)
#undef DEFAULTINT
external fget_rn_int_ptr, fget_rn_flt_ptr, fget_rn_dbl_ptr
external fspawn_rng_ptr, ffree_rng_ptr, finit_rng_ptr
external fpack_rng_ptr, funpack_rng_ptr, fprint_rng_ptr

integer fget_rn_int_ptr, ffree_rng_ptr, fpack_rng_ptr
SPRNG_POINTER finit_rng_ptr, funpack_rng_ptr
integer fspawn_rng_ptr, fprint_rng_ptr
real*4 fget_rn_flt_ptr
real*8 fget_rn_dbl_ptr

#ifndef _sprngf_h_
#define isprng fget_rn_int_ptr
#define free_sprng ffree_rng_ptr
#define spawn_sprng(A,B,C) fspawn_rng_ptr(A,B,C,CHECK)
#define pack_sprng fpack_rng_ptr
#define unpack_sprng funpack_rng_ptr
#define init_sprng finit_rng_ptr
#define print_sprng fprint_rng_ptr
#ifdef FLOAT_GEN
#define sprng fget_rn_flt_ptr
#else
#define sprng fget_rn_dbl_ptr
#endif
#endif
#endif

#if defined(DEFAULTINT)
external fget_rn_int, fget_rn_flt, fget_rn_dbl
external fspawn_rng, ffree_rng, finit_rng
external fpack_rng, funpack_rng, fprint_rng

integer fget_rn_int, ffree_rng, fpack_rng
SPRNG_POINTER finit_rng, funpack_rng
integer fspawn_rng, fprint_rng
real*4 fget_rn_flt
real*8 fget_rn_dbl

#ifndef _sprngf_h_
#define isprng fget_rn_int
#define free_sprng ffree_rng
#define spawn_sprng(A,B,C) fspawn_rng(A,B,C,CHECK)
#define pack_sprng fpack_rng
#define unpack_sprng funpack_rng
#define init_sprng finit_rng
#define print_sprng fprint_rng
#ifdef FLOAT_GEN
#define sprng fget_rn_flt
#else
#define sprng fget_rn_dbl
#endif
#endif

#endif



#ifndef _sprngf_h_
#define _sprngf_h_
#endif
------------------------------------------------


2. After included and preprocessed

------------------------------------------------









external fmake_new_seed
integer fmake_new_seed




external fget_rn_int, fget_rn_flt, fget_rn_dbl
external fspawn_rng, ffree_rng, finit_rng
external fpack_rng, funpack_rng, fprint_rng

integer fget_rn_int, ffree_rng, fpack_rng
integer*4 finit_rng, funpack_rng
integer fspawn_rng, fprint_rng
real*4 fget_rn_flt
real*8 fget_rn_dbl





------------------------------------------------
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6134
Location: The Portland Group Inc.

PostPosted: Tue Feb 28, 2006 9:22 am    Post subject: Reply with quote

Hi Toki,

Without adding any command line define flags, this looks correct to me. I tested it with pgf90, pgcpp, pgcc, and cpp and each produced the same output.

What define flags are you using? Which preprocessor are you using? (ex pgf90 -E, pgf90 with "F" file extension, cpp, pgcc -Mpreprocess, etc). What output are you expecting?

- Mat
Back to top
View user's profile
Toki



Joined: 22 Feb 2006
Posts: 3

PostPosted: Mon Mar 06, 2006 4:55 am    Post subject: Reply with quote

Hello Mat:

Thank you for your message.

I also found that the file was compiled correctly.

I'm sorry for bothering you.

Thank you,

Toki
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group