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

Preprocessor directives in ifx

Phy_Soham
Novice
2,662 Views

The following types of preprocessor directives fail in ifx, while it is valid in ifort and gfortran:

 

program test_fpp
    implicit none
#ifdef PRE_PROC_DIR
    write(*, *) "Version : ", PRE_PROC_DIR
#endif
end program test_fpp

 

ifort:

$ ifort -DPRE_PROC_DIR=\""0.1.0 ifx-test"\" -fpp test_fpp.f90 ; ./a.out
 Version : 0.1.0 ifx-test

 

ifx:

$ ifx -DPRE_PROC_DIR=\""0.1.0 ifx-test"\" -fpp test_fpp.f90 ; ./a.out 
/tmp/ifx05354667172WKmlC/ifx1ycjS6.i90: catastrophic error: Internal Compiler Error: Only one file name allowed on command line
compilation aborted for test_fpp.f90 (code 1)

 

11 Replies
jimdempseyatthecove
Honored Contributor III
2,639 Views

Looks like command line parsing issue. Try:

ifx -DPRE_PROC_DIR=ABCDEFG -fpp test_fpp.f90 ; ./a.out

 

to see if it is an enquoted text (with arg delimiter) issue.

 

Jim Dempsey

Barbara_P_Intel
Employee
2,583 Views

Thank you for reporting this.

Here's a workaround: I took out the space, kept the shell escapes and ifx compiles it without error. It runs as expected.

As @jimdempseyatthecove said, it looks like a parsing error. The ICE is reported on the .i90 file, the file that has been preprocessed.

I filed a bug report, CMPLRLLVM-49553.



0 Kudos
Barbara_P_Intel
Employee
2,560 Views

One of the compiler team found another workaround. Lead the macro definition with a letter; keep the space. For example, -DPRE_PROC_DIR="""V0.1.0 ifx-test"""



Phy_Soham
Novice
2,543 Views

Thanks for your response.
Following error occurred when I tried your recommendations:

 

$ ifx -DPRE_PROC_DIR="""V0.1.0 ifx-test""" -fpp test_fpp.f90 ; ./a.out
test_fpp.f90(8): error #5082: Syntax error, found REAL_CONSTANT '.1' when expecting one of: :: ) ( , : * <END-OF-STATEMENT> ; . % (/ + - [ ] /) . ** / 
// ...
    write(*, *) "Version : ", V0.1.0 ifx-test
--------------------------------^
compilation aborted for test_fpp.f90 (code 1)

 

$ ifx -DPRE_PROC_DIR=ABCDEFG -fpp test_fpp.f90 ; ./a.out
test_fpp.f90(8): error #6404: This name does not have a type, and must have an explicit type.   [ABCDEFG]
    write(*, *) "Version : ", ABCDEFG
------------------------------^
compilation aborted for test_fpp.f90 (code 1)
0 Kudos
Arjen_Markus
Honored Contributor I
2,523 Views

The problem is no much the compiler, but the interference of the quoting rules. Try:

ifx -DPRE_PROC_DIR="\"V0.1.0 ifx-test\"" -fpp test_fpp.f90

The double quotes are eliminated by the shell you use, so the preprocessor never sees any. The backslash escapes the ones around the string so that these ARE passed to the preprocessor. I tested this both on Windows and Linux :).

(I noticed one thing: the preprocessor is aware of literal strings, text in quotes is not replaced.)

 

Phy_Soham
Novice
2,504 Views

Thanks, it works, although the definition must start with a letter.

0 Kudos
Kevin_McGrattan
2,181 Views

I have a similar issue as above. I am trying to include compiler directives on a command line that starts with mpiifort (not ifort). There seems to be an issue with the spaces in the character strings.

 

 

mpiifort -c /Qipo /O2 /wrap-margin- -fpp -DGITHASH_PP="\"FDS-6.8.0-1034-gb2f9f39-master\"" -DGITDATE_PP="\"Wed Nov 29 10:25:10 2023 -0500\"" -DBUILDDATE_PP="\"Wed 11/29/2023 11:39 AM\"" -DCOMPVER_PP="\""Intel ifort 2021.11.0"\"" -DWITH_MKL
/I"C:\Program Files (x86)\Intel\oneAPI\mkl\latest"\include ../../Source/func.f90
mpifc.bat for the Intel(R) MPI Library 2021.11 for Windows*
Copyright Intel Corporation.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.11.0 Build 20231010_
000000
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.

ifort: command line warning #10161: unrecognized source type 'Nov'; object file assumed
ifort: command line warning #10161: unrecognized source type '29'; object file assumed
ifort: command line warning #10161: unrecognized source type '10:25:10'; object file assumed
ifort: command line warning #10161: unrecognized source type '2023'; object file assumed
ifort: command line warning #10006: ignoring unknown option '/0500" -DBUILDDATE_PP=\Wed 11/29/2023 11:39 AM"'
../../Source\func.f90(5966): error #5078: Unrecognized token '\' skipped
WRITE(LU,'(A,A)') ' Revision : ',TRIM(\FDS-6.8.0-1034-gb2f9f39-master\)
---------------------------------------------------^

0 Kudos
Kevin_McGrattan
2,179 Views

I should add that my problems are on Windows using the Command Prompt. I run setvars.bat and that works fine. Also, everything works on linux with mpiifort and compiler directives.

0 Kudos
Barbara_P_Intel
Employee
2,140 Views

Can you please ask your question on the HPC Toolkit Forum? They work on IMPI issues.

0 Kudos
Devorah_H_Intel
Moderator
755 Views

This issue is fixed in the 2025.0 ifx release. 

0 Kudos
jimdempseyatthecove
Honored Contributor III
737 Views

Prior to getting the 2025.0 fix. As a work around, mpiifort ... executes mpiifort.bat, which calls mpifc.bat, which then calls ifort.exe (or maybe ifx.exe).

In order to pass arguments with spaces, you may require an additional quote/enquote around those arguments. It looks like you have two, you may need three.

... "\"\"Wed 11...\"\"" ...

 

Jim Dempsey

 

 

Reply