Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Makefile
!developer_tests/time_manager/Makefile
!developer_tests/mpi_utilities/tests/Makefile
build_templates/mkmf.template
build_templates/version_mod.f90
dart_log.*
mkmf.template
input.nml.*default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ assimilation_code/modules/utilities/parse_args_mod.f90
assimilation_code/modules/utilities/time_manager_mod.f90
assimilation_code/modules/utilities/types_mod.f90
assimilation_code/modules/utilities/utilities_mod.f90
build_templates/version_mod.F90
build_templates/version_mod.f90
assimilation_code/programs/preprocess/preprocess.f90
5 changes: 2 additions & 3 deletions build_templates/buildconvfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ mpisrc="null_mpi"
m=""
LIBRARIES=""
EXTRA=""
version_def=""

source "$DART"/build_templates/buildpreprocess.sh
dartversion
Expand Down Expand Up @@ -117,7 +116,7 @@ local misc="$DART/models/utilities/ \
$DART/assimilation_code/modules/observations/obs_sequence_mod.f90 \
$DART/assimilation_code/modules/observations/forward_operator_mod.f90 \
$DART/observations/obs_converters/utilities/obs_utilities_mod.f90 \
$DART/build_templates/version_mod.F90"
$DART/build_templates/version_mod.f90"
local obserrsrc=$DART/observations/obs_converters/obs_error/$OBS_ERROR"_obs_err_mod.f90"

# remove null/mpi from list
Expand Down Expand Up @@ -192,7 +191,7 @@ else
mkmf_libs=""
fi

$DART/build_templates/mkmf -c $version_def -a $DART -x $m $mkmf_libs -p $(basename $1) \
$DART/build_templates/mkmf -a $DART -x $m $mkmf_libs -p $(basename $1) \
$EXTRA \
$convsrc \
$program \
Expand Down
9 changes: 4 additions & 5 deletions build_templates/buildfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ EXTRA=""
EXCLUDE=""
TEST=""
dev_test=0
version_def=""

declare -a programs
declare -a serial_programs
Expand Down Expand Up @@ -156,7 +155,7 @@ local misc="$DART/models/utilities/ \
$DART/assimilation_code/modules/observations/obs_kind_mod.f90 \
$DART/assimilation_code/modules/observations/obs_sequence_mod.f90 \
$DART/assimilation_code/modules/observations/forward_operator_mod.f90 \
$DART/build_templates/version_mod.F90"
$DART/build_templates/version_mod.f90"

# The quantity_mod.f90 files are in assimilation_code/modules/observations
# so adding individual files from assimilation_code/modules/observations
Expand Down Expand Up @@ -242,7 +241,7 @@ else
devlibs=$DART/developer_tests/contrib/fortran-testanything
fi

$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $1 \
$DART/build_templates/mkmf -x -a $DART $m -p $1 \
$dartsrc \
$EXTRA \
$devlibs \
Expand All @@ -255,7 +254,7 @@ fi
#-------------------------
function buildlib() {
findsrc
$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $1 \
$DART/build_templates/mkmf -x -a $DART $m -p $1 \
$dartsrc \
$EXTRA
}
Expand All @@ -266,7 +265,7 @@ $DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $1 \
# program name
#-------------------------
function modelbuild() {
$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $(basename $1) $DART/models/$MODEL/$1.f90 \
$DART/build_templates/mkmf -x -a $DART $m -p $(basename $1) $DART/models/$MODEL/$1.f90 \
$EXTRA \
$dartsrc
}
Expand Down
71 changes: 62 additions & 9 deletions build_templates/buildpreprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,80 @@
# http://www.image.ucar.edu/DAReS/DART/DART_download

#-------------------------
# Build and run preprocess
# Arguements:
# Generate build_templates/version_mod.f90 with the version from git describe.
# Arguments:
# none
# Globals:
# DART - root of DART
#-------------------------
function dartversion() {

local git_version
local git_version out tmp

git_version=""
if command -v git >/dev/null 2>&1 && [ -e "$DART/.git" ]; then
git_version=$(cd "$DART" && git describe --tags --dirty --always 2>/dev/null || echo "version_unknown")
else
git_version="version_unknown"
git_version=$(cd "$DART" && git describe --tags --dirty --always 2>/dev/null) || git_version=""
fi

# preprocessor definition for DART version
version_def="-DDART_VERSION=\"'$git_version'\""
# The version becomes a Fortran character literal.
# Restrict it to characters that cannot break out of the quotes and cap length to 64 characters
git_version=$(printf '%s' "$git_version" | LC_ALL=C tr -c 'A-Za-z0-9._+-' '_' | cut -c1-64)
git_version="${git_version:-unknown}"

out="$DART/build_templates/version_mod.f90"
tmp="$out.$$"

cat > "$tmp" << EOF
! DART software - Copyright UCAR. This open source software is provided
! by UCAR, "as is", without charge, subject to all terms of use at
! http://www.image.ucar.edu/DAReS/DART/DART_download

!> Module to provide version information for DART programs
!>
!> Generated at build time by dartversion() in
!> \$DART/build_templates/buildpreprocess.sh - do not edit, do not commit.

module version_mod

implicit none
private

character(len=*), parameter :: dart_version_string = &
'$git_version'

public :: get_dart_version

contains

! Return DART version in string
function get_dart_version() result(version)

character(len=len(dart_version_string)) :: version

version = dart_version_string

end function get_dart_version

end module version_mod
EOF

# leave the file alone if the version has not changed, so make does not
# rebuild everything that uses version_mod on every build
if cmp -s "$tmp" "$out" ; then
\rm -f -- "$tmp"
else
mv -f -- "$tmp" "$out"
fi

}

#-------------------------
# Build and run preprocess
# Arguements:
# none
# Globals:
# DART - root of DART
#-------------------------
function buildpreprocess() {

local pp_dir=$DART/assimilation_code/programs/preprocess
Expand All @@ -45,7 +98,7 @@ fi

# build preprocess, link, run
cd $pp_dir
$DART/build_templates/mkmf -c $version_def -x -p $pp_dir/preprocess \
$DART/build_templates/mkmf -x -p $pp_dir/preprocess \
-a $DART $pp_dir/path_names_preprocess
cd -
ln -s $pp_dir/preprocess .
Expand Down
38 changes: 0 additions & 38 deletions build_templates/version_mod.F90

This file was deleted.

4 changes: 3 additions & 1 deletion developer_tests/build_everything/run_all_quickbuilds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ esac

cp build_templates/$mkmf_template build_templates/mkmf.template

# Build preprocess once
# Build preprocess once, and get dart_version
pp_dir=$DART/assimilation_code/programs/preprocess
source "$DART"/build_templates/buildpreprocess.sh
dartversion
cd $pp_dir
$DART/build_templates/mkmf -x -p $pp_dir/preprocess \
-a $DART $pp_dir/path_names_preprocess
Expand Down
Loading