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

Merge branch 'develop-bugfixes-valentina' into 'master'

Develop bugfixes valentina

See merge request !14
parents 9b810826 c61d871d
......@@ -59,10 +59,10 @@
# Link constant file for co #
###############################################################################
ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mesh_hgr.nc
ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mesh_zgr.nc
ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mask.nc
ln -sf ${CON_FILES}/new_maskglo.${NEMOVERSION}.nc new_maskglo.nc
[[ ! -f mesh_hgr.nc ]] && ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mesh_hgr.nc
[[ ! -f mesh_zgr.nc ]] && ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mesh_zgr.nc
[[ ! -f mask.nc ]] && ln -sf ${CON_FILES}/mesh_mask_nemo.${NEMOVERSION}.nc mask.nc
[[ ! -f new_maskglo.nc ]] && ln -sf ${CON_FILES}/new_maskglo.${NEMOVERSION}.nc new_maskglo.nc
if [ -e ${CON_FILES}/mask.regions.${NEMOVERSION}.nc ] ; then
cp ${CON_FILES}/mask.regions.${NEMOVERSION}.nc mask_regions.nc
......@@ -174,7 +174,7 @@ function concat_startdate {
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`
file1=`echo "${lstfiles}" | tail -n 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
......@@ -205,7 +205,7 @@ function concat_startdate {
if [[ ${lstdims/gsize} != ${lstdims} ]] ; then
ncrename -d gsize,y ${outfile}
fi
lenx=`ncdump -h ${outfile} | grep 'x =' | head -1 | awk '{print $3}'`
lenx=`ncdump -h ${outfile} | grep 'x =' | head -n 1 | awk '{print $3}'`
if [[ $lenx > 1 ]] ; then
if [[ ${lstvars/nav_lon} != ${lstvars} ]] ; then
ncks -O -x -v nav_lon,nav_lat ${outfile} ${outfile}
......@@ -406,17 +406,23 @@ typeset var ntime=`cdo ntime $1`
typeset var list=""
typeset var jt
for jt in $(seq 1 $ntime); do
ncks -d time,$((jt-1)) $1 intvertmeansal.nc
ncks -O -d time,$((jt-1)) $1 intvertmeansal.nc
#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
ncatted -O -a valid_max,deptht,d,, intvertmeansal.nc
ncatted -O -a valid_min,deptht,d,, intvertmeansal.nc
fi
cdfvertmean intvertmeansal.nc vosaline T $2 $3
ncrename -O -v sovertmean,vertmeansal -d time_counter,time -v time_counter,time vertmean.nc
mv vertmean.nc outputvertmeansal_$jt.nc
list=$list" "outputvertmeansal_$jt.nc
rm -f intvertmeansal.nc
#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
ncatted -O -a valid_max,vertmeansal,d,, outputvertmeansal_$jt.nc outputvertmeansal_$jt.nc
ncatted -O -a valid_min,vertmeansal,d,, outputvertmeansal_$jt.nc outputvertmeansal_$jt.nc
fi
# #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
# ncatted -O -a valid_max,vertmeansal,d,, outputvertmeansal_$jt.nc outputvertmeansal_$jt.nc
# ncatted -O -a valid_min,vertmeansal,d,, outputvertmeansal_$jt.nc outputvertmeansal_$jt.nc
# fi
done
cdo cat $list $4
ncks -A -v time $1 $4
......@@ -438,7 +444,7 @@ typeset var list=""
typeset var jt
typeset var lstvars=`cdo showvar $1`
for jt in $(seq 1 $ntime); do
ncks -d time,$((jt-1)) $1 intheat_sal_mxl.nc
ncks -O -d time,$((jt-1)) $1 intheat_sal_mxl.nc
if [[ ${lstvars/somxl010} == ${lstvars} ]] ; then
cdfmxl intheat_sal_mxl.nc mxl.nc
ncrename -d time_counter,time mxl.nc
......@@ -489,7 +495,7 @@ for jt in $(seq 1 $ntime); do
cdo mul intmeantem.nc e3t_file.nc heatc_sl_out.nc
#? ncks -A -m -v nav_lon,nav_lat $1 heatc_sl_out.nc
# extract the data between the two given depths --> heatc_sl_top.nc
ncks -d deptht,$2,$3 heatc_sl_out.nc heatc_sl_top.nc
ncks -O -d deptht,$2,$3 heatc_sl_out.nc heatc_sl_top.nc
#perform the integration of ohc down to that level (main contribution)
ncap2 -O -s 'heatc_sl=heatc_sl.total($deptht)' heatc_sl_top.nc heatc_sl_top.nc
# now extract a few levels below, to compute the residual ohc
......@@ -498,14 +504,14 @@ for jt in $(seq 1 $ntime); do
stripped=`echo ${3/.*}`
# addition with float returned:
lower_bnd=`echo $(printf "%f" $(( $stripped + 200)))`
ncks -d deptht,$3,$lower_bnd heatc_sl_out.nc heatc_sl_bottom.nc
ncks -O -d deptht,$3,$lower_bnd heatc_sl_out.nc heatc_sl_bottom.nc
# obtain the weight for the extra level containing the 300 m
# deptht in the gridT files is positive
# weight = (300.0 - depth_top)/(depth_bottom - depth_top)
# and add the thickness down to 300 m in the next layer
ncpdq -a '-deptht' heatc_sl_top.nc heatc_sl_top_invert.nc
ncks -d deptht,0,0,1 heatc_sl_top_invert.nc level_above.nc
ncks -d deptht,0,0,1 heatc_sl_bottom.nc level_below.nc
ncks -O -d deptht,0,0,1 heatc_sl_top_invert.nc level_above.nc
ncks -O -d deptht,0,0,1 heatc_sl_bottom.nc level_below.nc
## Here, add the residual contribution, before adding it to the main contribution
ncrename -v deptht,layerthcknss level_below.nc
ncrename -v deptht,layerthcknss level_above.nc
......@@ -591,7 +597,7 @@ esac
cdo fldmax -selindexbox,${A1},${A2},${A3},${A4} $1 Labrador.nc
ncrename -v somxl010,Labrador Labrador.nc
ncks -v Labrador Labrador.nc convection.nc
ncks -O -v Labrador Labrador.nc convection.nc
rm -f Labrador.nc
cdo fldmax -selindexbox,${B1},${B2},${B3},${B4} $1 Irminger.nc
......@@ -757,7 +763,7 @@ else
fi
ncrename -O -d y,lat -v nav_lat,lat tmpmoc.nc tmpmoc.nc
ncks -O -v $basin,time,depthw,lat tmpmoc.nc tmpmoc.nc
ncks -d lat,$2,$3 -d depthw,${depmax},${depmin} tmpmoc.nc area_moc.nc
ncks -O -d lat,$2,$3 -d depthw,${depmax},${depmin} tmpmoc.nc area_moc.nc
cdo vertmean area_moc.nc area_ave_moc.nc
ncap -O -s "coslat[lat]=cos(lat[lat]*3.141592657/180.0)" area_ave_moc.nc area_ave_moc2.nc
ncwa -w coslat -a lat area_ave_moc2.nc area_ave_moc3.nc
......@@ -832,7 +838,7 @@ function siasiesiv {
cp ${CON_FILES}/ice_template.nc toto_N.nc
cp ${CON_FILES}/ice_template.nc toto_S.nc
case ${NEMOVERSION} in
'Ec3.0_O1L46'|'Ec3.0_O25L46'|'Ec3.0_O25L75') for var in `cdo showvar $1 | head -1`
'Ec3.0_O1L46'|'Ec3.0_O25L46'|'Ec3.0_O25L75') for var in `cdo showvar $1 | head -n 1`
do
[[ $var = "ice_pres" || $var = "iiceconc" ]] && ncrename -v $var,ileadfra $1
done;;
......@@ -879,8 +885,8 @@ for d in N S;do
ncatted -O -a units,sia,m,c,1000km2 ice_${d}_${2}
ncatted -O -a units,sie,m,c,1000km2 ice_${d}_${2}
ncks -v siv ice_${d}_${2} siv_${d}_${2}1
ncks -v sia ice_${d}_${2} sia_${d}_${2}1
ncks -O -v siv ice_${d}_${2} siv_${d}_${2}1
ncks -O -v sia ice_${d}_${2} sia_${d}_${2}1
ncrename -h -v sia,siv sia_${d}_${2}1
ncbo -O --op_typ=dvd siv_${d}_${2}1 sia_${d}_${2}1 sit_${d}_${2}
ncatted -O -a standard_name,siv,m,c,Mean_sea_ice_thickness sit_${d}_${2}
......@@ -948,9 +954,9 @@ fi
if [[ ${up} -eq 1 ]] ; then
typeset var depmin=0
else
typeset var depmin=`cat depth.txt |head -${up} |tail -1 | awk '{print $2}' | awk '{printf "%.0f",$1}'`
typeset var depmin=`cat depth.txt |head -n ${up} |tail -n 1 | awk '{print $2}' | awk '{printf "%.0f",$1}'`
fi
typeset var depmax=`cat depth.txt |head -${down} |tail -1 | awk '{print $2}' | awk '{printf "%.0f",$1}'`
typeset var depmax=`cat depth.txt |head -n ${down} |tail -n 1 | awk '{print $2}' | awk '{printf "%.0f",$1}'`
cp ${CON_FILES}/heatc_template.nc template_heatc.nc
ncdump template_heatc.nc > template_heatc.cdl
......@@ -1000,7 +1006,7 @@ for jt in $(seq 1 $ntime) ; do
ncrename -d x_2,x tmpohc.nc
fi
if [[ ${lstvars/somxl010} != ${lstvars} ]] ; then
ncks -v somxl010 tmpohc.nc mxl.nc
ncks -O -v somxl010 tmpohc.nc mxl.nc
else
cdfmxl tmpohc.nc mxl.nc
fi
......@@ -1036,9 +1042,9 @@ setminmax ${output}$2 thc uhc
function cutsection {
typeset var ntime=`cdo ntime $1`
typeset var nx=`ncdump -h $1|grep 'x = '|head -1|cut -f3 -d" "`
typeset var ny=`ncdump -h $1|grep 'y = '|head -1|cut -f3 -d" "`
typeset var nz=`ncdump -h $1|grep 'depth'|head -1|cut -f3 -d" "`
typeset var nx=`ncdump -h $1|grep 'x = '|head -n 1|cut -f3 -d" "`
typeset var ny=`ncdump -h $1|grep 'y = '|head -n 1|cut -f3 -d" "`
typeset var nz=`ncdump -h $1|grep 'depth'|head -n 1|cut -f3 -d" "`
cat>section.R<<EOF1
library(ncdf)
# Get latitudes, longitudes, depth, mask
......@@ -1113,12 +1119,12 @@ ncks -h -A -v time $1 $5
###############################################################################
function interp3d {
typeset var nz=`ncdump -h $1|grep 'deptht'|head -1|cut -f3 -d" "`
ln -sf /shared/earth/software/scripts/interpolation/scrip_use scrip_use
typeset var nz=`ncdump -h $1|grep 'deptht'|head -n 1|cut -f3 -d" "`
[[ ! -f scrip_use ]] && ln -sf /shared/earth/software/scripts/interpolation/scrip_use scrip_use
for lev in $(seq 1 $nz) ; do
ncks -d deptht,$((lev-1)) -v $2 $1 tmp_${lev}.nc
ncks -O -d deptht,$((lev-1)) -v $2 $1 tmp_${lev}.nc
ncwa -O -h -a deptht tmp_${lev}.nc tmp_${lev}.nc
ln -sf /esnas/autosubmit/con_files/weigths/${NEMOVERSION}/rmp_${NEMOVERSION}_to_*_lev${lev}.nc rmp_${NEMOVERSION}_to_regular_lev${lev}.nc
[[ ! -f rmp_${NEMOVERSION}_to_regular_lev${lev}.nc ]] && ln -sf /esnas/autosubmit/con_files/weigths/${NEMOVERSION}/rmp_${NEMOVERSION}_to_*_lev${lev}.nc rmp_${NEMOVERSION}_to_regular_lev${lev}.nc
cat > scrip_use_in <<EOF
&remap_inputs
remap_wgt = 'rmp_${NEMOVERSION}_to_regular_lev${lev}.nc'
......@@ -1167,9 +1173,9 @@ function setminmax {
done
typeset name
for name in ${listvars[@]} ; do
typeset var var_max=`ncdump -v $name intmax.nc | tail -2 | head -1 | awk '{print $1}'`
typeset var var_max=`ncdump -v $name intmax.nc | tail -n 2 | head -n 1 | awk '{print $1}'`
ncatted -h -a valid_max,$name,m,f,$var_max $1
typeset var var_min=`ncdump -v $name intmin.nc | tail -2 | head -1 | awk '{print $1}'`
typeset var var_min=`ncdump -v $name intmin.nc | tail -n 2 | head -n 1 | awk '{print $1}'`
ncatted -h -a valid_min,$name,m,f,$var_min $1
done
rm -f intmax.nc intmin.nc
......@@ -1236,11 +1242,11 @@ function gather_memb {
ncks -O -x -v ${varex} $file $file
fi
done
if [[ ! -z "`ncdump -h ${file} | grep ensemble | head -1 | awk '{print $3}' | grep [0-9]`" ]] ; then
typeset var nrec=`ncdump -h ${file} | grep ensemble | head -1 | awk '{print $3}' | grep [0-9]`
if [[ ! -z "`ncdump -h ${file} | grep ensemble | head -n 1 | awk '{print $3}' | grep [0-9]`" ]] ; then
typeset var nrec=`ncdump -h ${file} | grep ensemble | head -n 1 | awk '{print $3}' | grep [0-9]`
typeset var jrec
for jrec in $(seq 1 $nrec) ; do
ncks -d ensemble,$((jrec-1)) $file tmp_record_${ind}.nc
ncks -O -d ensemble,$((jrec-1)) $file tmp_record_${ind}.nc
ncwa -O -a ensemble tmp_record_${ind}.nc tmp_record_${ind}.nc
lstfiles2=${lstfiles2}" "tmp_record_${ind}.nc
ind=$((ind+1))
......@@ -1279,7 +1285,7 @@ function vertmeanvar {
typeset var list=""
typeset var jt
for jt in $(seq 1 $ntime); do
ncks -d time,$((jt-1)) $1 a1
ncks -O -d time,$((jt-1)) $1 a1
# The oras4 data do not have gdepth data in their mask, but only gdept_0, so:
if grep -q nemovar_s4 $1 ; then
l1=$(( $3 % 6 ))
......@@ -1318,8 +1324,8 @@ lev=$3
echo $lev
cp $5 tmp_${lev}.nc
## Here we interpolate horizontally onto a regular grid
ln -sf /esnas/autosubmit/con_files/weigths/${NEMOVERSION}/rmp_${NEMOVERSION}_to_*_lev${lev}.nc rmp_${NEMOVERSION}_to_regular_lev${lev}.nc
ln -sf /shared/earth/software/scripts/interpolation/scrip_use scrip_use
[[ ! -f rmp_${NEMOVERSION}_to_regular_lev${lev}.nc ]] && ln -sf /esnas/autosubmit/con_files/weigths/${NEMOVERSION}/rmp_${NEMOVERSION}_to_*_lev${lev}.nc rmp_${NEMOVERSION}_to_regular_lev${lev}.nc
[[ ! -f scrip_use ]] && ln -sf /shared/earth/software/scripts/interpolation/scrip_use scrip_use
cat > scrip_use_in <<EOF
&remap_inputs
remap_wgt = 'rmp_${NEMOVERSION}_to_regular_lev${lev}.nc'
......
#!/bin/bash
set -evx
module load CDFTOOLS/2.1-foss-2015a CDO NCO
#module load CDFTOOLS/2.1-foss-2015a CDO NCO
function delete {
at now +7 days << EOF
......@@ -422,10 +422,10 @@ for ((yeari=$syeari;yeari<=$syearf;yeari=$(($yeari+intsdate)))) ; do
siasiesiv ${pref}_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc tmp.nc $sea
ncks -v sia ice_N_tmp.nc sia_N_tmp.nc
ncks -v sie ice_N_tmp.nc sie_N_tmp.nc
ncks -v siv ice_N_tmp.nc siv_N_tmp.nc
ncks -v sit ice_N_tmp.nc sit_N_tmp.nc
ncks -O -v sia ice_N_tmp.nc sia_N_tmp.nc
ncks -O -v sie ice_N_tmp.nc sie_N_tmp.nc
ncks -O -v siv ice_N_tmp.nc siv_N_tmp.nc
ncks -O -v sit ice_N_tmp.nc sit_N_tmp.nc
ncrename -h -v sia,sia_$sea sia_N_tmp.nc
ncrename -h -v sie,sie_$sea sie_N_tmp.nc
......@@ -606,7 +606,7 @@ for ((yeari=$syeari;yeari<=$syearf;yeari=$(($yeari+intsdate)))) ; do
# you need to use the concat option rather than the ncrcat one below.
# Any doubt ---> vguemas@ic3.cat
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
lsyrsb=${yeari}${moni}_$((year0-(1-(10#$moni+10)/12)))$(printf "%02d" $(((mon0-13)%12+12)) ).nc
lsyrsb=${yeari}${moni}_$((year0-(1-(10#$mon0+10)/12)))$(printf "%02d" $(((mon0-13)%12+12)) ).nc
lsyrso=${yeari}${moni}_${yearf}$(printf "%02d" ${monf}).nc
if [ -e ${pathout}/${prefix}${lsmbsh}_${lsyrsb} ] ; then
case $post in
......
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