Skip to content

Commit

Permalink
Merge pull request #742 from ckoven/tools
Browse files Browse the repository at this point in the history
Two new command-line scripts for comparing parameter files
  • Loading branch information
rgknox authored Jun 14, 2021
2 parents 1723d14 + c31e17d commit 1758ffe
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/ncdiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

while getopts ":h" option; do
case $option in
h) # display Help
echo "script that compares the differences between two netcdf files."
echo "two arguments are the paths to two files to compare"
exit;;
esac
done

tempfile1=$(mktemp)
tempfile2=$(mktemp)

ncdump $1 >> ${tempfile1}
ncdump $2 >> ${tempfile2}

diff ${tempfile1} ${tempfile2}

rm ${tempfile1}
rm ${tempfile2}
33 changes: 33 additions & 0 deletions tools/pftdiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

while getopts ":h" option; do
case $option in
h) # display Help
echo "script to compare two PFTs in a FATES parameter file. takes three arguments: "
echo "first argument is the parameter file name"
echo "second argument is the first pft number (PFT numbering starts with 1)"
echo "third argument is the second pft number (PFT numbering starts with 1)"
exit;;
esac
done


tempfile1=$(mktemp)
tempfile2=$(mktemp)
tempfile3=$(mktemp)
tempfile4=$(mktemp)

toolsdir=$(dirname "$0")

$toolsdir/FatesPFTIndexSwapper.py --pft-indices=$2 --fin=$1 --fout=${tempfile1} 1>/dev/null
$toolsdir/FatesPFTIndexSwapper.py --pft-indices=$3 --fin=$1 --fout=${tempfile2} 1>/dev/null

ncdump ${tempfile1} >> ${tempfile3}
ncdump ${tempfile2} >> ${tempfile4}

diff ${tempfile3} ${tempfile4}

rm ${tempfile1}
rm ${tempfile2}
rm ${tempfile3}
rm ${tempfile4}

0 comments on commit 1758ffe

Please sign in to comment.