Skip to content

Conversation

@jim-p-w
Copy link
Contributor

@jim-p-w jim-p-w commented Jan 7, 2026

This PR addresses a problem with the intel fortran preprocessor (fpp).

In particular, the default preprocessor ordering results in a failure to expand a macro properly when it is used as an argument to another macro.
Given the following definitions:

#define COMMA ,
#define STREAM_DEBUG_WRITE(M) call mpas_log_write(M)

followed by the following invocation:

STREAM_DEBUG_WRITE(' -- Setting record to: $i' COMMA intArgs=(/stream % nRecords/))

results in the COMMA and everything after it being eliminated from the final expansion:

call mpas_log_write(' -- Setting record to: $i')

There is a switch you can provide to fpp (via the compiler) which changes the order of nexted macro expansion and gives the desire result.

I tested this by running test_model and verifying correct printouts, using both an intel make build and an intl cmake build.

This fixes a problem when using a macro in the invocation of another macro.
This is only for the intel target when running gnu make.
This fixes a problem when using a macro in the invocation of another macro.
This change is only when running cmake with an intel environment loaded.
@jim-p-w jim-p-w marked this pull request as ready for review January 7, 2026 22:11
@pb475
Copy link

pb475 commented Jan 9, 2026

Can confirm, experienced the same issue with intel oneapi compiler.

My hack of a fix was to edit the lined using the COMMA expansion, but yours is a much better fix.

I grabbed your fix and re-compiled and ran a quick test run on my machine too. All looks good.

@mgduda mgduda self-requested a review January 9, 2026 18:26
@mgduda mgduda added bug fix Build System Changes related to the build system, either `Make` or `CMake`. labels Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Build System Changes related to the build system, either `Make` or `CMake`.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants