Newer
Older
#!/bin/bash
set -xuve
#griddir=/gpfs/scratch/bsc32/bsc32051/pub/scripts/convert-tm5-grids
griddir=.
newdate=$1
#taxis="settaxis,21450101,00:00:00,1day"
taxis="settaxis,$newdate,00:00:00,1day"
gridname_ifs=L128
griddef_ifs=ICMGGa22e+000000 # copy from /gpfs/scratch/bsc32/bsc32051/pub/scripts/convert-tm5-grids
gridname_AMIP=AMIP
griddef_amip=grid-amip.txt # cdo griddes tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc > grid-amip.txt
Etienne Tourigny
committed
griddef_co2=grid-${grid_co2_emis}.txt
Etienne Tourigny
committed
[ -f namelist.co2box ] && CO2BOX=true || CO2BOX=false
Etienne Tourigny
committed
[[ ${CO2_EMODE} == true ]] && vars_ifs+=" A_CO2_emis A_CO2_veg A_CO2_fire A_CO2_oce"
grids="AMIP L128 B128 A128 R128"
Etienne Tourigny
committed
#[[ ${CO2_EMODE} == true ]] && grids+=" CO2_emis"
grids+=" ${grid_co2_emis}"
Etienne Tourigny
committed
# copy from runtime dir the following files grids.nc areas.nc masks.nc
do
if [[ ${gridname} == AMIP ]] ; then
format=nc
suffix=".nc"
griddef=${griddef_amip}
Etienne Tourigny
committed
elif [[ ${gridname} == CEDS ]] ; then
format=nc
suffix=".nc"
griddef=grid-CEDS.txt
elif [[ ${gridname} == REG_1X1 ]] ; then
Etienne Tourigny
committed
griddef=grid-REG_1X1.txt
else
format=grb1
suffix=".grb"
griddef=${griddef_ifs}
fi
cdo -f $format -setgrid,${griddir}/${griddef} -selvar,${gridname}.msk masks.nc masks_${gridname}${suffix}
cdo -f $format -setgrid,${griddir}/${griddef} -selvar,${gridname}.srf areas.nc areas_${gridname}${suffix}
if [[ ${format} == "grb1" ]] ; then
for t in masks areas ; do
cdo -f nc -setgridtype,regularnn ${t}_${gridname}.grb ${t}_${gridname}.nc
done
fi
Etienne Tourigny
committed
vars_co2=""
vars_co2_co2box=""
vars_co2_ifs=""
if [[ ${CO2BOX} == true ]]; then
model_amip=CO2BOX
model_co2=CO2BOX
Etienne Tourigny
committed
[[ ${CO2_CMODE} == true ]] && vars_co2_co2box="CO2BOX_CO2_cconc CO2BOX_CO2_econc"
[[ ${CO2_CMODE} == true ]] && vars_co2_ifs="A_CO2_cconc A_CO2_econc"
[[ ${CO2_EMODE} == true ]] && vars_co2="CO2BOX_CO2_emis"
Etienne Tourigny
committed
else
model_amip=AMIPFORC
model_co2=AMIPFORC
Etienne Tourigny
committed
[[ ${CO2_EMODE} == true ]] && vars_co2="AMIP_CO2_emis"
Etienne Tourigny
committed
fi
for v in $vars_ifs
do
cdo -O -f grb1 -r $taxis -setgrid,${griddir}/${griddef_ifs} ${v}_${model_ifs}_??.nc ${v}.grb
cdo -O -f nc -r $taxis -setgridtype,regular -chvar,var1,${v} ${v}.grb ${v}.nc
done
for v in $vars_amip
do
HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis -setgrid,${griddir}/${griddef_amip} ${v}_${model_amip}_??.nc ${v}.nc
done
for v in $vars_co2
do
HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis -setgrid,${griddir}/${griddef_co2} ${v}_${model_co2}_??.nc ${v}.nc
done
for v in $vars_co2_co2box
do
HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis ${v}_${model_co2}_??.nc ${v}.nc
done
for v in $vars_co2_ifs
do
HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis ${v}_${model_ifs}_??.nc ${v}.nc
done