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

Preprocessing Partial Words

Larry_R_
Beginner
3,565 Views

I want to use to the fpp preprocessor to achieve the following, however fpp doesnt seem to support the preprocessing of partial words. Is there a work around?

#ifdef DOUBLE_PRE

#define pre_ D0

#else

#define pre_ E0

#endif

...

myrealvar = 10.0pre_

0 Kudos
1 Solution
FortranFan
Honored Contributor III
3,562 Views

Larry R. wrote:

I want to use to the fpp preprocessor to achieve the following, ..

Larry,

Depending on what all needs you have for the preprecessor, you may wish to consider an alternative based on Intel Fortran compiler directive syntax which I find more flexible:

MODULE MyKinds

   USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : I4 => INT32, SP => REAL32, DP => REAL64, QP => REAL128

   IMPLICIT NONE

   !DEC$ IF DEFINED (SINGLE)
   INTEGER(I4), PARAMETER :: WP = SP
   !DEC$ IF DEFINED (DOUBLE)
   INTEGER(I4), PARAMETER :: WP = DP
   !DEC$ IF DEFINED (QUAD)
   INTEGER(I4), PARAMETER :: WP = QP
   !DEC$ ELSE
   INTEGER(I4), PARAMETER :: WP = SP  !.. Default
   !DEC$ ENDIF

END MODULE MyKinds

PROGRAM p

   USE MyKinds, ONLY : WP

   REAL(WP) :: x

   x = 1E3_wp

   PRINT *, " x = ", x

   STOP

END PROGRAM p

 

View solution in original post

0 Kudos
22 Replies
Steven_L_Intel1
Employee
352 Views

Not sure I understand your question, Jim. If y is private in the module you're using, it's not accessible. If you have a rename, x is the local symbol and y is not defined. You can certainly make x private, but that affects only USErs of the module with the private declaration.

0 Kudos
FortranFan
Honored Contributor III
352 Views
module m3
   ...
   contains
      subroutine sub
         use M2, x => x
         use M2
         use M2, y => x
         ...

My section, "Just because you can, doesn't mean you should." on Fortran just became longer!  

0 Kudos
Reply