Skip to content

Commit

Permalink
Default to not including git hash in build for non ACCESS-OM2 models (#…
Browse files Browse the repository at this point in the history
…384)

* Removed adding a version hash to build to every build except ACCESS-OM. Added option to also remove from ACCESS-OM
* Add COSIMA_VERSION pre-processor flag for including version hash in build
* Fenced use of MOM_COMMIT_HASH with ifdef conditional
---------
Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com>
  • Loading branch information
aidanheerdegen authored Aug 8, 2023
1 parent 4f27455 commit d7ba13a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
40 changes: 33 additions & 7 deletions exp/MOM_compile.csh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ set debug = 0
set repro = 0
set use_netcdf4 = 0
set environ = 1
set cosima_version = unset


set argv = (`getopt -u -o h -l type: -l platform: -l help -l unit_testing -l debug -l repro -l use_netcdf4 -l no_environ -- $*`)
set argv = (`getopt -u -o h -l type: -l platform: -l help -l unit_testing -l debug -l repro -l use_netcdf4 -l no_environ -l no_version -- $*`)
if ($status != 0) then
# Die if there are incorrect options
set help = 1
Expand All @@ -34,6 +35,8 @@ while ("$argv[1]" != "--")
set use_netcdf4 = 1; breaksw
case --no_environ:
set environ = 0; breaksw
case --no_version:
set cosima_version = 0; breaksw
case --help:
set help = 1; breaksw
case -h:
Expand Down Expand Up @@ -63,7 +66,9 @@ if ( $help ) then
echo
echo "--use_netcdf4 use NetCDF4, the default is NetCDF4. Warning: many of the standard experiments don't work with NetCDF4."
echo
echo "--no_environ do not source platform specific environment. Allows customising/overriding default environment"
echo "--no_environ do not source platform specific environment. Allows customising/overriding default environment"
echo
echo "--no_version disable COSIMA specific versioning for ACCESS-OM* builds"
echo
exit 1
endif
Expand All @@ -87,6 +92,15 @@ if($static) then
set cppDefs = "$cppDefs -DMOM_STATIC_ARRAYS -DNI_=360 -DNJ_=200 -DNK_=50 -DNI_LOCAL_=60 -DNJ_LOCAL_=50"
endif

if( $cosima_version == "unset" ) then
if( $type =~ ACCESS-OM* ) then
# default to cosima versioning for ACCESS-OM if not set explicitly as no_version argument
set cosima_version = 1
else
set cosima_version = 0
endif
endif

if ( $type == EBM ) then
set cppDefs = ( "-Duse_netCDF -Duse_netCDF3 -Duse_libMPI -DLAND_BND_TRACERS -DOVERLOAD_C8 -DOVERLOAD_C4 -DOVERLOAD_R4" )
else if( $type == ACCESS-OM ) then
Expand Down Expand Up @@ -133,13 +147,21 @@ endif
set mkmf_lib = "$mkmf -f -m Makefile -a $code_dir -t $mkmfTemplate"
set lib_include_dirs = "$root/include $code_dir/shared/include $code_dir/shared/mpp/include"

# Build version
source ./version_compile.csh
if ( $cosima_version ) then
echo "Including COSIMA version in build"
# Build version. This prevents builds outside a git repo, so only enabled for COSIMA builds
source ./version_compile.csh
set cppDefs = "$cppDefs -DCOSIMA_VERSION"
endif

# Build FMS.
source ./FMS_compile.csh

set includes = "-I$code_dir/shared/include -I$executable:h:h/lib_FMS -I$executable:h:h/lib_ocean -I$executable:h:h/lib_version/"
set includes = "-I$code_dir/shared/include -I$executable:h:h/lib_FMS -I$executable:h:h/lib_ocean"

if ( $cosima_version ) then
set includes = "$includes -I$executable:h:h/lib_version/"
endif

# Build the core ocean.
cd $root/exp
Expand Down Expand Up @@ -232,8 +254,12 @@ else
exit 1
endif

# Always include FMS and version
set libs = "$libs $executable:h:h/lib_version/lib_version.a $executable:h:h/lib_FMS/lib_FMS.a"
# Always include FMS
set libs = "$libs $executable:h:h/lib_FMS/lib_FMS.a"

if ( $cosima_version ) then
set libs = "$libs $executable:h:h/lib_version/lib_version.a"
endif

$mkmf_exec -o "$includes" -c "$cppDefs" -l "$libs" $srcList
make
Expand Down
6 changes: 5 additions & 1 deletion src/mom5/ocean_core/ocean_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ module ocean_model_mod
use ocean_drifters_mod, only: ocean_drifters_init, update_ocean_drifters, ocean_drifters_end
use wave_types_mod, only: ocean_wave_type
use ocean_wave_mod, only: ocean_wave_init, ocean_wave_end, ocean_wave_model
use version_mod, only: MOM_COMMIT_HASH
#if defined(COSIMA_VERSION)
use version_mod, only: MOM_COMMIT_HASH
#endif

#if defined(ACCESS_CM) || defined(ACCESS_OM)
use auscom_ice_mod, only: auscom_ice_init
Expand Down Expand Up @@ -696,9 +698,11 @@ subroutine ocean_model_init(Ocean, Ocean_state, Time_init, Time_in, &
stdoutunit=stdout()
stdlogunit=stdlog()

#ifdef COSIMA_VERSION
if (mpp_pe() == mpp_root_pe()) then
write(stdoutunit,*) MOM_COMMIT_HASH
endif
#endif

if (module_is_initialized) then
call mpp_error(FATAL, &
Expand Down

0 comments on commit d7ba13a

Please sign in to comment.