Skip to content

Commit

Permalink
Merge branch 'develop' into hotfix/add_missing_doc_page
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhelan committed Mar 12, 2024
2 parents 33ff150 + a347a37 commit b02d724
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
#

add_executable(jbdiagnose.x src/jbdiagnose.F90)
add_executable(cv_header_list.x src/cv_header_list.F90)
add_executable(dfscomp.x src/dfscomp.F90)
add_executable(prepdiacov.x src/prepdiacov.F90)

Expand All @@ -32,6 +33,10 @@ install (TARGETS jbdiagnose.x
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION libexec)

install (TARGETS cv_header_list.x
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION libexec)

install (TARGETS dfscomp.x
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION libexec)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ rundiacov -h

Example:
```
rundiacov -i dataTest -c METCOOP25D_65_2021100300-2021111006_412.cv -t METCOOP25D_65_2021100300-2021111006_412.cvt -l 65 -g 2.5 -m 539 -n 1080 -d DIACOV
rundiacov -i dataTest -c METCOOP25D_65_2021100300-2021111006_412 -l 65 -g 2.5 -m 539 -n 1080 -d DIACOV
```

#### Produce diagonal stats
Expand Down
49 changes: 49 additions & 0 deletions doc/src/cvheaderlist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# cv headaer list

A simple tool that reads a binary _cv_ file and lists relevant header data.

## Usage
```shell
user@localhost:~$ cv_header_list -h

NAME
cv_header_list - list cv header

USAGE
cv_header_list -i <cv-file>
[ -h ]

DESCRIPTION
Script to start new LBC processing suite

OPTIONS

-i cv-file
cv file

-h Help! Print usage information.

user@localhost:~$

```

## Example
```shell
user@localhost:~$ cv_header_list -i /home/ewhelan/stab_40h1_IRELAND25_064_480.cv

JPDAYS :: 480
SW(lon-lat) :: -19.520623099467286 42.575525141583732
NE(lon-lat) :: 4.3664253929474990 63.303769438767112
REF(lon-lat) :: 5.0000001489527870 53.500001593794821
NDGL :: 800
NDLON :: 800
NDGUX :: 789
NDLUX :: 789
NSMAX :: 399
NMSMAX :: 399
NFLEVG :: 65

user@localhost:~$
```


1 change: 1 addition & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function (install_scripts)
endfunction()

install_scripts (jbdiagnose.sh plotjbbal.py plotjbdiag.py)
install_scripts (cv_header_list.sh)
install_scripts (varbcdiagnose.sh plotvarbcpred.py)
install_scripts (rundiacov.sh diag_diacov.sh plotdiacov.py)
install_scripts (dfscomp.sh plotdfs.py)
Expand Down
90 changes: 90 additions & 0 deletions scripts/cv_header_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/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} - list cv header
${bold}USAGE${normal}
${PROGNAME} -i <cv-file>
[ -h ]
${bold}DESCRIPTION${normal}
Script to start new LBC processing suite
${bold}OPTIONS${normal}
-i ${unline}cv-file${normal}
cv file
-h Help! Print usage information.
USAGE
}

CVFILE=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 i:h option
do
case $option in
i)
CVFILE=$OPTARG
;;
h)
usage
exit 0
;;
*)
echo
echo "Try '${PROGNAME} -h' for more information"
;;
esac
done

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

if [ ! -s ${CVFILE} ]; then
echo "cv-file, ${CVFILE}, not found"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi

#
# Create soft links for cv_header_list.x
#
ln -sf ${CVFILE} stabal96.cv

${exedir}/cv_header_list.x

exit 0
7 changes: 4 additions & 3 deletions scripts/plotdiacov.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import glob
import matplotlib as mpl
from matplotlib.colors import TwoSlopeNorm
mpl.use('Agg')

# Authors Magnus Lindskog and Ulf Andrae, Dec 2021
Expand All @@ -32,8 +33,8 @@ def plotme(idata, oplot) :
cc=plt.contour(xx,colors='black')
plt.clabel(cc, inline=True, fontsize=12)


