Skip to content

Commit d7ba13a

Browse files
Default to not including git hash in build for non ACCESS-OM2 models (#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 <[email protected]>
1 parent 4f27455 commit d7ba13a

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

exp/MOM_compile.csh

+33-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ set debug = 0
1010
set repro = 0
1111
set use_netcdf4 = 0
1212
set environ = 1
13+
set cosima_version = unset
1314

1415

15-
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 -- $*`)
16+
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 -- $*`)
1617
if ($status != 0) then
1718
# Die if there are incorrect options
1819
set help = 1
@@ -34,6 +35,8 @@ while ("$argv[1]" != "--")
3435
set use_netcdf4 = 1; breaksw
3536
case --no_environ:
3637
set environ = 0; breaksw
38+
case --no_version:
39+
set cosima_version = 0; breaksw
3740
case --help:
3841
set help = 1; breaksw
3942
case -h:
@@ -63,7 +66,9 @@ if ( $help ) then
6366
echo
6467
echo "--use_netcdf4 use NetCDF4, the default is NetCDF4. Warning: many of the standard experiments don't work with NetCDF4."
6568
echo
66-
echo "--no_environ do not source platform specific environment. Allows customising/overriding default environment"
69+
echo "--no_environ do not source platform specific environment. Allows customising/overriding default environment"
70+
echo
71+
echo "--no_version disable COSIMA specific versioning for ACCESS-OM* builds"
6772
echo
6873
exit 1
6974
endif
@@ -87,6 +92,15 @@ if($static) then
8792
set cppDefs = "$cppDefs -DMOM_STATIC_ARRAYS -DNI_=360 -DNJ_=200 -DNK_=50 -DNI_LOCAL_=60 -DNJ_LOCAL_=50"
8893
endif
8994

95+
if( $cosima_version == "unset" ) then
96+
if( $type =~ ACCESS-OM* ) then
97+
# default to cosima versioning for ACCESS-OM if not set explicitly as no_version argument
98+
set cosima_version = 1
99+
else
100+
set cosima_version = 0
101+
endif
102+
endif
103+
90104
if ( $type == EBM ) then
91105
set cppDefs = ( "-Duse_netCDF -Duse_netCDF3 -Duse_libMPI -DLAND_BND_TRACERS -DOVERLOAD_C8 -DOVERLOAD_C4 -DOVERLOAD_R4" )
92106
else if( $type == ACCESS-OM ) then
@@ -133,13 +147,21 @@ endif
133147
set mkmf_lib = "$mkmf -f -m Makefile -a $code_dir -t $mkmfTemplate"
134148
set lib_include_dirs = "$root/include $code_dir/shared/include $code_dir/shared/mpp/include"
135149

136-
# Build version
137-
source ./version_compile.csh
150+
if ( $cosima_version ) then
151+
echo "Including COSIMA version in build"
152+
# Build version. This prevents builds outside a git repo, so only enabled for COSIMA builds
153+
source ./version_compile.csh
154+
set cppDefs = "$cppDefs -DCOSIMA_VERSION"
155+
endif
138156

139157
# Build FMS.
140158
source ./FMS_compile.csh
141159

142-
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/"
160+
set includes = "-I$code_dir/shared/include -I$executable:h:h/lib_FMS -I$executable:h:h/lib_ocean"
161+
162+
if ( $cosima_version ) then
163+
set includes = "$includes -I$executable:h:h/lib_version/"
164+
endif
143165

144166
# Build the core ocean.
145167
cd $root/exp
@@ -232,8 +254,12 @@ else
232254
exit 1
233255
endif
234256

235-
# Always include FMS and version
236-
set libs = "$libs $executable:h:h/lib_version/lib_version.a $executable:h:h/lib_FMS/lib_FMS.a"
257+
# Always include FMS
258+
set libs = "$libs $executable:h:h/lib_FMS/lib_FMS.a"
259+
260+
if ( $cosima_version ) then
261+
set libs = "$libs $executable:h:h/lib_version/lib_version.a"
262+
endif
237263

238264
$mkmf_exec -o "$includes" -c "$cppDefs" -l "$libs" $srcList
239265
make

src/mom5/ocean_core/ocean_model.F90

+5-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ module ocean_model_mod
334334
use ocean_drifters_mod, only: ocean_drifters_init, update_ocean_drifters, ocean_drifters_end
335335
use wave_types_mod, only: ocean_wave_type
336336
use ocean_wave_mod, only: ocean_wave_init, ocean_wave_end, ocean_wave_model
337-
use version_mod, only: MOM_COMMIT_HASH
337+
#if defined(COSIMA_VERSION)
338+
use version_mod, only: MOM_COMMIT_HASH
339+
#endif
338340

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

701+
#ifdef COSIMA_VERSION
699702
if (mpp_pe() == mpp_root_pe()) then
700703
write(stdoutunit,*) MOM_COMMIT_HASH
701704
endif
705+
#endif
702706

703707
if (module_is_initialized) then
704708
call mpp_error(FATAL, &

0 commit comments

Comments
 (0)