Commit 9b810826 authored by Pierre-Antoine Bretonnière's avatar Pierre-Antoine Bretonnière
Browse files

Merge branch 'develop-bugi025' into 'master'

Develop bugi025

Hi @rcruzgar
In order to follow up on the changes you did in develop-bugi025 the standard procedure is to open a merge request into master branch.
@pabretonniere how do you want to proceed for testing it before including it into master ?
@vsicardi needs this bug fix for going on with her experiment.
Regards

See merge request !13
parents a6818bfb ebe0a2e2
......@@ -167,54 +167,56 @@ function concat_startdate {
typeset var root
typeset var lstfiles
for root in ${listroots[@]} ; do
if [[ "$8" == "MMO" ]] ; then
lstfiles=`ls *${root}* | grep -v "${root}_$2_$1_fc" | grep -v "${freqexcl1}" | grep -v "${freqexcl2}" | grep -v "km" `
else
lstfiles=`ls ${root}* | grep -v "${root}_$2_$1_fc" | grep -v "${freqexcl1}" | grep -v "${freqexcl2}" | grep -v "km" `
fi
if [[ ! -z ${lstfiles} ]] ; then
file1=`echo "${lstfiles}" | tail -1`
cdo_version=`cdo -V &> ff ; grep Climate ff | cut -d \ -f 5`
rm ff
#test on cdo version: if >1.5.6, remove valid_min/max attributes to avoid values out of that range to be replaced by NaN
if [[ "$cdo_version" = "`echo -e "$cdo_version\n1.5.6" | sort -V | head -n1`" ]] ; then
if [[ $root == 'grid_T' || $root == 't3d' ]] ; then
for file in $lstfiles ; do
ncatted -O -a valid_max,votemper,d,, $file $file
ncatted -O -a valid_min,votemper,d,, $file $file
done
fi
if [[ $root == 'heat_sal_mxl' ]] ; then
for file in $lstfiles ; do
ncatted -O -a valid_max,somxlheatc,d,, $file $file
ncatted -O -a valid_min,somxlheatc,d,, $file $file
done
fi
fi
outfile=${root}_$2_$1_fc$3_$(($yyyy0+(10#$mm0+$4-2)/12))$(printf "%02d" $(((10#$mm0+$4-2)%12+1)))_${year2}$(printf "%02d" $mon2).nc
typeset var lstvars=`cdo showvar $file1`
if [[ ${lstvars/iicenflx} != ${lstvars} ]] ; then for file in $lstfiles ; do ncks -O -x -v iicenflx $file $file ; done ; fi
cdo mergetime $lstfiles ${outfile}
timevar=`ncdump -h ${outfile} | grep UNLIMITED | awk '{print $1}'`
if [[ $timevar == 'time_counter' ]] ; then ncrename -v time_counter,time -d time_counter,time ${outfile} ; fi
if [[ $root == 'moc' ]] ; then
lstdims=`ncdump -h ${outfile} | awk /dimensions:/,/variables:/ | grep -v dimensions: | grep -v variables: | awk '{print $1}'`
if [[ ${lstdims/gsize} != ${lstdims} ]] ; then
ncrename -d gsize,y ${outfile}
if [[ `ls *${root}*` != '' ]] && [[ `ls *${root}*` != ${root}_1m.nc ]] && [[ `ls *${root}* | grep -v "${freqexcl1}" | grep -v "${freqexcl2}"` != '' ]] ; then
if [[ "$8" == "MMO" ]] ; then
lstfiles=`ls *${root}* | grep -v "${root}_$2_$1_fc" | grep -v "${freqexcl1}" | grep -v "${freqexcl2}" | grep -v "km" `
else
lstfiles=`ls ${root}* | grep -v "${root}_$2_$1_fc" | grep -v "${freqexcl1}" | grep -v "${freqexcl2}" | grep -v "km" `
fi
lenx=`ncdump -h ${outfile} | grep 'x =' | head -1 | awk '{print $3}'`
if [[ $lenx > 1 ]] ; then
if [[ ${lstvars/nav_lon} != ${lstvars} ]] ; then
ncks -O -x -v nav_lon,nav_lat ${outfile} ${outfile}
fi
ncrename -d x,y ${outfile}
if [[ ! -z ${lstfiles} ]] ; then
file1=`echo "${lstfiles}" | tail -1`
cdo_version=`cdo -V &> ff ; grep Climate ff | cut -d \ -f 5`
rm ff
#test on cdo version: if >1.5.6, remove valid_min/max attributes to avoid values out of that range to be replaced by NaN
if [[ "$cdo_version" = "`echo -e "$cdo_version\n1.5.6" | sort -V | head -n1`" ]] ; then
if [[ $root == 'grid_T' || $root == 't3d' ]] ; then
for file in $lstfiles ; do
ncatted -O -a valid_max,votemper,d,, $file $file
ncatted -O -a valid_min,votemper,d,, $file $file
done
fi
if [[ $root == 'heat_sal_mxl' ]] ; then
for file in $lstfiles ; do
ncatted -O -a valid_max,somxlheatc,d,, $file $file
ncatted -O -a valid_min,somxlheatc,d,, $file $file
done
fi
fi
outfile=${root}_$2_$1_fc$3_$(($yyyy0+(10#$mm0+$4-2)/12))$(printf "%02d" $(((10#$mm0+$4-2)%12+1)))_${year2}$(printf "%02d" $mon2).nc
typeset var lstvars=`cdo showvar $file1`
if [[ ${lstvars/iicenflx} != ${lstvars} ]] ; then for file in $lstfiles ; do ncks -O -x -v iicenflx $file $file ; done ; fi
cdo mergetime $lstfiles ${outfile}
timevar=`ncdump -h ${outfile} | grep UNLIMITED | awk '{print $1}'`
if [[ $timevar == 'time_counter' ]] ; then ncrename -v time_counter,time -d time_counter,time ${outfile} ; fi
if [[ $root == 'moc' ]] ; then
lstdims=`ncdump -h ${outfile} | awk /dimensions:/,/variables:/ | grep -v dimensions: | grep -v variables: | awk '{print $1}'`
if [[ ${lstdims/gsize} != ${lstdims} ]] ; then
ncrename -d gsize,y ${outfile}
fi
lenx=`ncdump -h ${outfile} | grep 'x =' | head -1 | awk '{print $3}'`
if [[ $lenx > 1 ]] ; then
if [[ ${lstvars/nav_lon} != ${lstvars} ]] ; then
ncks -O -x -v nav_lon,nav_lat ${outfile} ${outfile}
fi
ncrename -d x,y ${outfile}
fi
ncks -A -v nav_lon,nav_lat `echo $lstfiles | awk '{print $1}' ` ${outfile}
fi
rm -f $lstfiles
if [[ $root == 'sstsimld' || $root == 'sstsssmld' ]] ; then mv ${outfile} oce_$2_$1_fc$3_$(($yyyy0+(10#$mm0+$4-2)/12))$(printf "%02d" $(((10#$mm0+$4-2)%12+1)))_${year2}$(printf "%02d" $mon2).nc ; fi
fi
ncks -A -v nav_lon,nav_lat `echo $lstfiles | awk '{print $1}' ` ${outfile}
fi
rm -f $lstfiles
if [[ $root == 'sstsimld' || $root == 'sstsssmld' ]] ; then mv ${outfile} oce_$2_$1_fc$3_$(($yyyy0+(10#$mm0+$4-2)/12))$(printf "%02d" $(((10#$mm0+$4-2)%12+1)))_${year2}$(printf "%02d" $mon2).nc ; fi
fi
done
}
......
#!/bin/bash
set -evx
module load CDFTOOLS/2.1-foss-2015a
module load CDFTOOLS/2.1-foss-2015a CDO NCO
function delete {
at now +7 days << EOF
......
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