plt.contourf(xx, cmap='RdBu_r', alpha=0.5)
limit=np.max(np.abs(xx))
plt.contourf(xx, cmap='RdBu_r', alpha=0.5, norm=TwoSlopeNorm(vmin=-limit, vcenter=0, vmax=limit))

plt.colorbar(orientation='vertical');
if dim1==dim2:
Expand All @@ -51,7 +52,7 @@ def plotme(idata, oplot) :
def main(argv) :

parser = argparse.ArgumentParser(description='Plotting DIACOV diagnostics')
parser.add_argument('-d',dest="indir",help='Plot all input data files in this directory',default=False,required=False)
parser.add_argument('-d',dest="indir",help='Plot all the input data files in this directory',default=False,required=False)
parser.add_argument('-i',dest="idata",help='Input data files',default=False,required=False)
parser.add_argument('-o',dest="oplot",help='Output plot file names',default='output.png',required=False)

Expand Down
40 changes: 13 additions & 27 deletions scripts/rundiacov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ ${bold}NAME${normal}
${bold}USAGE${normal}
${PROGNAME} -i <data-dir>
-c <cv-file>
-t <cvt-file>
-c <jb-file-name>
-l <level-nr>
-g <grid-spacing>
-m <nsmax>
Expand All @@ -32,11 +31,8 @@ ${bold}OPTIONS${normal}
-i ${unline}data-dir${normal}
Input data directory (full path)
-c ${unline}cv-file${normal}
.cv file
-t ${unline}cvt-file${normal}
.cvt file
-c ${unline}jb-file-name${normal}
Name of *.cv and *.cvt files (without extension)
-l ${unline}level-nr${normal}
Number of domain's vertical levels
Expand All @@ -51,16 +47,15 @@ ${bold}OPTIONS${normal}
NDGL parameter specified in domain properties
-d ${unline}diacov-binary${normal}
PATH to DIACOV executable compiled by makeup/GMKPACK.
PATH to DIACOV binary.
-h Help! Print usage information.
USAGE
}

DATADIR=DUMMY
CVFILE=DUMMY
CVTFILE=DUMMY
JBFILE=DUMMY
LEVELNUM=DUMMY
GRIDSIZE=DUMMY
NSMAX=DUMMY
Expand All @@ -79,17 +74,14 @@ if [ ${#} -eq 0 ]; then
exit 1
fi

while getopts i:c:t:l:g:m:n:d:h option
while getopts i:c:l:g:m:n:d:h option
do
case $option in
i)
DATADIR=$OPTARG
;;
c)
CVFILE=$OPTARG
;;
t)
CVTFILE=$OPTARG
JBFILE=$OPTARG
;;
l)
LEVELNUM=$OPTARG
Expand Down Expand Up @@ -123,14 +115,8 @@ if [ ${DATADIR} == "DUMMY" ]; then
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 [ ${CVTFILE} == "DUMMY" ]; then
echo "Please define cvt-file using -t"
if [ ${JBFILE} == "DUMMY" ]; then
echo "Please define jb-file-name using -c"
echo "Try '${PROGNAME} -h' for more information"
exit 1
fi
Expand Down Expand Up @@ -190,14 +176,14 @@ cat > nam_diag2 <<EOF
EOF

#Run DIACOV with stabal.cv
ln -sf ../${DATADIR}/$CVTFILE stabal.cvt
ln -sf ../${DATADIR}/${JBFILE}.cvt stabal.cvt
cp nam_diag1 fort.4
../${BINPATH}
${BINPATH}

#Run DIACOV with stabal.cvt
ln -sf ../${DATADIR}/$CVFILE stabal.cv
ln -sf ../${DATADIR}/${JBFILE}.cv stabal.cv
cp nam_diag2 fort.4
../${BINPATH}
${BINPATH}

