1 | #!/usr/bin/env python3 |
---|
2 | ### |
---|
3 | ### Script to check water conservation in NEMO |
---|
4 | ### |
---|
5 | ## Warning, to install, configure, run, use any of included software or |
---|
6 | ## to read the associated documentation you'll need at least one (1) |
---|
7 | ## brain in a reasonably working order. Lack of this implement will |
---|
8 | ## void any warranties (either express or implied). Authors assumes |
---|
9 | ## no responsability for errors, omissions, data loss, or any other |
---|
10 | ## consequences caused directly or indirectly by the usage of his |
---|
11 | ## software by incorrectly or partially configured personal |
---|
12 | ## |
---|
13 | ## |
---|
14 | ## SVN information |
---|
15 | # $Author$ |
---|
16 | # $Date$ |
---|
17 | # $Revision$ |
---|
18 | # $Id$ |
---|
19 | # $HeadURL$ |
---|
20 | |
---|
21 | |
---|
22 | ## Define Experiment |
---|
23 | ## ----------------- |
---|
24 | |
---|
25 | if False : |
---|
26 | JobName="TEST-CM72-SIMPLE-ROUTING.12" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
27 | Freq = 'MO' ; YearBegin = 1970 ; YearEnd = 1979 ; YearInc = 10 ; PackFrequency=10 |
---|
28 | #Freq = 'MO' ; YearBegin = 1852 ; YearEnd = 1852 ; PackFrequency = 1 |
---|
29 | ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
30 | |
---|
31 | if False : |
---|
32 | JobName="TEST-CM72-SIMPLE-ROUTING.10" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
33 | Freq = 'MO' ; YearBegin = 1860 ; YearEnd = 1869 ; PackFrequency = 10 |
---|
34 | ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
35 | |
---|
36 | if False : |
---|
37 | JobName="VALID-CM622-LR.01" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
38 | Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10 |
---|
39 | ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
40 | |
---|
41 | if False : |
---|
42 | JobName="VALID-CM622-SIMPLE-ROUTING" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
43 | Freq = 'MO' ; YearBegin = 1898 ; YearEnd = 1898 ; PackFrequency = 1 |
---|
44 | ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
45 | |
---|
46 | if False : |
---|
47 | JobName="VALID-CM622-NORESTART" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
48 | Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10 |
---|
49 | ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
50 | |
---|
51 | if True : |
---|
52 | JobName="CM65v420-LR-SKL-pi-05" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p48ethe" ; Project="gencmip6" |
---|
53 | Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10 |
---|
54 | ORCA = 'eORCA1.2' ; NEMO=4.2 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
55 | #/ccc/store/cont003/gencmip6/p48ethe/IGCM_OUT/IPSLCM6/DEVT/piControl/CM65v420-LR-SKL-pi-05 |
---|
56 | |
---|
57 | import numpy as np |
---|
58 | ##-- Some physical constants |
---|
59 | #-- Earth Radius |
---|
60 | Ra = 40.e6 / (2. * np.pi) |
---|
61 | #-- Gravity |
---|
62 | g = 9.81 |
---|
63 | #-- Ice density (kg/m3) in LIM3 |
---|
64 | ICE_rho_ice = 917.0 |
---|
65 | #-- Snow density (kg/m3) in LIM3 |
---|
66 | ICE_rho_sno = 330.0 |
---|
67 | #-- Ocean water density (kg/m3) in NEMO |
---|
68 | OCE_rho_liq = 1026. |
---|
69 | #-- Water density in ice pounds in SI3 |
---|
70 | ICE_rho_pnd = 1000. |
---|
71 | |
---|
72 | ## |
---|
73 | ## Import system modules |
---|
74 | import sys, os, shutil, subprocess |
---|
75 | |
---|
76 | # Where do we run ? |
---|
77 | TGCC = False ; IDRIS = False |
---|
78 | SysName, NodeName, Release, Version, Machine = os.uname () |
---|
79 | if 'irene' in NodeName : TGCC = True |
---|
80 | if 'jeanzay' in NodeName : IDRIS = True |
---|
81 | |
---|
82 | ## Set site specific libIGCM directories, and other specific stuff |
---|
83 | if TGCC : |
---|
84 | CPU = subprocess.getoutput ( 'lscpu | grep "Model name"' ) |
---|
85 | if "Intel(R) Xeon(R) Platinum" in CPU : Machine = 'irene' |
---|
86 | if "AMD" in CPU : Machine = 'irene-amd' |
---|
87 | |
---|
88 | ARCHIVE = subprocess.getoutput ( f'ccc_home --cccstore -d {Project} -u {User}' ) |
---|
89 | STORAGE = subprocess.getoutput ( f'ccc_home --cccwork -d {Project} -u {User}' ) |
---|
90 | SCRATCHDIR = subprocess.getoutput ( f'ccc_home --cccscratch -d {Project} -u {User}' ) |
---|
91 | R_IN = os.path.join ( subprocess.getoutput ( f'ccc_home --cccwork -d igcmg -u igcmg'), 'IGCM') |
---|
92 | rebuild = os.path.join ( subprocess.getoutput ( f'ccc_home --ccchome -d igcmg -u igcmg'), 'Tools', Machine, 'rebuild_nemo', 'bin', 'rebuild_nemo' ) |
---|
93 | |
---|
94 | ## Specific to run at TGCC. |
---|
95 | # Needed before importing a NetCDF library (netCDF4, xarray, cmds, etc ...) |
---|
96 | import mpi4py |
---|
97 | mpi4py.rc.initialize = False |
---|
98 | |
---|
99 | ## Access to the nemo module |
---|
100 | sys.path.append ( os.path.join (subprocess.getoutput ( f'ccc_home -u p86mart' ), 'Python', 'Library') ) |
---|
101 | |
---|
102 | ## Creates output directory |
---|
103 | TmpDir = os.path.join ( subprocess.getoutput ( 'ccc_home --cccscratch' ), f'WATER_{JobName}_{YearBegin}_{YearEnd}' ) |
---|
104 | |
---|
105 | if IDRIS : |
---|
106 | raise Exception ("Pour IDRIS : repertoires et chemins a definir") |
---|
107 | |
---|
108 | |
---|
109 | ## Import specific module |
---|
110 | import nemo |
---|
111 | ## Now import needed scientific modules |
---|
112 | import xarray as xr |
---|
113 | |
---|
114 | # Output file |
---|
115 | FileOut = f'OCE_waterbudget_{JobName}_{YearBegin}_{YearEnd}.out' |
---|
116 | f_out = open ( FileOut, mode = 'w' ) |
---|
117 | |
---|
118 | # Function to print to stdout *and* output file |
---|
119 | def echo (string) : |
---|
120 | print ( string ) |
---|
121 | f_out.write ( string + '\n' ) |
---|
122 | f_out.flush () |
---|
123 | return None |
---|
124 | |
---|
125 | ## Set libIGCM directories |
---|
126 | R_OUT = os.path.join ( ARCHIVE , 'IGCM_OUT') |
---|
127 | R_BUF = os.path.join ( SCRATCHDIR, 'IGCM_OUT') |
---|
128 | |
---|
129 | L_EXP = os.path.join (TagName, SpaceName, ExperimentName, JobName) |
---|
130 | R_SAVE = os.path.join ( R_OUT, L_EXP ) |
---|
131 | R_BUFR = os.path.join ( R_BUF, L_EXP ) |
---|
132 | POST_DIR = os.path.join ( R_BUF, L_EXP, 'Out' ) |
---|
133 | REBUILD_DIR = os.path.join ( R_BUF, L_EXP, 'REBUILD' ) |
---|
134 | R_BUF_KSH = os.path.join ( R_BUFR, 'Out' ) |
---|
135 | R_FIGR = os.path.join ( STORAGE, 'IGCM_OUT', L_EXP ) |
---|
136 | |
---|
137 | #if os.path.isdir (TmpDir) : shutil.rmtree ( TmpDir ) |
---|
138 | if not os.path.isdir (TmpDir) : os.mkdir (TmpDir) |
---|
139 | TmpDirOCE = os.path.join (TmpDir, 'OCE') |
---|
140 | TmpDirICE = os.path.join (TmpDir, 'ICE') |
---|
141 | if not os.path.exists (TmpDirOCE) : os.mkdir (TmpDirOCE ) |
---|
142 | if not os.path.exists (TmpDirICE) : os.mkdir (TmpDirICE ) |
---|
143 | |
---|
144 | echo ( f'Working in TMPDIR : {TmpDir}' ) |
---|
145 | |
---|
146 | echo ( f'\nDealing with {L_EXP}' ) |
---|
147 | |
---|
148 | #-- Model output directories |
---|
149 | if Freq == "MO" : FreqDir = os.path.join ('Output' , 'MO' ) |
---|
150 | if Freq == "SE" : FreqDir = os.path.join ('Analyse', 'SE' ) |
---|
151 | dir_OCE_his = os.path.join ( R_SAVE, "OCE", FreqDir ) |
---|
152 | dir_ICE_his = os.path.join ( R_SAVE, "ICE", FreqDir ) |
---|
153 | |
---|
154 | echo ( f'The analysis relies on files from the following model output directories : ' ) |
---|
155 | echo ( f'{dir_OCE_his}' ) |
---|
156 | echo ( f'{dir_ICE_his}' ) |
---|
157 | |
---|
158 | #-- Files Names |
---|
159 | if Freq == 'MO' : File = f'{JobName}_{YearBegin}0101_{YearEnd}1231_1M' |
---|
160 | if Freq == 'SE' : File = f'{JobName}_SE_{YearBegin}0101_{YearEnd}1231_1M' |
---|
161 | |
---|
162 | echo ('\nOpen history files' ) |
---|
163 | file_OCE_his = os.path.join ( dir_OCE_his, f'{File}_grid_T.nc' ) |
---|
164 | file_OCE_sca = os.path.join ( dir_OCE_his, f'{File}_scalar.nc' ) |
---|
165 | file_ICE_his = os.path.join ( dir_ICE_his, f'{File}_icemod.nc' ) |
---|
166 | |
---|
167 | d_OCE_his = xr.open_dataset ( file_OCE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
168 | d_OCE_sca = xr.open_dataset ( file_OCE_sca, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
169 | d_ICE_his = xr.open_dataset ( file_ICE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
170 | if NEMO == 3.6 :d_ICE_his = d_ICE_his.rename ( {'y_grid_T':'y', 'x_grid_T':'x'} ) |
---|
171 | |
---|
172 | echo ( file_OCE_his ) |
---|
173 | echo ( file_OCE_sca ) |
---|
174 | echo ( file_ICE_his ) |
---|
175 | |
---|
176 | ## Compute run length |
---|
177 | dtime = ( d_OCE_his.time_counter_bounds.max() - d_OCE_his.time_counter_bounds.min() ) |
---|
178 | echo ('\nRun length : {:8.2f} days'.format ( (dtime/np.timedelta64(1, "D")).values ) ) |
---|
179 | dtime_sec = (dtime/np.timedelta64(1, "s")).values.item() # Convert in seconds |
---|
180 | |
---|
181 | ## Compute length of each period |
---|
182 | dtime_per = (d_OCE_his.time_counter_bounds[:,-1] - d_OCE_his.time_counter_bounds[:,0] ) |
---|
183 | echo ('\nPeriods lengths (days) : ') |
---|
184 | echo (' {:}'.format ( (dtime_per/np.timedelta64(1, "D")).values ) ) |
---|
185 | dtime_per_sec = (dtime_per/np.timedelta64(1, "s")).values # In seconds |
---|
186 | dtime_per_sec = xr.DataArray (dtime_per_sec, dims=["time_counter", ], coords=[d_OCE_his.time_counter,] ) |
---|
187 | dtime_per_sec.attrs['unit'] = 's' |
---|
188 | |
---|
189 | #-- Open restart files |
---|
190 | YearRes = YearBegin - 1 # Year of the restart of beginning of simulation |
---|
191 | YearPre = YearBegin - PackFrequency # Year to find the tarfile of the restart of beginning of simulation |
---|
192 | |
---|
193 | echo (f'Restart dates - Start : {YearRes}-12-31 / End : {YearEnd}-12-31 ') |
---|
194 | |
---|
195 | file_restart_beg = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearPre}0101_{YearRes}1231_restart.tar' ) |
---|
196 | file_restart_end = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearBegin}0101_{YearEnd}1231_restart.tar' ) |
---|
197 | |
---|
198 | echo ( f'{file_restart_beg}' ) |
---|
199 | echo ( f'{file_restart_end}' ) |
---|
200 | |
---|
201 | file_OCE_beg = f'OCE_{JobName}_{YearRes}1231_restart.nc' |
---|
202 | file_OCE_end = f'OCE_{JobName}_{YearEnd}1231_restart.nc' |
---|
203 | file_ICE_beg = f'ICE_{JobName}_{YearRes}1231_restart_icemod.nc' |
---|
204 | file_ICE_end = f'ICE_{JobName}_{YearEnd}1231_restart_icemod.nc' |
---|
205 | |
---|
206 | echo ( f'{file_OCE_beg}' ) |
---|
207 | echo ( f'{file_OCE_end}' ) |
---|
208 | echo ( f'{file_ICE_beg}' ) |
---|
209 | echo ( f'{file_ICE_end}' ) |
---|
210 | |
---|
211 | echo ('\nExtract and rebuild OCE and ICE restarts') |
---|
212 | def get_ndomain (zfile) : |
---|
213 | #d_zfile = xr.open_dataset (zfile, decode_times=False).squeeze() |
---|
214 | #ndomain_opa = d_zfile.attrs['DOMAIN_number_total'] |
---|
215 | #d_zfile.close () |
---|
216 | ndomain_opa = subprocess.getoutput ( f'ls {zfile}_*.nc | wc -l' ).format() |
---|
217 | return int (ndomain_opa) |
---|
218 | |
---|
219 | if not os.path.exists ( os.path.join (TmpDir, file_OCE_beg) ) : |
---|
220 | echo ( 'Extracting '+ os.path.join (TmpDir, file_OCE_beg) ) |
---|
221 | if not os.path.exists ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearRes}1231_restart_0000.nc') ) : |
---|
222 | command = f'cd {TmpDirOCE} ; tar xf {file_restart_beg} OCE_{JobName}_{YearRes}1231_restart_*.nc' |
---|
223 | echo ( command ) |
---|
224 | os.system ( command ) |
---|
225 | print ('1.2') |
---|
226 | echo ('extract ndomain' ) |
---|
227 | ndomain_opa = get_ndomain ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearRes}1231_restart') ) |
---|
228 | command = f'cd {TmpDirOCE} ; {rebuild} OCE_{JobName}_{YearRes}1231_restart {ndomain_opa} ; mv {file_OCE_beg} {TmpDir}' |
---|
229 | echo ( command ) |
---|
230 | os.system ( command ) |
---|
231 | echo ( f'Rebuild done : {file_OCE_beg}') |
---|
232 | |
---|
233 | if not os.path.exists ( os.path.join (TmpDir, file_OCE_end) ) : |
---|
234 | if not os.path.exists ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearEnd}1231_restart_0000.nc') ): |
---|
235 | command = f'cd {TmpDirOCE} ; tar xf {file_restart_end} OCE_{JobName}_{YearEnd}1231_restart_*.nc' |
---|
236 | echo ( command ) |
---|
237 | os.system ( command ) |
---|
238 | echo ('extract ndomain' ) |
---|
239 | ndomain_opa = get_ndomain ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearEnd}1231_restart') ) |
---|
240 | command = f'cd {TmpDirOCE} ; {rebuild} OCE_{JobName}_{YearEnd}1231_restart {ndomain_opa} ; mv {file_OCE_end} {TmpDir}' |
---|
241 | echo ( command ) |
---|
242 | os.system ( command ) |
---|
243 | echo ( f'Rebuild done : {file_OCE_end}') |
---|
244 | |
---|
245 | if not os.path.exists ( os.path.join (TmpDir, file_ICE_beg) ) : |
---|
246 | if not os.path.exists ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod_0000.nc') ): |
---|
247 | command = f'cd {TmpDirICE} ; tar xf {file_restart_beg} ICE_{JobName}_{YearRes}1231_restart_icemod_*.nc' |
---|
248 | echo ( command ) |
---|
249 | os.system ( command ) |
---|
250 | echo ('extract ndomain' ) |
---|
251 | ndomain_opa = get_ndomain ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod') ) |
---|
252 | command = f'cd {TmpDirICE} ; {rebuild} ICE_{JobName}_{YearRes}1231_restart_icemod {ndomain_opa} ; mv {file_ICE_beg} {TmpDir} ' |
---|
253 | echo ( command ) |
---|
254 | os.system ( command ) |
---|
255 | echo ( f'Rebuild done : {file_OCE_beg}') |
---|
256 | |
---|
257 | if not os.path.exists ( os.path.join (TmpDir, file_ICE_end) ) : |
---|
258 | if not os.path.exists ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearEnd}1231_restart_icemod_0000.nc') ): |
---|
259 | command = f'cd {TmpDirICE} ; tar xf {file_restart_end} ICE_{JobName}_{YearEnd}1231_restart_icemod_*.nc' |
---|
260 | echo ( command ) |
---|
261 | os.system ( command ) |
---|
262 | echo ('extract ndomain' ) |
---|
263 | ndomain_opa = get_ndomain ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod') ) |
---|
264 | command = f'cd {TmpDirICE} ; {rebuild} ICE_{JobName}_{YearEnd}1231_restart_icemod {ndomain_opa} ; mv {file_ICE_end} {TmpDir}' |
---|
265 | echo ( command ) |
---|
266 | os.system ( command ) |
---|
267 | echo ( f'Rebuild done : {file_ICE_end}') |
---|
268 | |
---|
269 | echo ('Opening OCE and ICE restart files') |
---|
270 | if NEMO == 3.6 : |
---|
271 | d_OCE_beg = xr.open_dataset ( os.path.join (TmpDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
272 | d_OCE_end = xr.open_dataset ( os.path.join (TmpDir, file_OCE_end), decode_times=False, decode_cf=True).squeeze() |
---|
273 | d_ICE_beg = xr.open_dataset ( os.path.join (TmpDir, file_ICE_beg), decode_times=False, decode_cf=True).squeeze() |
---|
274 | d_ICE_end = xr.open_dataset ( os.path.join (TmpDir, file_ICE_end), decode_times=False, decode_cf=True).squeeze() |
---|
275 | if NEMO == 4.0 or NEMO == 4.2 : |
---|
276 | d_OCE_beg = xr.open_dataset ( os.path.join (TmpDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
277 | d_OCE_end = xr.open_dataset ( os.path.join (TmpDir, file_OCE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
278 | d_ICE_beg = xr.open_dataset ( os.path.join (TmpDir, file_ICE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
279 | d_ICE_end = xr.open_dataset ( os.path.join (TmpDir, file_ICE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
280 | |
---|
281 | # Get mask and surfaces |
---|
282 | sos = d_OCE_his ['sos'][0].squeeze() |
---|
283 | OCE_msk = nemo.lbc_mask ( xr.where ( sos>0., 1., 0. ), cd_type = 'T', sval = 0. ) |
---|
284 | |
---|
285 | so = sos = d_OCE_his ['sos'][0].squeeze() |
---|
286 | OCE_msk3 = nemo.lbc_mask ( xr.where ( so>0., 1., 0. ), cd_type = 'T', sval = 0. ) |
---|
287 | |
---|
288 | # lbc_mask removes the duplicate points (periodicity and north fold) |
---|
289 | OCE_aire = nemo.lbc_mask ( d_OCE_his ['area'] * OCE_msk, cd_type = 'T', sval = 0.0 ) |
---|
290 | ICE_aire = OCE_aire |
---|
291 | |
---|
292 | OCE_aire_tot = np.sum (OCE_aire).values.item() |
---|
293 | ICE_aire_tot = np.sum (ICE_aire).values.item() |
---|
294 | |
---|
295 | |
---|
296 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
297 | echo ( '-- NEMO change in stores (for the records)' ) |
---|
298 | #-- Note that the total number of days of the run should be diagnosed rather than assumed |
---|
299 | #-- Here the result is in Sv |
---|
300 | # |
---|
301 | #-- Change in ocean volume in freshwater equivalent |
---|
302 | |
---|
303 | OCE_ssh_beg = d_OCE_beg['sshn'] |
---|
304 | OCE_ssh_end = d_OCE_end['sshn'] |
---|
305 | OCE_sum_ssh_beg = np.sum ( OCE_ssh_beg * OCE_aire ).values.item() |
---|
306 | OCE_sum_ssh_end = np.sum ( OCE_ssh_end * OCE_aire ).values.item() |
---|
307 | |
---|
308 | if NEMO == 3.6 : |
---|
309 | OCE_e3tn_beg = d_OCE_beg['fse3t_n'] |
---|
310 | OCE_e3tn_end = d_OCE_end['fse3t_n'] |
---|
311 | OCE_sum_e3tn_beg = np.sum ( OCE_e3tn_beg * OCE_aire * OCE_msk3).values.item() |
---|
312 | OCE_sum_e3tn_end = np.sum ( OCE_e3tn_end * OCE_aire * OCE_msk3).values.item() |
---|
313 | |
---|
314 | echo ( 'OCE_sum_ssh_beg = {:12.6e} m^3 - OCE_sum_ssh_end = {:12.6e} m^3'.format (OCE_sum_ssh_beg, OCE_sum_ssh_end) ) |
---|
315 | dOCE_ssh_vol = ( OCE_sum_ssh_end - OCE_sum_ssh_beg ) |
---|
316 | dOCE_ssh_mas = dOCE_ssh_vol * OCE_rho_liq |
---|
317 | |
---|
318 | if NEMO == 3.6 : |
---|
319 | echo ( 'OCE_sum_e3tn_beg = {:12.6e} m^3 - OCE_sum_e3tn_end = {:12.6e} m^3'.format (OCE_sum_e3tn_beg, OCE_sum_e3tn_end) ) |
---|
320 | dOCE_e3tn_vol = ( OCE_sum_e3tn_end - OCE_sum_e3tn_beg ) |
---|
321 | dOCE_e3tn_mas = dOCE_e3tn_vol * OCE_rho_liq |
---|
322 | |
---|
323 | dOCE_vol_wat = dOCE_ssh_vol ; dOCE_mas_wat = dOCE_ssh_mas |
---|
324 | |
---|
325 | echo ( 'dOCE vol = {:12.3e} m^3'.format ( dOCE_vol_wat) ) |
---|
326 | echo ( 'dOCE ssh = {:12.3e} m '.format ( dOCE_vol_wat/OCE_aire_tot) ) |
---|
327 | echo ( 'dOCE mass = {:12.3e} kg '.format ( dOCE_mas_wat) ) |
---|
328 | echo ( 'dOCE mass = {:12.3e} Sv '.format ( dOCE_mas_wat/dtime_sec*1E-9) ) |
---|
329 | |
---|
330 | if NEMO == 3.6 : |
---|
331 | echo ( 'dOCE e3tn vol = {:12.3e} m^3'.format ( dOCE_e3tn_vol) ) |
---|
332 | echo ( 'dOCE e3tn mass = {:12.3e} kg '.format ( dOCE_e3tn_mas) ) |
---|
333 | |
---|
334 | |
---|
335 | ## Glace et neige |
---|
336 | if NEMO == 3.6 : |
---|
337 | ICE_ice_beg = d_ICE_beg['v_i_htc1']+d_ICE_beg['v_i_htc2']+d_ICE_beg['v_i_htc3']+d_ICE_beg['v_i_htc4']+d_ICE_beg['v_i_htc5'] |
---|
338 | ICE_ice_end = d_ICE_end['v_i_htc1']+d_ICE_end['v_i_htc2']+d_ICE_end['v_i_htc3']+d_ICE_end['v_i_htc4']+d_ICE_end['v_i_htc5'] |
---|
339 | |
---|
340 | ICE_sno_beg = d_ICE_beg['v_s_htc1']+d_ICE_beg['v_s_htc2']+d_ICE_beg['v_s_htc3']+d_ICE_beg['v_s_htc4']+d_ICE_beg['v_s_htc5'] |
---|
341 | ICE_sno_end = d_ICE_end['v_s_htc1']+d_ICE_end['v_s_htc2']+d_ICE_end['v_s_htc3']+d_ICE_end['v_s_htc4']+d_ICE_end['v_s_htc5'] |
---|
342 | |
---|
343 | ICE_pnd_beg = 0.0 |
---|
344 | ICE_pnd_end = 0.0 |
---|
345 | |
---|
346 | ICE_fzl_beg = 0.0 |
---|
347 | ICE_fzl_end = 0.0 |
---|
348 | |
---|
349 | ICE_mas_wat_beg = ICE_ice_beg*ICE_rho_ice + ICE_sno_beg*ICE_rho_sno |
---|
350 | ICE_mas_wat_end = ICE_ice_end*ICE_rho_ice + ICE_sno_end*ICE_rho_sno |
---|
351 | |
---|
352 | if NEMO == 4.0 or NEMO == 4.2 : |
---|
353 | ICE_ice_beg = d_ICE_beg['v_i'] |
---|
354 | ICE_ice_end = d_ICE_end['v_i'] |
---|
355 | |
---|
356 | ICE_sno_beg = d_ICE_beg['v_s'] |
---|
357 | ICE_sno_end = d_ICE_end['v_s'] |
---|
358 | |
---|
359 | ICE_pnd_beg = d_ICE_beg['v_ip'] # Ice ponds |
---|
360 | ICE_pnd_end = d_ICE_end['v_ip'] |
---|
361 | |
---|
362 | ICE_fzl_beg = d_ICE_beg['v_il'] # Frozen Ice Ponds |
---|
363 | ICE_fzl_end = d_ICE_end['v_il'] |
---|
364 | |
---|
365 | ICE_mas_wat_beg = np.sum ( d_ICE_beg['snwice_mass']*ICE_aire ).values.item() |
---|
366 | ICE_mas_wat_end = np.sum ( d_ICE_end['snwice_mass']*ICE_aire ).values.item() |
---|
367 | |
---|
368 | |
---|
369 | ICE_vol_ice_beg = np.sum ( ICE_ice_beg*ICE_aire ).values.item() |
---|
370 | ICE_vol_ice_end = np.sum ( ICE_ice_end*ICE_aire ).values.item() |
---|
371 | |
---|
372 | ICE_vol_sno_beg = np.sum ( ICE_sno_beg*ICE_aire ).values.item() |
---|
373 | ICE_vol_sno_end = np.sum ( ICE_sno_end*ICE_aire ).values.item() |
---|
374 | |
---|
375 | ICE_vol_pnd_beg = np.sum ( ICE_pnd_beg*ICE_aire ).values.item() |
---|
376 | ICE_vol_pnd_end = np.sum ( ICE_pnd_end*ICE_aire ).values.item() |
---|
377 | |
---|
378 | ICE_vol_fzl_beg = np.sum ( ICE_fzl_beg*ICE_aire ).values.item() |
---|
379 | ICE_vol_fzl_end = np.sum ( ICE_fzl_end*ICE_aire ).values.item() |
---|
380 | |
---|
381 | #-- Converting to freswater volume |
---|
382 | dICE_vol_ice = ICE_vol_ice_end - ICE_vol_ice_beg |
---|
383 | dICE_mas_ice = dICE_vol_ice * ICE_rho_ice |
---|
384 | |
---|
385 | dICE_vol_sno = ICE_vol_sno_end - ICE_vol_sno_beg |
---|
386 | dICE_mas_sno = dICE_vol_sno * ICE_rho_sno |
---|
387 | |
---|
388 | dICE_vol_pnd = ICE_vol_pnd_end - ICE_vol_pnd_beg |
---|
389 | dICE_mas_pnd = dICE_vol_pnd * ICE_rho_pnd |
---|
390 | |
---|
391 | dICE_vol_fzl= ICE_vol_fzl_end - ICE_vol_fzl_beg |
---|
392 | dICE_mas_fzl = dICE_vol_fzl * ICE_rho_pnd |
---|
393 | |
---|
394 | if NEMO == 3.6 : |
---|
395 | dICE_mas_wat = dICE_mas_ice + dICE_mas_sno |
---|
396 | dSEA_mas_wat = dOCE_mas_wat + dICE_mas_ice + dICE_mas_sno |
---|
397 | |
---|
398 | if NEMO == 4.0 or NEMO == 4.2 : |
---|
399 | dICE_mas_wat = ICE_mas_wat_end - ICE_mas_wat_beg |
---|
400 | dSEA_mas_wat = dOCE_mas_wat + dICE_mas_wat |
---|
401 | |
---|
402 | echo ( 'ICE_vol_ice_beg = {:12.6e} m^3 - ICE_vol_ice_end = {:12.6e} m^3'.format (ICE_vol_ice_beg, ICE_vol_ice_end) ) |
---|
403 | echo ( 'ICE_vol_sno_beg = {:12.6e} m^3 - ICE_vol_sno_end = {:12.6e} m^3'.format (ICE_vol_sno_beg, ICE_vol_sno_end) ) |
---|
404 | echo ( 'ICE_vol_pnd_beg = {:12.6e} m^3 - ICE_vol_pnd_end = {:12.6e} m^3'.format (ICE_vol_pnd_beg, ICE_vol_pnd_end) ) |
---|
405 | echo ( 'ICE_vol_fzl_beg = {:12.6e} m^3 - ICE_vol_fzl_end = {:12.6e} m^3'.format (ICE_vol_fzl_beg, ICE_vol_fzl_end) ) |
---|
406 | |
---|
407 | echo ( 'dICE_vol_ice = {:12.3e} m^3'.format (dICE_vol_ice) ) |
---|
408 | echo ( 'dICE_vol_sno = {:12.3e} m^3'.format (dICE_vol_sno) ) |
---|
409 | echo ( 'dICE_vol_pnd = {:12.3e} m^3'.format (dICE_vol_pnd) ) |
---|
410 | echo ( 'dICE_mas_ice = {:12.3e} m^3'.format (dICE_mas_ice) ) |
---|
411 | echo ( 'dICE_mas_sno = {:12.3e} m^3'.format (dICE_mas_sno) ) |
---|
412 | echo ( 'dICE_mas_pnd = {:12.3e} m^3'.format (dICE_mas_pnd) ) |
---|
413 | echo ( 'dICE_mas_fzl = {:12.3e} m^3'.format (dICE_mas_fzl) ) |
---|
414 | |
---|
415 | |
---|
416 | echo ( '\n------------------------------------------------------------') |
---|
417 | echo ( 'Variation du contenu en eau ocean + glace ' ) |
---|
418 | echo ( 'dMass(ocean) = {:12.6e} kg '.format(dSEA_mas_wat) ) |
---|
419 | echo ( 'dVol (ocean) = {:12.3e} Sv '.format(dSEA_mas_wat/dtime_sec*1E-9) ) |
---|
420 | echo ( 'dVol (ocean) = {:12.3e} m '.format(dSEA_mas_wat*1E-3/OCE_aire_tot) ) |
---|
421 | |
---|
422 | |
---|
423 | ### |
---|
424 | ### And now, working on fluxes !! |
---|
425 | |
---|
426 | # if coupled: |
---|
427 | # emp_oce = evap - precip (including blowing snow) - calving |
---|
428 | # emp_ice = evap - precip (excluding blowing snow) |
---|
429 | # emp_ice = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0) |
---|
430 | # runoffs = rivers + icebergs |
---|
431 | # empmr = emp_oce - wfx_ice - wfx_snw - wfx_pnd(v4.0.6) - wfx_err_sub - runoffs |
---|
432 | # doce+ice = - evap + precip + calving (emp_oce) |
---|
433 | # + rivers + icebergs (friver+iceberg ou runoffs) |
---|
434 | # + iceshelf (iceshelf) |
---|
435 | # - emp_ice (emp_ice) |
---|
436 | # dice = - emp_ice - wfx_snw - wfx_ice - wfx_pnd(v4.0.6) - wfx_err_sub |
---|
437 | |
---|
438 | #OCE_emp = evap - precip (including blowing snow) - calving |
---|
439 | #ICE_emp = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0) |
---|
440 | |
---|
441 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
442 | echo ( '-- Checks in NEMO - from budget_modipsl.sh (Clement Rousset)' ) |
---|
443 | |
---|
444 | def OCE_flux_int (flux, aire=OCE_aire, dt=dtime_per_sec) : |
---|
445 | '''Integrate flux on ocean grid''' |
---|
446 | OCE_flux_int = np.sum ( flux * aire * dt).values.item() |
---|
447 | #OCE_flux_int = np.sum ( flux.to_masked_array()[:,:] * aire.to_masked_array()[np.newaxis,:,:] * dt.to_masked_array()[:,np.newaxis,np.newaxis]) |
---|
448 | return OCE_flux_int |
---|
449 | |
---|
450 | # Read variable and computes integral over space and time |
---|
451 | OCE_empmr = d_OCE_his['wfo'] ; OCE_mas_empmr = OCE_flux_int ( OCE_empmr ) |
---|
452 | OCE_wfob = d_OCE_his['wfob'] ; OCE_mas_wfob = OCE_flux_int ( OCE_wfob ) |
---|
453 | OCE_emp_oce = d_OCE_his['emp_oce'] ; OCE_mas_emp_oce = OCE_flux_int ( OCE_emp_oce ) |
---|
454 | OCE_emp_ice = d_OCE_his['emp_ice'] ; OCE_mas_emp_ice = OCE_flux_int ( OCE_emp_ice ) |
---|
455 | OCE_iceshelf = d_OCE_his['iceshelf'] ; OCE_mas_iceshelf = OCE_flux_int ( OCE_iceshelf ) |
---|
456 | OCE_calving = d_OCE_his['calving'] ; OCE_mas_calving = OCE_flux_int ( OCE_calving ) |
---|
457 | OCE_iceberg = d_OCE_his['iceberg'] ; OCE_mas_iceberg = OCE_flux_int ( OCE_iceberg ) |
---|
458 | OCE_friver = d_OCE_his['friver'] ; OCE_mas_friver = OCE_flux_int ( OCE_friver ) |
---|
459 | OCE_runoffs = d_OCE_his['runoffs'] ; OCE_mas_runoffs = OCE_flux_int ( OCE_runoffs ) |
---|
460 | if NEMO == 4.0 or NEMO == 4.2 : |
---|
461 | OCE_wfxice = d_OCE_his['vfxice'] ; OCE_mas_wfxice = OCE_flux_int ( OCE_wfxice ) |
---|
462 | OCE_wfxsnw = d_OCE_his['vfxsnw'] ; OCE_mas_wfxsnw = OCE_flux_int ( OCE_wfxsnw ) |
---|
463 | OCE_wfxsub = d_OCE_his['vfxsub'] ; OCE_mas_wfxsub = OCE_flux_int ( OCE_wfxsub ) |
---|
464 | if NEMO == 3.6 : |
---|
465 | OCE_wfxice = d_OCE_his['vfxice']/86400.*ICE_rho_ice ; OCE_mas_wfxice = OCE_flux_int ( OCE_wfxice ) |
---|
466 | OCE_wfxsnw = d_OCE_his['vfxsnw']/86400.*ICE_rho_sno ; OCE_mas_wfxsnw = OCE_flux_int ( OCE_wfxsnw ) |
---|
467 | OCE_wfxsub = d_OCE_his['vfxsub']/86400.*ICE_rho_sno ; OCE_mas_wfxsub = OCE_flux_int ( OCE_wfxsub ) |
---|
468 | # Additional checks |
---|
469 | OCE_evap_oce = d_OCE_his['evap_ao_cea'] ; OCE_mas_evap_oce = OCE_flux_int ( OCE_evap_oce ) |
---|
470 | ICE_evap_ice = d_OCE_his['subl_ai_cea'] ; ICE_mas_evap_ice = OCE_flux_int ( ICE_evap_ice ) |
---|
471 | OCE_snow_oce = d_OCE_his['snow_ao_cea'] ; OCE_mas_snow_oce = OCE_flux_int ( OCE_snow_oce ) |
---|
472 | OCE_snow_ice = d_OCE_his['snow_ai_cea'] ; OCE_mas_snow_ice = OCE_flux_int ( OCE_snow_ice ) |
---|
473 | OCE_rain = d_OCE_his['rain'] ; OCE_mas_rain = OCE_flux_int ( OCE_rain ) |
---|
474 | ICE_wfxsub_err = d_ICE_his['vfxsub_err'] ; ICE_mas_wfxsub_err = OCE_flux_int ( ICE_wfxsub_err ) |
---|
475 | if NEMO == 4.0 or NEMO == 4.2 : |
---|
476 | ICE_wfxpnd = d_ICE_his['vfxpnd'] ; ICE_mas_wfxpnd = OCE_flux_int ( ICE_wfxpnd ) |
---|
477 | ICE_wfxsnw_sub = d_ICE_his['vfxsnw_sub'] ; ICE_mas_wfxsnw_sub = OCE_flux_int ( ICE_wfxsnw_sub ) |
---|
478 | ICE_wfxsnw_pre = d_ICE_his['vfxsnw_pre'] ; ICE_mas_wfxsnw_pre = OCE_flux_int ( ICE_wfxsnw_pre ) |
---|
479 | if NEMO == 3.6 : |
---|
480 | ICE_wfxpnd = 0.0 ; ICE_mas_wfxpnd = 0.0 |
---|
481 | ICE_wfxsnw_sub = d_ICE_his['vfxsub']/86400.*ICE_rho_sno ; ICE_mas_wfxsnw_sub = OCE_flux_int ( ICE_wfxsnw_sub ) |
---|
482 | ICE_wfxsnw_pre = d_ICE_his['vfxspr']/86400.*ICE_rho_sno ; ICE_mas_wfxsnw_pre = OCE_flux_int ( ICE_wfxsnw_pre ) |
---|
483 | |
---|
484 | OCE_wfcorr = d_OCE_his['wfcorr'] ; OCE_mas_wfcorr = OCE_flux_int ( OCE_wfcorr ) |
---|
485 | if OCE_relax : |
---|
486 | # ssr and fwb are included in emp=>empmr but not in emp_oce (outputed by sea-ice) |
---|
487 | OCE_vflx_fwb = d_OCE_his['vflx_fwb'] ; OCE_mas_vflx_fwb = OCE_flux_int ( OCE_vflx_fwb ) |
---|
488 | OCE_vflx_ssr = d_OCE_his['vflx_ssr'] ; OCE_mas_vflx_ssr = OCE_flux_int ( OCE_vflx_ssr ) |
---|
489 | else : |
---|
490 | OCE_fwb = 0.0 ; OCE_mas_fwb = 0.0 |
---|
491 | OCE_ssr = 0.0 ; OCE_mas_ssr = 0.0 |
---|
492 | if OCE_icb : |
---|
493 | OCE_berg_icb = d_OCE_his['berg_floating_melt'] ; OCE_mas_berg_icb = OCE_flux_int ( OCE_berg_icb ) |
---|
494 | OCE_calving_icb = d_OCE_his['calving_icb'] ; OCE_mas_calv_icb = OCE_flux_int ( OCE_calving_icb ) |
---|
495 | else : |
---|
496 | OCE_berg_icb = 0. ; OCE_mas_berg_icb = 0. |
---|
497 | OCE_calv_icb = 0. ; OCE_mas_calv_icb = 0. |
---|
498 | |
---|
499 | OCE_mas_emp = OCE_mas_emp_oce - OCE_mas_wfxice - OCE_mas_wfxsnw - ICE_mas_wfxpnd - ICE_mas_wfxsub_err |
---|
500 | |
---|
501 | |
---|
502 | echo ('\n-- Fields:' ) |
---|
503 | echo (' EMPMR {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_empmr , OCE_mas_empmr / dtime_sec*1E-9 )) |
---|
504 | echo (' WFOB {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_wfob , OCE_mas_wfob / dtime_sec*1E-9 )) |
---|
505 | echo (' EMP_OCE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_emp_oce , OCE_mas_emp_oce / dtime_sec*1E-9 )) |
---|
506 | echo (' EMP_ICE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_emp_ice , OCE_mas_emp_ice / dtime_sec*1E-9 )) |
---|
507 | echo (' ICEBERG {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_iceberg , OCE_mas_iceberg / dtime_sec*1E-9 )) |
---|
508 | echo (' ICESHELF {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_iceshelf , OCE_mas_iceshelf / dtime_sec*1E-9 )) |
---|
509 | echo (' CALVING {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_calving , OCE_mas_calving / dtime_sec*1E-9 )) |
---|
510 | echo (' FRIVER {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_friver , OCE_mas_friver / dtime_sec*1E-9 )) |
---|
511 | echo (' RUNOFFS {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_runoffs , OCE_mas_runoffs / dtime_sec*1E-9 )) |
---|
512 | echo (' WFXICE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_wfxice , OCE_mas_wfxice / dtime_sec*1E-9 )) |
---|
513 | echo (' WFXSNW {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_wfxsnw , OCE_mas_wfxsnw / dtime_sec*1E-9 )) |
---|
514 | echo (' WFXSUB {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_wfxsub , OCE_mas_wfxsub / dtime_sec*1E-9 )) |
---|
515 | echo (' WFXPND {:12.3e} (kg) {:12.3f} (Sv) '.format ( ICE_mas_wfxpnd , ICE_mas_wfxpnd / dtime_sec*1E-9 )) |
---|
516 | echo (' WFXSNW_SUB {:12.3e} (kg) {:12.3f} (Sv) '.format ( ICE_mas_wfxsnw_sub, ICE_mas_wfxsnw_sub / dtime_sec*1E-9 )) |
---|
517 | echo (' WFXSNW_PRE {:12.3e} (kg) {:12.3f} (Sv) '.format ( ICE_mas_wfxsnw_pre, ICE_mas_wfxsnw_pre / dtime_sec*1E-9 )) |
---|
518 | echo (' WFXSUB_ERR {:12.3e} (kg) {:12.3e} (Sv) '.format ( ICE_mas_wfxsub_err, ICE_mas_wfxsub_err / dtime_sec*1E-9 )) |
---|
519 | echo (' EVAP_OCE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_evap_oce , OCE_mas_evap_oce / dtime_sec*1E-9 )) |
---|
520 | echo (' EVAP_ICE {:12.3e} (kg) {:12.3f} (Sv) '.format ( ICE_mas_evap_ice , ICE_mas_evap_ice / dtime_sec*1E-9 )) |
---|
521 | echo (' SNOW_OCE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_snow_oce , OCE_mas_snow_oce / dtime_sec*1E-9 )) |
---|
522 | echo (' SNOW_ICE {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_snow_ice , OCE_mas_snow_ice / dtime_sec*1E-9 )) |
---|
523 | echo (' RAIN {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_rain , OCE_mas_rain / dtime_sec*1E-9 )) |
---|
524 | echo (' FWB {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_fwb , OCE_mas_fwb / dtime_sec*1E-9 )) |
---|
525 | echo (' SSR {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_ssr , OCE_mas_ssr / dtime_sec*1E-9 )) |
---|
526 | echo (' WFCORR {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_wfcorr , OCE_mas_wfcorr / dtime_sec*1E-9 )) |
---|
527 | echo (' BERG_ICB {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_berg_icb , OCE_mas_berg_icb / dtime_sec*1E-9 )) |
---|
528 | echo (' CALV_ICB {:12.3e} (kg) {:12.3f} (Sv) '.format ( OCE_mas_calv_icb , OCE_mas_calv_icb / dtime_sec*1E-9 )) |
---|
529 | |
---|
530 | echo ('\n===> Comparing ===>' ) |
---|
531 | echo (' WFX OCE = -empmr + iceshelf = {:12.5e} (kg) '.format ( -OCE_mas_empmr + OCE_mas_iceshelf) ) |
---|
532 | echo (' versus d OCE = {:12.5e} (kg) '.format ( dOCE_mas_wat) ) |
---|
533 | echo (' WFX ICE+SNW+PND 1 = emp_ice - wfxice - wfxsnw - wfxpnd - wfxsub_err = {:12.5e} (kg) '.format ( -OCE_mas_emp_ice - OCE_mas_wfxice - OCE_mas_wfxsnw - ICE_mas_wfxpnd - ICE_mas_wfxsub_err) ) |
---|
534 | echo (' WFX ICE+SNW+PND 2 = -emp_ice + empmr - emp_oce + runoffs = {:12.5e} (kg) '.format ( -OCE_mas_emp_ice + OCE_mas_empmr - OCE_mas_emp_oce + OCE_mas_runoffs )) |
---|
535 | echo (' versus d ICE+SNW+PND = {:12.5e} (kg) '.format ( dICE_mas_wat)) # Manque PND ? |
---|
536 | if Coupled : |
---|
537 | echo (' WFX OCE+ICE+SNW+PND = -emp_oce - emp_ice + runoffs + iceshelf = {:12.5e} (kg) '.format ( -OCE_mas_emp_oce - OCE_mas_emp_ice + OCE_mas_runoffs + OCE_mas_iceshelf)) |
---|
538 | else : |
---|
539 | echo (' WFX OCE+ICE+SNW+PND = -emp_oce - emp_ice + runoffs + iceberg + calving + iceshelf = {:12.5e} (kg) '.format ( -OCE_mas_emp_oce - OCE_mas_emp_ice + OCE_mas_runoffs + OCE_mas_iceberg + OCE_mas_calving + OCE_mas_iceshelf)) |
---|
540 | echo (' versus d OCE+ICE+SNW+PND = {:12.5e} (kg) '.format ( dSEA_mas_wat )) # Manque PND |
---|
541 | |
---|
542 | echo ('\n===> Leaks ===>') |
---|
543 | echo (' Leak OCE = dOCE_mas_wat + empmr - iceshelf = {:12.3e} (kg) '.format ( dOCE_mas_wat + OCE_mas_empmr - OCE_mas_iceshelf) ) |
---|
544 | echo (' = (dOCE_mas_wat + empmr - iceshelf)/abs(dOCE_mas_wat) = {:12.1e} (-) '.format ( (dOCE_mas_wat + OCE_mas_empmr - OCE_mas_iceshelf ) / abs (dOCE_mas_wat) ) ) |
---|
545 | echo (' Leak ICE+SNW+PND 1 = dICE_mas_wat + emp_ice + wfxice + wfxsnw + wfxpnd + wfxsub_err = {:12.3e} (kg) '.format ( dICE_mas_wat + OCE_mas_emp_ice + OCE_mas_wfxice + OCE_mas_wfxsnw + ICE_mas_wfxpnd + ICE_mas_wfxsub_err ) ) |
---|
546 | echo (' = (dICE_mas_wat + emp_ice + wfxice + wfxsnw + wfxpnd + wfxsub_err )/dICE_mas_wat = {:12.1e} (-) '.format ( (dICE_mas_wat + OCE_mas_emp_ice + OCE_mas_wfxice + OCE_mas_wfxsnw + ICE_mas_wfxpnd + ICE_mas_wfxsub_err)/abs(dICE_mas_wat)) ) |
---|
547 | echo (' Leak ICE+SNW+PND 2 = dICE_mas_wat + emp_ice - empmr + emp_oce - runoffs = {:12.3e} (kg) '.format ( dICE_mas_wat + OCE_mas_emp_ice - OCE_mas_empmr + OCE_mas_emp_oce - OCE_mas_runoffs )) |
---|
548 | echo (' = (dICE_mas_wat - empmr + emp_oce - runoffs)/abs(dICE_mas_wat) = {:12.1e} (-) '.format ( (dICE_mas_wat - OCE_mas_empmr + OCE_mas_emp_oce - OCE_mas_runoffs)/abs(dICE_mas_wat)) ) |
---|
549 | echo (' Leak OCE+ICE+SNW+PND = d(ICE+OCE)_mas_wat + emp_oce + emp_ice - runoffs - iceshelf = {:12.3e} (kg) '.format ( dSEA_mas_wat + OCE_mas_emp_oce +OCE_mas_emp_ice - OCE_mas_runoffs - OCE_mas_iceshelf )) |
---|
550 | echo (' = (dSEA_mas_wat + emp_oce + emp_ice - runoffs - iceshelf)*/abs(dSEA_mas_wat) = {:12.1e} (-) '.format ( (dSEA_mas_wat + OCE_mas_emp_oce + OCE_mas_emp_ice - OCE_mas_runoffs - OCE_mas_iceshelf)/abs(dSEA_mas_wat) ) ) |
---|
551 | |
---|
552 | |
---|
553 | # check if emp = emp_ice + emp_oce - calving |
---|
554 | # emp_ice = wfxsub + wfxsnw_sub + wfxsnw_pre - wfxsub_err |
---|
555 | |
---|
556 | echo ('\n===> Checks ===>' ) |
---|
557 | echo (' Check EMPMR = empmr - emp_oce + runoffs + wfxice + wfxsnw + wfxpnd + wfxsub_err = {:12.5e} (kg) '.format ( OCE_mas_empmr - OCE_mas_emp_oce + OCE_mas_runoffs + OCE_mas_wfxice + OCE_mas_wfxsnw + ICE_mas_wfxpnd + ICE_mas_wfxsub_err )) |
---|
558 | if Coupled : |
---|
559 | echo (' Check EMP_OCE = emp_oce + fwb + ssr - evap_oce + rain + snow_oce + calving = {:12.5e} (kg) '.format ( OCE_mas_emp_oce + OCE_mas_fwb + OCE_mas_ssr - OCE_mas_evap_oce + OCE_mas_rain + OCE_mas_snow_oce + OCE_mas_calving )) |
---|
560 | else : |
---|
561 | echo (' Check EMP_OCE = emp_oce + ssr + fwb - evap_oce + rain + snow_oce = {:12.5e} (kg) '.format ( OCE_mas_emp_oce + OCE_mas_ssr + OCE_mas_fwb - OCE_mas_evap_oce + OCE_mas_rain + OCE_mas_snow_oce )) |
---|
562 | echo (' Check EMP_ICE = emp_ice - evap_ice + snow_ice = {:12.5e} (kg) '.format ( OCE_mas_emp_ice - ICE_mas_evap_ice + OCE_mas_snow_ice )) |
---|
563 | echo (' Check EMP_ICE vs WFX = emp_ice - wfxsub - wfxsnw_sub - wfxsnw_pre + wfxsub_err = {:12.5e} (kg) '.format ( OCE_mas_emp_ice - OCE_mas_wfxsub - ICE_mas_wfxsnw_sub - ICE_mas_wfxsnw_pre + ICE_mas_wfxsub_err )) |
---|
564 | |
---|
565 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
566 | echo ( '-- Calculs dans la note PDF de Clement') |
---|
567 | echo ( 'Freshwater budget of the ice-ocean system = emp_oce + emp_ice - runoffs - iceberg - iceshelf = {:12.5e} (kg) '.format ( OCE_mas_emp_oce + OCE_mas_emp_ice - OCE_mas_runoffs - OCE_mas_iceberg - OCE_mas_iceshelf )) |
---|
568 | echo ( 'Freshwater budget of the ice-ocean system = emp_oce + emp_ice - friver - iceberg - iceshelf = {:12.5e} (kg) '.format ( OCE_mas_emp_oce + OCE_mas_emp_ice - OCE_mas_friver - OCE_mas_iceberg - OCE_mas_iceshelf )) |
---|
569 | echo ( 'Freshwater budget in the ocean = ocean mass change = emp_oce - vfxice - ( vfxsnw + vfxsub_err ) - runoffs - iceshelf = {:12.5e} (kg) '.format ( OCE_mas_emp_oce - OCE_mas_wfxice - ( OCE_mas_wfxsnw + ICE_mas_wfxsub_err ) - OCE_mas_runoffs - OCE_mas_iceshelf )) |
---|
570 | echo ( 'Freshwater budget in the ocean = ocean mass change = emp_oce - vfxice - ( vfxsnw + vfxsub_err ) - friver - iceshelf = {:12.5e} (kg) '.format ( OCE_mas_emp_oce - OCE_mas_wfxice - ( OCE_mas_wfxsnw + ICE_mas_wfxsub_err ) - OCE_mas_friver - OCE_mas_iceshelf )) |
---|
571 | echo ( 'Freshwater budget in the ice = ice mass change = vfxice + ( vfxsnw + vfxsub + vfxspr ) = {:12.5e} (kg) '.format ( OCE_mas_wfxice + OCE_mas_wfxsnw + OCE_mas_wfxsub + ICE_mas_wfxsnw_pre )) |
---|
572 | echo ( 'Freshwater flux at the interface [ice/snow]-ocean = vfxice + ( vfxsnw + vfxsub_err ) = {:12.5e} (kg) '.format ( OCE_mas_wfxsub + ICE_mas_wfxsnw_pre )) |
---|
573 | echo ( 'Freshwater flux at the interface [ice/snow]-atm = ( vfxsub + vfxspr ) = {:12.5e} (kg) '.format ( OCE_mas_emp_ice + ICE_mas_wfxsub_err )) |
---|
574 | echo ( 'Freshwater flux at the interface [ice/snow]-atm = emp_ice + vfxsub_err = {:12.5e} (kg) '.format ( OCE_mas_emp_ice + ICE_mas_wfxsub_err )) |
---|
575 | echo ( 'Freshwater flux at the interface ocean-atm = emp_oce + calving - vfxsub_err = {:12.5e} (kg) '.format ( OCE_mas_emp_oce + OCE_mas_calving - ICE_mas_wfxsub_err )) |
---|
576 | |
---|
577 | echo ( "scsshtot : global_average_sea_level_change = {:12.3e} (m) ".format ( np.sum (d_OCE_sca['scsshtot'] ).values ) ) |
---|
578 | echo ( "scsshtot : global_average_sea_level_change = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['scsshtot'] ).values * OCE_aire_tot*OCE_rho_liq ) ) |
---|
579 | echo ( "bgvolssh : drift in global mean ssh volume wrt timestep 1 = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgvolssh'] ).values * 1e9 * OCE_rho_liq ) ) |
---|
580 | echo ( "bgvole3t : drift in global mean volume variation (e3t) wrt timestep 1 = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgvole3t'] ).values * 1e9 * OCE_rho_liq ) ) |
---|
581 | echo ( "bgfrcvol : global mean volume from forcing = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgfrcvol'] ).values * 1e9 * OCE_rho_liq ) ) |
---|
582 | echo ( "ibgvol_tot : global mean ice volume = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvol_tot']).values * 1e9 * OCE_rho_liq ) ) |
---|
583 | echo ( "sbgvol_tot : global mean snow volume = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['sbgvol_tot']).values * 1e9 * OCE_rho_liq ) ) |
---|
584 | echo ( "ibgvolume : drift in ice/snow volume (equivalent ocean volume) = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvolume'] ).values * 1e9 * OCE_rho_liq ) ) |
---|
585 | |
---|