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

How to retrieve compilation options the code has benn compiled with at run-time

FlyingHermes
New Contributor I
688 Views

Hi,

Is there a way to retrieve the compilation options a given fortran code has been compiled with.

In particular, I'm  interested in knowing if the code is being run in parallel using the "-coarray" option.

If so, some variables need to have the "codimension" attribute in their declaration.

For the time being, I added these lines in my Make.inc file which is included in my Makefile:


PARALLEL=on
ifeq ($(PARALLEL),on)
      PARALLEL_FLAG= -coarray -coarray-num-images=2 -DPARALLEL
else
      PARALLEL_FLAG=
endif
FFLAGS= ... (OTHER COMPILATION OPTIONS) ... $(PARALLEL_FLAG) -fpp

The source code is being preprocessed (option "-fpp") and the "PARALLEL" keyword is defined (option "-DPARALLEL")

Then, in my source code, I'm using the following preprocessing conditional structure:

[fortran]
#IFDEF PARALLEL
  class(Mesh_Type) ,codimension

  • ,intent(inout)  ::      This
    #ELSE
      class(Mesh_Type)                 ,intent(inout)  ::      This
    #ENDIF
    [/fortran]
  • Is there a better way to do it?

    Thanks

    0 Kudos
    3 Replies
    Steven_L_Intel1
    Employee
    688 Views

    Sorry, no.

    0 Kudos
    jimdempseyatthecove
    Honored Contributor III
    688 Views

    If you are using FPP you could

    #ifdef PARALLEL
    #define _CODIMENSION_   ,codimension


  • #else
    #define _CODIMENSION_
    #endif
  • ...

    class(Mesh_Type) _CODIMENSION_ ,intent(inout)  ::      This

    A lot cleaner than using #if... and/or !DEC$ IF...

    Jim Dempsey

    0 Kudos
    FlyingHermes
    New Contributor I
    688 Views

    Yes, it is indeed much cleaner !!!

    Thanks Jim

    0 Kudos
    Reply