Skip to content
Merged
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
18 changes: 10 additions & 8 deletions assimilation_code/modules/utilities/utilities_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module utilities_mod
!> another util module?

use types_mod, only : r4, r8, digits12, i2, i4, i8, PI, MISSING_R8, MISSING_I
use version_mod, only : get_dart_version

implicit none
private
Expand Down Expand Up @@ -225,9 +226,10 @@ subroutine initialize_utilities(progname, alternatename, output_flag, standalone
if (do_output_flag) then
if ( present(progname) ) then
call log_time (logfileunit, label='Starting ', &
string1='Program '//trim(progname))
string1='Program '//trim(progname)//' '//get_dart_version())
else
call log_time (logfileunit, label='Starting ')
call log_time (logfileunit, label='Starting ', &
string1=' '//get_dart_version())
endif
endif

Expand Down Expand Up @@ -259,9 +261,9 @@ subroutine initialize_utilities(progname, alternatename, output_flag, standalone
if (do_output_flag) then
if (do_nml_file() .and. (nmlfileunit /= logfileunit)) then
if ( present(progname) ) then
write(nmlfileunit, *) '!Starting Program '//trim(progname)
write(nmlfileunit, *) '!Starting Program '//trim(progname)//' '//get_dart_version()
else
write(nmlfileunit, *) '!Starting Program '
write(nmlfileunit, *) '!Starting Program '//' '//get_dart_version()
endif
endif
if (do_nml_file()) write(nmlfileunit, nml=utilities_nml)
Expand Down Expand Up @@ -290,16 +292,16 @@ subroutine finalize_utilities(progname)
if (do_output_flag) then
if ( present(progname) ) then
call log_time (logfileunit, label='Finished ', &
string1='Program '//trim(progname))
string1='Program '//trim(progname)//' '//get_dart_version())
else
call log_time (logfileunit, label='Finished ')
call log_time (logfileunit, label='Finished ', string1=' '//get_dart_version())
endif

if (do_nml_file() .and. (nmlfileunit /= logfileunit)) then
if ( present(progname) ) then
write(nmlfileunit, *) '!Finished Program '//trim(progname)
write(nmlfileunit, *) '!Finished Program '//trim(progname)//' '//get_dart_version()
else
write(nmlfileunit, *) '!Finished Program '
write(nmlfileunit, *) '!Finished Program '//' '//get_dart_version()
endif
endif
endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +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
assimilation_code/programs/preprocess/preprocess.f90
8 changes: 6 additions & 2 deletions build_templates/buildconvfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
#-------------------------
set -e
declare -a programs
source "$DART"/build_templates/buildpreprocess.sh

# Defaults
mpisrc="null_mpi"
m=""
LIBRARIES=""
EXTRA=""
version_def=""

source "$DART"/build_templates/buildpreprocess.sh
dartversion

#-------------------------
# print usage and exit
Expand Down Expand Up @@ -113,7 +116,8 @@ 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/observations/obs_converters/utilities/obs_utilities_mod.f90"
$DART/observations/obs_converters/utilities/obs_utilities_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
12 changes: 7 additions & 5 deletions build_templates/buildfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ EXTRA=""
EXCLUDE=""
TEST=""
dev_test=0
version_def=""

declare -a programs
declare -a serial_programs
declare -a model_programs
declare -a model_serial_programs

source "$DART"/build_templates/buildpreprocess.sh

dartversion
#-------------------------
# print usage and exit
#-------------------------
Expand Down Expand Up @@ -154,7 +155,8 @@ local misc="$DART/models/utilities/ \
$DART//observations/forward_operators/obs_def_utilities_mod.f90 \
$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/assimilation_code/modules/observations/forward_operator_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 @@ -240,7 +242,7 @@ else
devlibs=$DART/developer_tests/contrib/fortran-testanything
fi

$DART/build_templates/mkmf -x -a $DART $m -p $1 \
$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $1 \
$dartsrc \
$EXTRA \
$devlibs \
Expand All @@ -253,7 +255,7 @@ fi
#-------------------------
function buildlib() {
findsrc
$DART/build_templates/mkmf -x -a $DART $m -p $1 \
$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $1 \
$dartsrc \
$EXTRA
}
Expand All @@ -264,7 +266,7 @@ $DART/build_templates/mkmf -x -a $DART $m -p $1 \
# program name
#-------------------------
function modelbuild() {
$DART/build_templates/mkmf -x -a $DART $m -p $(basename $1) $DART/models/$MODEL/$1.f90 \
$DART/build_templates/mkmf -c $version_def -x -a $DART $m -p $(basename $1) $DART/models/$MODEL/$1.f90 \
$EXTRA \
$dartsrc
}
Expand Down
19 changes: 17 additions & 2 deletions build_templates/buildpreprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,25 @@
# Globals:
# DART - root of DART
#-------------------------
function dartversion() {

local git_version

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

# preprocessor definition for DART version
version_def="-DDART_VERSION=\"'$git_version'\""

}

function buildpreprocess() {

local pp_dir=$DART/assimilation_code/programs/preprocess

dartversion
# run preprocess if it is in the current directory
if [ -f preprocess ]; then
./preprocess
Expand All @@ -30,7 +45,7 @@ fi

# build preprocess, link, run
cd $pp_dir
$DART/build_templates/mkmf -x -p $pp_dir/preprocess \
$DART/build_templates/mkmf -c $version_def -x -p $pp_dir/preprocess \
-a $DART $pp_dir/path_names_preprocess
cd -
ln -s $pp_dir/preprocess .
Expand Down
2 changes: 1 addition & 1 deletion build_templates/mkmf
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ if ( $opt_c ) {
$compile_cmd{'.F90'} = q/$(FC) $(CPPDEFS_XLF) $(FFLAGS) -c/;
}
}
&print_formatted_list("CPPDEFS = $opt_c") if $opt_c;
&print_formatted_list("\nCPPDEFS += $opt_c") if $opt_c;
}
print MAKEFILE "\nOTHERFLAGS = $opt_o" if $opt_o;
print MAKEFILE "\n.DEFAULT:\n\t-touch \$@\n";
Expand Down
38 changes: 38 additions & 0 deletions build_templates/version_mod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
! 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
!>
!> This module stores the version information that is captured at build time
!> from git describe and provides a function to access it.

module version_mod

implicit none
private

! Assign a preprocessor variable for the version, which we'll get using git
#ifndef DART_VERSION
#define DART_VERSION 'unknown'
#endif

character(len=*), parameter :: dart_version_string = DART_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