dirin1="/prodigfs/project/input4MIPs/UReading/surfaceFluxes/CMIP/NCAR-CCMI-2-0/mon"
dirin2="gn/v20161207"
dirout="./OUTPUT"
if [ ! -d ${dirout} ] ; then mkdir ${dirout} ; fi
#
#--1850 climatological N deposition 
#
drynhx=${dirin1}"/drynhx/"${dirin2}"/drynhx_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-185012-clim.nc"
wetnhx=${dirin1}"/wetnhx/"${dirin2}"/wetnhx_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-185012-clim.nc"
drynoy=${dirin1}"/drynoy/"${dirin2}"/drynoy_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-185012-clim.nc"
wetnoy=${dirin1}"/wetnoy/"${dirin2}"/wetnoy_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-185012-clim.nc"
#
cdo merge $drynhx $wetnhx $dirout/CMIP6_fluxnhx_merged_clim_1850.nc
cdo merge $drynoy $wetnoy $dirout/CMIP6_fluxnoy_merged_clim_1850.nc
cdo expr,'fluxnhx=drynhx+wetnhx' $dirout/CMIP6_fluxnhx_merged_clim_1850.nc $dirout/CMIP6_fluxnhx_clim_1850.nc
cdo expr,'fluxnoy=drynoy+wetnoy' $dirout/CMIP6_fluxnoy_merged_clim_1850.nc $dirout/CMIP6_fluxnoy_clim_1850.nc
rm -f $dirout/CMIP6_fluxnhx_merged_clim_1850.nc $dirout/CMIP6_fluxnoy_merged_clim_1850.nc
#
#
#--1850-2014 annual N deposition 
#
drynhx=${dirin1}"/drynhx/"${dirin2}"/drynhx_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-201412.nc"
wetnhx=${dirin1}"/wetnhx/"${dirin2}"/wetnhx_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-201412.nc"
drynoy=${dirin1}"/drynoy/"${dirin2}"/drynoy_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-201412.nc"
wetnoy=${dirin1}"/wetnoy/"${dirin2}"/wetnoy_input4MIPs_surfaceFluxes_CMIP_NCAR-CCMI-2-0_gn_185001-201412.nc"
#
cdo merge $drynhx $wetnhx $dirout/CMIP6_fluxnhx_merged_annual_1850-2014.nc
cdo merge $drynoy $wetnoy $dirout/CMIP6_fluxnoy_merged_annual_1850-2014.nc
cdo splityear -expr,'fluxnhx=drynhx+wetnhx' $dirout/CMIP6_fluxnhx_merged_annual_1850-2014.nc $dirout/CMIP6_fluxnhx_annual_
cdo splityear -expr,'fluxnoy=drynoy+wetnoy' $dirout/CMIP6_fluxnoy_merged_annual_1850-2014.nc $dirout/CMIP6_fluxnoy_annual_
rm -f $dirout/CMIP6_fluxnhx_merged_annual_1850-2014.nc $dirout/CMIP6_fluxnoy_merged_annual_1850-2014.nc
