-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #702 from NCAR/libdart
Buildtools for compiling dart as a library
- Loading branch information
Showing
13 changed files
with
276 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*.a | ||
*.so | ||
*.mod | ||
*.o | ||
*.swp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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 | ||
# | ||
|
||
MPIFC = mpif90 | ||
MPILD = mpif90 | ||
FC = gfortran | ||
LD = gfortran | ||
|
||
#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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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., | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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., | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/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 mpif08 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 mpif08 | ||
|
||
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 mpif08 | ||
|
||
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 . | ||
|
||
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/ | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd) | ||
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 "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters