Commit 63d1c4c4 authored by shkjocke's avatar shkjocke

second commit

parent 2b13abd2
#!/bin/bash
NAME=TL159L91-g001_19820101
# First we glue all files to one SH and one GG file
INDIR=/gfs1/work/shkjocke/data/OIFS/T159L91/g001/SAVED/
OUTDIR=/gfs1/work/shkjocke/data/OIFS/T159L91/g001/ANALYSIS/
PREFIX=${OUTDIR}/${NAME}
#echo " Glue files "
#./glue_openifs.sh --expid=g001 --startstep=0 --endstep=10176 --directory=$INDIR --shfile=${PREFIX}_SH.grb --ggfile=${PREFIX}_GG.grb -v
# Next we regrid the data for humans
echo " Regrid files "
./regrid.sh --shfile=${PREFIX}_SH.grb --ggfile=${PREFIX}_GG.grb --regfile=${PREFIX}_R.nc --plevfile=${PREFIX}_P.nc --ncout=1 --grbedition=2 -v --tmp=$WORK/tmp/
# Now we make seasonal means of all variables
echo " Make seasonal means "
cdo -O -f nc -seasmean ${PREFIX}_R.nc ${PREFIX}_R_seasmean.nc
cdo -O -f nc -seasmean ${PREFIX}_P.nc ${PREFIX}_P_seasmean.nc
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Usage documentation line # Usage documentation line
USAGE1=" Usage: " USAGE1=" Usage: "
USAGE2=" ./regrid.sh --shfile=test_sh.grb --ggfile=test_gg.grb --regfile=all_regular.grb --plevfile=all_plevels.grb --ncout=0 --grbedition=2 " USAGE2=" ./regrid.sh --shfile=test_sh.grb --ggfile=test_gg.grb --regfile=all_regular.grb --plevfile=all_plevels.grb --ncout=0 --grbedition=2 --geopot"
USAGE="$USAGE1 $USAGE2" USAGE="$USAGE1 $USAGE2"
# Default configuratons # Default configuratons
...@@ -10,6 +10,7 @@ VERBOSE=0 ...@@ -10,6 +10,7 @@ VERBOSE=0
TMPDIR=../tmp/ TMPDIR=../tmp/
GRBED=2 GRBED=2
NCOUT=1 NCOUT=1
GEOPOT=0
# Loop over all arguments # Loop over all arguments
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
...@@ -51,6 +52,10 @@ while [ $# -gt 0 ]; do ...@@ -51,6 +52,10 @@ while [ $# -gt 0 ]; do
TMPDIR="${1#*=}" TMPDIR="${1#*=}"
;; ;;
--geopot)
GEOPOT=1
;;
*) *)
printf "***************************\n" printf "***************************\n"
printf "* Error: Invalid argument.*\n" printf "* Error: Invalid argument.*\n"
...@@ -62,7 +67,15 @@ while [ $# -gt 0 ]; do ...@@ -62,7 +67,15 @@ while [ $# -gt 0 ]; do
done done
# Make tmp directory # Make tmp directory
mkdir -p $TMPDIR TMPDIR=${TMPDIR}/$(date '+%Y%m%d_%H%M%S')
mkdir -vp $TMPDIR
# Set file endings
if [ $NCOUT -gt 0 ]; then
SUFF="nc"
else
SUFF="grb"
fi
# This script needs grib_copy and cdo # This script needs grib_copy and cdo
# Check if they exist # Check if they exist
...@@ -162,6 +175,7 @@ fi ...@@ -162,6 +175,7 @@ fi
cdo -O merge $string $TMPDIR/tmpfile.grb cdo -O merge $string $TMPDIR/tmpfile.grb
rm -f $string rm -f $string
# Convert to netCDF # Convert to netCDF
if [ $NCOUT -gt 0 ]; then if [ $NCOUT -gt 0 ]; then
if [ $VERBOSE -ge 1 ]; then if [ $VERBOSE -ge 1 ]; then
...@@ -172,30 +186,32 @@ if [ $NCOUT -gt 0 ]; then ...@@ -172,30 +186,32 @@ if [ $NCOUT -gt 0 ]; then
fi fi
# Split file into hybrid coordinates and not # Split file into hybrid coordinates and not
if [ $NCOUT -gt 0 ]; then cdo selzaxis,hybrid $TMPDIR/tmpfile.${SUFF} $TMPDIR/tmpfile_hybrid.${SUFF}
cdo selzaxis,hybrid $TMPDIR/tmpfile.nc $TMPDIR/tmpfile_hybrid.nc
else # Calculate geopotential (does not work with GRIB2)
cdo selzaxis,hybrid $TMPDIR/tmpfile.grb $TMPDIR/tmpfile_hybrid.grb if [ $GEOPOT -gt 0 ];then
fi if [ $VERBOSE -ge 1 ]; then
echo " Calculate geopotential height "
fi
cdo -O expr,'surface_air_pressure=exp(lnsp)' $TMPDIR/tmpfile_hybrid.nc $TMPDIR/tmpfile_ps.nc
cdo -O merge $TMPDIR/tmpfile_hybrid.nc $TMPDIR/tmpfile_ps.nc $TMPDIR/tmpfile_hybrid.nc
ncdump -h $TMPDIR/tmpfile_hybrid.nc
cdo -O geopotheight $TMPDIR/tmpfile_hybrid.${SUFF} $TMPDIR/tmpfile_geopot.${SUFF}
exit
cdo -O merge $TMPDIR/tmpfile.${SUFF} $TMPDIR/tmpfile_geopot.${SUFF} $TMPDIR/tmpfile.${SUFF}
fi
# Convert hybrid data to pressure level data # Convert hybrid data to pressure level data
plevels=100000,92500,85000,75000,60000,50000,40000,30000,20000,10000,5000,2000,1000 plevels=100000,92500,85000,75000,60000,50000,40000,30000,20000,10000,5000,2000,1000
if [ $NCOUT -gt 0 ]; then if [ $VERBOSE -ge 1 ]; then
cdo -O ml2plx,${plevels} $TMPDIR/tmpfile_hybrid.nc $TMPDIR/tmpfile_plevels.nc echo " Regrid to pressure levels: " $plevels
rm -f $TMPDIR/tmpfile_hybrid.nc fi
else cdo -O ml2plx,${plevels} $TMPDIR/tmpfile_hybrid.${SUFF} $TMPDIR/tmpfile_plevels.${SUFF}
cdo -O ml2plx,${plevels} $TMPDIR/tmpfile_hybrid.grb $TMPDIR/tmpfile_plevels.grb rm -f $TMPDIR/tmpfile_hybrid.${SUFF}
rm -f $TMPDIR/tmpfile_hybrid.grb
fi
# Make new file names # Make new file names
if [ $NCOUT -gt 0 ]; then mv $TMPDIR/tmpfile.${SUFF} $REGOUT
mv $TMPDIR/tmpfile.nc $REGOUT mv $TMPDIR/tmpfile_plevels.${SUFF} $PLEVOUT
mv $TMPDIR/tmpfile_plevels.nc $PLEVOUT
else
mv $TMPDIR/tmpfile.grb $REGOUT
mv $TMPDIR/tmpfile_plevels.grb $PLEVOUT
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment