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
초보자
4,329 조회수

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 응답
jimdempseyatthecove
명예로운 기여자 III
4,306 조회수

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
4,250 조회수

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 포인트
Barbara_P_Intel
4,227 조회수

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
초보자
4,210 조회수

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 포인트
Arjen_Markus
명예로운 기여자 II
4,190 조회수

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
초보자
4,171 조회수

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

0 포인트
Kevin_McGrattan
초보자
3,848 조회수

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 포인트
Kevin_McGrattan
초보자
3,846 조회수

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 포인트
Barbara_P_Intel
3,807 조회수

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

0 포인트
Devorah_H_Intel
중재자
2,422 조회수

This issue is fixed in the 2025.0 ifx release. 

0 포인트
jimdempseyatthecove
명예로운 기여자 III
2,404 조회수

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

 

 

응답