From 4fb15b6d090badade14a2593219fafdbf4e7c081 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Mon, 15 Jul 2024 14:19:51 -0400 Subject: [PATCH 1/8] feat: build dart as a static library developer test builds dart as a static library library is libdart.a quickbuild.sh clean removes libdart.a rather than *.a since we do not want to remove any other static libaries some has built --- .gitignore | 2 ++ build_templates/buildfunctions.sh | 11 ++++++ developer_tests/library/static/work/input.nml | 18 ++++++++++ .../library/static/work/quickbuild.sh | 36 +++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 developer_tests/library/static/work/input.nml create mode 100755 developer_tests/library/static/work/quickbuild.sh diff --git a/.gitignore b/.gitignore index 5d1f27c778..7d4937541c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.a +*.so *.mod *.o *.swp diff --git a/build_templates/buildfunctions.sh b/build_templates/buildfunctions.sh index e83475c7e5..fb5ba04304 100644 --- a/build_templates/buildfunctions.sh +++ b/build_templates/buildfunctions.sh @@ -84,6 +84,7 @@ for p in ${all_programs[@]}; do done \rm -f -- preprocess +\rm -f -- libdart.a cleanpreprocess } @@ -253,6 +254,16 @@ fi $program } +#------------------------- +# Build a library +# +#------------------------- +function buildlib() { +findsrc +$DART/build_templates/mkmf -x -a $DART $m -p $1 \ + $dartsrc \ + $EXTRA +} #------------------------- # Build a model specific program # looks in $DART/models/$MODEL/src/programs for {main}.f90 diff --git a/developer_tests/library/static/work/input.nml b/developer_tests/library/static/work/input.nml new file mode 100644 index 0000000000..a088a84317 --- /dev/null +++ b/developer_tests/library/static/work/input.nml @@ -0,0 +1,18 @@ +&preprocess_nml + overwrite_output = .true. + input_obs_def_mod_file = '../../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../../observations/forward_operators/obs_def_mod.f90' + input_obs_qty_mod_file = '../../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../../assimilation_code/modules/observations/obs_kind_mod.f90' + obs_type_files = '../../../../observations/forward_operators/obs_def_1d_state_mod.f90' + quantity_files = '../../../../assimilation_code/modules/observations/oned_quantities_mod.f90' + / + +&utilities_nml + termlevel = 1, + module_details = .false., + logfilename = 'dart_log.out', + nmlfilename = 'dart_log.nml', + write_nml = 'file', + print_debug = .false., + / diff --git a/developer_tests/library/static/work/quickbuild.sh b/developer_tests/library/static/work/quickbuild.sh new file mode 100755 index 0000000000..25b868ac39 --- /dev/null +++ b/developer_tests/library/static/work/quickbuild.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# 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 + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL=lorenz_96 +LOCATION=oned + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- libdart.a *.o *.mod Makefile .cppdefs + +# build any NetCDF files from .cdl files +cdl_to_netcdf + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build static library +buildlib libdart.a + +# clean up +\rm -f -- *.o + +} + +main "$@" From 527f3262b5bca1b596f8847d5efa792e69e27d5e Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Mon, 15 Jul 2024 15:12:45 -0400 Subject: [PATCH 2/8] feat: build dart as a shared library assumes library is called libdart.so --- build_templates/buildfunctions.sh | 1 + build_templates/mkmf | 8 +- developer_tests/library/shared/work/input.nml | 18 +++ .../shared/work/mkmf.template.gfortran | 147 ++++++++++++++++++ .../library/shared/work/quickbuild.sh | 36 +++++ 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 developer_tests/library/shared/work/input.nml create mode 100644 developer_tests/library/shared/work/mkmf.template.gfortran create mode 100755 developer_tests/library/shared/work/quickbuild.sh diff --git a/build_templates/buildfunctions.sh b/build_templates/buildfunctions.sh index fb5ba04304..f8188a8cad 100644 --- a/build_templates/buildfunctions.sh +++ b/build_templates/buildfunctions.sh @@ -85,6 +85,7 @@ done \rm -f -- preprocess \rm -f -- libdart.a +\rm -f -- libdart.so cleanpreprocess } diff --git a/build_templates/mkmf b/build_templates/mkmf index 821982978d..dbd8ea45f1 100755 --- a/build_templates/mkmf +++ b/build_templates/mkmf @@ -73,7 +73,7 @@ my $endline = $/; my @src_suffixes = ( q/\.F/, q/\.F90/, q/\.c/, q/\.f/, q/\.f90/ ); my @inc_suffixes = ( q/\.H/, q/\.fh/, q/\.h/, q/\.inc/ ); push @inc_suffixes, @src_suffixes; # sourcefiles can be includefiles too -my @tgt_suffixes = ( q/\.a/ ); +my @tgt_suffixes = ( q/\.a/, q/\.so/ ); print "Using MPI wrappers\n" if $opt_w; my %compile_cmd; @@ -481,6 +481,12 @@ print MAKEFILE "tags: \$(SRC)\n\tctags \$(SRC)\n"; ( $name, $path, $suffix ) = fileparse( $opt_p, @tgt_suffixes ); if( $suffix eq '.a' ) { print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(AR) \$(ARFLAGS) $opt_p \$(OBJ)\n"; +} elsif ( $suffix eq '.so' ) { + if ( $opt_w ) { + print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(MPILD) \$(SHR) \$(OBJ) -o $opt_p \$(LDFLAGS)"; + } else { + print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(LD) \$(SHR) \$(OBJ) -o $opt_p \$(LDFLAGS)"; + } } elsif ( $opt_w ){ print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(MPILD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n"; } else { diff --git a/developer_tests/library/shared/work/input.nml b/developer_tests/library/shared/work/input.nml new file mode 100644 index 0000000000..a088a84317 --- /dev/null +++ b/developer_tests/library/shared/work/input.nml @@ -0,0 +1,18 @@ +&preprocess_nml + overwrite_output = .true. + input_obs_def_mod_file = '../../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../../observations/forward_operators/obs_def_mod.f90' + input_obs_qty_mod_file = '../../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../../assimilation_code/modules/observations/obs_kind_mod.f90' + obs_type_files = '../../../../observations/forward_operators/obs_def_1d_state_mod.f90' + quantity_files = '../../../../assimilation_code/modules/observations/oned_quantities_mod.f90' + / + +&utilities_nml + termlevel = 1, + module_details = .false., + logfilename = 'dart_log.out', + nmlfilename = 'dart_log.nml', + write_nml = 'file', + print_debug = .false., + / diff --git a/developer_tests/library/shared/work/mkmf.template.gfortran b/developer_tests/library/shared/work/mkmf.template.gfortran new file mode 100644 index 0000000000..3b91f3b7a1 --- /dev/null +++ b/developer_tests/library/shared/work/mkmf.template.gfortran @@ -0,0 +1,147 @@ +# Template for GNU gfortran on Linux or Mac OSX +# +# 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 +# +# DART $Id$ + +# typical use with mkmf +# mkmf -t mkmf.template.xxxx ... +# +# Suggested (perhaps required) flags: +# -ffree-line-length-none handles "long" lines - i.e. longer than 72 chars +# -O2 default level of code optimization +# (remove for debugging) +# +# Suggested debugging flags: +# -g add debugging information to executable +# -Wuninitialized catch uninitialized variables +# -Wunused issue warning for unused variables - keeps code clean +# -fbacktrace runtime errors try to print out a stack backtrace +# -fbounds-check add runtime-checking for out-of-range array indices +# -ffpe-trap=invalid,zero,overflow +# stop on floating point errors +# +# Earlier versions of this mkmf file listed 'precision' as one of the options on +# the fpe-trap line. This is not recommended anymore as some of the gfortran internal +# routines will trap, as well as some perfectly valid DART computations. +# +# Generally not needed but possibly useful for non-DART code: +# +# -ffree-form forces input file to be read as free format regardless +# of what file extension it has. +# +# -fdefault-real-8 force all real variables to be real*8. not needed for DART code +# since all real variables in DART are declared with a size. +# +# Binary (unformatted) file issues: +# +# Files which use NetCDF format (e.g. input/output ensemble member model state) +# automatically convert between big-endian and little-endian number formats +# if needed, and handle differences between single and double precision reals. +# +# Ascii files (e.g. obs_seq files using ascii format, control files, scripts) +# are portable between different systems. +# +# However, binary observation sequence (obs_seq) files and other model-specific +# binary files can have some or all of the following issues: +# +# - Record Marker size +# +# Some older versions of the gfortran compiler (including 4.1.2) changed +# the record marker size to 8 bytes, which made binary files written with +# the 'unformatted' option unreadable by programs built with other compilers. +# Later versions of the compiler changed the default back to 4 bytes. +# If you have a version that defaults to 8 byte record markers, use this +# compile time flag to write files with 4 byte markers: +# -frecord-marker=4 +# If you have files written by older versions of the gfortran compiler that +# cannot be read now, try this compile time flag: +# -frecord-marker=8 +# +# - Real variable precision/size: +# +# If binary files are written with code that declares the variables to +# be real*8 (8 byte reals), which is the default in DART, the executable +# that reads this file must be compiled the same way. Some DART users +# redefine all DART reals to be real*4 (4 byte reals) so all code computes +# with and reads/writes single precision values. In that case, all +# executables must be compiled this same way to read binary (unformatted) +# files successfully. See the "types_mod.f90" file for this setting. +# +# - Endian issues +# +# Intel CPU chips use "little-endian" number format. IBM Power chips +# use "big-endian" number format. When binary files are written they +# default to writing numbers with the byte order native to the machine. +# +# To read DART observation sequence (obs_seq) binary files on a +# computing platform with a different "endian-ness": +# +# There is a runtime namelist item in the &obs_sequence_nml namelist +# to set a different endian for the observation sequence files only. +# This is the recommended way to read binary obs_seq files if written +# by a different platform. Options: big_endian, little_endian, native. +# +# To read other model-specific binary files on a different platform: +# +# You can convert big-endian or little-endian binary files at runtime +# on a unit-number by unit-number basis. Note that if you set all +# open file units to a different endian-ness, any new files you write +# will also have that same endian-ness. You may need to add some print +# statements in the code after opening the file to determine which +# unit numbers are being used. You can then set them in the environment +# to override the default: +# +# setenv GFORTRAN_CONVERT_UNIT 'big_endian' +# Treats ALL open file units as big_endian. (Not recommended if new files +# will be written.) Options: big_endian, little_endian, native. +# +# setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20' +# Treats file units 10-20 as native; the rest are 'big_endian' +# +# For more information on unit conversions: +# http://gcc.gnu.org/onlinedocs/gfortran/GFORTRAN_005fCONVERT_005fUNIT.html +# + + +MPIFC = mpif90 +MPILD = mpif90 +FC = gfortran +LD = gfortran + +# DISCUSSION ABOUT NETCDF. DART works with both V3 and V4 flavors of netCDF. +# Some V4 installations also require the HDF5 libraries. Some don't. +# Some netCDF installations require both -lnetcdff and -lnetcdf, some only +# require -lnetcdf. The permutations make it difficult to cover the possible +# installations. Here are some candidates, you might just have to resort to +# trial and error: +# LIBS = -L$(NETCDF)/lib -lnetcdf +# LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf +# LIBS = -L$(NETCDF)/lib -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm +# LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm +# +# If you get an error "ld: library not found for -lnetcdff" (note 2 f's), +# remove it from the LIBS line. The same is true for any library. If 'ld' +# does not complain - it worked. + +# If your NETCDF environment variable is not set correctly, +# uncomment the following line and set value to where lib and include +# are found for the netcdf files that match this compiler. +# +NETCDF = /opt/local + +INCS = -I$(NETCDF)/include +LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf +FFLAGS = -O2 -ffree-line-length-none -fPIC $(INCS) +LDFLAGS = $(FFLAGS) $(LIBS) +SHR = -shared + +# FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check \ +# -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS) + +# +# $URL$ +# $Revision$ +# $Date$ diff --git a/developer_tests/library/shared/work/quickbuild.sh b/developer_tests/library/shared/work/quickbuild.sh new file mode 100755 index 0000000000..f9b029fc33 --- /dev/null +++ b/developer_tests/library/shared/work/quickbuild.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# 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 + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL=lorenz_96 +LOCATION=oned + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- libdart.so *.o *.mod Makefile .cppdefs + +# build any NetCDF files from .cdl files +cdl_to_netcdf + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build static library +buildlib libdart.so + +# clean up +\rm -f -- *.o + +} + +main "$@" From b2c4d52c42ad1623fd75808e9742a523077fcc25 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Tue, 16 Jul 2024 10:52:17 -0400 Subject: [PATCH 3/8] test bitwise library builds of filter with regular build of filter lorenz_96 compiling everything with -fPIC --- .../{shared/work => }/mkmf.template.gfortran | 0 developer_tests/library/test_libraries.sh | 96 +++++++++++++++++++ 2 files changed, 96 insertions(+) rename developer_tests/library/{shared/work => }/mkmf.template.gfortran (100%) create mode 100755 developer_tests/library/test_libraries.sh diff --git a/developer_tests/library/shared/work/mkmf.template.gfortran b/developer_tests/library/mkmf.template.gfortran similarity index 100% rename from developer_tests/library/shared/work/mkmf.template.gfortran rename to developer_tests/library/mkmf.template.gfortran diff --git a/developer_tests/library/test_libraries.sh b/developer_tests/library/test_libraries.sh new file mode 100755 index 0000000000..b97764ec1d --- /dev/null +++ b/developer_tests/library/test_libraries.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -e +export DART=$(git rev-parse --show-toplevel) + +main () { + +NETCDF_LIB=/opt/local/ +testdir=$(pwd) + +# remove any previous test directoires +rm -rf nolib +rm -rf sharedlib +rm -rf staticlib + +# use library mkmf.template +cp "$testdir"/mkmf.template.gfortran "$DART"/build_templates/mkmf.template + +# regular filter build - this goes first so test directories get *.nc and obs_seq.out input files +cd "$DART"/models/lorenz_96/work +./quickbuild.sh clean +./quickbuild.sh filter +rm *.o *.mod + +#----------------- +# setup test direcories +cd "$testdir" +cp -r "$DART"/models/lorenz_96/work nolib +cp -r "$DART"/models/lorenz_96/work sharedlib +cp -r "$DART"/models/lorenz_96/work staticlib + +#----------------- +# shared library build +cd "$DART"/developer_tests/library/shared/work +./quickbuild.sh clean +./quickbuild.sh + +mpif90 -o filter "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. -ldart + +#----------------- +# static library build +cd "$DART"/developer_tests/library/static/work +./quickbuild.sh clean +./quickbuild.sh + +mpif90 "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. -ldart -L/$NETCDF_LIB -lnetcdff -o filter + +#----------------- +# copy executables built from libraries to test directories +cd "$testdir"/sharedlib +rm filter +cp "$DART"/developer_tests/library/shared/work/filter . +cp "$DART"/developer_tests/library/shared/work/libdart.so . # rather than setting library paths + +cd "$testdir"/staticlib +rm filter +cp "$DART"/developer_tests/library/static/work/filter . + +#----------------- +# run filter +cd "$testdir"/nolib/ +mpirun -n 4 ./filter + +cd "$testdir"/sharedlib/ +mpirun -n 4 ./filter + +cd "$testdir"/staticlib/ +mpirun -n 4 ./filter + +check_bitwise "$testdir"/nolib/ "$testdir"/sharedlib/ +check_bitwise "$testdir"/nolib/ "$testdir"/staticlib/ + +} + +#----------------- +check_bitwise () { +diff -s "$1"/obs_seq.final "$2"/obs_seq.final + +netcdffiles=(\ +analysis.nc +filter_input.nc +filter_output.nc +perfect_input.nc +preassim.nc \ +) + +for f in "${netcdffiles[@]}" +do + echo -n "$f" " " + nccmp -d "$1"/"$f" "$2"/"$f" + echo "" +done +} + +main "$@" + From 6ed8b619fe29f5f96281553e6d9655b633348ea4 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 19 Jul 2024 13:24:46 -0400 Subject: [PATCH 4/8] chore: trim down mkmf.template file --- .../library/mkmf.template.gfortran | 124 ------------------ 1 file changed, 124 deletions(-) diff --git a/developer_tests/library/mkmf.template.gfortran b/developer_tests/library/mkmf.template.gfortran index 3b91f3b7a1..2f38c5f3a3 100644 --- a/developer_tests/library/mkmf.template.gfortran +++ b/developer_tests/library/mkmf.template.gfortran @@ -4,132 +4,12 @@ # by UCAR, "as is", without charge, subject to all terms of use at # http://www.image.ucar.edu/DAReS/DART/DART_download # -# DART $Id$ - -# typical use with mkmf -# mkmf -t mkmf.template.xxxx ... -# -# Suggested (perhaps required) flags: -# -ffree-line-length-none handles "long" lines - i.e. longer than 72 chars -# -O2 default level of code optimization -# (remove for debugging) -# -# Suggested debugging flags: -# -g add debugging information to executable -# -Wuninitialized catch uninitialized variables -# -Wunused issue warning for unused variables - keeps code clean -# -fbacktrace runtime errors try to print out a stack backtrace -# -fbounds-check add runtime-checking for out-of-range array indices -# -ffpe-trap=invalid,zero,overflow -# stop on floating point errors -# -# Earlier versions of this mkmf file listed 'precision' as one of the options on -# the fpe-trap line. This is not recommended anymore as some of the gfortran internal -# routines will trap, as well as some perfectly valid DART computations. -# -# Generally not needed but possibly useful for non-DART code: -# -# -ffree-form forces input file to be read as free format regardless -# of what file extension it has. -# -# -fdefault-real-8 force all real variables to be real*8. not needed for DART code -# since all real variables in DART are declared with a size. -# -# Binary (unformatted) file issues: -# -# Files which use NetCDF format (e.g. input/output ensemble member model state) -# automatically convert between big-endian and little-endian number formats -# if needed, and handle differences between single and double precision reals. -# -# Ascii files (e.g. obs_seq files using ascii format, control files, scripts) -# are portable between different systems. -# -# However, binary observation sequence (obs_seq) files and other model-specific -# binary files can have some or all of the following issues: -# -# - Record Marker size -# -# Some older versions of the gfortran compiler (including 4.1.2) changed -# the record marker size to 8 bytes, which made binary files written with -# the 'unformatted' option unreadable by programs built with other compilers. -# Later versions of the compiler changed the default back to 4 bytes. -# If you have a version that defaults to 8 byte record markers, use this -# compile time flag to write files with 4 byte markers: -# -frecord-marker=4 -# If you have files written by older versions of the gfortran compiler that -# cannot be read now, try this compile time flag: -# -frecord-marker=8 -# -# - Real variable precision/size: -# -# If binary files are written with code that declares the variables to -# be real*8 (8 byte reals), which is the default in DART, the executable -# that reads this file must be compiled the same way. Some DART users -# redefine all DART reals to be real*4 (4 byte reals) so all code computes -# with and reads/writes single precision values. In that case, all -# executables must be compiled this same way to read binary (unformatted) -# files successfully. See the "types_mod.f90" file for this setting. -# -# - Endian issues -# -# Intel CPU chips use "little-endian" number format. IBM Power chips -# use "big-endian" number format. When binary files are written they -# default to writing numbers with the byte order native to the machine. -# -# To read DART observation sequence (obs_seq) binary files on a -# computing platform with a different "endian-ness": -# -# There is a runtime namelist item in the &obs_sequence_nml namelist -# to set a different endian for the observation sequence files only. -# This is the recommended way to read binary obs_seq files if written -# by a different platform. Options: big_endian, little_endian, native. -# -# To read other model-specific binary files on a different platform: -# -# You can convert big-endian or little-endian binary files at runtime -# on a unit-number by unit-number basis. Note that if you set all -# open file units to a different endian-ness, any new files you write -# will also have that same endian-ness. You may need to add some print -# statements in the code after opening the file to determine which -# unit numbers are being used. You can then set them in the environment -# to override the default: -# -# setenv GFORTRAN_CONVERT_UNIT 'big_endian' -# Treats ALL open file units as big_endian. (Not recommended if new files -# will be written.) Options: big_endian, little_endian, native. -# -# setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20' -# Treats file units 10-20 as native; the rest are 'big_endian' -# -# For more information on unit conversions: -# http://gcc.gnu.org/onlinedocs/gfortran/GFORTRAN_005fCONVERT_005fUNIT.html -# - MPIFC = mpif90 MPILD = mpif90 FC = gfortran LD = gfortran -# DISCUSSION ABOUT NETCDF. DART works with both V3 and V4 flavors of netCDF. -# Some V4 installations also require the HDF5 libraries. Some don't. -# Some netCDF installations require both -lnetcdff and -lnetcdf, some only -# require -lnetcdf. The permutations make it difficult to cover the possible -# installations. Here are some candidates, you might just have to resort to -# trial and error: -# LIBS = -L$(NETCDF)/lib -lnetcdf -# LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf -# LIBS = -L$(NETCDF)/lib -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm -# LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm -# -# If you get an error "ld: library not found for -lnetcdff" (note 2 f's), -# remove it from the LIBS line. The same is true for any library. If 'ld' -# does not complain - it worked. - -# If your NETCDF environment variable is not set correctly, -# uncomment the following line and set value to where lib and include -# are found for the netcdf files that match this compiler. -# NETCDF = /opt/local INCS = -I$(NETCDF)/include @@ -141,7 +21,3 @@ SHR = -shared # FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check \ # -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS) -# -# $URL$ -# $Revision$ -# $Date$ From cd95a1e7f10f116af4d166e5278d5005c4a1e922 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Tue, 23 Jul 2024 13:36:27 -0600 Subject: [PATCH 5/8] changes for people who want to run the developer test on Derecho --- developer_tests/library/mkmf.template.gfortran | 2 +- developer_tests/library/test_libraries.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/developer_tests/library/mkmf.template.gfortran b/developer_tests/library/mkmf.template.gfortran index 2f38c5f3a3..46f8e087f3 100644 --- a/developer_tests/library/mkmf.template.gfortran +++ b/developer_tests/library/mkmf.template.gfortran @@ -10,7 +10,7 @@ MPILD = mpif90 FC = gfortran LD = gfortran -NETCDF = /opt/local +#NETCDF = /opt/local INCS = -I$(NETCDF)/include LIBS = -L$(NETCDF)/lib -lnetcdff -lnetcdf diff --git a/developer_tests/library/test_libraries.sh b/developer_tests/library/test_libraries.sh index b97764ec1d..614e89737b 100755 --- a/developer_tests/library/test_libraries.sh +++ b/developer_tests/library/test_libraries.sh @@ -19,7 +19,7 @@ cp "$testdir"/mkmf.template.gfortran "$DART"/build_templates/mkmf.template # regular filter build - this goes first so test directories get *.nc and obs_seq.out input files cd "$DART"/models/lorenz_96/work ./quickbuild.sh clean -./quickbuild.sh filter +./quickbuild.sh mpif08 filter rm *.o *.mod #----------------- @@ -33,7 +33,7 @@ cp -r "$DART"/models/lorenz_96/work staticlib # shared library build cd "$DART"/developer_tests/library/shared/work ./quickbuild.sh clean -./quickbuild.sh +./quickbuild.sh mpif08 mpif90 -o filter "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. -ldart @@ -41,7 +41,7 @@ mpif90 -o filter "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. - # static library build cd "$DART"/developer_tests/library/static/work ./quickbuild.sh clean -./quickbuild.sh +./quickbuild.sh mpif08 mpif90 "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. -ldart -L/$NETCDF_LIB -lnetcdff -o filter @@ -50,7 +50,7 @@ mpif90 "$DART"/assimilation_code/programs/filter/filter.f90 -I. -L. -ldart -L/ cd "$testdir"/sharedlib rm filter cp "$DART"/developer_tests/library/shared/work/filter . -cp "$DART"/developer_tests/library/shared/work/libdart.so . # rather than setting library paths +cp "$DART"/developer_tests/library/shared/work/libdart.so . cd "$testdir"/staticlib rm filter @@ -62,6 +62,7 @@ cd "$testdir"/nolib/ mpirun -n 4 ./filter cd "$testdir"/sharedlib/ +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd) mpirun -n 4 ./filter cd "$testdir"/staticlib/ From 62a29ffce4cde13ccb86cafbdf3d3ca877f64624 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Thu, 25 Jul 2024 10:32:52 -0400 Subject: [PATCH 6/8] doc: add building a library to quickbuild documentation --- guide/quickbuild.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/guide/quickbuild.rst b/guide/quickbuild.rst index 04cc8678e9..7d09ec624f 100644 --- a/guide/quickbuild.rst +++ b/guide/quickbuild.rst @@ -242,3 +242,20 @@ finds your new code and ignores any code you do not want compiled. a directory, a list of files, or a single file. +Building DART as a library +-------------------------- + +For developers who want to build DART as a library for use with another applications, we provide +the buildlib buildfunction. + +.. code-block :: bash + + buildlib libdart.a # for a static library + buildlib libdart.so # for a shared library + + +Example quickbuild.sh scripts for building a shared and a static library are given in +``DART/developer_tests/library/{shared|static}/work``. + + + From 7edcbe59498bcaf0c4c1fe3714daef2b9bbb5014 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 26 Jul 2024 09:58:09 -0400 Subject: [PATCH 7/8] library build added to run_all_quickuild.sh action --- .github/workflows/run_all_quickbuilds.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_all_quickbuilds.yml b/.github/workflows/run_all_quickbuilds.yml index a153aa0064..49f7468b7c 100644 --- a/.github/workflows/run_all_quickbuilds.yml +++ b/.github/workflows/run_all_quickbuilds.yml @@ -68,6 +68,9 @@ jobs: *GMI* | *GOES* | *forward_operators* | *NSIDC* ) cp /home/mkmf.template.rttov.gfortran mkmf.template ;; + *library*) + cp ../developer_tests/library/mkmf.template.gfortran mkmf.template + ;; *) cp mkmf.template.gfortran mkmf.template echo 'FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS)' >> mkmf.template From 362bdbb8d2c1c203e73bee1ff245508f54a87e3c Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 26 Jul 2024 10:19:38 -0400 Subject: [PATCH 8/8] bump version and changelog for release --- CHANGELOG.rst | 6 ++++++ conf.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d50c46d295..5e2c1706f5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,12 @@ individual files. The changes are now listed with the most recent at the top. +**July 26 2024 :: Library build tools for DART. Tag v11.6.0** + +- Buildtools for compiling DART as a shared or a static library. +- Bugfix: correct order of arguments in count_state_ens_copies for 'input' + stages_to_write. + **July 11 2024 :: Bgrid documentation and scripting fix. Tag v11.5.1** - Updated Bgrid documentation and removed outdated scripts and files diff --git a/conf.py b/conf.py index db0041097f..deb053a0be 100644 --- a/conf.py +++ b/conf.py @@ -21,7 +21,7 @@ author = 'Data Assimilation Research Section' # The full version, including alpha/beta/rc tags -release = '11.5.1' +release = '11.6.0' root_doc = 'index' # -- General configuration ---------------------------------------------------