From 35ca3b03c3725d9414fb8ac6aa3cf6f6732d1ed9 Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Mon, 15 Apr 2024 15:18:36 -0600 Subject: [PATCH] Set the git version string of MPAS to a more descriptive value Before, it would always show "N/A" in the log, which is not very helpful. Now, if the git submodule of MPAS is aligned at a tag, it will just show the tag name (e.g., "v8.2.1"). Otherwise, if the git submodule of MPAS is not aligned at a tag, it will show the nearest tag name, the number of commits after that tag and the abbreviated commit hash (e.g., "v8.0.1-54-ged6f8e39e"). --- src/dynamics/mpas/Makefile.in.CESM | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dynamics/mpas/Makefile.in.CESM b/src/dynamics/mpas/Makefile.in.CESM index f4016f0e..1b6cf71c 100644 --- a/src/dynamics/mpas/Makefile.in.CESM +++ b/src/dynamics/mpas/Makefile.in.CESM @@ -4,6 +4,15 @@ ifeq ($(strip $(LIBROOT)),) LIBROOT = .. endif +ifeq ($(strip $(SRCROOT)),) + $(warning `SRCROOT` should not be empty. Defaulting to `..`) + + SRCROOT = .. + MPAS_SRC_ROOT = $(SRCROOT) +else + MPAS_SRC_ROOT = $(SRCROOT)/src/dynamics/mpas/dycore +endif + # # Define and export variables used by MPAS build infrastructure. # @@ -19,7 +28,7 @@ export BUILD_TARGET = N/A export CORE = atmosphere export EXE_NAME = atmosphere_model export GEN_F90 = false -export GIT_VERSION = N/A +export GIT_VERSION = $(shell git -C "$(MPAS_SRC_ROOT)" describe --always --dirty --tags || echo "N/A") export NAMELIST_SUFFIX = atmosphere # Customize variables (e.g., build options) for use with CESM. @@ -57,9 +66,9 @@ all: @echo 'Users are responsible to provide all necessary build options via environment variables or command line arguments.' @echo '' @echo 'Usage hints:' - @echo ' `make libmpas-prepare ESM="CESM" LIBROOT="..."`' - @echo ' `make libmpas-build ESM="CESM" LIBROOT="..."`' - @echo ' `make libmpas-clean ESM="CESM" LIBROOT="..."`' + @echo ' `make libmpas-prepare ESM="CESM" LIBROOT="..." SRCROOT="..."`' + @echo ' `make libmpas-build ESM="CESM" LIBROOT="..." SRCROOT="..."`' + @echo ' `make libmpas-clean ESM="CESM" LIBROOT="..." SRCROOT="..."`' .PHONY: libmpas-prepare libmpas-prepare: libmpas-archiver-script.txt libmpas-no-physics libmpas-prefix-namelist-groups libmpas-preview