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 = { |
---|
15 | 'Author' : "$Author$", |
---|
16 | 'Date' : "$Date$", |
---|
17 | 'Revision': "$Revision$", |
---|
18 | 'Id' : "$Id: ATM_waterbudget.py 6508 2023-06-13 10:58:38Z omamce $", |
---|
19 | 'HeadURL' : "$HeadUrl: svn+ssh://omamce@forge.ipsl.jussieu.fr/ipsl/forge/projets/igcmg/svn/TOOLS/WATER_BUDGET/ATM_waterbudget.py $" |
---|
20 | } |
---|
21 | |
---|
22 | ### |
---|
23 | ## Import system modules |
---|
24 | import sys |
---|
25 | import os |
---|
26 | import subprocess |
---|
27 | import configparser |
---|
28 | from pathlib import Path |
---|
29 | |
---|
30 | ## Import needed scientific modules |
---|
31 | import numpy as np |
---|
32 | import xarray as xr |
---|
33 | |
---|
34 | ## Import local module |
---|
35 | import WaterUtils as wu |
---|
36 | import libIGCM_sys |
---|
37 | import nemo |
---|
38 | |
---|
39 | from WaterUtils import RA, GRAV, ICE_RHO_ICE, ICE_RHO_SNO, OCE_RHO_LIQ, ATM_RHO, \ |
---|
40 | SRF_RHO, RUN_RHO, ICE_RHO_PND, YEAR_LENGTH |
---|
41 | |
---|
42 | ## Creates parser for reading .ini input file |
---|
43 | ## ------------------------------------------- |
---|
44 | config = configparser.ConfigParser ( interpolation=configparser.ExtendedInterpolation() ) |
---|
45 | config.optionxform = str # To keep capitals |
---|
46 | |
---|
47 | ## Experiment parameters |
---|
48 | ## --------------------- |
---|
49 | JobName=None ; TagName=None ; ExperimentName=None ; SpaceName=None |
---|
50 | SRF=True ; RUN=True |
---|
51 | ATM=None ; ATM_HIS='latlon' ; SRF_HIS='latlon' ; RUN_HIS='latlon' ; ORCA=None |
---|
52 | NEMO=None ; OCE_relax=False |
---|
53 | OCE_icb=False ; Coupled=False ; Rsouting=None ; TestInterp=None |
---|
54 | TarRestartPeriod_beg=None ; TarRestartPeriod_end=None ; Comment=None |
---|
55 | Period=None ; Title=None |
---|
56 | YearBegin=None ; YearEnd=None ; DateBegin=None ; DateEnd=None |
---|
57 | Freq=None ; libIGCM=None ; User=None; Group=None ; Routing=None |
---|
58 | PackFrequency = None ; FreqDir=None |
---|
59 | |
---|
60 | Timer=False ; Debug=False |
---|
61 | |
---|
62 | ## |
---|
63 | ARCHIVE=None ; STORAGE=None ; SCRATCHDIR=None ; R_IN=None |
---|
64 | TmpDir=None ; FileDir=None ; FileOut=None ; R_OUT=None ; R_FIG=None |
---|
65 | R_FIGR=None ; R_BUF=None ; R_BUFR=None ; R_SAVE=None |
---|
66 | R_BUF_KSH=None ; POST_DIR=None ; L_EXP=None |
---|
67 | |
---|
68 | dir_ATM_his=None ; dir_SRF_his=None ; dir_OCE_his=None ; dir_ICE_his=None |
---|
69 | FileCommon=None ; file_ATM_his=None ; file_SRF_his=None ; file_RUN_his=None |
---|
70 | file_OCE_his=None ; file_ICE_his=None ; file_OCE_sca=None |
---|
71 | tar_restart_beg=None ; tar_restart_end=None ; file_ATM_beg=None |
---|
72 | file_ATM_end=None ; file_DYN_beg=None |
---|
73 | file_DYN_end=None ; file_SRF_beg=None ; file_SRF_end=None |
---|
74 | file_RUN_beg=None ; file_RUN_end=None ; file_RUN_end=None ; file_OCE_beg=None |
---|
75 | file_ICE_beg=None ; file_OCE_beg=None |
---|
76 | file_OCE_end=None ; file_ICE_beg=None ; file_OCE_end=None ; file_ICE_end=None |
---|
77 | TarRestartDate_beg=None ; TarRestartDate_end=None |
---|
78 | file_DYN_aire=None |
---|
79 | tar_restart_beg_ATM=None ; tar_restart_beg_DYN=None ; tar_restart_beg_SRF=None |
---|
80 | tar_restart_beg_RUN=None ; tar_restart_beg_OCE=None ; tar_restart_beg_ICE=None |
---|
81 | tar_restart_end_ATM=None ; tar_restart_end_DYN=None ; tar_restart_end_SRF=None |
---|
82 | tar_restart_end_RUN=None ; tar_restart_end_OCE=None ; tar_restart_end_ICE=None |
---|
83 | ContinueOnError=False ; ErrorCount=0 ; SortIco = False |
---|
84 | |
---|
85 | d_OCE_beg=None ; d_OCE_end=None |
---|
86 | |
---|
87 | FileDirOCE=None ; FileDirATM=None ; FileDirICE=None ; FileDirSRF=None ; FileDirRUN=None |
---|
88 | |
---|
89 | rebuild=None ; REBUILD_DIR=None |
---|
90 | |
---|
91 | ## |
---|
92 | ## Precision of history file reading |
---|
93 | ## --------------------------------- |
---|
94 | # Default is float (full precision). Degrade the precision by using np.float32 |
---|
95 | # Restart files are always read at the full precision |
---|
96 | readPrec=float |
---|
97 | |
---|
98 | ## Read command line arguments |
---|
99 | ## --------------------------- |
---|
100 | print ( "Name of Python script:", sys.argv[0] ) |
---|
101 | IniFile = sys.argv[1] |
---|
102 | |
---|
103 | # Test existence of IniFile |
---|
104 | if not os.path.exists (IniFile ) : |
---|
105 | raise FileExistsError ( f"File not found : {IniFile = }" ) |
---|
106 | |
---|
107 | if 'full' in IniFile : FullIniFile = IniFile |
---|
108 | else : FullIniFile = 'full_' + IniFile |
---|
109 | |
---|
110 | print ("Input file : ", IniFile ) |
---|
111 | config.read (IniFile) |
---|
112 | FullIniFile = 'full_' + IniFile |
---|
113 | |
---|
114 | # Reading config.card if possible |
---|
115 | ## ------------------------------- |
---|
116 | ConfigCard = None |
---|
117 | |
---|
118 | if 'Experiment' in config.keys () : ## Read Experiment on Config file if possible |
---|
119 | if 'ConfigCard' in config['Experiment'].keys () : |
---|
120 | ConfigCard = config['Experiment']['ConfigCard'] |
---|
121 | print ( f'{ConfigCard=}' ) |
---|
122 | |
---|
123 | if ConfigCard : ## Read config card if it exists |
---|
124 | # Text existence of ConfigCard |
---|
125 | if os.path.exists ( ConfigCard ) : |
---|
126 | print ( f'Reading Config Card : {ConfigCard}' ) |
---|
127 | ## Creates parser for reading .ini input file |
---|
128 | MyReader = configparser.ConfigParser (interpolation=configparser.ExtendedInterpolation() ) |
---|
129 | MyReader.optionxform = str # To keep capitals |
---|
130 | |
---|
131 | MyReader.read (ConfigCard) |
---|
132 | |
---|
133 | for VarName in ['JobName', 'ExperimentName', 'SpaceName', 'LongName', 'ModelName', 'TagName'] : |
---|
134 | if VarName in MyReader['UserChoices'].keys() : |
---|
135 | locals()[VarName] = MyReader['UserChoices'][VarName] |
---|
136 | exec ( f'{VarName} = wu.setBool ({VarName})' ) |
---|
137 | exec ( f'{VarName} = wu.setNum ({VarName})' ) |
---|
138 | exec ( f'{VarName} = wu.setNone ({VarName})' ) |
---|
139 | exec ( f'wu.{VarName} = {VarName}' ) |
---|
140 | print ( f' {VarName:21} set to : {locals()[VarName]:}' ) |
---|
141 | |
---|
142 | for VarName in ['PackFrequency'] : |
---|
143 | if VarName in MyReader['Post'].keys() : |
---|
144 | locals()[VarName] = MyReader['Post'][VarName] |
---|
145 | exec ( f'{VarName} = wu.setBool ({VarName})' ) |
---|
146 | exec ( f'{VarName} = wu.setNum ({VarName})' ) |
---|
147 | exec ( f'{VarName} = wu.setNone ({VarName})' ) |
---|
148 | exec ( f'wu.{VarName} = {VarName}' ) |
---|
149 | print ( f' {VarName:21} set to : {locals()[VarName]:}' ) |
---|
150 | else : |
---|
151 | raise FileExistsError ( f"File not found : {ConfigCard = }" ) |
---|
152 | |
---|
153 | ## Reading config file |
---|
154 | ## ------------------- |
---|
155 | # Each entry in the .ini file will create a Python variable with the same name |
---|
156 | for Section in config.keys () : |
---|
157 | print ( f'\nReading [{Section}]' ) |
---|
158 | for VarName in config[Section].keys() : |
---|
159 | locals()[VarName] = config[Section][VarName] |
---|
160 | exec ( f'{VarName} = wu.setBool ({VarName})' ) |
---|
161 | exec ( f'{VarName} = wu.setNum ({VarName})' ) |
---|
162 | exec ( f'{VarName} = wu.setNone ({VarName})' ) |
---|
163 | exec ( f'wu.{VarName} = {VarName}' ) |
---|
164 | print ( f' {VarName:21} set to : {locals()[VarName]}' ) |
---|
165 | |
---|
166 | print ( f'\nConfig file readed : {IniFile} ' ) |
---|
167 | |
---|
168 | ## |
---|
169 | ## Reading prec |
---|
170 | if not readPrec : |
---|
171 | readPrec = np.float64 |
---|
172 | else : |
---|
173 | if readPrec in ["float", "float64", "r8", "double", "<class 'float'>" ] : readPrec = float |
---|
174 | if readPrec in [ "float32", "r4", "single", "<class 'numpy.float32'>" ] : readPrec = np.float32 |
---|
175 | if readPrec in [ "float16", "r2", "half" , "<class 'numpy.float16'>" ] : readPrec = np.float16 |
---|
176 | |
---|
177 | ## Some physical constants |
---|
178 | ## ======================= |
---|
179 | if not RA : RA = wu.RA #-- Earth Radius (m) |
---|
180 | if not GRAV : GRAV = wu.GRAV #-- Gravity (m^2/s |
---|
181 | if not ICE_RHO_ICE : ICE_RHO_ICE = wu.ICE_RHO_ICE #-- Ice volumic mass (kg/m3) in LIM3 |
---|
182 | if not ICE_RHO_SNO : ICE_RHO_SNO = wu.ICE_RHO_SNO #-- Snow volumic mass (kg/m3) in LIM3 |
---|
183 | if not OCE_RHO_LIQ : OCE_RHO_LIQ = wu.OCE_RHO_LIQ #-- Ocean water volumic mass (kg/m3) in NEMO |
---|
184 | if not ATM_RHO : ATM_RHO = wu.ATM_RHO #-- Water volumic mass in atmosphere (kg/m^3) |
---|
185 | if not SRF_RHO : SRF_RHO = wu.SRF_RHO #-- Water volumic mass in surface reservoir (kg/m^3) |
---|
186 | if not RUN_RHO : RUN_RHO = wu.RUN_RHO #-- Water volumic mass of rivers (kg/m^3) |
---|
187 | if not ICE_RHO_PND : ICE_RHO_PND = wu.ICE_RHO_PND #-- Water volumic mass in ice ponds (kg/m^3) |
---|
188 | if not YEAR_LENGTH : YEAR_LENGTH = wu.YEAR_LENGTH #-- Year length (s) |
---|
189 | |
---|
190 | ## Set libIGCM and machine dependant values |
---|
191 | ## ---------------------------------------- |
---|
192 | if 'Files' not in config.keys () : config['Files'] = {} |
---|
193 | if 'Physics' not in config.keys () : config['Physics'] = {} |
---|
194 | if 'Config' not in config.keys () : config['Physics'] = {} |
---|
195 | |
---|
196 | config['Physics'].update ( { 'RA':str(RA), 'GRAV':str(GRAV), 'ICE_RHO_ICE':str(ICE_RHO_ICE), 'ICE_RHO_SNO':str(ICE_RHO_SNO), |
---|
197 | 'OCE_RHO_LIQ':str(OCE_RHO_LIQ), 'ATM_RHO':str(ATM_RHO), 'SRF_RHO':str(SRF_RHO), 'RUN_RHO':str(RUN_RHO)} ) |
---|
198 | |
---|
199 | config['Config'].update ( { 'ContinueOnError':str(ContinueOnError), 'TestInterp':str(TestInterp), 'readPrec':str(readPrec), |
---|
200 | 'Debug':str(Debug), 'Timer':str(Timer)} ) |
---|
201 | |
---|
202 | Timer = wu.functools.partial (wu.Timer, debug=False, timer=True) |
---|
203 | |
---|
204 | |
---|
205 | ## -------------------------- |
---|
206 | ICO = ( 'ICO' in ATM ) |
---|
207 | LMDZ = ( 'LMD' in ATM ) |
---|
208 | |
---|
209 | mm = libIGCM_sys.config ( TagName=TagName, SpaceName=SpaceName, ExperimentName=ExperimentName, JobName=JobName, User=User, Group=Group, |
---|
210 | ARCHIVE=ARCHIVE, SCRATCHDIR=SCRATCHDIR, STORAGE=STORAGE, R_IN=R_IN, R_OUT=R_OUT, R_FIG=R_FIG, rebuild=rebuild, TmpDir=TmpDir, |
---|
211 | R_SAVE=R_SAVE, R_FIGR=R_FIGR, R_BUFR=R_BUFR, R_BUF_KSH=R_BUF_KSH, REBUILD_DIR=REBUILD_DIR, POST_DIR=POST_DIR, L_EXP=L_EXP ) |
---|
212 | globals().update(mm) |
---|
213 | |
---|
214 | config['Files']['TmpDir'] = TmpDir |
---|
215 | |
---|
216 | if 'libIGCM' not in config.keys () : config['libIGCM'] = {} |
---|
217 | config['libIGCM'].update ( { 'ARCHIVE':str(ARCHIVE), 'STORAGE':str(STORAGE), 'TmpDir':str(TmpDir), 'R_IN':str(R_IN), 'rebuild':str(rebuild) } ) |
---|
218 | |
---|
219 | ## Debuging and timer |
---|
220 | Timer = wu.functools.partial (wu.Timer, debug=Debug, timer=Timer) |
---|
221 | |
---|
222 | ## Defines begining and end of experiment |
---|
223 | ## -------------------------------------- |
---|
224 | if not DateBegin : |
---|
225 | DateBegin = f'{YearBegin}0101' |
---|
226 | config['Experiment']['DateBegin'] = DateBegin |
---|
227 | else : |
---|
228 | YearBegin, MonthBegin, DayBegin = wu.SplitDate ( DateBegin ) |
---|
229 | DateBegin = wu.FormatToGregorian ( DateBegin) |
---|
230 | config['Experiment']['YearBegin'] = str(YearBegin) |
---|
231 | |
---|
232 | if not DateEnd : |
---|
233 | DateEnd = f'{YearEnd}1231' |
---|
234 | config['Experiment']['DateEnd'] = str(DateEnd) |
---|
235 | else : |
---|
236 | YearEnd, MonthEnd, DayEnd = wu.SplitDate ( DateEnd ) |
---|
237 | DateEnd = wu.FormatToGregorian ( DateEnd) |
---|
238 | config['Experiment']['DateEnd'] = str(DateEnd) |
---|
239 | |
---|
240 | if not PackFrequency : |
---|
241 | PackFrequency = YearEnd - YearBegin +1 |
---|
242 | config['Experiment']['PackFrequency'] = f'{PackFrequency}' |
---|
243 | |
---|
244 | if isinstance ( PackFrequency, str) : |
---|
245 | if 'Y' in PackFrequency : PackFrequency = PackFrequency.replace ( 'Y', '') |
---|
246 | if 'M' in PackFrequency : PackFrequency = PackFrequency.replace ( 'M', '') |
---|
247 | PackFrequency = int ( PackFrequency ) |
---|
248 | |
---|
249 | print ( f'{YearBegin=} {DateBegin=}' ) |
---|
250 | print ( f'{YearEnd =} {DateEnd =}' ) |
---|
251 | print ( f'{PackFrequency=}' ) |
---|
252 | |
---|
253 | ## Output file with water budget diagnostics |
---|
254 | ## ----------------------------------------- |
---|
255 | if not FileOut : |
---|
256 | FileOut = f'OCE_waterbudget_{JobName}_{YearBegin}_{YearEnd}' |
---|
257 | if readPrec == np.float32 : FileOut = f'{FileOut}_float32' |
---|
258 | FileOut = f'{FileOut}.out' |
---|
259 | |
---|
260 | config['Files']['FileOut'] = FileOut |
---|
261 | |
---|
262 | f_out = open ( FileOut, mode = 'w', encoding='utf-8' ) |
---|
263 | |
---|
264 | ## Useful functions |
---|
265 | ## ---------------- |
---|
266 | |
---|
267 | # Degrades precision |
---|
268 | if repr(readPrec) == "<class 'numpy.float64'>" or readPrec == float : |
---|
269 | def rprec (ptab) : |
---|
270 | '''This version does nothing |
---|
271 | |
---|
272 | rprec may be use to reduce floating precision when reading history files |
---|
273 | ''' |
---|
274 | return ptab |
---|
275 | else : |
---|
276 | def rprec (ptab) : |
---|
277 | '''Return float with a different precision''' |
---|
278 | return ptab.astype(readPrec).astype(float) |
---|
279 | |
---|
280 | def kg2Sv (val, rho=ATM_RHO) : |
---|
281 | '''From kg to Sverdrup''' |
---|
282 | return val/dtime_sec*1.0e-6/rho |
---|
283 | |
---|
284 | def kg2myear (val, rho=ATM_RHO) : |
---|
285 | '''From kg to m/year''' |
---|
286 | return val/OCE_aire_tot/rho/NbYear |
---|
287 | |
---|
288 | def var2prt (var, small=False, rho=ATM_RHO) : |
---|
289 | '''Formats value for printing''' |
---|
290 | if small : return var , kg2Sv(var, rho=rho)*1000., kg2myear(var, rho=rho)*1000. |
---|
291 | else : return var , kg2Sv(var, rho=rho) , kg2myear(var, rho=rho) |
---|
292 | |
---|
293 | def prtFlux (Desc, var, Form='F', small=False, rho=ATM_RHO, width=15) : |
---|
294 | '''Pretty print of formattd value''' |
---|
295 | if small : |
---|
296 | if Form in ['f', 'F'] : ff=" {:14.6e} kg | {:12.4f} mSv | {:12.4f} mm/year " |
---|
297 | if Form in ['e', 'E'] : ff=" {:14.6e} kg | {:12.4e} mSv | {:12.4e} mm/year " |
---|
298 | else : |
---|
299 | if Form in ['f', 'F'] : ff=" {:14.6e} kg | {:12.4f} Sv | {:12.4f} m/year " |
---|
300 | if Form in ['e', 'E'] : ff=" {:14.6e} kg | {:12.4e} Sv | {:12.4e} m/year " |
---|
301 | echo ( (' {:>{width}} = ' +ff).format (Desc, *var2prt(var, small, rho=rho), width=width ) ) |
---|
302 | |
---|
303 | def echo (string, end='\n') : |
---|
304 | '''Function to print to stdout *and* output file''' |
---|
305 | print ( str(string), end=end ) |
---|
306 | sys.stdout.flush () |
---|
307 | f_out.write ( str(string) + end ) |
---|
308 | f_out.flush () |
---|
309 | |
---|
310 | |
---|
311 | ## Set libIGCM directories |
---|
312 | ## ----------------------- |
---|
313 | if not R_OUT : R_OUT = os.path.join ( ARCHIVE , 'IGCM_OUT' ) |
---|
314 | if not R_BUF : R_BUF = os.path.join ( SCRATCHDIR, 'IGCM_OUT' ) |
---|
315 | if not L_EXP : L_EXP = os.path.join (TagName, SpaceName, ExperimentName, JobName) |
---|
316 | if not R_SAVE : R_SAVE = os.path.join ( R_OUT, L_EXP ) |
---|
317 | if not R_BUFR : R_BUFR = os.path.join ( R_BUF, L_EXP ) |
---|
318 | if not POST_DIR : POST_DIR = os.path.join ( R_BUFR, 'Out' ) |
---|
319 | if not REBUILD_DIR : REBUILD_DIR = os.path.join ( R_BUFR, 'REBUILD' ) |
---|
320 | if not R_BUF_KSH : R_BUF_KSH = os.path.join ( R_BUFR, 'Out' ) |
---|
321 | if not R_FIGR : R_FIGR = os.path.join ( STORAGE, 'IGCM_OUT', L_EXP ) |
---|
322 | |
---|
323 | config['libIGCM'].update ( { 'R_OUT':R_OUT, 'R_BUF':R_BUF, 'L_EXP':L_EXP, 'R_BUFR':R_BUFR, 'R_SAVE':R_SAVE, 'POST_DIR':POST_DIR, |
---|
324 | 'REBUILD_DIR':REBUILD_DIR, 'R_BUF_KSH':R_BUF_KSH, 'R_FIGR':R_FIGR, 'rebuild':rebuild, |
---|
325 | 'YEAR_LENGTH':str(YEAR_LENGTH)} ) |
---|
326 | |
---|
327 | ## Set directory to extract files |
---|
328 | ## ------------------------------ |
---|
329 | if not FileDir : FileDir = os.path.join ( TmpDir, f'WATER_{JobName}' ) |
---|
330 | config['Files']['FileDir'] = FileDir |
---|
331 | |
---|
332 | if not os.path.isdir ( FileDir ) : os.makedirs ( FileDir ) |
---|
333 | |
---|
334 | ##- Set directories to rebuild ocean and ice restart files |
---|
335 | if not FileDirOCE : FileDirOCE = os.path.join ( FileDir, 'OCE' ) |
---|
336 | if not FileDirICE : FileDirICE = os.path.join ( FileDir, 'ICE' ) |
---|
337 | if not os.path.exists ( FileDirOCE ) : os.mkdir ( FileDirOCE ) |
---|
338 | if not os.path.exists ( FileDirICE ) : os.mkdir ( FileDirICE ) |
---|
339 | |
---|
340 | echo (' ') |
---|
341 | echo ( f'JobName : {JobName}' ) |
---|
342 | echo ( f'Comment : {Comment}' ) |
---|
343 | echo ( f'TmpDir : {TmpDir}' ) |
---|
344 | echo ( f'FileDir : {FileDir}' ) |
---|
345 | echo ( f'FileDirOCE : {FileDirOCE}' ) |
---|
346 | echo ( f'FileDirICE : {FileDirICE}' ) |
---|
347 | |
---|
348 | echo ( f'\nDealing with {L_EXP}' ) |
---|
349 | |
---|
350 | ## Creates model output directory names |
---|
351 | ## ------------------------------------ |
---|
352 | if Freq == "MO" : FreqDir = os.path.join ( 'Output' , 'MO' ) |
---|
353 | if Freq == "SE" : FreqDir = os.path.join ( 'Analyse', 'SE' ) |
---|
354 | if not dir_OCE_his : |
---|
355 | dir_OCE_his = os.path.join ( R_SAVE, "OCE", FreqDir ) |
---|
356 | config['Files']['dir_OCE_his'] = dir_OCE_his |
---|
357 | if not dir_ICE_his : |
---|
358 | dir_ICE_his = os.path.join ( R_SAVE, "ICE", FreqDir ) |
---|
359 | config['Files']['dir_OCE_his'] = dir_OCE_his |
---|
360 | |
---|
361 | echo ( 'The analysis relies on files from the following model output directories : ' ) |
---|
362 | echo ( f'{dir_OCE_his}' ) |
---|
363 | echo ( f'{dir_ICE_his}' ) |
---|
364 | |
---|
365 | #-- Creates files names |
---|
366 | if not Period : |
---|
367 | if Freq == 'MO' : Period = f'{DateBegin}_{DateEnd}_1M' |
---|
368 | if Freq == 'SE' : Period = f'SE_{DateBegin}_{DateEnd}_1M' |
---|
369 | config['Files']['Period'] = Period |
---|
370 | |
---|
371 | config['Files']['DateBegin'] = DateBegin |
---|
372 | config['Files']['DateBegin'] = DateEnd |
---|
373 | |
---|
374 | echo ( f'Period : {Period}' ) |
---|
375 | |
---|
376 | if not FileCommon : |
---|
377 | FileCommon = f'{JobName}_{Period}' |
---|
378 | config['Files']['FileCommon'] = FileCommon |
---|
379 | |
---|
380 | if not Title : |
---|
381 | Title = f'{JobName} : {Freq} : {DateBegin} - {DateEnd}' |
---|
382 | config['Files']['Title'] = Title |
---|
383 | |
---|
384 | echo ('\nOpen history files' ) |
---|
385 | if not file_OCE_his : |
---|
386 | file_OCE_his = os.path.join ( dir_OCE_his, f'{FileCommon}_grid_T.nc' ) |
---|
387 | config['Files']['file_OCE_his'] = file_OCE_his |
---|
388 | if not file_OCE_sca : |
---|
389 | file_OCE_sca = os.path.join ( dir_OCE_his, f'{FileCommon}_scalar.nc' ) |
---|
390 | config['Files']['file_OCE_sca'] = file_OCE_sca |
---|
391 | if not file_ICE_his : |
---|
392 | file_ICE_his = os.path.join ( dir_ICE_his, f'{FileCommon}_icemod.nc' ) |
---|
393 | config['Files']['file_ICE_his'] = file_ICE_his |
---|
394 | |
---|
395 | d_OCE_his = xr.open_dataset ( file_OCE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
396 | d_OCE_sca = xr.open_dataset ( file_OCE_sca, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
397 | d_ICE_his = xr.open_dataset ( file_ICE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
398 | |
---|
399 | udims = udims={'y':'y', 'x':'x'} |
---|
400 | d_OCE_his = nemo.unify_dims ( d_OCE_his, **udims, verbose=False ) |
---|
401 | d_OCE_sca = nemo.unify_dims ( d_OCE_sca, **udims, verbose=False ) |
---|
402 | d_ICE_his = nemo.unify_dims ( d_ICE_his, **udims, verbose=False ) |
---|
403 | |
---|
404 | echo ( f'{file_OCE_his = }' ) |
---|
405 | echo ( f'{file_OCE_sca = }' ) |
---|
406 | echo ( f'{file_ICE_his = }' ) |
---|
407 | |
---|
408 | ## Compute run length |
---|
409 | ## ------------------ |
---|
410 | dtime = ( d_OCE_his.time_counter_bounds.max() - d_OCE_his.time_counter_bounds.min() ) |
---|
411 | echo ( '\nRun length : {(dtime/np.timedelta64(1, "D")).values:8.2f} days' ) |
---|
412 | dtime_sec = (dtime/np.timedelta64(1, "s")).values.item() # Convert in seconds |
---|
413 | |
---|
414 | ## Compute length of each period |
---|
415 | ## ----------------------------- |
---|
416 | dtime_per = ( d_OCE_his.time_counter_bounds[:,-1] - d_OCE_his.time_counter_bounds[:,0] ) |
---|
417 | echo ( '\nPeriods lengths (days) : ') |
---|
418 | echo ( f' {(dtime_per/np.timedelta64(1, "D")).values}' ) |
---|
419 | dtime_per_sec = (dtime_per/np.timedelta64(1, "s")).values # In seconds |
---|
420 | dtime_per_sec = xr.DataArray (dtime_per_sec, dims=["time_counter", ], coords=[d_OCE_his.time_counter,] ) |
---|
421 | dtime_per_sec.attrs['unit'] = 's' |
---|
422 | |
---|
423 | ## Number of years |
---|
424 | NbYear = dtime_sec / YEAR_LENGTH |
---|
425 | |
---|
426 | ##-- Extract restart files from tar |
---|
427 | |
---|
428 | if wu.unDefined ('TarRestartDate_beg' ) : TarRestartDate_beg = wu.DateMinusOneDay ( DateBegin ) |
---|
429 | if wu.unDefined ('TarRestartDate_end' ) : TarRestartDate_end = wu.FormatToGregorian ( DateEnd ) |
---|
430 | |
---|
431 | if not TarRestartPeriod_beg : |
---|
432 | |
---|
433 | TarRestartPeriod_beg_DateEnd = TarRestartDate_beg |
---|
434 | TarRestartPeriod_beg_DateBeg = wu.DateAddYear ( TarRestartPeriod_beg_DateEnd, -PackFrequency ) |
---|
435 | TarRestartPeriod_beg_DateBeg = wu.DatePlusOneDay ( TarRestartPeriod_beg_DateBeg ) |
---|
436 | |
---|
437 | TarRestartPeriod_beg = f'{TarRestartPeriod_beg_DateBeg}_{TarRestartPeriod_beg_DateEnd}' |
---|
438 | echo (f'Tar period for initial restart : {TarRestartPeriod_beg}') |
---|
439 | config['Files']['TarRestartPeriod_beg'] = TarRestartPeriod_beg |
---|
440 | |
---|
441 | if not TarRestartPeriod_end : |
---|
442 | |
---|
443 | TarRestartPeriod_end_DateEnd = TarRestartDate_end |
---|
444 | TarRestartPeriod_end_DateBeg = wu.DateAddYear ( TarRestartPeriod_end_DateEnd, -PackFrequency ) |
---|
445 | TarRestartPeriod_end_DateBeg = wu.DatePlusOneDay ( TarRestartPeriod_end_DateBeg ) |
---|
446 | |
---|
447 | TarRestartPeriod_end = f'{TarRestartPeriod_end_DateBeg}_{TarRestartPeriod_end_DateEnd}' |
---|
448 | echo (f'Tar period for final restart : {TarRestartPeriod_end}') |
---|
449 | config['Files']['TarRestartPeriod_end'] = TarRestartPeriod_end |
---|
450 | |
---|
451 | echo (f'Restart dates - Start : {TarRestartPeriod_beg} / End : {TarRestartPeriod_end}') |
---|
452 | |
---|
453 | if not tar_restart_beg : |
---|
454 | tar_restart_beg = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{TarRestartPeriod_beg}_restart.tar' ) |
---|
455 | config['Files']['tar_restart_beg'] = tar_restart_beg |
---|
456 | if not tar_restart_end : |
---|
457 | tar_restart_end = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{TarRestartPeriod_end}_restart.tar' ) |
---|
458 | config['Files']['tar_restart_end'] = tar_restart_end |
---|
459 | |
---|
460 | echo ( f'{tar_restart_beg = }' ) |
---|
461 | echo ( f'{tar_restart_end = }' ) |
---|
462 | |
---|
463 | # |
---|
464 | if not tar_restart_beg_ATM : tar_restart_beg_ATM = tar_restart_beg |
---|
465 | if not tar_restart_beg_DYN : tar_restart_beg_DYN = tar_restart_beg |
---|
466 | if not tar_restart_beg_RUN : tar_restart_beg_RUN = tar_restart_beg |
---|
467 | if not tar_restart_beg_OCE : tar_restart_beg_OCE = tar_restart_beg |
---|
468 | if not tar_restart_beg_ICE : tar_restart_beg_ICE = tar_restart_beg |
---|
469 | |
---|
470 | if not tar_restart_end_ATM : tar_restart_end_ATM = tar_restart_end |
---|
471 | if not tar_restart_end_DYN : tar_restart_end_DYN = tar_restart_end |
---|
472 | if not tar_restart_end_RUN : tar_restart_end_RUN = tar_restart_end |
---|
473 | if not tar_restart_end_OCE : tar_restart_end_OCE = tar_restart_end |
---|
474 | if not tar_restart_end_ICE : tar_restart_end_ICE = tar_restart_end |
---|
475 | |
---|
476 | if not file_OCE_beg : |
---|
477 | file_OCE_beg = f'{FileDir}/OCE_{JobName}_{TarRestartDate_beg}_restart.nc' |
---|
478 | config['Files']['file_OCE_beg'] = file_OCE_beg |
---|
479 | if not file_OCE_end : |
---|
480 | file_OCE_end = f'{FileDir}/OCE_{JobName}_{TarRestartDate_end}_restart.nc' |
---|
481 | config['Files']['file_OCE_end'] = file_OCE_end |
---|
482 | if not file_ICE_beg : |
---|
483 | file_ICE_beg = f'{FileDir}/ICE_{JobName}_{TarRestartDate_beg}_restart_icemod.nc' |
---|
484 | config['Files']['file_ICE_beg'] = file_ICE_beg |
---|
485 | if not file_ICE_end : |
---|
486 | file_ICE_end = f'{FileDir}/ICE_{JobName}_{TarRestartDate_end}_restart_icemod.nc' |
---|
487 | config['Files']['file_ICE_end'] = file_ICE_end |
---|
488 | |
---|
489 | echo ( f'{file_OCE_beg}' ) |
---|
490 | echo ( f'{file_OCE_end}' ) |
---|
491 | echo ( f'{file_ICE_beg}' ) |
---|
492 | echo ( f'{file_ICE_end}' ) |
---|
493 | |
---|
494 | liste_beg = [file_OCE_beg, file_ICE_beg ] |
---|
495 | liste_end = [file_ATM_end, file_ICE_end ] |
---|
496 | |
---|
497 | echo ('\nExtract and rebuild OCE and ICE restarts') |
---|
498 | def get_ndomain (zfile) : |
---|
499 | #d_zfile = xr.open_dataset (zfile, decode_times=False).squeeze() |
---|
500 | #ndomain_opa = d_zfile.attrs['DOMAIN_number_total'] |
---|
501 | #d_zfile.close () |
---|
502 | ndomain_opa = subprocess.getoutput ( f'ls {zfile}_*.nc | wc -l' ) #.format() |
---|
503 | return int (ndomain_opa) |
---|
504 | |
---|
505 | @Timer |
---|
506 | def extract_and_rebuild ( file_name=file_OCE_beg, tar_restart=tar_restart_end, file_dir_comp=FileDirOCE, error_count=ErrorCount ) : |
---|
507 | '''Extract restart file from tar. Rebuild ocean files if needed''' |
---|
508 | echo ( '----------') |
---|
509 | if os.path.exists ( file_name ) : |
---|
510 | echo ( f'-- File ready : {file_name = }' ) |
---|
511 | else : |
---|
512 | echo ( f'-- Extracting {file_name = }' ) |
---|
513 | base_resFile = Path (file_name).stem # basename, and remove suffix |
---|
514 | # Try to extract the rebuilded file |
---|
515 | if os.path.exists ( tar_restart ) : |
---|
516 | command = f'cd {file_dir_comp} ; tar xf {tar_restart} {base_resFile}.nc' |
---|
517 | echo ( command ) |
---|
518 | try : |
---|
519 | os.system ( command ) |
---|
520 | except : |
---|
521 | if not os.path.exists ( os.path.join (FileDir, f'{base_resFile}_0000.nc') ): |
---|
522 | command = f'cd {file_dir_comp} ; tar xf {tar_restart_end} {base_resFile}_*.nc' |
---|
523 | echo ( command ) |
---|
524 | ierr = os.system ( command ) |
---|
525 | if ierr == 0 : echo ( f'tar done : {base_resFile}.nc') |
---|
526 | else : raise OSError ( f'command failed : {command}' ) |
---|
527 | echo ( 'extract ndomain' ) |
---|
528 | ndomain_opa = get_ndomain ( os.path.join (FileDir, f'{base_resFile}') ) |
---|
529 | command = f'cd {file_dir_comp} ; {rebuild} {base_resFile} {ndomain_opa} ; mv {base_resFile}.nc {FileDir}' |
---|
530 | echo ( command ) |
---|
531 | ierr = os.system ( command ) |
---|
532 | if ierr == 0 : echo ( f'Rebuild done : {base_resFile}.nc') |
---|
533 | else : raise OSError ( f'command failed : {command}' ) |
---|
534 | else : |
---|
535 | echo ( f'tar done : {base_resFile}') |
---|
536 | command = f'cd {file_dir_comp} ; mv {base_resFile}.nc {FileDir}' |
---|
537 | ierr = os.system ( command ) |
---|
538 | if ierr == 0 : echo ( f'command done : {command}' ) |
---|
539 | else : raise OSError ( f'command failed : {command = }' ) |
---|
540 | else : |
---|
541 | echo ( f'****** Tar restart file {tar_restart = } not found ' ) |
---|
542 | if ContinueOnError : |
---|
543 | error_count += 1 |
---|
544 | else : |
---|
545 | raise OSError ( f'****** tar file not found {tar_restart = } - Stopping' ) |
---|
546 | return error_count |
---|
547 | |
---|
548 | ErrorCount += extract_and_rebuild ( file_name=file_OCE_beg, tar_restart=tar_restart_beg, file_dir_comp=FileDirOCE, error_count=ErrorCount ) |
---|
549 | ErrorCount += extract_and_rebuild ( file_name=file_OCE_end, tar_restart=tar_restart_end, file_dir_comp=FileDirOCE, error_count=ErrorCount ) |
---|
550 | ErrorCount += extract_and_rebuild ( file_name=file_ICE_beg, tar_restart=tar_restart_beg, file_dir_comp=FileDirICE, error_count=ErrorCount ) |
---|
551 | ErrorCount += extract_and_rebuild ( file_name=file_ICE_end, tar_restart=tar_restart_end, file_dir_comp=FileDirICE, error_count=ErrorCount ) |
---|
552 | |
---|
553 | echo ('Opening OCE and ICE restart files') |
---|
554 | if NEMO == 3.6 : |
---|
555 | d_OCE_beg = xr.open_dataset ( os.path.join (FileDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
556 | d_OCE_end = xr.open_dataset ( os.path.join (FileDir, file_OCE_end), decode_times=False, decode_cf=True).squeeze() |
---|
557 | d_ICE_beg = xr.open_dataset ( os.path.join (FileDir, file_ICE_beg), decode_times=False, decode_cf=True).squeeze() |
---|
558 | d_ICE_end = xr.open_dataset ( os.path.join (FileDir, file_ICE_end), decode_times=False, decode_cf=True).squeeze() |
---|
559 | if NEMO in [ 4.0, 4.2 ] : |
---|
560 | d_OCE_beg = xr.open_dataset ( os.path.join (FileDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
561 | d_OCE_end = xr.open_dataset ( os.path.join (FileDir, file_OCE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
562 | d_ICE_beg = xr.open_dataset ( os.path.join (FileDir, file_ICE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
563 | d_ICE_end = xr.open_dataset ( os.path.join (FileDir, file_ICE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze() |
---|
564 | |
---|
565 | ## Write the full configuration |
---|
566 | config_out = open (FullIniFile, 'w', encoding='utf-8') |
---|
567 | config.write (config_out ) |
---|
568 | config_out.close () |
---|
569 | |
---|
570 | # Get mask and surfaces |
---|
571 | sos = d_OCE_his ['sos'][0].squeeze() |
---|
572 | OCE_msk = nemo.lbc_mask ( xr.where ( sos>0., 1., 0. ), cd_type = 'T', sval = 0. ) |
---|
573 | |
---|
574 | so = sos = d_OCE_his ['sos'][0].squeeze() |
---|
575 | OCE_msk3 = nemo.lbc_mask ( xr.where ( so>0., 1., 0. ), cd_type = 'T', sval = 0. ) |
---|
576 | |
---|
577 | # lbc_mask removes the duplicate points (periodicity and north fold) |
---|
578 | OCE_aire = nemo.lbc_mask ( d_OCE_his ['area'] * OCE_msk, cd_type = 'T', sval = 0.0 ) |
---|
579 | ICE_aire = OCE_aire |
---|
580 | |
---|
581 | @Timer |
---|
582 | def OCE_stock_int (stock) : |
---|
583 | '''Integrate stock on ocean grid''' |
---|
584 | return wu.Psum ( (stock * OCE_aire ).to_masked_array().ravel() ) |
---|
585 | |
---|
586 | @Timer |
---|
587 | def ONE_stock_int (stock) : |
---|
588 | '''Sum stock''' |
---|
589 | return wu.Psum ( stock.to_masked_array().ravel() ) |
---|
590 | |
---|
591 | @Timer |
---|
592 | def OCE_flux_int (flux) : |
---|
593 | '''Integrate flux on oce grid''' |
---|
594 | return wu.Psum ( (flux * OCE_aire * dtime_per_sec).to_masked_array().ravel() ) |
---|
595 | |
---|
596 | @Timer |
---|
597 | def ONE_flux_int (flux) : |
---|
598 | '''Integrate flux on oce grid''' |
---|
599 | return wu.Psum ( (flux * dtime_per_sec).to_masked_array().ravel() ) |
---|
600 | |
---|
601 | OCE_aire_tot = ONE_stock_int ( OCE_aire ) |
---|
602 | ICE_aire_tot = ONE_stock_int ( ICE_aire ) |
---|
603 | |
---|
604 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
605 | echo ( '-- NEMO change in stores (for the records)' ) |
---|
606 | #-- Note that the total number of days of the run should be diagnosed rather than assumed |
---|
607 | #-- Here the result is in Sv |
---|
608 | # |
---|
609 | #-- Change in ocean volume in freshwater equivalent |
---|
610 | |
---|
611 | OCE_ssh_beg = d_OCE_beg['sshn'] |
---|
612 | OCE_ssh_end = d_OCE_end['sshn'] |
---|
613 | |
---|
614 | OCE_sum_ssh_beg = OCE_stock_int ( OCE_ssh_beg ) |
---|
615 | OCE_sum_ssh_end = OCE_stock_int ( OCE_ssh_end ) |
---|
616 | |
---|
617 | if NEMO == 3.6 : |
---|
618 | OCE_e3tn_beg = d_OCE_beg['fse3t_n'] |
---|
619 | OCE_e3tn_end = d_OCE_end['fse3t_n'] |
---|
620 | OCE_sum_e3tn_beg = OCE_stock_int ( OCE_e3tn_beg * OCE_msk3) |
---|
621 | OCE_sum_e3tn_end = OCE_stock_int ( OCE_e3tn_end * OCE_msk3) |
---|
622 | |
---|
623 | echo ( f'OCE_sum_ssh_beg = {OCE_sum_ssh_beg:12.6e} m^3 - OCE_sum_ssh_end = {OCE_sum_ssh_end:12.6e} m^3' ) |
---|
624 | dOCE_ssh_vol = OCE_sum_ssh_end - OCE_sum_ssh_beg |
---|
625 | dOCE_ssh_mas = dOCE_ssh_vol * OCE_RHO_LIQ |
---|
626 | |
---|
627 | if NEMO == 3.6 : |
---|
628 | echo ( f'OCE_sum_e3tn_beg = {OCE_sum_e3tn_beg:12.6e} m^3 - OCE_sum_e3tn_end = {OCE_sum_e3tn_end:12.6e} m^3' ) |
---|
629 | dOCE_e3tn_vol = OCE_sum_e3tn_end - OCE_sum_e3tn_beg |
---|
630 | dOCE_e3tn_mas = dOCE_e3tn_vol * OCE_RHO_LIQ |
---|
631 | |
---|
632 | dOCE_vol_wat = dOCE_ssh_vol ; dOCE_mas_wat = dOCE_ssh_mas |
---|
633 | |
---|
634 | echo ( f'dOCE vol = {dOCE_vol_wat :12.3e} m^3' ) |
---|
635 | echo ( f'dOCE ssh = {dOCE_vol_wat/OCE_aire_tot:12.3e} m ' ) |
---|
636 | prtFlux ( 'dOCE mass ', dOCE_mas_wat, 'e' ) |
---|
637 | |
---|
638 | if NEMO == 3.6 : |
---|
639 | echo ( f'dOCE e3tn vol = {dOCE_e3tn_vol:12.3e} m^3' ) |
---|
640 | prtFlux ( 'dOCE e3tn mass', dOCE_e3tn_mas, 'e' ) |
---|
641 | |
---|
642 | ## Glace et neige |
---|
643 | if NEMO == 3.6 : |
---|
644 | 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'] |
---|
645 | 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'] |
---|
646 | |
---|
647 | 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'] |
---|
648 | 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'] |
---|
649 | |
---|
650 | ICE_pnd_beg = 0.0 ; ICE_pnd_end = 0.0 ; ICE_fzl_beg = 0.0 ; ICE_fzl_end = 0.0 |
---|
651 | |
---|
652 | ICE_mas_wat_beg = ICE_ice_beg*ICE_RHO_ICE + ICE_sno_beg*ICE_RHO_SNO |
---|
653 | ICE_mas_wat_end = ICE_ice_end*ICE_RHO_ICE + ICE_sno_end*ICE_RHO_SNO |
---|
654 | |
---|
655 | if NEMO in [ 4.0, 4.2 ] : |
---|
656 | ICE_ice_beg = d_ICE_beg['v_i'] ; ICE_ice_end = d_ICE_end['v_i'] |
---|
657 | ICE_sno_beg = d_ICE_beg['v_s'] ; ICE_sno_end = d_ICE_end['v_s'] |
---|
658 | ICE_pnd_beg = d_ICE_beg['v_ip'] ; ICE_pnd_end = d_ICE_end['v_ip'] # Ice ponds |
---|
659 | ICE_fzl_beg = d_ICE_beg['v_il'] ; ICE_fzl_end = d_ICE_end['v_il'] # Frozen Ice Ponds |
---|
660 | |
---|
661 | ICE_mas_wat_beg = OCE_stock_int ( d_ICE_beg['snwice_mass'] ) |
---|
662 | ICE_mas_wat_end = OCE_stock_int ( d_ICE_end['snwice_mass'] ) |
---|
663 | |
---|
664 | ICE_vol_ice_beg = OCE_stock_int ( ICE_ice_beg ) |
---|
665 | ICE_vol_ice_end = OCE_stock_int ( ICE_ice_end ) |
---|
666 | |
---|
667 | ICE_vol_sno_beg = OCE_stock_int ( ICE_sno_beg ) |
---|
668 | ICE_vol_sno_end = OCE_stock_int ( ICE_sno_end ) |
---|
669 | |
---|
670 | ICE_vol_pnd_beg = OCE_stock_int ( ICE_pnd_beg ) |
---|
671 | ICE_vol_pnd_end = OCE_stock_int ( ICE_pnd_end ) |
---|
672 | |
---|
673 | ICE_vol_fzl_beg = OCE_stock_int ( ICE_fzl_beg ) |
---|
674 | ICE_vol_fzl_end = OCE_stock_int ( ICE_fzl_end ) |
---|
675 | |
---|
676 | #-- Converting to freswater volume |
---|
677 | dICE_vol_ice = ICE_vol_ice_end - ICE_vol_ice_beg |
---|
678 | dICE_mas_ice = dICE_vol_ice * ICE_RHO_ICE |
---|
679 | |
---|
680 | dICE_vol_sno = ICE_vol_sno_end - ICE_vol_sno_beg |
---|
681 | dICE_mas_sno = dICE_vol_sno * ICE_RHO_SNO |
---|
682 | |
---|
683 | dICE_vol_pnd = ICE_vol_pnd_end - ICE_vol_pnd_beg |
---|
684 | dICE_mas_pnd = dICE_vol_pnd * ICE_RHO_PND |
---|
685 | |
---|
686 | dICE_vol_fzl= ICE_vol_fzl_end - ICE_vol_fzl_beg |
---|
687 | dICE_mas_fzl = dICE_vol_fzl * ICE_RHO_PND |
---|
688 | |
---|
689 | if NEMO == 3.6 : |
---|
690 | dICE_mas_wat = dICE_mas_ice + dICE_mas_sno |
---|
691 | dSEA_mas_wat = dOCE_mas_wat + dICE_mas_ice + dICE_mas_sno |
---|
692 | |
---|
693 | if NEMO in [4.0, 4.2 ] : |
---|
694 | dICE_mas_wat = ICE_mas_wat_end - ICE_mas_wat_beg |
---|
695 | dSEA_mas_wat = dOCE_mas_wat + dICE_mas_wat |
---|
696 | |
---|
697 | echo ( f'ICE_vol_ice_beg = {ICE_vol_ice_beg:12.6e} m^3 | ICE_vol_ice_end = {ICE_vol_ice_end:12.6e} m^3' ) |
---|
698 | echo ( f'ICE_vol_sno_beg = {ICE_vol_sno_beg:12.6e} m^3 | ICE_vol_sno_end = {ICE_vol_sno_end:12.6e} m^3' ) |
---|
699 | echo ( f'ICE_vol_pnd_beg = {ICE_vol_pnd_beg:12.6e} m^3 | ICE_vol_pnd_end = {ICE_vol_pnd_end:12.6e} m^3' ) |
---|
700 | echo ( f'ICE_vol_fzl_beg = {ICE_vol_fzl_beg:12.6e} m^3 | ICE_vol_fzl_end = {ICE_vol_fzl_end:12.6e} m^3' ) |
---|
701 | |
---|
702 | echo ( f'dICE_vol_ice = {dICE_vol_ice:12.3e} m^3' ) |
---|
703 | echo ( f'dICE_vol_sno = {dICE_vol_sno:12.3e} m^3' ) |
---|
704 | echo ( f'dICE_vol_pnd = {dICE_vol_pnd:12.3e} m^3' ) |
---|
705 | echo ( f'dICE_mas_ice = {dICE_mas_ice:12.3e} m^3' ) |
---|
706 | echo ( f'dICE_mas_sno = {dICE_mas_sno:12.3e} m^3' ) |
---|
707 | echo ( f'dICE_mas_pnd = {dICE_mas_pnd:12.3e} m^3' ) |
---|
708 | echo ( f'dICE_mas_fzl = {dICE_mas_fzl:12.3e} m^3' ) |
---|
709 | |
---|
710 | echo ( '\n------------------------------------------------------------') |
---|
711 | echo ( 'Change in water content (ocean + ice) ' ) |
---|
712 | prtFlux ( 'dMass (ocean)', dSEA_mas_wat, 'e', True ) |
---|
713 | |
---|
714 | |
---|
715 | ### |
---|
716 | ### And now, working on fluxes !! |
---|
717 | |
---|
718 | # if coupled: |
---|
719 | # emp_oce = evap - precip (including blowing snow) - calving |
---|
720 | # emp_ice = evap - precip (excluding blowing snow) |
---|
721 | # emp_ice = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0) |
---|
722 | # runoffs = rivers + icebergs |
---|
723 | # empmr = emp_oce - wfx_ice - wfx_snw - wfx_pnd(v4.0.6) - wfx_err_sub - runoffs |
---|
724 | # doce+ice = - evap + precip + calving (emp_oce) |
---|
725 | # + rivers + icebergs (friver+iceberg ou runoffs) |
---|
726 | # + iceshelf (iceshelf) |
---|
727 | # - emp_ice (emp_ice) |
---|
728 | # dice = - emp_ice - wfx_snw - wfx_ice - wfx_pnd(v4.0.6) - wfx_err_sub |
---|
729 | |
---|
730 | #OCE_emp = evap - precip (including blowing snow) - calving |
---|
731 | #ICE_emp = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0) |
---|
732 | |
---|
733 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
734 | echo ( '-- Checks in NEMO - from budget_modipsl.sh (Clément Rousset)' ) |
---|
735 | |
---|
736 | # Read variable and computes integral over space and time |
---|
737 | OCE_empmr = rprec (d_OCE_his['wfo'] ) ; OCE_mas_empmr = OCE_flux_int ( OCE_empmr ) |
---|
738 | OCE_wfob = rprec (d_OCE_his['wfob'] ) ; OCE_mas_wfob = OCE_flux_int ( OCE_wfob ) |
---|
739 | OCE_emp_oce = rprec (d_OCE_his['emp_oce'] ) ; OCE_mas_emp_oce = OCE_flux_int ( OCE_emp_oce ) |
---|
740 | OCE_emp_ice = rprec (d_OCE_his['emp_ice'] ) ; OCE_mas_emp_ice = OCE_flux_int ( OCE_emp_ice ) |
---|
741 | OCE_iceshelf = rprec (d_OCE_his['iceshelf']) ; OCE_mas_iceshelf = OCE_flux_int ( OCE_iceshelf ) |
---|
742 | OCE_calving = rprec (d_OCE_his['calving'] ) ; OCE_mas_calving = OCE_flux_int ( OCE_calving ) |
---|
743 | OCE_iceberg = rprec (d_OCE_his['iceberg'] ) ; OCE_mas_iceberg = OCE_flux_int ( OCE_iceberg ) |
---|
744 | OCE_friver = rprec (d_OCE_his['friver'] ) ; OCE_mas_friver = OCE_flux_int ( OCE_friver ) |
---|
745 | OCE_runoffs = rprec (d_OCE_his['runoffs'] ) ; OCE_mas_runoffs = OCE_flux_int ( OCE_runoffs ) |
---|
746 | if NEMO in [ 4.0, 4.2 ] : |
---|
747 | OCE_wfxice = rprec (d_OCE_his['vfxice']) ; OCE_mas_wfxice = OCE_flux_int ( OCE_wfxice ) |
---|
748 | OCE_wfxsnw = rprec (d_OCE_his['vfxsnw']) ; OCE_mas_wfxsnw = OCE_flux_int ( OCE_wfxsnw ) |
---|
749 | OCE_wfxsub = rprec (d_OCE_his['vfxsub']) ; OCE_mas_wfxsub = OCE_flux_int ( OCE_wfxsub ) |
---|
750 | if NEMO == 3.6 : |
---|
751 | OCE_wfxice = rprec (d_OCE_his['vfxice'])/nemo.RDAY*ICE_RHO_ICE ; OCE_mas_wfxice = OCE_flux_int ( OCE_wfxice ) |
---|
752 | OCE_wfxsnw = rprec (d_OCE_his['vfxsnw'])/nemo.RDAY*ICE_RHO_SNO ; OCE_mas_wfxsnw = OCE_flux_int ( OCE_wfxsnw ) |
---|
753 | OCE_wfxsub = rprec (d_OCE_his['vfxsub'])/nemo.RDAY*ICE_RHO_SNO ; OCE_mas_wfxsub = OCE_flux_int ( OCE_wfxsub ) |
---|
754 | # Additional checks |
---|
755 | OCE_evap_oce = rprec (d_OCE_his['evap_ao_cea']) ; OCE_mas_evap_oce = OCE_flux_int ( OCE_evap_oce ) |
---|
756 | ICE_evap_ice = rprec (d_OCE_his['subl_ai_cea']) ; ICE_mas_evap_ice = OCE_flux_int ( ICE_evap_ice ) |
---|
757 | OCE_snow_oce = rprec (d_OCE_his['snow_ao_cea']) ; OCE_mas_snow_oce = OCE_flux_int ( OCE_snow_oce ) |
---|
758 | OCE_snow_ice = rprec (d_OCE_his['snow_ai_cea']) ; OCE_mas_snow_ice = OCE_flux_int ( OCE_snow_ice ) |
---|
759 | OCE_rain = rprec (d_OCE_his['rain'] ) ; OCE_mas_rain = OCE_flux_int ( OCE_rain ) |
---|
760 | ICE_wfxsub_err = rprec (d_ICE_his['vfxsub_err'] ) ; ICE_mas_wfxsub_err = OCE_flux_int ( ICE_wfxsub_err ) |
---|
761 | if NEMO in [ 4.0, 4.2 ] : |
---|
762 | ICE_wfxpnd = rprec (d_ICE_his['vfxpnd'] ) ; ICE_mas_wfxpnd = OCE_flux_int ( ICE_wfxpnd ) |
---|
763 | ICE_wfxsnw_sub = rprec (d_ICE_his['vfxsnw_sub']) ; ICE_mas_wfxsnw_sub = OCE_flux_int ( ICE_wfxsnw_sub ) |
---|
764 | ICE_wfxsnw_pre = rprec (d_ICE_his['vfxsnw_pre']) ; ICE_mas_wfxsnw_pre = OCE_flux_int ( ICE_wfxsnw_pre ) |
---|
765 | if NEMO == 3.6 : |
---|
766 | ICE_wfxpnd = 0.0 ; ICE_mas_wfxpnd = 0.0 |
---|
767 | ICE_wfxsnw_sub = rprec (d_ICE_his['vfxsub'])/nemo.RDAY*ICE_RHO_SNO ; ICE_mas_wfxsnw_sub = OCE_flux_int ( ICE_wfxsnw_sub ) |
---|
768 | ICE_wfxsnw_pre = rprec (d_ICE_his['vfxspr'])/nemo.RDAY*ICE_RHO_SNO ; ICE_mas_wfxsnw_pre = OCE_flux_int ( ICE_wfxsnw_pre ) |
---|
769 | |
---|
770 | OCE_wfcorr = rprec (d_OCE_his['wfcorr']) ; OCE_mas_wfcorr = OCE_flux_int ( OCE_wfcorr ) |
---|
771 | if OCE_relax : |
---|
772 | # ssr and fwb are included in emp=>empmr but not in emp_oce (outputed by sea-ice) |
---|
773 | OCE_vflx_fwb = rprec (d_OCE_his['vflx_fwb']) ; OCE_mas_vflx_fwb = OCE_flux_int ( OCE_vflx_fwb ) |
---|
774 | OCE_vflx_ssr = rprec (d_OCE_his['vflx_ssr']) ; OCE_mas_vflx_ssr = OCE_flux_int ( OCE_vflx_ssr ) |
---|
775 | else : |
---|
776 | OCE_fwb = 0.0 ; OCE_mas_fwb = 0.0 |
---|
777 | OCE_ssr = 0.0 ; OCE_mas_ssr = 0.0 |
---|
778 | if OCE_icb : |
---|
779 | OCE_berg_icb = rprec (d_OCE_his['berg_floating_melt']) ; OCE_mas_berg_icb = OCE_flux_int ( OCE_berg_icb ) |
---|
780 | OCE_calving_icb = rprec (d_OCE_his['calving_icb'] ) ; OCE_mas_calv_icb = OCE_flux_int ( OCE_calving_icb ) |
---|
781 | else : |
---|
782 | OCE_berg_icb = 0. ; OCE_mas_berg_icb = 0. |
---|
783 | OCE_calv_icb = 0. ; OCE_mas_calv_icb = 0. |
---|
784 | |
---|
785 | OCE_mas_emp = OCE_mas_emp_oce - OCE_mas_wfxice - OCE_mas_wfxsnw - ICE_mas_wfxpnd - ICE_mas_wfxsub_err |
---|
786 | OCE_mas_all = OCE_mas_emp_oce + OCE_mas_emp_ice - OCE_mas_runoffs - OCE_mas_iceshelf |
---|
787 | |
---|
788 | echo ('\n-- Fields:' ) |
---|
789 | prtFlux ('OCE+ICE budget ', OCE_mas_all , 'e', True) |
---|
790 | prtFlux (' EMPMR ', OCE_mas_empmr , 'e', True) |
---|
791 | prtFlux (' WFOB ', OCE_mas_wfob , 'e', True) |
---|
792 | prtFlux (' EMP_OCE ', OCE_mas_emp_oce , 'e', True) |
---|
793 | prtFlux (' EMP_ICE ', OCE_mas_emp_ice , 'e', True) |
---|
794 | prtFlux (' EMP ', OCE_mas_emp , 'e', True) |
---|
795 | prtFlux (' ICEBERG ', OCE_mas_iceberg , 'e', True) |
---|
796 | prtFlux (' ICESHELF ', OCE_mas_iceshelf , 'e', True) |
---|
797 | prtFlux (' CALVING ', OCE_mas_calving , 'e', True) |
---|
798 | prtFlux (' FRIVER ', OCE_mas_friver , 'e', True) |
---|
799 | prtFlux (' RUNOFFS ', OCE_mas_runoffs , 'e', True) |
---|
800 | prtFlux (' WFXICE ', OCE_mas_wfxice , 'e', True) |
---|
801 | prtFlux (' WFXSNW ', OCE_mas_wfxsnw , 'e', True) |
---|
802 | prtFlux (' WFXSUB ', OCE_mas_wfxsub , 'e', True) |
---|
803 | prtFlux (' WFXPND ', ICE_mas_wfxpnd , 'e', True) |
---|
804 | prtFlux (' WFXSNW_SUB ', ICE_mas_wfxsnw_sub, 'e', True) |
---|
805 | prtFlux (' WFXSNW_PRE ', ICE_mas_wfxsnw_pre, 'e', True) |
---|
806 | prtFlux (' WFXSUB_ERR ', ICE_mas_wfxsub_err, 'e', True) |
---|
807 | prtFlux (' EVAP_OCE ', OCE_mas_evap_oce , 'e' ) |
---|
808 | prtFlux (' EVAP_ICE ', ICE_mas_evap_ice , 'e', True) |
---|
809 | prtFlux (' SNOW_OCE ', OCE_mas_snow_oce , 'e', True) |
---|
810 | prtFlux (' SNOW_ICE ', OCE_mas_snow_ice , 'e', True) |
---|
811 | prtFlux (' RAIN ', OCE_mas_rain , 'e' ) |
---|
812 | prtFlux (' FWB ', OCE_mas_fwb , 'e', True) |
---|
813 | prtFlux (' SSR ', OCE_mas_ssr , 'e', True) |
---|
814 | prtFlux (' WFCORR ', OCE_mas_wfcorr , 'e', True) |
---|
815 | prtFlux (' BERG_ICB ', OCE_mas_berg_icb , 'e', True) |
---|
816 | prtFlux (' CALV_ICB ', OCE_mas_calv_icb , 'e', True) |
---|
817 | |
---|
818 | echo (' ') |
---|
819 | if Coupled : |
---|
820 | prtFlux ( 'Bilan ocean :', -OCE_mas_emp_oce - OCE_mas_emp_ice + OCE_mas_runoffs + OCE_mas_iceshelf, 'e', True ) |
---|
821 | else : |
---|
822 | prtFlux ( 'Bilan ocean :', -OCE_mas_emp_oce - OCE_mas_emp_ice + OCE_mas_runoffs + OCE_mas_iceberg + OCE_mas_calving + OCE_mas_iceshelf, 'e', True ) |
---|
823 | |
---|
824 | |
---|
825 | echo ('\n===> Comparing ===>' ) |
---|
826 | echo (' WFX OCE = -empmr + iceshelf = {:12.5e} (kg) '.format ( -OCE_mas_empmr + OCE_mas_iceshelf) ) |
---|
827 | echo (' versus d OCE = {:12.5e} (kg) '.format ( dOCE_mas_wat) ) |
---|
828 | 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) ) |
---|
829 | 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 )) |
---|
830 | echo (' versus d ICE+SNW+PND = {:12.5e} (kg) '.format ( dICE_mas_wat)) # Manque PND ? |
---|
831 | if Coupled : |
---|
832 | 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)) |
---|
833 | else : |
---|
834 | 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)) |
---|
835 | echo (' versus d OCE+ICE+SNW+PND = {:12.5e} (kg) '.format ( dSEA_mas_wat )) # Manque PND |
---|
836 | |
---|
837 | echo ('\n===> Leaks ===>') |
---|
838 | echo (' Leak OCE = dOCE_mas_wat + empmr - iceshelf = {:12.3e} (kg) '.format ( dOCE_mas_wat + OCE_mas_empmr - OCE_mas_iceshelf) ) |
---|
839 | 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) ) ) |
---|
840 | 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 ) ) |
---|
841 | 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)) ) |
---|
842 | 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 )) |
---|
843 | 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)) ) |
---|
844 | 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 )) |
---|
845 | 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) ) ) |
---|
846 | |
---|
847 | prtFlux (' Leak OCE ', ( dOCE_mas_wat + OCE_mas_empmr - OCE_mas_iceshelf) , 'e', True ) |
---|
848 | prtFlux (' Leak ICE+SNW+PND ', ( dICE_mas_wat + OCE_mas_emp_ice + OCE_mas_wfxice + OCE_mas_wfxsnw + ICE_mas_wfxpnd + ICE_mas_wfxsub_err ) , 'e', True ) |
---|
849 | prtFlux (' Leak OCE+ICE+SNW+PND ', ( dSEA_mas_wat + OCE_mas_emp_oce +OCE_mas_emp_ice - OCE_mas_runoffs - OCE_mas_iceshelf ) , 'e', True ) |
---|
850 | |
---|
851 | |
---|
852 | |
---|
853 | |
---|
854 | # check if emp = emp_ice + emp_oce - calving |
---|
855 | # emp_ice = wfxsub + wfxsnw_sub + wfxsnw_pre - wfxsub_err |
---|
856 | |
---|
857 | echo ('\n===> Checks ===>' ) |
---|
858 | 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 )) |
---|
859 | if Coupled : |
---|
860 | 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 )) |
---|
861 | else : |
---|
862 | 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 )) |
---|
863 | 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 )) |
---|
864 | 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 )) |
---|
865 | |
---|
866 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
867 | echo ( '-- Computations in the PDF note of Clément Rousset') |
---|
868 | 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 )) |
---|
869 | 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 )) |
---|
870 | 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 )) |
---|
871 | 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 )) |
---|
872 | 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 )) |
---|
873 | echo ( 'Freshwater flux at the interface [ice/snow]-ocean = vfxice + ( vfxsnw + vfxsub_err ) = {:12.5e} (kg) '.format ( OCE_mas_wfxsub + ICE_mas_wfxsnw_pre )) |
---|
874 | echo ( 'Freshwater flux at the interface [ice/snow]-atm = ( vfxsub + vfxspr ) = {:12.5e} (kg) '.format ( OCE_mas_emp_ice + ICE_mas_wfxsub_err )) |
---|
875 | 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 )) |
---|
876 | 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 )) |
---|
877 | |
---|
878 | echo ( "scsshtot : global_average_sea_level_change = {:12.3e} (m) ".format ( np.sum (d_OCE_sca['scsshtot'] ) ) ) |
---|
879 | echo ( "scsshtot : global_average_sea_level_change = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['scsshtot'] ) * OCE_aire_tot*OCE_RHO_LIQ ) ) |
---|
880 | echo ( "bgvolssh : drift in global mean ssh volume wrt timestep 1 = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgvolssh'] ) * 1e9 * OCE_RHO_LIQ ) ) |
---|
881 | echo ( "bgvole3t : drift in global mean volume variation (e3t) wrt timestep 1 = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgvole3t'] ) * 1e9 * OCE_RHO_LIQ ) ) |
---|
882 | echo ( "bgfrcvol : global mean volume from forcing = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgfrcvol'] ) * 1e9 * OCE_RHO_LIQ ) ) |
---|
883 | echo ( "ibgvol_tot : global mean ice volume = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvol_tot']) * 1e9 * OCE_RHO_LIQ ) ) |
---|
884 | echo ( "sbgvol_tot : global mean snow volume = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['sbgvol_tot']) * 1e9 * OCE_RHO_LIQ ) ) |
---|
885 | echo ( "ibgvolume : drift in ice/snow volume (equivalent ocean volume) = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvolume'] ) * 1e9 * OCE_RHO_LIQ ) ) |
---|
886 | |
---|
887 | echo ( ' ' ) |
---|
888 | echo ( f'{Title = }' ) |
---|
889 | |
---|
890 | echo ( 'SVN Information' ) |
---|
891 | for kk in SVN.keys(): |
---|
892 | print ( SVN[kk] ) |
---|