source: TOOLS/CMIP6_FORCING/GHG/extract_scenario_v.1.2.0.sh @ 4049

Last change on this file since 4049 was 3928, checked in by tlurton, 6 years ago

Script for scenario GHG extraction: updated for subdirectory organisation by scenario.

  • Property svn:executable set to *
File size: 7.5 KB
Line 
1#--Update Th.Lurton 18/06/2018 for v.1.2.0
2#
3#--Update Th.Lurton 05/02/2018 for paths to new version
4# ** species-directory take hyphens instead of underscores previously;
5# ** likewise for species names within filenames;
6# ** variable names stay with underscores.
7
8#--v3 of my script to extract global mean and put to IGCM format
9
10#--according to Malte Meinsheausen two options are possible
11#    CFC11=CFC11eq and CCFC12=CFC12
12# or CFC11=HFC134a-eq * (0.0100/62.7)/(0.062/238) [values from AR5] and CFC12=CFC12eq
13# in the second case the HFC134a-eq is converted into CFC11eq using RF efficiencies from AR5 in Wm-2pptv-1
14
15#--11/10/2016 New format for the data, now global, NH and SH means are in a sector dimension
16#--hence I parse the first value from the cdo outputf to get the global mean
17#--outputf is used with format %12.4e to make sure there is a space between values and 3 values per line
18
19#--dir for annual mean data
20dirin1='/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UoM/'
21dirin2='gr1-GMNHSH/v20180611/'
22
23dirout='./OUTPUT/'
24if [ ! -d ${dirout} ] ; then mkdir ${dirout} ; fi
25
26rm -f years.txt
27for i in `seq -w 2015 2500`
28do
29echo 'Annee_'$i'=' >> years.txt
30done
31
32for scenario in 'ssp119' 'ssp126' 'ssp245' 'ssp370' 'ssp434' 'ssp460' 'ssp534' 'ssp585'
33do
34
35rep=${scenario}'/'
36
37if [ ${scenario} == 'ssp119' ] ; then prefixe='IMAGE' ; fi
38if [ ${scenario} == 'ssp126' ] ; then prefixe='IMAGE' ; fi
39if [ ${scenario} == 'ssp245' ] ; then prefixe='MESSAGE-GLOBIOM' ; fi
40if [ ${scenario} == 'ssp370' ] ; then prefixe='AIM' ; fi
41if [ ${scenario} == 'ssp434' ] ; then prefixe='GCAM4' ; fi
42if [ ${scenario} == 'ssp460' ] ; then prefixe='GCAM4' ; fi
43if [ ${scenario} == 'ssp534' ] ; then prefixe='REMIND-MAGPIE' ; fi
44if [ ${scenario} == 'ssp585' ] ; then prefixe='REMIND-MAGPIE' ; fi
45
46if [ ${scenario} == 'ssp119' ] ; then suffixe='' ; fi
47if [ ${scenario} == 'ssp126' ] ; then suffixe='' ; fi
48if [ ${scenario} == 'ssp245' ] ; then suffixe='' ; fi
49if [ ${scenario} == 'ssp370' ] ; then suffixe='' ; fi
50if [ ${scenario} == 'ssp434' ] ; then suffixe='' ; fi
51if [ ${scenario} == 'ssp460' ] ; then suffixe='' ; fi
52if [ ${scenario} == 'ssp534' ] ; then suffixe='over-' ; fi
53if [ ${scenario} == 'ssp585' ] ; then suffixe='' ; fi
54
55if [ ! -d ${dirout}${rep} ] ; then mkdir -p ${dirout}${rep} ; fi
56
57#--N2O we leave unit to ppb
58GHG='N2O'
59name='nitrous-oxide'
60namevar='nitrous_oxide'
61dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
62file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
63rm -f tmp.txt ${dirout}${GHG}_CMIP6_${scenario}_2015_2500.txt
64cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
65paste years.txt tmp.txt > ${dirout}${rep}${GHG}_CMIP6_2015_2500.txt
66
67#--CH4 here we leave unit in ppb
68GHG='CH4'
69name='methane'
70namevar='methane'
71dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
72file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
73rm -f tmp.txt ${dirout}${GHG}_CMIP6_${scenario}_2015_2500.txt
74cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
75paste years.txt tmp.txt > ${dirout}${rep}${GHG}_CMIP6_2015_2500.txt
76
77#--CO2 here we leave unit in ppm
78GHG='CO2'
79name='carbon-dioxide'
80namevar='carbon_dioxide'
81dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
82file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
83rm -f tmp.txt ${dirout}${GHG}_CMIP6_${scenario}_2015_2500.txt
84cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
85paste years.txt tmp.txt > ${dirout}${rep}${GHG}_CMIP6_2015_2500.txt
86
87#--CFC11eq we leave in pptv
88#--not used for CMIP6
89GHG='CFC11eq'
90name='cfc11eq'
91namevar=${name}
92dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
93file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
94rm -f tmp.txt ${dirout}${GHG}_${scenario}_2015_2500.txt
95cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
96paste years.txt tmp.txt > ${dirout}${rep}${GHG}_2015_2500.txt
97
98#--CFC12eq we leave in pptv
99GHG='CFC12eq'
100name='cfc12eq'
101namevar=${name}
102dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
103file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
104rm -f tmp.txt ${dirout}${GHG}_${scenario}_2015_2500.txt ${dirout}/${GHG}_CMIP6_${scenario}_2015_2500.txt
105cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
106paste years.txt tmp.txt > ${dirout}${rep}${GHG}_2015_2500.txt
107#--we will use CFC12eq for CMIP6
108cp ${dirout}${rep}${GHG}_2015_2500.txt ${dirout}${rep}${GHG}_CMIP6_2015_2500.txt
109
110#--CFC11 we leave in pptv
111#--not used for CMIP6
112GHG='CFC11'
113name='cfc11'
114namevar=${name}
115dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
116file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
117rm -f tmp.txt ${dirout}${GHG}_${scenario}_2015_2500.txt
118cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
119paste years.txt tmp.txt > ${dirout}${rep}${GHG}_2015_2500.txt
120
121#--CFC12 we leave in pptv
122#--not used for CMIP6
123GHG='CFC12'
124name='cfc12'
125namevar=${name}
126dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
127file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
128rm -f tmp.txt ${dirout}${GHG}_${scenario}_2015_2500.txt
129cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
130paste years.txt tmp.txt > ${dirout}${rep}${GHG}_2015_2500.txt
131
132#--HFC134aeq we leave in pptv
133GHG='HFC134aeq'
134name='hfc134aeq'
135namevar=${name}
136dirin=${dirin1}'UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0/atmos/yr/mole_fraction_of_'${namevar}'_in_air/'${dirin2}
137file='mole-fraction-of-'${name}'-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-'${prefixe}'-'${scenario}'-'${suffixe}'1-2-0_gr1-GMNHSH_2015-2500.nc'
138rm -f tmp.txt ${dirout}${GHG}_${scenario}_2015_2500.txt ${dirout}/CFC11eq_CMIP6_${scenario}_2015_2500.txt
139cdo outputf,%12.4e,3 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
140paste years.txt tmp.txt > ${dirout}${rep}${GHG}_2015_2500.txt
141#--HFC134a-eq converted to CFC11-eq for CMIP6
142#--by multiplying by (0.0100/62.7)/(0.062/238)=0.6122344
143cdo outputf,%12.4e,3 -mulc,0.6122344 -selvar,'mole_fraction_of_'${namevar}'_in_air' ${dirin}${file} | awk '{print $1}' > tmp.txt
144paste years.txt tmp.txt > ${dirout}${rep}CFC11eq_CMIP6_2015_2500.txt
145
146done
147#--fin boucle sur scenarios
148
149#--clean up
150rm -f tmp.txt years.txt
151
Note: See TracBrowser for help on using the repository browser.