# Take care of results
mv *.xy ../${DATADIR}/.
Expand Down
89 changes: 89 additions & 0 deletions src/cv_header_list.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
program cv_header_list
!
implicit none
!
! Geometry definition
!
real(kind=8) :: gsize_in
integer(kind=4) :: nlev_nl
integer(kind=4) :: jpnlev_nl
parameter (jpnlev_nl=200)
real(kind=8) :: ahalf_nl(jpnlev_nl+1),bhalf_nl(jpnlev_nl+1)
integer(kind=4) :: printlev
namelist/namjbconv/ gsize_in,nlev_nl,ahalf_nl,bhalf_nl,printlev

integer(kind=4) :: nlon_in,nlat_in
real(kind=8) :: lon0_in,lat0_in
real(kind=8) :: lon1_in,lat1_in,lon2_in,lat2_in
real(kind=8) :: afull_nl(jpnlev_nl),bfull_nl(jpnlev_nl)
real(kind=8) :: pfull_nl(jpnlev_nl)
!
! Variables read from input file or written to output file
!
character :: clid*10,clcom*70
integer(kind=4) :: iorig,idate,itime,inbset
integer(kind=4) :: inbmat,iweight,itypmat,isetdist,ilendef
integer(kind=4) :: idim1,idim2,ipar1,ipar2,itypdi1,itypdi2
real(kind=8) :: zlon1,zlat1,zlon2,zlat2,zlon0,zlat0
integer(kind=4) :: idgl,idlon,idgux,idlux,iismax,imsmax,iflevg,ichkwd
real(kind=8),allocatable :: zfcovtps_in(:,:,:),zfcovq_in(:,:,:),zfcovp_in(:,:,:),zfcovd_in(:,:,:)
real(kind=8),allocatable :: zpdat_in(:)
real(kind=8),allocatable :: sdiv_in(:,:,:), stps_in(:,:,:),shum_in(:,:,:), bfact_in(:)
real(kind=8),allocatable :: bfact_iso(:)
!
! File unit numbers
!
integer(kind=4) :: nuljb_in,nulout,nulnam
!
! Other local variables
!
integer(kind=4) :: itrunc,nflevg
integer(kind=4) :: jn,jk,jj,jl
integer(kind=4) :: nsmax_jb_in,nmsmax_jb_in
integer(kind=4),allocatable :: isorel2_in(:),isodor2_in(:)
integer(kind=4) :: ispec2_in,iii
character :: fnspdens*15
real(kind=8) :: zsumcov,zsumvar1,zsumvar2,pi,zscale
!
! Initialize some work variables
!
nuljb_in=10
nulout=06
nulnam=05
printlev=1
pi=atan(1.)*4.

! Open input covariance file
!
open(nuljb_in,file='stabal96.cv',form='unformatted')
!
! Read GSA file header
!
read(nuljb_in) clid
read(nuljb_in) clcom
read(nuljb_in) iorig,idate,itime,inbset
write(nulout,*) ''
!
! Read GSA set 0 header : model geometry definition (LAM case !)
!
read(nuljb_in) inbmat,iweight,itypmat,isetdist,ilendef
read(nuljb_in) idim1,idim2,ipar1,ipar2,itypdi1,itypdi2
read(nuljb_in)
read(nuljb_in)
read(nuljb_in) zlon1,zlat1,zlon2,zlat2,zlon0,zlat0,&
& idgl,idlon,idgux,idlux,iismax,imsmax,iflevg,ichkwd

write(nulout,*) 'JPDAYS :: ',iweight
write(nulout,*) 'SW(lon-lat) :: ',zlon1,zlat1
write(nulout,*) 'NE(lon-lat) :: ',zlon2,zlat2
write(nulout,*) 'REF(lon-lat) :: ',zlon0,zlat0
write(nulout,*) 'NDGL :: ',idgl
write(nulout,*) 'NDLON :: ',idlon
write(nulout,*) 'NDGUX :: ',idgux
write(nulout,*) 'NDLUX :: ',idlux
write(nulout,*) 'NSMAX :: ',iismax
write(nulout,*) 'NMSMAX :: ',imsmax
write(nulout,*) 'NFLEVG :: ',iflevg
!
stop
end program cv_header_list
Loading

0 comments on commit b02d724

Please sign in to comment.