Changeset 4051
- Timestamp:
- 10/11/18 13:52:39 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/CMIP6_FORCING/SCENARIOS/AER_TROP_EMISSIONS/REGRID/regrid_scen.sh
r4007 r4051 1 #--corrected 2080 bug 9/2018, ThL 1 2 #--reworked 7/2018 for scenario emissions, ThL 2 3 #--updated on 5/2/2018 with new paths, ThL … … 16 17 fileINCAex="/home/oboucher/CMIP6/AER_EMISSIONS/INCAfile/sflx_lmdz_phy_1997.nc" 17 18 18 #--input directory for emissions19 #--input directory for anthropogenic (non-BB) emissions 19 20 dirin="/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/IAMC/" 20 21 … … 28 29 29 30 #--output directory 30 dirout="/data/"${USER}"/CMIP6/AEROSOL/ScenarioMIP/${scen}/v 1/"31 dirout="/data/"${USER}"/CMIP6/AEROSOL/ScenarioMIP/${scen}/v2_correcte/" 31 32 if [ ! -d ${dirout} ] ; then mkdir -p ${dirout} ; fi 32 33 … … 40 41 if [ ${scen} == "ssp585" ] ; then prefix="REMIND-MAGPIE" ; fi 41 42 42 #--Unique file for the whole period, so fixed variables: 43 #--loop on years 44 for year in {2015..2100} 45 do 46 47 if [ ${year} -ge "2015" -a ${year} -lt "2020" ] 48 then 43 49 year1=2015 50 year2=2020 51 fi 52 if [ ${year} -ge "2020" -a ${year} -lt "2030" ] 53 then 54 year1=2020 55 year2=2030 56 fi 57 if [ ${year} -ge "2030" -a ${year} -lt "2040" ] 58 then 59 year1=2030 60 year2=2040 61 fi 62 if [ ${year} -ge "2040" -a ${year} -lt "2050" ] 63 then 64 year1=2040 65 year2=2050 66 fi 67 if [ ${year} -ge "2050" -a ${year} -lt "2060" ] 68 then 69 year1=2050 70 year2=2060 71 fi 72 if [ ${year} -ge "2060" -a ${year} -lt "2070" ] 73 then 74 year1=2060 75 year2=2070 76 fi 77 if [ ${year} -ge "2070" -a ${year} -lt "2080" ] 78 then 79 year1=2070 80 year2=2080 81 fi 82 if [ ${year} -ge "2080" -a ${year} -lt "2090" ] 83 then 84 year1=2080 85 year2=2090 86 fi 87 if [ ${year} -ge "2090" -a ${year} -lt "2100" ] 88 then 89 year1=2090 44 90 year2=2100 45 46 #--Loop on species (anthro) 91 fi 92 if [ ${year} == 2100 ] 93 then 94 year1=2100 95 year2=2100 96 fi 97 #--weights for linear interpolation 98 if [ ${year} == 2015 ] 99 then 100 pond1="1" 101 pond2="0" 102 fi 103 if [ ${year} == 2016 ] 104 then 105 pond1="0.8" 106 pond2="0.2" 107 fi 108 if [ ${year} == 2017 ] 109 then 110 pond1="0.6" 111 pond2="0.4" 112 fi 113 if [ ${year} == 2018 ] 114 then 115 pond1="0.4" 116 pond2="0.6" 117 fi 118 if [ ${year} == 2019 ] 119 then 120 pond1="0.2" 121 pond2="0.8" 122 fi 123 if [ ${year} == 2020 -o ${year} == 2030 -o ${year} == 2040 -o ${year} == 2050 -o ${year} == 2060 -o ${year} == 2070 -o ${year} == 2080 -o ${year} == 2090 ] 124 then 125 pond1="1" 126 pond2="0" 127 fi 128 if [ ${year} == 2021 -o ${year} == 2031 -o ${year} == 2041 -o ${year} == 2051 -o ${year} == 2061 -o ${year} == 2071 -o ${year} == 2081 -o ${year} == 2091 ] 129 then 130 pond1="0.9" 131 pond2="0.1" 132 fi 133 if [ ${year} == 2022 -o ${year} == 2032 -o ${year} == 2042 -o ${year} == 2052 -o ${year} == 2062 -o ${year} == 2072 -o ${year} == 2082 -o ${year} == 2092 ] 134 then 135 pond1="0.8" 136 pond2="0.2" 137 fi 138 if [ ${year} == 2023 -o ${year} == 2033 -o ${year} == 2043 -o ${year} == 2053 -o ${year} == 2063 -o ${year} == 2073 -o ${year} == 2083 -o ${year} == 2093 ] 139 then 140 pond1="0.7" 141 pond2="0.3" 142 fi 143 if [ ${year} == 2024 -o ${year} == 2034 -o ${year} == 2044 -o ${year} == 2054 -o ${year} == 2064 -o ${year} == 2074 -o ${year} == 2084 -o ${year} == 2094 ] 144 then 145 pond1="0.6" 146 pond2="0.4" 147 fi 148 if [ ${year} == 2025 -o ${year} == 2035 -o ${year} == 2045 -o ${year} == 2055 -o ${year} == 2065 -o ${year} == 2075 -o ${year} == 2085 -o ${year} == 2095 ] 149 then 150 pond1="0.5" 151 pond2="0.5" 152 fi 153 if [ ${year} == 2026 -o ${year} == 2036 -o ${year} == 2046 -o ${year} == 2056 -o ${year} == 2066 -o ${year} == 2076 -o ${year} == 2086 -o ${year} == 2096 ] 154 then 155 pond1="0.4" 156 pond2="0.6" 157 fi 158 if [ ${year} == 2027 -o ${year} == 2037 -o ${year} == 2047 -o ${year} == 2057 -o ${year} == 2067 -o ${year} == 2077 -o ${year} == 2087 -o ${year} == 2097 ] 159 then 160 pond1="0.3" 161 pond2="0.7" 162 fi 163 if [ ${year} == 2028 -o ${year} == 2038 -o ${year} == 2048 -o ${year} == 2058 -o ${year} == 2068 -o ${year} == 2078 -o ${year} == 2088 -o ${year} == 2098 ] 164 then 165 pond1="0.2" 166 pond2="0.8" 167 fi 168 if [ ${year} == 2029 -o ${year} == 2039 -o ${year} == 2049 -o ${year} == 2059 -o ${year} == 2069 -o ${year} == 2079 -o ${year} == 2089 -o ${year} == 2099 ] 169 then 170 pond1="0.1" 171 pond2="0.9" 172 fi 173 if [ ${year} == 2100 ] 174 then 175 pond1="0" 176 pond2="1" 177 fi 178 179 #--species 47 180 for species in "BC" "NOx" "OC" "SO2" "NH3" 48 181 do 49 50 echo "... "${year}" : Dealing with "${species}" anthro input file..."51 182 52 183 if [ ${species} = "BC" ] ; then speciesinca="bc" ; fi … … 62 193 if [ ${species} = "NH3" ] ; then speciesUp="NH3" ; fi 63 194 64 #--input file anthro 65 filename=${dirin}IAMC-${prefix}-${scen}-1-1/atmos/mon/${species}_em_anthro/gn/v20180628/${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12.nc 66 67 #--input file summed over sectors 68 filesum=${dirout}${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_sum.nc 69 #--reworked input file 70 filetmp=${dirout}${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_tmp.nc 71 #--time-interpolated input file 72 fileintanthro=${dirout}${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_interp.nc 73 74 if [ -f ${fileintanthro} ] 75 then 76 echo "...Nothing to do!" 77 else 78 79 rm -f ${filesum} ${filetmp} ${fileintanthro} 80 81 #--re-formatting the input file 82 #--summing over sectors 83 rm -f sumsectors.jnl 84 cat << eod > sumsectors.jnl 85 set memory/size=100 86 use "${filename}" 87 save/clobber/file="${filesum}" ${species}_EM_ANTHRO[k=@sum] 88 eod 89 #--run ferret script 90 ferret << eod 91 go sumsectors.jnl 92 exit 93 eod 94 95 #--reformatting input file for IDL to be able to read 96 ncks -3 ${filesum} ${filetmp} 97 #--cleaning up 98 rm -f ${filesum} 99 100 #--IDL code for time interpolation, to fill in 9-year gaps in input file 101 rm -f time_interp_over_gaps.pro 102 cat << eod >> time_interp_over_gaps.pro 103 pro time_interp_over_gaps 104 105 ; Les dimensions des fichiers 106 nlon=720 107 nlat=360 108 nt=1032 109 110 une_annee=[31,30,29,31,30,31,30,31,31,30,31,30] 111 les_mois = [31,28,31,30,31,30,31,31,30,31,30,31] 112 113 jours_in = [15, 45, 74, 105, 135, 166, 196, 227, 258, 288, 319, 349, 1840, 1870, $ 114 1899, 1930, 1960, 1991, 2021, 2052, 2083, 2113, 2144, 2174, 5490, 5520, $ 115 5549, 5580, 5610, 5641, 5671, 5702, 5733, 5763, 5794, 5824, 9140, 9170, $ 116 9199, 9230, 9260, 9291, 9321, 9352, 9383, 9413, 9444, 9474, 12790, 12820, $ 117 12849, 12880, 12910, 12941, 12971, 13002, 13033, 13063, 13094, 13124, $ 118 16440, 16470, 16499, 16530, 16560, 16591, 16621, 16652, 16683, 16713, $ 119 16744, 16774, 20090, 20120, 20149, 20180, 20210, 20241, 20271, 20302, $ 120 20333, 20363, 20394, 20424, 23740, 23770, 23799, 23830, 23860, 23891, $ 121 23921, 23952, 23983, 24013, 24044, 24074, 27390, 27420, 27449, 27480, $ 122 27510, 27541, 27571, 27602, 27633, 27663, 27694, 27724, 31040, 31070, $ 123 31099, 31130, 31160, 31191, 31221, 31252, 31283, 31313, 31344, 31374] 124 125 jours_out=make_array(1032) 126 jours_out(0) = 15 127 for cpt=1,1031 do jours_out(cpt) = jours_out(cpt-1) + une_annee(cpt mod 12) 128 129 idin = ncdf_open('${filetmp}') 130 varid = ncdf_varid(idin,'${speciesUp}_EM_ANTHRO') 131 lonid = ncdf_varid(idin,'LON') 132 latid = ncdf_varid(idin,'LAT') 133 ;lonbndid = ncdf_varid(idin,'LON_bnds') 134 ;latbndid = ncdf_varid(idin,'LAT_bnds') 135 timbndid = ncdf_varid(idin,'TIME_bnds') 136 ncdf_varget, idin, varid, emiss_init 137 ncdf_attget, idin, varid, "units", emiss_unit 138 ncdf_attget, idin, varid, "long_name", emiss_longname 139 ncdf_varget, idin, lonid, lon 140 ncdf_varget, idin, latid, lat 141 ;ncdf_varget, idin, lonbndid, lonbnds 142 ;ncdf_varget, idin, latbndid, latbnds 143 ncdf_varget, idin, timbndid, timbnds_in 144 ncdf_close, idin 145 146 timbnds_out = make_array(2,1032) 147 timbnds_out(*,0) = [0,31] 148 timbnds_out(*,1) = [31,59] 149 for cpt=2,1031 do timbnds_out(0,cpt) = timbnds_out(0,cpt-1) + les_mois((cpt-1) mod 12) 150 for cpt=1,1030 do timbnds_out(1,cpt) = timbnds_out(0,cpt+1) 151 timbnds_out(1,1031) = 31390 152 153 emiss_interpol=make_array(nlon,nlat,1032,value=0.) 154 155 indices_out_mois = make_array(86,12,value=0) 156 for m=0,11 do begin 157 for n=0,85 do indices_out_mois(n,m) = 12*n + m 158 endfor 159 160 jours_out_mois = make_array(86,12,value=0) 161 for n=0,85 do begin 162 for m=0,11 do jours_out_mois(n,m) = jours_out(indices_out_mois(n,m)) 163 endfor 164 165 jours_in_mois = make_array(n_elements(jours_in)/12,12,value=0) 166 for m=0,11 do begin 167 for n=0,n_elements(jours_in)/12-1 do jours_in_mois(n,m) = jours_in(n*12 + m) 168 endfor 169 170 indices_in_mois = make_array(n_elements(jours_in)/12,12,value=0) 171 for m=0,11 do begin 172 for n=0,n_elements(jours_in)/12-1 do indices_in_mois(n,m) = where(jours_in eq jours_in_mois(n,m)) 173 endfor 174 175 ; Interpolation mois par mois... 176 for i=0,nlon-1 do begin 177 for j=0,nlat-1 do begin 178 for m=0,11 do begin 179 emiss_interpol(i,j,indices_out_mois(*,m)) = interpol(emiss_init(i,j,indices_in_mois(*,m)),jours_in_mois(*,m),jours_out_mois(*,m)) 180 endfor 181 endfor 182 endfor 183 184 idout = ncdf_create('${fileintanthro}', /clobber) 185 dimlonid = ncdf_dimdef(idout,'lon',nlon) 186 dimlatid = ncdf_dimdef(idout,'lat',nlat) 187 dimtimid = ncdf_dimdef(idout,'time',1032) 188 dimbndid = ncdf_dimdef(idout,'bound',2) 189 varlonid = ncdf_vardef(idout, 'lon', [dimlonid], /double) 190 varlatid = ncdf_vardef(idout, 'lat', [dimlatid], /double) 191 vartimid = ncdf_vardef(idout, 'time', [dimtimid], /double) 192 ;varlonbndsid = ncdf_vardef(idout, 'lon_bnds', [dimbndid,dimlonid], /double) 193 ;varlatbndsid = ncdf_vardef(idout, 'lat_bnds', [dimbndid,dimlatid], /double) 194 vartimbndsid = ncdf_vardef(idout, 'time_bnds', [dimbndid,dimtimid], /double) 195 varemissid = ncdf_vardef(idout, '${species}_em_anthro', [dimlonid,dimlatid,dimtimid], /float) 196 ncdf_control, idout, /endef 197 ncdf_varput, idout, varlonid, lon 198 ncdf_varput, idout, varlatid, lat 199 ;ncdf_varput, idout, varlonbndsid, lonbnds 200 ;ncdf_varput, idout, varlatbndsid, latbnds 201 ncdf_varput, idout, vartimbndsid, timbnds_out 202 ncdf_varput, idout, varemissid, emiss_interpol 203 ncdf_varput, idout, vartimid, jours_out 204 ncdf_control, idout, /redef 205 ncdf_attput, idout, varlonid, "units", "degrees_east" 206 ncdf_attput, idout, varlonid, "long_name", "longitude" 207 ncdf_attput, idout, varlonid, "axis", "X" 208 ncdf_attput, idout, varlonid, "bounds", "lon_bnds" 209 ncdf_attput, idout, varlonid, "modulo", 360. 210 ncdf_attput, idout, varlonid, "realtopology", "circular" 211 ncdf_attput, idout, varlonid, "standard_name", "longitude" 212 ncdf_attput, idout, varlonid, "topology", "circular" 213 ncdf_attput, idout, varlatid, "units", "degrees_north" 214 ncdf_attput, idout, varlatid, "long_name", "latitude" 215 ncdf_attput, idout, varlatid, "axis", "Y" 216 ncdf_attput, idout, varlatid, "bounds", "lat_bnds" 217 ncdf_attput, idout, varlatid, "realtopology", "linear" 218 ncdf_attput, idout, varlatid, "standard_name", "latitude" 219 ncdf_attput, idout, varemissid, "units", string(emiss_unit) 220 ncdf_attput, idout, varemissid, "_FillValue", 1.e+20 221 ncdf_attput, idout, varemissid, "cell_methods", "time: mean" 222 ncdf_attput, idout, varemissid, "long_name", string(emiss_longname) 223 ncdf_attput, idout, varemissid, "missing_value", 1.e+20 224 ncdf_attput, idout, vartimid, "units", "days since 2015-01-01 0:0:0" 225 ncdf_attput, idout, vartimid, "long_name", "time" 226 ncdf_attput, idout, vartimid, "calendar", '365_day' 227 ncdf_attput, idout, vartimid, "axis", "T" 228 ncdf_attput, idout, vartimid, "bounds", "time_bnds" 229 ncdf_attput, idout, vartimid, "realtopology", "linear" 230 ncdf_attput, idout, vartimid, "standard_name", "time" 231 ncdf_close, idout 232 end 233 eod 234 # 235 #--calling IDL 236 # 237 /opt/idl-6.4/idl/bin/idl << eod 238 .r time_interp_over_gaps.pro 239 time_interp_over_gaps 240 exit 241 eod 242 # 243 244 #--adding lat_bnds and lon_bnds variables 245 ncks -A -v lat_bnds,lon_bnds ${filename} ${fileintanthro} 246 247 #--cleaning up 248 rm -f ${filetmp} 249 250 #--end test whether file tmp already exists 251 fi 252 253 254 255 #--now dealing with the BB input file 256 257 echo "... "${year}" : Dealing with "${species}" openburning input file..." 258 259 #--input file BB 260 filename=${dirin}IAMC-${prefix}-${scen}-1-1/atmos/mon/${species}_em_openburning/gn/v20180628/${species}-em-openburning_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12.nc 261 #--reworked input file 262 filetmp=${dirout}${species}-em-openburning_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_tmp.nc 263 #--time-interpolated input file 264 fileintbb=${dirout}${species}-em-openburning_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_interp.nc 265 266 if [ -f ${fileintbb} ] 267 then 268 echo "...Nothing to do!" 269 else 270 271 rm -f ${filetmp} ${fileintbb} 272 273 #--no need to sum over sectors, as none in BB files 274 275 #--reformatting input file for IDL to be able to read 276 ncks -3 ${filename} ${filetmp} 277 278 #--IDL code for time interpolation, to fill in 9-year gaps in input file 279 rm -f time_interp_over_gaps.pro 280 cat << eod >> time_interp_over_gaps.pro 281 pro time_interp_over_gaps 282 283 ; Les dimensions des fichiers 284 nlon=720 285 nlat=360 286 nt=1032 287 288 une_annee=[31,30,29,31,30,31,30,31,31,30,31,30] 289 les_mois = [31,28,31,30,31,30,31,31,30,31,30,31] 290 291 jours_in = [15, 45, 74, 105, 135, 166, 196, 227, 258, 288, 319, 349, 1840, 1870, $ 292 1899, 1930, 1960, 1991, 2021, 2052, 2083, 2113, 2144, 2174, 5490, 5520, $ 293 5549, 5580, 5610, 5641, 5671, 5702, 5733, 5763, 5794, 5824, 9140, 9170, $ 294 9199, 9230, 9260, 9291, 9321, 9352, 9383, 9413, 9444, 9474, 12790, 12820, $ 295 12849, 12880, 12910, 12941, 12971, 13002, 13033, 13063, 13094, 13124, $ 296 16440, 16470, 16499, 16530, 16560, 16591, 16621, 16652, 16683, 16713, $ 297 16744, 16774, 20090, 20120, 20149, 20180, 20210, 20241, 20271, 20302, $ 298 20333, 20363, 20394, 20424, 23740, 23770, 23799, 23830, 23860, 23891, $ 299 23921, 23952, 23983, 24013, 24044, 24074, 27390, 27420, 27449, 27480, $ 300 27510, 27541, 27571, 27602, 27633, 27663, 27694, 27724, 31040, 31070, $ 301 31099, 31130, 31160, 31191, 31221, 31252, 31283, 31313, 31344, 31374] 302 303 jours_out=make_array(1032) 304 jours_out(0) = 15 305 for cpt=1,1031 do jours_out(cpt) = jours_out(cpt-1) + une_annee(cpt mod 12) 306 307 idin = ncdf_open('${filetmp}') 308 varid = ncdf_varid(idin,'${species}_em_openburning') ; Here, small caps 309 lonid = ncdf_varid(idin,'lon') 310 latid = ncdf_varid(idin,'lat') 311 ;lonbndid = ncdf_varid(idin,'lon_bnds') 312 ;latbndid = ncdf_varid(idin,'lat_bnds') 313 timbndid = ncdf_varid(idin,'time_bnds') 314 ncdf_varget, idin, varid, emiss_init 315 ncdf_attget, idin, varid, "units", emiss_unit 316 ncdf_attget, idin, varid, "long_name", emiss_longname 317 ncdf_varget, idin, lonid, lon 318 ncdf_varget, idin, latid, lat 319 ;ncdf_varget, idin, lonbndid, lonbnds 320 ;ncdf_varget, idin, latbndid, latbnds 321 ncdf_varget, idin, timbndid, timbnds_in 322 ncdf_close, idin 323 324 timbnds_out = make_array(2,1032) 325 timbnds_out(*,0) = [0,31] 326 timbnds_out(*,1) = [31,59] 327 for cpt=2,1031 do timbnds_out(0,cpt) = timbnds_out(0,cpt-1) + une_annee((cpt-1) mod 12) 328 for cpt=1,1030 do timbnds_out(1,cpt) = timbnds_out(0,cpt+1) 329 timbnds_out(1,1031) = 31390 330 331 emiss_interpol=make_array(nlon,nlat,1032,value=0.) 332 333 indices_out_mois = make_array(86,12,value=0) 334 for m=0,11 do begin 335 for n=0,85 do indices_out_mois(n,m) = 12*n + m 336 endfor 337 338 jours_out_mois = make_array(86,12,value=0) 339 for n=0,85 do begin 340 for m=0,11 do jours_out_mois(n,m) = jours_out(indices_out_mois(n,m)) 341 endfor 342 343 jours_in_mois = make_array(n_elements(jours_in)/12,12,value=0) 344 for m=0,11 do begin 345 for n=0,n_elements(jours_in)/12-1 do jours_in_mois(n,m) = jours_in(n*12 + m) 346 endfor 347 348 indices_in_mois = make_array(n_elements(jours_in)/12,12,value=0) 349 for m=0,11 do begin 350 for n=0,n_elements(jours_in)/12-1 do indices_in_mois(n,m) = where(jours_in eq jours_in_mois(n,m)) 351 endfor 352 353 ; Interpolation mois par mois... 354 for i=0,nlon-1 do begin 355 for j=0,nlat-1 do begin 356 for m=0,11 do begin 357 emiss_interpol(i,j,indices_out_mois(*,m)) = interpol(emiss_init(i,j,indices_in_mois(*,m)),jours_in_mois(*,m),jours_out_mois(*,m)) 358 endfor 359 endfor 360 endfor 361 362 idout = ncdf_create('${fileintbb}', /clobber) 363 dimlonid = ncdf_dimdef(idout,'lon',nlon) 364 dimlatid = ncdf_dimdef(idout,'lat',nlat) 365 dimtimid = ncdf_dimdef(idout,'time',1032) 366 dimbndid = ncdf_dimdef(idout,'bound',2) 367 varlonid = ncdf_vardef(idout, 'lon', [dimlonid], /double) 368 varlatid = ncdf_vardef(idout, 'lat', [dimlatid], /double) 369 vartimid = ncdf_vardef(idout, 'time', [dimtimid], /double) 370 ;varlonbndsid = ncdf_vardef(idout, 'lon_bnds', [dimbndid,dimlonid], /double) 371 ;varlatbndsid = ncdf_vardef(idout, 'lat_bnds', [dimbndid,dimlatid], /double) 372 vartimbndsid = ncdf_vardef(idout, 'time_bnds', [dimbndid,dimtimid], /double) 373 varemissid = ncdf_vardef(idout, '${species}_em_openburning', [dimlonid,dimlatid,dimtimid], /float) 374 ncdf_control, idout, /endef 375 ncdf_varput, idout, varlonid, lon 376 ncdf_varput, idout, varlatid, lat 377 ;ncdf_varput, idout, varlonbndsid, lonbnds 378 ;ncdf_varput, idout, varlatbndsid, latbnds 379 ncdf_varput, idout, vartimbndsid, timbnds_out 380 ncdf_varput, idout, varemissid, emiss_interpol 381 ncdf_varput, idout, vartimid, jours_out 382 ncdf_control, idout, /redef 383 ncdf_attput, idout, varlonid, "units", "degrees_east" 384 ncdf_attput, idout, varlonid, "long_name", "longitude" 385 ncdf_attput, idout, varlonid, "axis", "X" 386 ncdf_attput, idout, varlonid, "bounds", "lon_bnds" 387 ncdf_attput, idout, varlonid, "modulo", 360. 388 ncdf_attput, idout, varlonid, "realtopology", "circular" 389 ncdf_attput, idout, varlonid, "standard_name", "longitude" 390 ncdf_attput, idout, varlonid, "topology", "circular" 391 ncdf_attput, idout, varlatid, "units", "degrees_north" 392 ncdf_attput, idout, varlatid, "long_name", "latitude" 393 ncdf_attput, idout, varlatid, "axis", "Y" 394 ncdf_attput, idout, varlatid, "bounds", "lat_bnds" 395 ncdf_attput, idout, varlatid, "realtopology", "linear" 396 ncdf_attput, idout, varlatid, "standard_name", "latitude" 397 ncdf_attput, idout, varemissid, "units", string(emiss_unit) 398 ncdf_attput, idout, varemissid, "_FillValue", 1.e+20 399 ncdf_attput, idout, varemissid, "cell_methods", "time: mean" 400 ncdf_attput, idout, varemissid, "long_name", string(emiss_longname) 401 ncdf_attput, idout, varemissid, "missing_value", 1.e+20 402 ncdf_attput, idout, vartimid, "units", "days since 2015-01-01 0:0:0" 403 ncdf_attput, idout, vartimid, "long_name", "time" 404 ncdf_attput, idout, vartimid, "calendar", '365_day' 405 ncdf_attput, idout, vartimid, "axis", "T" 406 ncdf_attput, idout, vartimid, "bounds", "time_bnds" 407 ncdf_attput, idout, vartimid, "realtopology", "linear" 408 ncdf_attput, idout, vartimid, "standard_name", "time" 409 ncdf_close, idout 410 end 411 eod 412 # 413 #--calling IDL 414 # 415 /opt/idl-6.4/idl/bin/idl << eod 416 .r time_interp_over_gaps.pro 417 time_interp_over_gaps 418 exit 419 eod 420 # 421 422 #--adding lat_bnds and lon_bnds variables 423 ncks -A -v lat_bnds,lon_bnds ${filename} ${fileintbb} 424 425 #--cleaning up 426 rm -f ${filetmp} 427 428 #--end test if interpolated file already exists 429 fi 430 431 #--end loop on species 432 done 433 434 435 436 #--anthro and BB input files fileintanthro and fileintbb are now ready, for the whole period and for the current scenario 437 #--new double loop on species and years 438 439 #--loop on years 440 for year in {2015..2100} 441 do 442 443 #--loop on species 444 for species in "BC" "NOx" "OC" "SO2" "NH3" 445 do 446 447 if [ ${species} = "BC" ] ; then speciesinca="bc" ; fi 448 if [ ${species} = "NOx" ] ; then speciesinca="nox" ; fi 449 if [ ${species} = "OC" ] ; then speciesinca="pom" ; fi 450 if [ ${species} = "SO2" ] ; then speciesinca="so2" ; fi 451 if [ ${species} = "NH3" ] ; then speciesinca="nh3" ; fi 452 453 #--dealing with anthro 454 455 #--input file 456 fileintanthro=${dirout}${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_interp.nc 195 #--Dealing with anthro emissions file... 196 197 echo "... "${year}" : Dealing with "${species}" anthro input file..." 198 199 #--input file anthro (fossil fuel emissions) 200 filename=${dirin}IAMC-${prefix}-${scen}-1-1/atmos/mon/${species}_em_anthro/gn/v20180628/${species}-em-anthro_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_201501-210012.nc 201 202 #--two temporary files for interpolation 203 filetmp1=${dirout}tmp1.nc 204 filetmp2=${dirout}tmp2.nc 205 457 206 #--output files 458 207 filenameout1=${dirout}flux_${speciesinca}_${year}.nc … … 461 210 filenameout3=${dirout}flux_vector_${speciesinca}_${year}.nc 462 211 463 echo ${fileintanthro} ${filenameout1} ${filenameout2} ${filenameout3} 464 rm -f ${filenameout1} ${filenameout2} ${filenameout3} 465 466 #--extracting the correct year 467 rm -f select_yr.jnl 468 cat << eod > select_yr.jnl 469 set memory/size=100 470 use "${fileintanthro}" 471 set region/t=16-jan-${year}:16-dec-${year} 472 save/clobber/file="${filenameout1}" ${species}_EM_ANTHRO 212 echo ${filename} ${filenameout1} ${filenameout2} ${filenameout3} 213 rm -f ${filetmp1} ${filetmp2} ${filenameout1} ${filenameout2} ${filenameout3} 214 215 #--unfortunately idl not happy with input netcdf files so need to ferretize files 216 #--I also sum over sectors and I extract the correct years as well 217 #--first year (start of 5-Y or 10-Y period, for later interpolation) 218 rm -f rewrite.jnl 219 cat << eod > rewrite.jnl 220 use "${filename}" 221 set region/t=16-jan-${year1}:16-dec-${year1} 222 save/clobber/file="${filetmp1}" ${speciesUp}_EM_ANTHRO[k=@sum] 223 eod 224 #--run ferret script 225 ferret << eod 226 go rewrite.jnl 227 exit 228 eod 229 #--second year (end of 5-Y or 10-Y period, for later interpolation) 230 rm -f rewrite.jnl 231 cat << eod > rewrite.jnl 232 use "${filename}" 233 set region/t=16-jan-${year2}:16-dec-${year2} 234 save/clobber/file="${filetmp2}" ${speciesUp}_EM_ANTHRO[k=@sum] 473 235 eod 474 236 #--run ferret script 475 237 ferret << eod 476 go select_yr.jnl238 go rewrite.jnl 477 239 exit 478 240 eod 479 241 480 #--replace undef with 0 242 #--performing time interpolation 243 cdo add -mulc,${pond1} -selname,${speciesUp}_EM_ANTHRO ${filetmp1} -mulc,${pond2} -selname,${speciesUp}_EM_ANTHRO ${filetmp2} ${filenameout1} 244 481 245 cdo setmisstoc,0.0 ${filenameout1} ${filenameout1b} 482 246 … … 624 388 end 625 389 eod 390 626 391 # 627 392 #--calling IDL … … 637 402 # 638 403 639 #--cleaning the mess 640 rm -f ferret* 641 rm -f regrid.pro 642 643 644 #--now dealing with BB 645 646 #--input file 647 fileintbb=${dirout}${species}-em-openburning_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_${year1}01-${year2}12_interp.nc 404 405 #--now dealing with BB sources 406 echo "... "${year}" : Dealing with "${species}" openburning input file..." 407 408 filename=${dirin}IAMC-${prefix}-${scen}-1-1/atmos/mon/${species}_em_openburning/gn/v20180628/${species}-em-openburning_input4MIPs_emissions_ScenarioMIP_IAMC-${prefix}-${scen}-1-1_gn_201501-210012.nc 409 410 if [ ${species} = "BC" ] ; then speciesinca="bc" ; fi 411 if [ ${species} = "NOx" ] ; then speciesinca="nox" ; fi 412 if [ ${species} = "OC" ] ; then speciesinca="pom" ; fi 413 if [ ${species} = "SO2" ] ; then speciesinca="so2" ; fi 414 if [ ${species} = "NH3" ] ; then speciesinca="nh3" ; fi 415 416 #--two temporary files for interpolation 417 filetmp1=${dirout}tmp1.nc 418 filetmp2=${dirout}tmp2.nc 419 648 420 #--output files 649 421 filenameout1=${dirout}flux_${speciesinca}bb_${year}.nc … … 652 424 filenameout3=${dirout}flux_vector_${speciesinca}bb_${year}.nc 653 425 654 echo ${file intbb} ${filenameout1} ${filenameout1b} ${filenameout2} ${filenameout3}655 rm -f ${file nameout1} ${filenameout1b} ${filenameout2} ${filenameout3}426 echo ${filename} ${filenameout1} ${filenameout1b} ${filenameout2} ${filenameout3} 427 rm -f ${filetmp1} ${filetmp2} ${filenameout1} ${filenameout1b} ${filenameout2} ${filenameout3} 656 428 657 429 #--unfortunately idl not happy with input netcdf files so need to ferretize files 658 #--I extract the correct year as well; no need to sum up sectors, as none in BB files 430 #--I also sum over sectors and I extract the correct years as well 431 #--first year (start of 5-Y or 10-Y period, for later interpolation) 659 432 rm -f rewrite.jnl 660 433 cat << eod > rewrite.jnl 661 set memory/size=100 662 use "${fileintbb}" 663 set region/t=16-jan-${year}:16-dec-${year} 664 save/clobber/file="${filenameout1}" ${species}_EM_OPENBURNING 434 use "${filename}" 435 set region/t=16-jan-${year1}:16-dec-${year1} 436 save/clobber/file="${filetmp1}" ${speciesUp}_EM_OPENBURNING[k=@sum] 665 437 eod 666 438 #--run ferret script … … 669 441 exit 670 442 eod 671 672 #--replace undef with 0 443 #--second year (end of 5-Y or 10-Y period, for later interpolation) 444 rm -f rewrite.jnl 445 cat << eod > rewrite.jnl 446 use "${filename}" 447 set region/t=16-jan-${year2}:16-dec-${year2} 448 save/clobber/file="${filetmp2}" ${speciesUp}_EM_OPENBURNING[k=@sum] 449 eod 450 #--run ferret script 451 ferret << eod 452 go rewrite.jnl 453 exit 454 eod 455 456 #--performing time interpolation 457 cdo add -mulc,${pond1} -selname,${speciesUp}_EM_OPENBURNING ${filetmp1} -mulc,${pond2} -selname,${speciesUp}_EM_OPENBURNING ${filetmp2} ${filenameout1} 458 459 #--replace undef with 0 673 460 cdo setmisstoc,0.0 ${filenameout1} ${filenameout1b} 674 461 … … 676 463 #--OC to POM conversion factor 677 464 #--as ferret returns NOX, treat NOx NOX inconsistency in names by converting to upper case 678 if [ ${species} != "OC" ] ; then465 if [ ${species} != "OC" ] ; then 679 466 echo cdo remapcon,${gridfile} -chname,`echo ${species}_EM_OPENBURNING | awk '{print toupper($0)}'`,flux ${filenameout1b} ${filenameout2} 680 467 cdo remapcon,${gridfile} -chname,`echo ${species}_EM_OPENBURNING | awk '{print toupper($0)}'`,flux ${filenameout1b} ${filenameout2} … … 816 603 end 817 604 eod 605 818 606 # 819 607 #--calling IDL … … 832 620 done 833 621 622 #--cleaning up 623 rm -f ferret* 624 834 625 #--unfortunately idl use capital letters for variable names so need to change to small letters for now 835 626 rm -f ${dirout}flux_vector_h2s_${year}.nc ${dirout}flux_vector_so4_${year}.nc … … 845 636 rm -f ${dirout}sflx_lmdz_cmip6_${year}.nc 846 637 #--merging all files into a single one 847 #-- anthroNOx is NO2 so 30/46 scaling factor to change to NO848 #-- openburningNOx is NO so no change in unit638 #--PNNL NOx is NO2 so 30/46 scaling factor to change to NO 639 #--VUA NOx is NO so no change in unit 849 640 cdo merge -expr,'flx_bc=FLX_BC' ${dirout}flux_vector_bc_${year}.nc -expr,'flx_bbbc=FLX_BBBC' ${dirout}flux_vector_bcbb_${year}.nc -expr,'flx_pom=FLX_POM' ${dirout}flux_vector_pom_${year}.nc -expr,'flx_bbpom=FLX_BBPOM' ${dirout}flux_vector_pombb_${year}.nc -expr,'flx_nox=30.*FLX_NOX/46.' ${dirout}flux_vector_nox_${year}.nc -expr,'flx_bbnox=FLX_BBNOX;' ${dirout}flux_vector_noxbb_${year}.nc -expr,'flx_so2=FLX_SO2' ${dirout}flux_vector_so2_${year}.nc -expr,'flx_bbso2=FLX_BBSO2' ${dirout}flux_vector_so2bb_${year}.nc -expr,'flx_nh3=FLX_NH3' ${dirout}flux_vector_nh3_${year}.nc -expr,'flx_bbnh3=FLX_BBNH3' ${dirout}flux_vector_nh3bb_${year}.nc ${dirout}flux_vector_h2s_${year}.nc ${dirout}flux_vector_so4_${year}.nc -selname,conc_dms ${fileINCAex} ${dirout}sflx_lmdz_cmip6_${year}.nc 850 641 … … 853 644 854 645 #--cleaning up 855 #rm -f ${dirout}flux*_${year}.nc856 #--to be uncommented in final version646 rm -f ${dirout}flux*_${year}.nc 647 #--to be uncommented in final script 857 648 858 649 #--end loop on years 859 650 done 860 861 rm -f ${fileintanthro} ${fileintbb}862 651 863 652 #--end loop on scenarios … … 867 656 rm -f ferret* 868 657 rm -f regrid.pro 869 rm -f time_interp_over_gaps.pro sumsectors.jnl select_yr.jnlrewrite.jnl658 rm -f rewrite.jnl
Note: See TracChangeset
for help on using the changeset viewer.