Index: TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_OXY.sh
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_OXY.sh	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_OXY.sh	(revision 4004)
@@ -0,0 +1,49 @@
+#--weights on RCPs to yield ssp oxidant files
+#--Th. Lurton, IPSL, 07/2018
+
+# ssp1-19 = 19/26*RCP26
+# ssp1-26 = RCP26
+# ssp2-45 = RCP45
+# ssp3-70 = .4*RCP85 + .6*RCP60
+# ssp4-34 = 8/19*RCP45 + 11/19*RCP26
+# ssp4-60 = .6*RCP60 + .4*RCP45
+# ssp5-34-over = 8/19*RCP45 + 11/19*RCP26
+# ssp5-85 = RCP85
+
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp119 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp119 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp126 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp126 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp245 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp245 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp370 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp370 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp434 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp434 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp460 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp460 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp534-over ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp534-over ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp585 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp585 ; fi
+
+#--creating specific file "RCP0" for RCP26-->ssp119 weighting
+fileinRCP0=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/LOI_AR6_RCP0.nc
+rm -f ${fileinRCP0}
+ncrcat /ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/yearly_interp/LOI_AR6_RCP26_201[05].nc /ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/LOI_AR6_RCP26_2010-2015.nc
+cdo ymonmean /ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/LOI_AR6_RCP26_2010-2015.nc ${fileinRCP0}
+rm -f /ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/LOI_AR6_RCP26_2010-2015.nc
+
+for year in {2015..2100}
+do
+
+echo '... processing year '${year}'...'
+
+fileinRCP26=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/yearly_interp/LOI_AR6_RCP26_${year}.nc
+fileinRCP45=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/yearly_interp/LOI_AR6_RCP45_${year}.nc
+fileinRCP60=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/yearly_interp/LOI_AR6_RCP60_${year}.nc
+fileinRCP85=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/yearly_interp/LOI_AR6_RCP85sstA2_${year}.nc
+
+cdo add -mulc,19. -divc,26. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP26} -mulc,7. -divc,26. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP0} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp119/oxidants_ssp119_${year}.nc
+cp ${fileinRCP26} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp126/oxidants_ssp126_${year}.nc
+cp ${fileinRCP45} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp245/oxidants_ssp245_${year}.nc
+cdo add -mulc,.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP85} -mulc,.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP60} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp370/oxidants_ssp370_${year}.nc
+cdo add -mulc,8. -divc,19. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP45} -mulc,11. -divc,19. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP26} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp434/oxidants_ssp434_${year}.nc
+cdo add -mulc,.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP60} -mulc,.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP45} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp460/oxidants_ssp460_${year}.nc
+cdo add -mulc,8. -divc,19. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP45} -mulc,11. -divc,19. -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${fileinRCP26} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp534-over/oxidants_ssp534-over_${year}.nc
+cp ${fileinRCP85} ${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/Scenarios/ssp585/oxidants_ssp585_${year}.nc
+
+#--end loop on years
+done
Index: TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_SSTSIC.sh
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_SSTSIC.sh	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/RCP_to_ssp_SSTSIC.sh	(revision 4004)
@@ -0,0 +1,94 @@
+#--Weights on RCPs to yield ssp limit files.
+#--This script requires output from script SST_SIC_anomaly.sh.
+#--Th. Lurton, IPSL, 07/2018.
+
+# ssp1-19 = 19/26*RCP26
+# ssp1-26 = RCP26
+# ssp2-45 = RCP45
+# ssp3-70 = .4*RCP85 + .6*RCP60
+# ssp4-34 = 8/19*RCP45 + 11/19*RCP26
+# ssp4-60 = .6*RCP60 + .4*RCP45
+# ssp5-34-over = 8/19*RCP45 + 11/19*RCP26
+# ssp5-85 = RCP85
+
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp119 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp119 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp126 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp126 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp245 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp245 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp370 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp370 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp434 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp434 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp460 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp460 ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp534-over ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp534-over ; fi
+if [ ! -d ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp585 ] ; then mkdir -p ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp585 ; fi
+
+#--We need specific data for the ssp119 ponderation, which will be refered to as RCP0
+fileSSTAMIP=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/AMIP/tos_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc
+fileSICAMIP=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/AMIP/siconc_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc
+gridfile=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/GRID/grid_MR_CMIP5
+#--For SST
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileSSTAMIP} ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc
+cdo addc,273.15 -selvar,tos ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc
+cdo remapcon,${gridfile} ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc
+ncrename -v tos,tsol_oce ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SST_RCP0.nc
+rm -f ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc
+#--For SIC
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileSICAMIP} ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc
+cdo remapcon,${gridfile} ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc
+ncrename -v siconc,pourc_sic ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/rcp26/v5.rcp26MR1_20060101_21001231_1M_pourc_lic.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc
+ncrename -v pourc_lic,pourc_sic ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/lic_RCP0.nc
+cdo sub ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/lic_RCP0.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp3.nc
+ncap2 -s 'where(pourc_sic>100.) pourc_sic=100;' ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp3.nc -O ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc
+ncap2 -s 'where(pourc_sic<0.) pourc_sic=0;' ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SIC_RCP0.nc
+rm -f ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp1.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp2.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/tmp3.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/lic_RCP0.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SSTAMIP.nc ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SICAMIP.nc
+
+for year in {2015..2100}
+do
+
+fileSSTRCP26=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp26/OUT_anocorr/v5.rcp26MR1_tsol_oce_${year}_anocorr.nc
+fileSSTRCP45=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp45/OUT_anocorr/v5.rcp45MR1_tsol_oce_${year}_anocorr.nc
+fileSSTRCP60=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp60/OUT_anocorr/v5.rcp60MR1_tsol_oce_${year}_anocorr.nc
+fileSSTRCP85=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp85/OUT_anocorr/v5.rcp85MR1_tsol_oce_${year}_anocorr.nc
+
+fileSICRCP26=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp26/OUT_anocorr/v5.rcp26MR1_pourc_sic_${year}_anocorr.nc
+fileSICRCP45=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp45/OUT_anocorr/v5.rcp45MR1_pourc_sic_${year}_anocorr.nc
+fileSICRCP60=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp60/OUT_anocorr/v5.rcp60MR1_pourc_sic_${year}_anocorr.nc
+fileSICRCP85=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/Scenarios/rcp85/OUT_anocorr/v5.rcp85MR1_pourc_sic_${year}_anocorr.nc
+
+outSSTssp119=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp119/tsol_oce_ssp119_${year}.nc
+outSSTssp126=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp126/tsol_oce_ssp126_${year}.nc
+outSSTssp245=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp245/tsol_oce_ssp245_${year}.nc
+outSSTssp370=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp370/tsol_oce_ssp370_${year}.nc
+outSSTssp434=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp434/tsol_oce_ssp434_${year}.nc
+outSSTssp460=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp460/tsol_oce_ssp460_${year}.nc
+outSSTssp534=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp534-over/tsol_oce_ssp534-over_${year}.nc
+outSSTssp585=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp585/tsol_oce_ssp585_${year}.nc
+
+outSICssp119=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp119/pourc_sic_ssp119_${year}.nc
+outSICssp126=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp126/pourc_sic_ssp126_${year}.nc
+outSICssp245=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp245/pourc_sic_ssp245_${year}.nc
+outSICssp370=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp370/pourc_sic_ssp370_${year}.nc
+outSICssp434=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp434/pourc_sic_ssp434_${year}.nc
+outSICssp460=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp460/pourc_sic_ssp460_${year}.nc
+outSICssp534=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp534-over/pourc_sic_ssp534-over_${year}.nc
+outSICssp585=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/Scenarios/ssp585/pourc_sic_ssp585_${year}.nc
+
+cdo -L add -mulc,19. -divc,26. -selname,tsol_oce ${fileSSTRCP26} -mulc,7. -divc,26. -selname,tsol_oce ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SST_RCP0.nc ${outSSTssp119}
+cp ${fileSSTRCP26} ${outSSTssp126}
+cp ${fileSSTRCP45} ${outSSTssp245}
+cdo -L add -mulc,.4 -selname,tsol_oce ${fileSSTRCP85} -mulc,.6 -selname,tsol_oce ${fileSSTRCP60} ${outSSTssp370} 
+cdo -L add -mulc,8. -divc,19. -selname,tsol_oce ${fileSSTRCP45} -mulc,11. -divc,19. -selname,tsol_oce ${fileSSTRCP26} ${outSSTssp434} 
+cdo -L add -mulc,.6 -selname,tsol_oce ${fileSSTRCP60} -mulc,.4 -selname,tsol_oce ${fileSSTRCP45} ${outSSTssp460}
+cdo -L add -mulc,8. -divc,19. -selname,tsol_oce ${fileSSTRCP45} -mulc,11. -divc,19. -selname,tsol_oce ${fileSSTRCP26} ${outSSTssp534}
+cp ${fileSSTRCP85} ${outSSTssp585}
+
+cdo -L add -mulc,19. -divc,26. -selname,pourc_sic ${fileSICRCP26} -mulc,7. -divc,26. -selname,pourc_sic ${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/SIC_RCP0.nc ${outSICssp119}
+cp ${fileSICRCP26} ${outSICssp126}
+cp ${fileSICRCP45} ${outSICssp245}
+cdo -L add -mulc,.4 -selname,pourc_sic ${fileSICRCP85} -mulc,.6 -selname,pourc_sic ${fileSICRCP60} ${outSICssp370}
+cdo -L add -mulc,8. -divc,19. -selname,pourc_sic ${fileSICRCP45} -mulc,11. -divc,19. -selname,pourc_sic ${fileSICRCP26} ${outSICssp434}
+cdo -L add -mulc,.6 -selname,pourc_sic ${fileSICRCP60} -mulc,.4 -selname,pourc_sic ${fileSICRCP45} ${outSICssp460}
+cdo -L add -mulc,8. -divc,19. -selname,pourc_sic ${fileSICRCP45} -mulc,11. -divc,19. -selname,pourc_sic ${fileSICRCP26} ${outSICssp534}
+cp ${fileSICRCP85} ${outSICssp585}
+
+#--end loop on years
+done
Index: TOOLS/CMIP6_FORCING/SCENARIOS/README_OXY
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/README_OXY	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/README_OXY	(revision 4004)
@@ -0,0 +1,22 @@
+-------------------
+"oxidant.sh" generates oxidant forcing files for the historical period, and for scenarios RCP45, RCP60, RCP85sstA2 and RCP26.
+
+<!> This script must be run on Curie (not Ciclad) <!>
+As of 2nd July 2018, it was Irene-compatible.
+
+Output files will be found in directory $WORK/CMIP6_OXIDANTS/
+One file will be output per decade (= first year of the decade): 16 files for the historical period (1850..2000), and 10 files for each of the 4 RCP scenarios (2010..2100).
+
+--------------------
+Script "interp_time_OXY.sh" is to be run afterwards, to generate similar files year by year.
+
+--------------------
+Script "RCP_to_ssp_OXY.sh" performs weighting between CMIP5 RCP's to yield CMIP6 ssp's (based on 2100 forcing). Weights are detailled in file "correspondances_RCP_to_ssp.txt".
+
+
+Roadmap:
+1) oxidant.sh
+2) interp_time_OXY.sh
+3) RCP_to_ssp_OXY.sh
+
+--- ThL 7/2018
Index: TOOLS/CMIP6_FORCING/SCENARIOS/README_SSTSIC
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/README_SSTSIC	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/README_SSTSIC	(revision 4004)
@@ -0,0 +1,5 @@
+Script SST_SIC_anomaly.sh will correct the bias between CMIP5 RCP's and the AMIP.
+
+Script RCP_to_ssp_SSTSIC.sh is to be run afterwards, and will derive the eight ssp SST and SIC sets of data by weighting the bias-corrected RCP's.
+
+Th.Lurton, IPSL, 07/2018.
Index: TOOLS/CMIP6_FORCING/SCENARIOS/SST_SIC_anomaly.sh
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/SST_SIC_anomaly.sh	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/SST_SIC_anomaly.sh	(revision 4004)
@@ -0,0 +1,128 @@
+#--Script performing bias-correction of RCP scenarios with the AMIP runs
+#--over SST and SIC.
+#--Th. Lurton, IPSL, 07/2018
+
+#--working directory
+ici=${GENCMIP6_CCCWORKDIR}/CMIP6_LIMIT/
+if [ ! -d ${ici} ] ; then mkdir -p ${ici} ; fi
+
+gridfile=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/GRID/grid_MR_CMIP5
+
+#--AMIP input files
+dirinAMIP=/ccc/work/cont003/gencmip6/lurtont/CMIP6_LIMIT/AMIP/
+
+#--performing horizontal remapping for AMIP files between 2006 and 2017
+fileintsoloceAMIP=${dirinAMIP}tos_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc
+fileinpourcsicAMIP=${dirinAMIP}siconc_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-4_gn_187001-201712.nc
+
+fileinSSTyearsAMIP=${ici}SST_AMIP_2006_2017.nc
+fileinSICyearsAMIP=${ici}SIC_AMIP_2006_2017.nc
+
+cdo -seldate,2006-01-01,2017-12-31 ${fileintsoloceAMIP} ${fileinSSTyearsAMIP}
+cdo -seldate,2006-01-01,2017-12-31 ${fileinpourcsicAMIP} ${fileinSICyearsAMIP}
+
+#--AMIP files remapped to CMIP5-MR grid
+fileremaptsoloceAMIP=${ici}amipbc_sst_remapped_2006_2017.nc
+fileremappourcsicAMIP=${ici}amipbc_sic_remapped_2006_2017.nc
+
+echo "Remapping AMIP SST file towards CMIP5 MR grid, for years 2006-2017..."
+cdo remapcon,${gridfile} ${fileinSSTyearsAMIP} ${fileremaptsoloceAMIP}
+echo "Remapping AMIP SIC file towards CMIP5 MR grid, for years 2006-2017..."
+cdo remapcon,${gridfile} ${fileinSICyearsAMIP} ${fileremappourcsicAMIP}
+
+
+#--loop on RCPs
+for rcp in rcp26 rcp45 rcp60 rcp85
+do
+
+if [ ${rcp} == "rcp26" ] ; then dirinRCP=/ccc/store/cont003/dsmipsl/p86maf/dmf_import/IGCM_OUT/IPSLCM5A-MR/PROD/rcp26/v5.rcp26MR1/ATM/Analyse/TS_MO/ ; fi
+if [ ${rcp} == "rcp45" ] ; then dirinRCP=/ccc/store/cont003/dsmipsl/p86maf/dmf_import/IGCM_OUT/IPSLCM5A-MR/PROD/rcp45/v5.rcp45MR1/ATM/Analyse/TS_MO/ ; fi
+if [ ${rcp} == "rcp60" ] ; then dirinRCP=/ccc/store/cont003/dsm/p86denv/IGCM_OUT/IPSLCM5A-MR/PROD/rcp60/v5.rcp60MR1/ATM/Analyse/TS_MO/ ; fi
+if [ ${rcp} == "rcp85" ] ; then dirinRCP=/ccc/store/cont003/dsmipsl/p86maf/dmf_import/IGCM_OUT/IPSLCM5A-MR/PROD/rcp85/v5.rcp85MR1/ATM/Analyse/TS_MO/ ; fi
+
+rcpdir=${ici}Scenarios/${rcp}/
+if [ ! -d ${rcpdir} ] ; then mkdir -p ${rcpdir} ; fi
+
+rcpsplitdir=${rcpdir}split/
+if [ ! -d ${rcpsplitdir} ] ; then mkdir -p ${rcpsplitdir} ; fi
+
+#--RCP input files
+fileintsoloceRCP=${dirinRCP}v5.${rcp}MR1_20060101_21001231_1M_tsol_oce.nc
+fileinpourcsicRCP=${dirinRCP}v5.${rcp}MR1_20060101_21001231_1M_pourc_sic.nc
+fileinpourclicRCP=${dirinRCP}v5.${rcp}MR1_20060101_21001231_1M_pourc_lic.nc
+
+#--splitting years
+echo ${rcp}": splitting years for SST..."
+cdo splityear ${fileintsoloceRCP} ${rcpsplitdir}v5.${rcp}MR1_tsol_oce_
+echo ${rcp}": splitting years for SIC..."
+cdo splityear ${fileinpourcsicRCP} ${rcpsplitdir}v5.${rcp}MR1_pourc_sic_
+echo ${rcp}": splitting years for LIC..."
+cdo splityear ${fileinpourclicRCP} ${rcpsplitdir}v5.${rcp}MR1_pourc_lic_
+
+dirout=${rcpdir}/OUT_anocorr/
+if [ ! -d ${dirout} ] ; then mkdir -p ${dirout} ; fi
+
+tmpavgsstAMIP=${ici}tmpavgsstAMIP.nc
+tmpavgsicAMIP=${ici}tmpavgsicAMIP.nc
+tmpavgsstRCP=${ici}tmpavgsstRCP.nc
+tmpavgsicRCP=${ici}tmpavgsicRCP.nc
+tmpavglicRCP=${ici}tmpavglicRCP.nc
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileremaptsoloceAMIP} ${tmpavgsstAMIP}
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileremappourcsicAMIP} ${tmpavgsicAMIP}
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileintsoloceRCP} ${ici}sstRCP.nc
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileinpourcsicRCP} ${ici}sicRCP.nc
+cdo ymonmean -seldate,2006-01-01,2017-12-31 ${fileinpourclicRCP} ${tmpavglicRCP}
+ncrename -v siconc,pourc_sic ${tmpavgsicAMIP}
+ncrename -v tos,tsol_oce ${tmpavgsstAMIP} -O ${ici}tmp.nc
+cdo expr,'tsol_oce=tsol_oce+273.15' ${ici}tmp.nc ${tmpavgsstAMIP}
+rm -f ${ici}tmp.nc
+ncrename -v time,time_counter -d time,time_counter ${tmpavgsstAMIP}
+ncrename -v time,time_counter -d time,time_counter ${tmpavgsicAMIP}
+ncrename -v pourc_lic,pourc_sic ${tmpavglicRCP} -O ${ici}tmp.nc
+ncks -C -O -x -v aire ${ici}tmp.nc ${tmpavglicRCP}
+rm -f ${ici}tmp.nc
+ncks -C -O -x -v aire ${ici}sstRCP.nc ${tmpavgsstRCP}
+ncks -C -O -x -v aire ${ici}sicRCP.nc ${tmpavgsicRCP}
+rm -f ${ici}sstRCP.nc ${ici}sicRCP.nc
+
+for year in {2015..2100}
+do
+
+echo ${rcp}": Correcting anomaly for year "${year}"..."
+
+fileyeartsoloceRCP=${rcpsplitdir}v5.${rcp}MR1_tsol_oce_${year}.nc
+fileouttsoloce=${dirout}v5.${rcp}MR1_tsol_oce_${year}_anocorr.nc
+
+fileyearpourcsicRCP=${rcpsplitdir}v5.${rcp}MR1_pourc_sic_${year}.nc
+fileoutpourcsic=${dirout}v5.${rcp}MR1_pourc_sic_${year}_anocorr.nc
+
+ncks -C -O -x -v aire ${fileyeartsoloceRCP} ${ici}tmpyearSST.nc
+ncks -C -O -x -v aire ${fileyearpourcsicRCP} ${ici}tmpyearSIC.nc
+
+#--performing anomaly corrections
+echo "... for SST..."
+cdo add -sub ${ici}tmpyearSST.nc ${tmpavgsstRCP} ${tmpavgsstAMIP} ${fileouttsoloce}
+echo "... for SIC, as SIC = SIC(RCP) + <SICLIC(AMIP)> - <SIC(RCP)> - <LIC(RCP)>..."
+cdo add -sub ${ici}tmpyearSIC.nc ${tmpavgsicRCP} ${tmpavgsicAMIP} ${ici}tmp.nc
+cdo sub ${ici}tmp.nc ${tmpavglicRCP} ${fileoutpourcsic}
+rm -f ${ici}tmp.nc
+#--clipping of pourc_sic values between 0 and 100
+ncap2 -s 'where(pourc_sic>100.) pourc_sic=100;' ${fileoutpourcsic} -O ${ici}tmp.nc
+ncap2 -s 'where(pourc_sic<0.) pourc_sic=0;' ${ici}tmp.nc -O ${fileoutpourcsic}
+rm -f ${ici}tmp.nc ${ici}tmpyearSST.nc ${ici}tmpyearSIC.nc
+
+#--end loop on years
+done
+
+echo "Cleaning up..."
+rm -f ${tmpavgsstAMIP} ${tmpavgsicAMIP} ${tmpavgsstRCP} ${tmpavgsicRCP} ${tmpavglicRCP}
+rm -rf ${rcpsplitdir}
+
+#--end loop on RCPs
+done
+
+#--cleaning up remapped AMIPs
+echo "Cleaning up..."
+rm -f ${ici}amipbc_sst_2006_2017_remapped.nc
+rm -f ${ici}amipbc_sic_2006_2017_remapped.nc
+echo "...OK!"
Index: TOOLS/CMIP6_FORCING/SCENARIOS/interp_time_OXY.sh
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/interp_time_OXY.sh	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/interp_time_OXY.sh	(revision 4004)
@@ -0,0 +1,308 @@
+#--Script performing a linear time interpolation
+#--in order to yield every year between decade-years
+#--for oxidant files.
+#--Th. Lurton, IPSL, 07/2018
+
+dirinOXY=/ccc/work/cont003/gencmip6/lurtont/CMIP6_OXIDANTS/
+diroutOXY=${GENCMIP6_CCCWORKDIR}/CMIP6_OXIDANTS/yearly_interp/
+
+if [ ! -d ${diroutOXY} ] ; then mkdir -p ${diroutOXY} ; fi
+
+#--historical
+hist=$false
+if [ $hist ] ; then
+for year in {1850..1999}  #--note that the whole hist period is not covered
+do
+
+echo "Historical period, interpolation for year "${year}"..."
+
+if [ ${year} -ge 1850 -a ${year} -lt 1860 ]
+then
+year1=1850
+year2=1860
+fi
+if [ ${year} -ge 1860 -a ${year} -lt 1870 ]
+then
+year1=1860
+year2=1870
+fi
+if [ ${year} -ge 1870 -a ${year} -lt 1880 ]
+then
+year1=1870
+year2=1880
+fi
+if [ ${year} -ge 1880 -a ${year} -lt 1890 ]
+then
+year1=1880
+year2=1890
+fi
+if [ ${year} -ge 1890 -a ${year} -lt 1900 ]
+then
+year1=1890
+year2=1900
+fi
+if [ ${year} -ge 1900 -a ${year} -lt 1910 ]
+then
+year1=1900
+year2=1910
+fi
+if [ ${year} -ge 1910 -a ${year} -lt 1920 ]
+then
+year1=1910
+year2=1920
+fi
+if [ ${year} -ge 1920 -a ${year} -lt 1930 ]
+then
+year1=1920
+year2=1930
+fi
+if [ ${year} -ge 1930 -a ${year} -lt 1940 ]
+then
+year1=1930
+year2=1940
+fi
+if [ ${year} -ge 1940 -a ${year} -lt 1950 ]
+then
+year1=1940
+year2=1950
+fi
+if [ ${year} -ge 1950 -a ${year} -lt 1960 ]
+then
+year1=1950
+year2=1960
+fi
+if [ ${year} -ge 1960 -a ${year} -lt 1970 ]
+then
+year1=1960
+year2=1970
+fi
+if [ ${year} -ge 1970 -a ${year} -lt 1980 ]
+then
+year1=1970
+year2=1980
+fi
+if [ ${year} -ge 1980 -a ${year} -lt 1990 ]
+then
+year1=1980
+year2=1990
+fi
+if [ ${year} -ge 1990 -a ${year} -lt 2000 ]
+then
+year1=1990
+year2=2000
+fi
+
+file1=${dirinOXY}LOI_AR6_${year1}.nc
+file2=${dirinOXY}LOI_AR6_${year2}.nc
+filetmp=${diroutOXY}tmp.nc
+fileout=${diroutOXY}LOI_AR6_${year}.nc
+
+#--using separate file with time_counter and time_bnds
+#--to yield correct time_counter and time_bnds
+echo "... Creating time pattern for year "${year}", scenario "${scen}"..."
+filetimes=${diroutOXY}times_${year}.nc
+cdo addc,$(((${year}-1850)*365*24*3600)) -selname,time_counter,time_bnds ${dirinOXY}LOI_AR6_1850.nc ${filetmp}
+#--something weird happens, as time_counter is declared not found, and is not shifted as should be (time_bnds is). I am here forcing the shift by hand.
+cdo shifttime,$(((${year}-1850)*365))days ${filetmp} ${filetimes}
+ncrename -d x,bnds ${filetimes}
+
+if [ ${year:3:1} == 1 ]
+then
+cdo add -mulc,0.9 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.1 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 2 ]
+then
+cdo add -mulc,0.8 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.2 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 3 ]
+then
+cdo add -mulc,0.7 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.3 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 4 ]
+then
+cdo add -mulc,0.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 5 ]
+then
+cdo add -mulc,0.5 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.5 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 6 ]
+then
+cdo add -mulc,0.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 7 ]
+then
+cdo add -mulc,0.3 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.7 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 8 ]
+then
+cdo add -mulc,0.2 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.8 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 9 ]
+then
+cdo add -mulc,0.1 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.9 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+#--nothing to be done if we are on a decade-year.
+if [ ${year:3:1} == 0 ]
+then
+ncks -v H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+
+#--fixing presnivs, presnivs_bnds, time_counter and time_bnds
+echo "... Fixing presnivs, presnivs_bnds, time_counter and time_bnds for year "${year}", scenario "${scen}"..."
+ncks -A -v time_counter,time_bnds ${filetimes} ${filetmp}
+ncks -A -v presnivs,presnivs_bnds ${dirinOXY}LOI_AR6_1850.nc ${filetmp}
+cp ${filetmp} ${fileout}
+rm -f ${filetmp}
+
+#--end loop on historical years
+done
+
+#--skip historical
+fi 
+
+#--Scenarios
+
+for scen in "RCP26" "RCP45" "RCP60" "RCP85sstA2"
+do
+
+for year in {2000..2100}
+do
+
+echo "Scenario "${scen}", interpolation for year "${year}"..."
+
+if [ ${year} -ge 2000 -a ${year} -lt 2010 ]
+then
+year1=2000
+year2=2010
+fi
+if [ ${year} -ge 2010 -a ${year} -lt 2020 ]
+then
+year1=2010
+year2=2020
+fi
+if [ ${year} -ge 2020 -a ${year} -lt 2030 ]
+then
+year1=2020
+year2=2030
+fi
+if [ ${year} -ge 2030 -a ${year} -lt 2040 ]
+then
+year1=2030
+year2=2040
+fi
+if [ ${year} -ge 2040 -a ${year} -lt 2050 ]
+then
+year1=2040
+year2=2050
+fi
+if [ ${year} -ge 2050 -a ${year} -lt 2060 ]
+then
+year1=2050
+year2=2060
+fi
+if [ ${year} -ge 2060 -a ${year} -lt 2070 ]
+then
+year1=2060
+year2=2070
+fi
+if [ ${year} -ge 2070 -a ${year} -lt 2080 ]
+then
+year1=2070
+year2=2080
+fi
+if [ ${year} -ge 2080 -a ${year} -lt 2090 ]
+then
+year1=2080
+year2=2090
+fi
+if [ ${year} -ge 2090 -a ${year} -lt 2100 ]
+then
+year1=2090
+year2=2100
+fi
+if [ ${year} == 2100 ]
+then
+year1=2100
+year2=2100
+fi
+
+file1=${dirinOXY}LOI_AR6_${scen}_${year1}.nc
+file2=${dirinOXY}LOI_AR6_${scen}_${year2}.nc
+filetmp=${diroutOXY}tmp.nc
+fileout=${diroutOXY}LOI_AR6_${scen}_${year}.nc
+
+#--specific case for junction with historical -- year2=2010 is correct, but year1=2000 does not exist for scenarios. Let's override that...
+if [ ${year} -lt 2010 ]
+then
+file1=${dirinOXY}LOI_AR6_2000.nc
+fi
+
+rm -f ${diroutOXY}tmp.nc
+
+#--using separate file with time_counter and time_bnds
+#--to yield correct time_counter and time_bnds
+echo "... Creating time pattern for year "${year}", scenario "${scen}"..."
+filetimes=${diroutOXY}times_${year}.nc
+cdo addc,$(((${year}-2000)*365*24*3600)) -selname,time_counter,time_bnds ${dirinOXY}LOI_AR6_2000.nc ${filetmp}
+#--something weird happens, as time_counter is declared not found, and is not shifted as should be (time_bnds is). I am here forcing the shift by hand.
+cdo shifttime,$(((${year}-2000)*365))days ${filetmp} ${filetimes}
+ncrename -d x,bnds ${filetimes}
+
+rm -f ${filetmp}
+
+if [ ${year:3:1} == 1 ]
+then
+cdo add -mulc,0.9 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.1 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 2 ]
+then
+cdo add -mulc,0.8 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.2 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 3 ]
+then
+cdo add -mulc,0.7 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.3 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 4 ]
+then
+cdo add -mulc,0.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 5 ]
+then
+cdo add -mulc,0.5 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.5 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 6 ]
+then
+cdo add -mulc,0.4 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.6 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 7 ]
+then
+cdo add -mulc,0.3 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.7 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 8 ]
+then
+cdo add -mulc,0.2 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.8 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 9 ]
+then
+cdo add -mulc,0.1 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file1} -mulc,0.9 -selname,H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+if [ ${year:3:1} == 0 ]
+then
+ncks -v H2O2,HNO3,NO2,NO3,O1D,O3,OH ${file2} ${filetmp}
+fi
+
+#--fixing presnivs, presnivs_bnds, time_counter and time_bnds
+echo "... Fixing presnivs, presnivs_bnds, time_counter and time_bnds for year "${year}", scenario "${scen}"..."
+ncks -A -v time_counter,time_bnds ${filetimes} ${filetmp}
+ncks -A -v presnivs,presnivs_bnds ${dirinOXY}LOI_AR6_RCP26_2010.nc ${filetmp}
+cp ${filetmp} ${fileout}
+rm -f ${filetmp}
+
+#--end loop on years
+done
+
+rm -f ${diroutOXY}times*.nc
+
+#--end loop on scenario names
+done
Index: TOOLS/CMIP6_FORCING/SCENARIOS/oxidant.sh
===================================================================
--- TOOLS/CMIP6_FORCING/SCENARIOS/oxidant.sh	(revision 4004)
+++ TOOLS/CMIP6_FORCING/SCENARIOS/oxidant.sh	(revision 4004)
@@ -0,0 +1,228 @@
+#--scripts to regrid oxidant files from AR5 to AR6 
+#--Olivier Boucher / Yves Balkanski 
+#--30/01/2017
+#--Thibaut Lurton 28/06/2017 for the future period.
+#
+OUT=$CCCWORKDIR/CMIP6_OXIDANTS/
+
+if [ ! -d ${OUT} ] ; then mkdir -p ${OUT} ; fi
+
+# Booleans for possible bypass of processing (1=do bypass ; 0=run)
+bypass_hist=0
+bypass_RCP=0
+
+#--silly if statements to perform or bypass historical files
+if [ ${bypass_hist} == 0 ]; then
+#
+#HISTORICAL
+DIR=/ccc/store/cont003/dsm/p24lava/ARCHIVE/dmf_import/IGCM_OUT/LMDZORINCA/NMHC_AER/LOI_IPCC_3/CHM/Output/MO/INCA_AVGR_NC/
+#
+#--loop on years
+for yr in `seq 1850 10 2000`
+do 
+  #--loop on months
+  for mth in 0{1..9} {10..12} 
+  do
+    echo $yr $mth
+    filein=${DIR}'LOI_IPCC_3_'${yr}'_'${mth}'_MM_inca_avgr.nc'
+    fileout=${OUT}'LOI_AR5_'${yr}'_'${mth}'.nc'
+    #--remapping
+    cdo remapbil,grid-lmdz-lonlat_144x143 -selname,O3,HNO3,OH,NO3,H2O2,O1D,NO2 ${filein} ${fileout}
+  done
+  #--merging monthly means into single sile
+  cdo mergetime ${OUT}'LOI_AR5_'${yr}'_'??'.nc' ${OUT}'LOI_AR5_'${yr}'.nc'
+  rm -f ${OUT}'LOI_AR5_'${yr}'_'??'.nc'
+  #--change time axis - this does not work
+  #secsinyr=31557600
+  #yearref=1850
+  #if [ $yr != 1850 ]; then
+  #   ((nbyear=$yr-$yearref))
+  #   echo "yr, secsinyr=" $year $secsinyr
+  #   ((secsdiff = $yr * $secsinyr ))
+  #   echo "secsdiff=" $secsdiff
+  #   rm -f time_${yr}.nc
+  #   ncap2 -s"time=${secsdiff}" time_1850.nc time_${yr}.nc   
+  #fi
+  #--remove time
+  ncks -x -v time ${OUT}'LOI_AR5_'${yr}'.nc' ${OUT}'LOI_AR5_'${yr}'_notime.nc'
+  #--add time from Yves files
+  ncks -A -v time time_${yr}.nc ${OUT}'LOI_AR5_'${yr}'_notime.nc'
+  #--rename file
+  mv ${OUT}'LOI_AR5_'${yr}'_notime.nc' ${OUT}'LOI_AR5_'${yr}'_time.nc'
+  #--regrid vertically 
+ferret << EOF
+set MEMORY/SIZE=1024
+use "${OUT}LOI_AR5_${yr}_time.nc"
+use grid.nc
+define grid/z=Z[g=OZONE] grid79L
+let H2O2L79=H2O2[d=1,g=grid79L,gz=@AVE] 
+let HNO3L79=HNO3[d=1,g=grid79L,gz=@AVE] 
+let NO2L79=NO2[d=1,g=grid79L,gz=@AVE] 
+let NO3L79=NO3[d=1,g=grid79L,gz=@AVE]
+let O1DL79=O1D[d=1,g=grid79L,gz=@AVE]
+let O3L79=O3[d=1,g=grid79L,gz=@AVE] 
+let OHL79=OH[d=1,g=grid79L,gz=@AVE]
+SAVE/format=CDF/CLOBBER/file="${OUT}LOI_AR6_${yr}.nc" H2O2L79,HNO3L79,NO2L79,NO3L79,O1DL79,O3L79,OHL79
+quit
+EOF
+  rm -f ferret.jnl*
+  #--rename variables 
+  ncrename -v PRESNIVS1,presnivs           ${OUT}LOI_AR6_${yr}.nc
+  ncrename -d PRESNIVS1,presnivs           ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v PRESNIVS1_bnds,presnivs_bnds ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v H2O2L79,H2O2                 ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v HNO3L79,HNO3                 ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v NO2L79,NO2                   ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v NO3L79,NO3                   ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v O1DL79,O1D                   ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v O3L79,O3                     ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v OHL79,OH                     ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v LON,x                        ${OUT}LOI_AR6_${yr}.nc
+  ncrename -d LON,x                        ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v LAT,y                        ${OUT}LOI_AR6_${yr}.nc
+  ncrename -d LAT,y                        ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v TIME,time_counter            ${OUT}LOI_AR6_${yr}.nc
+  ncrename -d TIME,time_counter            ${OUT}LOI_AR6_${yr}.nc
+  ncrename -v TIME_bnds,time_bnds          ${OUT}LOI_AR6_${yr}.nc
+  #--This stupid ferret inverses both the vertical axis AND the latitude
+  rm -f ${OUT}toto.nc
+  #ncpdq -Oh --reorder -presnivs,-lat ${OUT}LOI_AR6_${yr}.nc ${OUT}toto.nc
+  ncpdq -Oh --reorder -presnivs,-y ${OUT}LOI_AR6_${yr}.nc ${OUT}toto.nc
+  ncatted -Oh -a units,x,o,c,"degrees_east"  ${OUT}toto.nc 
+  mv ${OUT}toto.nc ${OUT}LOI_AR6_${yr}.nc
+  rm -f ${OUT}'LOI_AR5_'${yr}'.nc' ${OUT}'LOI_AR5_'${yr}'_notime.nc' ${OUT}'LOI_AR5_'${yr}'_time.nc'
+  done 
+  #
+fi
+
+#RCP
+#--silly if statements to perform or bypass RCP files
+if [ ${bypass_RCP} == 0 ]; then
+for rcp in RCP45 RCP60 RCP85sstA2
+do
+  DIR=/ccc/store/cont003/dsm/p24lava/ARCHIVE/dmf_import/IGCM_OUT/LMDZORINCA/NMHC_AER/LOI_IPCC_${rcp}/CHM/Output/MO/
+  for yr in `seq 2010 10 2100`
+  do 
+  for mth in 0{1..9} {10..12} 
+  do
+    echo $yr $mth
+    filein=$DIR'LOI_IPCC_'${rcp}'_'${yr}'_'${mth}'_MM_inca_avgr.nc'
+    fileout=$OUT'LOI_AR5_'${rcp}'_'${yr}'_'${mth}'.nc'
+    #--remapping
+    cdo remapbil,grid-lmdz-lonlat_144x143 -selname,O3,HNO3,OH,NO3,H2O2,O1D,NO2 $filein $fileout
+  done
+  #--merging monthly means into single file
+  cdo mergetime $OUT'LOI_AR5_'${rcp}'_'${yr}'_'??'.nc' $OUT'LOI_AR5_'${rcp}'_'${yr}'.nc'
+  rm -f $OUT'LOI_AR5_'${rcp}'_'${yr}'_'??'.nc'
+  #--remove time
+  ncks -x -v time ${OUT}'LOI_AR5_'${rcp}'_'${yr}'.nc' ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_notime.nc'
+  #--add time
+  ncks -A -v time time_${yr}.nc ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_notime.nc'
+  #--rename file
+  mv ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_notime.nc' ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_time.nc'
+
+  #--regrid vertically 
+ferret << EOF
+set MEMORY/SIZE=1024
+use "${OUT}LOI_AR5_${rcp}_${yr}_time.nc"
+use grid.nc
+define grid/z=Z[g=OZONE] grid79L
+let H2O2L79=H2O2[d=1,g=grid79L,gz=@AVE] 
+let HNO3L79=HNO3[d=1,g=grid79L,gz=@AVE] 
+let NO2L79=NO2[d=1,g=grid79L,gz=@AVE] 
+let NO3L79=NO3[d=1,g=grid79L,gz=@AVE]
+let O1DL79=O1D[d=1,g=grid79L,gz=@AVE]
+let O3L79=O3[d=1,g=grid79L,gz=@AVE] 
+let OHL79=OH[d=1,g=grid79L,gz=@AVE]
+SAVE/format=CDF/CLOBBER/file="${OUT}LOI_AR6_${rcp}_${yr}.nc" H2O2L79,HNO3L79,NO2L79,NO3L79,O1DL79,O3L79,OHL79
+quit
+EOF
+  rm -f ferret.jnl*
+  #--rename variables 
+  ncrename -v PRESNIVS1,presnivs           ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d PRESNIVS1,presnivs           ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v PRESNIVS1_bnds,presnivs_bnds ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v H2O2L79,H2O2                 ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v HNO3L79,HNO3                 ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v NO2L79,NO2                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v NO3L79,NO3                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v O1DL79,O1D                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v O3L79,O3                     ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v OHL79,OH                     ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v LON,x                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d LON,x                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v LAT,y                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d LAT,y                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v TIME,time_counter            ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d TIME,time_counter            ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v TIME_bnds,time_bnds          ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  #--This stupid ferret inverses both the vertical axis AND the latitude
+  rm -f ${OUT}toto.nc
+  #ncpdq -Oh --reorder -presnivs,-lat ${OUT}LOI_AR6_${yr}.nc ${OUT}toto.nc
+  ncpdq -Oh --reorder -presnivs,-y ${OUT}LOI_AR6_${rcp}_${yr}.nc ${OUT}toto.nc
+  ncatted -Oh -a units,x,o,c,"degrees_east"  ${OUT}toto.nc 
+  mv ${OUT}toto.nc ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  rm -f ${OUT}'LOI_AR5_'${rcp}'_'${yr}'.nc' ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_notime.nc' ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_time.nc'
+done 
+done
+
+# Slightly different input format for RCP26...
+for rcp in RCP26
+do
+  DIR=/ccc/store/cont003/dsm/p24lava/ARCHIVE/dmf_import/IGCM_OUT/LMDZORINCA/NMHC_AER/LOI_IPCC_${rcp}/CHM/Output/MO/
+  for yr in `seq 2010 10 2100`
+  do
+    echo $yr
+    filein=$DIR'LOI_IPCC_'${rcp}'_'${yr}'_allMM_inca_avgr.nc'
+    fileout=$OUT'LOI_AR5_'${rcp}'_'${yr}'.nc'
+    #--remapping
+    cdo remapbil,grid-lmdz-lonlat_144x143 -selname,O3,HNO3,OH,NO3,H2O2,O1D,NO2 $filein $fileout
+  #--add time
+  ncks -A -v time time_${yr}.nc ${OUT}'LOI_AR5_'${rcp}'_'${yr}'.nc'
+
+  #--regrid vertically
+ferret << EOF
+set MEMORY/SIZE=1024
+use "${OUT}LOI_AR5_${rcp}_${yr}.nc"
+use grid.nc
+define grid/z=Z[g=OZONE] grid79L
+let H2O2L79=H2O2[d=1,g=grid79L,gz=@AVE]
+let HNO3L79=HNO3[d=1,g=grid79L,gz=@AVE]
+let NO2L79=NO2[d=1,g=grid79L,gz=@AVE]
+let NO3L79=NO3[d=1,g=grid79L,gz=@AVE]
+let O1DL79=O1D[d=1,g=grid79L,gz=@AVE]
+let O3L79=O3[d=1,g=grid79L,gz=@AVE]
+let OHL79=OH[d=1,g=grid79L,gz=@AVE]
+SAVE/format=CDF/CLOBBER/file="${OUT}LOI_AR6_${rcp}_${yr}.nc" H2O2L79,HNO3L79,NO2L79,NO3L79,O1DL79,O3L79,OHL79
+quit
+EOF
+  rm -f ferret.jnl*
+  #--rename variables
+  ncrename -v PRESNIVS1,presnivs           ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d PRESNIVS1,presnivs           ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v PRESNIVS1_bnds,presnivs_bnds ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v H2O2L79,H2O2                 ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v HNO3L79,HNO3                 ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v NO2L79,NO2                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v NO3L79,NO3                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v O1DL79,O1D                   ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v O3L79,O3                     ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v OHL79,OH                     ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v LON,x                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d LON,x                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v LAT,y                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d LAT,y                        ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v TIME,time_counter            ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -d TIME,time_counter          ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  ncrename -v TIME_bnds,time_bnds          ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  #--This stupid ferret inverses both the vertical axis AND the latitude
+  rm -f ${OUT}toto.nc
+  #ncpdq -Oh --reorder -presnivs,-lat ${OUT}LOI_AR6_${yr}.nc ${OUT}toto.nc
+  ncpdq -Oh --reorder -presnivs,-y ${OUT}LOI_AR6_${rcp}_${yr}.nc ${OUT}toto.nc
+  ncatted -Oh -a units,x,o,c,"degrees_east"  ${OUT}toto.nc
+  mv ${OUT}toto.nc ${OUT}LOI_AR6_${rcp}_${yr}.nc
+  rm -f ${OUT}'LOI_AR5_'${rcp}'_'${yr}'.nc' ${OUT}'LOI_AR5_'${rcp}'_'${yr}'_time.nc'
+done
+done
+
+fi
