Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

8.2.0: parse for .inc not working correctly (macos, osx)

microted

New member
In 8.2.0 on macos (Ventura, intel-based, gfortran/gcc-11), the parse tool is failing to correctly generate two files:
core_variables.inc (no definitions of executableName, git_version, and build_target)
domain_variables.inc (empty)

It appears to be an issue with the order of items in CPPFLAGS, where parse stops looking for the defined macros (MPAS_NAMELIST_SUFFIX, DMPAS_EXE_NAME, etc.) as soon as it encounters a define without an '='. For example, I can run the following manually, and then those .inc files are correct:

MPAS-Model/src/tools/registry/parse ../Registry_processed.xml -DMPAS_NAMELIST_SUFFIX=init_atmosphere -DMPAS_EXE_NAME=init_atmosphere_model -DMPAS_GIT_VERSION=v8.1.0-148-g82681e986-dirty -DMPAS_BUILD_TARGET=gfortran

but the following does not work (added -D_MPI):

MPAS-Model/src/tools/registry/parse ../Registry_processed.xml -D_MPI -DMPAS_NAMELIST_SUFFIX=init_atmosphere -DMPAS_EXE_NAME=init_atmosphere_model -DMPAS_GIT_VERSION=v8.1.0-148-g82681e986-dirty -DMPAS_BUILD_TARGET=gfortran

I don't know if this is somehow just a Mac issue or not, as I haven't tested on a linux system yet. A work-around is to change the particular lines that add these options to CPPFLAGS to prepend instead of append. For example,

override CPPFLAGS += -DMPAS_EXE_NAME=$(EXE_NAME)
becomes
override CPPFLAGS := -DMPAS_EXE_NAME=$(EXE_NAME) $(CPPFLAGS)

(Apparently the ":=" is needed instead of just "=" to avoid recursion. I'm not much of makefile programmer...)

- Ted Mansell
 
Although I haven't tried with the full MPAS-Model code, through a stand-alone test program I can reproduce what looks like an issue with the parse_macros routine that is used to parse macro definitions. I'll take a closer look, and if a fix to the parsing code is in order, I'll put together a PR to MPAS-Dev/MPAS-Model. Thanks for bringing this to our attention!
 
I think we have a fix for this issue in MPAS-Dev/MPAS-Model PR #1229.

@microted If you have a chance, would you be willing to merge the fix into your branch to see if this resolves the issues on macOS?
 
Top