Skip to content

Commit

Permalink
Get jbdiagnose working in a user-friendly manner
Browse files Browse the repository at this point in the history
 * Add script to call jbdiagnose.x
 * Add vertical level definitions in share/levdef
 * Update CMake infrastructure
  • Loading branch information
ewhelan committed Oct 28, 2021
1 parent 3bc3537 commit 46dc732
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 18 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ file(GLOB_RECURSE sources src/*.F90 src/*.h)
add_executable(jbdiagnose.x ${sources})

# install executables and scripts
install (TARGETS ${EXECUTABLES}
install (TARGETS jbdiagnose.x
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION bin)
DESTINATION libexec)

add_subdirectory (scripts)
add_subdirectory (share)
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# HarmonieDaTools
Collection of Harmonie DA tools

## Installation
```
cd HarmonieDaTools
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/da_tools
make
make install
```
Add DA Tools to your PATH:
```
export PATH=/path/to/da_tools:$PATH
```

## Tools
### Jb diagnose
Help/usage:
```
jbdiagnose -h
```

Example:
```
jbdiagnose -b jb_data/stabfiltn_IRELAND75L65_jbconv.bal -c jb_data/stabfiltn_IRELAND75L65_jbconv.cv -g 15000 -l harmL65
```

15 changes: 15 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function (install_scripts)
foreach (file ${ARGV})
get_filename_component (name_without_extension ${file} NAME_WE)
install (FILES ${file}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION bin
RENAME ${name_without_extension})
endforeach ()
endfunction()

install_scripts (jbdiagnose.sh)
#install (FILES python_script.py
# PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
# DESTINATION bin)
#
154 changes: 154 additions & 0 deletions scripts/jbdiagnose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/usr/bin/env bash

# This script will write stats from Jb files in ASCII
# suitable for plotting ...

bold=$(tput bold)
normal=$(tput sgr0)
unline=$(tput smul)

PROGNAME=`basename $0`

# Define a usage function
usage() {

cat << USAGE
${bold}NAME${normal}
${PROGNAME} - write Jb statistics
${bold}USAGE${normal}
${PROGNAME} -b <bal-file> -c <cv-file> -g <grid-spacing>
-l <level-definition> [-L] [ -h ]
${bold}DESCRIPTION${normal}
Script to start new LBC processing suite
${bold}OPTIONS${normal}
-b ${unline}bal-file${normal}
bal file
-c ${unline}cv-file${normal}
cv file
-g ${unline}grid-spacing${normal}
Grid-spacing in metres
-l ${unline}level-definition${normal}
Level definition (A's and B's)
-L List available level definitions
-h Help! Print usage information.
USAGE
}

BALFILE=DUMMY
CVILE=DUMMY
GRIDSIZE=DUMMY
LEVELDEF=DUMMY

#
# Where am I?
#
this_script_loc="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
appdir=$(dirname ${this_script_loc})
bindir=${appdir}/bin
libdir=${appdir}/lib
exedir=${appdir}/libexec
levdir=${appdir}/share/levdef

if [ ${#} -eq 0 ]; then
echo "No command line arguments provided"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

while getopts b:c:g:l:Lh option
do
case $option in
b)
BALFILE=$OPTARG
;;
c)
CVFILE=$OPTARG
;;
g)
GRIDSIZE=$OPTARG
;;
l)
LEVELDEF=$OPTARG
;;
L)
echo "Will list level defs here ..."
;;
h)
usage
exit 0
;;
*)
echo
echo "Try '${PROGNAME} -h' for more information"
;;
esac
done

if [ ${BALFILE} == "DUMMY" ]; then
echo "Please define bal-file using -b"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

if [ ${CVFILE} == "DUMMY" ]; then
echo "Please define cv-file using -c"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

if [ ${GRIDSIZE} == "DUMMY" ]; then
echo "Please define grid-size using -g"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

if [ ${LEVELDEF} == "DUMMY" ]; then
echo "Please define level-definition using -l"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

echo
echo "BALFILE=${BALFILE}"
echo "CVILE=${CVFILE}"
echo "GRIDSIZE=${GRIDSIZE}"
echo "LEVELDEF=${LEVELDEF}"
echo

#
# Construct namjbconv namelist
#
if [ ! -s ${levdir}/${LEVELDEF}.def ]; then
echo "${levdir}/${LEVELDEF}.def not found"
echo "Try $PROGNAME -L to list available level definitions"
exit 1
fi

echo "&namjbconv" > jbconv.nam
echo "gsize_in = ${GRIDSIZE}," >> jbconv.nam
cat ${levdir}/${LEVELDEF}.def >> jbconv.nam
echo "/" >> jbconv.nam

#
# Create soft links for jbdiagnose.x
#
ln ${BALFILE} stabal96.bal
ln ${CVFILE} stabal96.cv

${exedir}/jbdiagnose.x < jbconv.nam

rm -f stabal96.cv
rm -f stabal96.bal
rm -f jbconv.nam

exit 0
2 changes: 2 additions & 0 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install( DIRECTORY levdef DESTINATION share PATTERN "CMakeLists.txt" EXCLUDE )

45 changes: 45 additions & 0 deletions share/levdef/harmL65.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
nlev_nl = 65,
ahalf_nl = 0.00000000, 2000.00000000, 4000.21287319,
6002.09662113, 7911.25838577, 9633.01049417,
11169.37146237, 12522.57753978, 13695.00149653,
14689.11546998, 15507.49052823, 16154.69697732,
16632.12471208, 16940.14949960, 17082.34869816,
17065.28164099, 16898.18367797, 16592.58939571,
16161.90395878, 15620.94340550, 14985.46502362,
14271.70773051, 13495.95994372, 12674.16909910,
11821.60314859, 10952.57042620, 10080.20053763,
9216.28565403, 8371.17893039, 7553.74479607,
6771.35457397, 6029.92021691, 5333.95880836,
4686.68074804, 4090.09511346, 3545.12645110,
3051.73811264, 2609.05813936, 2215.50455766,
1868.90774223, 1566.62821060, 1305.66882073,
1081.85503306, 890.47596795, 727.74548529,
590.17748096, 474.58767980, 378.08857614,
298.07947335, 232.23312781, 178.48015386,
134.99207440, 100.16369201, 72.59529482,
51.07508967, 34.56216490, 22.17022046,
13.15225964, 6.88641310, 2.86306141,
0.67344356, 0.00000000, 0.00000000,
0.00000000, 0.00000000, 0.00000000,
bhalf_nl = 0.00000000, 0.00000000, 0.00000000,
0.00000000, 0.00095468, 0.00382570,
0.00862327, 0.01535782, 0.02404046,
0.03468314, 0.04729839, 0.06195102,
0.07868187, 0.09744325, 0.11815586,
0.14071098, 0.16497348, 0.19078554,
0.21797086, 0.24633925, 0.27569119,
0.30582244, 0.33652825, 0.36760726,
0.39886479, 0.43011564, 0.46118624,
0.49191624, 0.52215946, 0.55178443,
0.58067442, 0.60872709, 0.63585388,
0.66197911, 0.68703898, 0.71098036,
0.73375964, 0.75534143, 0.77569737,
0.79480486, 0.81264598, 0.82920633,
0.84454000, 0.85875505, 0.87191802,
0.88409276, 0.89534045, 0.90571965,
0.91528643, 0.92409452, 0.93219549,
0.93963895, 0.94647277, 0.95274328,
0.95849551, 0.96377340, 0.96862008,
0.97307803, 0.97718944, 0.98099640,
0.98454132, 0.98786727, 0.99102462,
0.99406510, 0.99703923, 1.00000000,
43 changes: 43 additions & 0 deletions share/levdef/hirlL60.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
nlev_nl = 60,
ahalf_nl = 0.00000000, 2000.05135426, 4033.40907891,
6074.40328124, 8099.63670588, 10087.89367010,
12020.06658606, 13879.06676239, 15649.75041085,
17318.83964105, 18874.85209658, 20308.02335589,
21610.23752964, 22774.95349175, 23797.14016962,
24673.19673574, 25400.90458140, 25979.33203475,
26408.79136269, 26690.74701491, 26827.77478534,
26823.47214753, 26682.39550616, 26409.99528681,
26012.54977341, 25497.08526683, 24871.31302372,
24143.55208429, 23322.66080848, 22417.97990382,
21439.22595692, 20396.44798444, 19299.92669234,
18160.12861384, 16987.58390227, 15792.86806530,
14586.45478044, 13378.69029188, 12179.68413384,
10999.25363904, 9846.77794029, 8731.20481400,
7660.88648378, 6643.53270367, 5686.12140321,
4794.80922574, 3974.84219208, 3230.45458673,
2564.80865572, 1979.88863358, 1476.41314284,
1053.75138659, 709.81576221, 441.03262309,
242.16324537, 106.30163568, 24.73731477,
0.00000000, 0.00000000, 0.00000000,
0.00000000,
bhalf_nl = 0.00000000, 0.00000000, 0.00000000,
0.00023670, 0.00092292, 0.00224844,
0.00438079, 0.00746615, 0.01163013,
0.01697863, 0.02359864, 0.03155913,
0.04091181, 0.05169201, 0.06391953,
0.07759939, 0.09272279, 0.10926775,
0.12720022, 0.14647459, 0.16703484,
0.18881506, 0.21174059, 0.23572858,
0.26068905, 0.28652551, 0.31313601,
0.34041375, 0.36824815, 0.39652539,
0.42512962, 0.45394336, 0.48284882,
0.51172809, 0.54046468, 0.56894389,
0.59705391, 0.62468618, 0.65173687,
0.67810731, 0.70370500, 0.72844406,
0.75224667, 0.77504346, 0.79677456,
0.81739014, 0.83685163, 0.85513240,
0.87221834, 0.88810912, 0.90281875,
0.91637651, 0.92882764, 0.94023440,
0.95067674, 0.96025322, 0.96908170,
0.97730036, 0.98506843, 0.99256705,
1.00000000,
Loading

0 comments on commit 46dc732

Please sign in to comment.