source: TOOLS/WATER_BUDGET/OCE_waterbudget.py @ 6786

Last change on this file since 6786 was 6764, checked in by omamce, 4 months ago

O.M. : water budget - version mars 2024

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL Author
File size: 35.2 KB
Line 
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##
14SVN = {
15    'Author'  : "$Author$",
16    'Date'    : "$Date$",
17    'Revision': "$Revision$",
18    'Id'      : "$Id: $",
19    'HeadURL' : "$HeadUrl: $"
20    }
21
22###
23## Import system modules
24import sys
25import os
26import subprocess
27import configparser
28from pathlib import Path
29
30## Import needed scientific modules
31import numpy  as np
32import xarray as xr
33
34## Import local module
35import WaterUtils as wu
36import nemo
37
38## Read command line arguments
39## ---------------------------
40print ( "Name of Python script:", sys.argv[0] )
41IniFile = sys.argv[1]
42
43# Test existence of IniFile
44if not os.path.exists (IniFile ) :
45    raise FileExistsError ( f"File not found : {IniFile = }" )
46
47if 'full' in IniFile or 'OCE' in IniFile :
48    FullIniFile = IniFile
49else :
50    FullIniFile = 'OCE_' + IniFile
51
52
53print ("Output parameter file : ", FullIniFile)
54
55## Experiment parameters
56## ---------------------
57dpar = wu.ReadConfig ( IniFile )
58
59## Configure all needed parameter from existant parameters
60## -------------------------------------------------------
61dpar = wu.SetDatesAndFiles (dpar)
62
63## Output file with water budget diagnostics
64## -----------------------------------------
65f_out = dpar['Files']['f_out']
66
67## Put dpar values in local namspace
68## ---------------------------------
69for Section in dpar.keys () : 
70    print ( f'\nReading [{Section}]' )
71    for VarName in dpar[Section].keys() :
72        locals()[VarName] = dpar[Section][VarName]
73        print ( f'    {VarName:21} set to : {locals()[VarName]}' )
74
75## Debuging and timer
76Timer = wu.functools.partial (wu.Timer, debug=Debug, timer=Timing)
77
78## Useful functions
79## ----------------
80
81# Degrades precision
82if repr (readPrec) == "<class 'numpy.float64'>" or readPrec == float :
83    def rprec (ptab) :
84        '''This version does nothing
85
86        rprec may be use to reduce floating precision when reading history files
87        '''
88        return ptab
89else                 :
90    def rprec (ptab) :
91        '''Return float with a different precision'''
92        return ptab.astype(readPrec).astype(float)
93
94def kg2Sv  (val, rho=ATM_RHO) :
95    '''From kg to Sverdrup'''
96    return val/dtime_sec*1.0e-6/rho
97
98def kg2myear (val, rho=ATM_RHO) :
99    '''From kg to m/year'''
100    return val/OCE.OCE_aire_tot/rho/NbYear
101
102def var2prt (var, small=False, rho=ATM_RHO) :
103    '''Formats value for printing'''
104    if small :  return var , kg2Sv(var, rho=rho)*1000., kg2myear(var, rho=rho)*1000.
105    else     :  return var , kg2Sv(var, rho=rho)      , kg2myear(var, rho=rho)
106
107def prtFlux (Desc, var, Form='F', small=False, rho=ATM_RHO, width=15) :
108    '''Pretty print of formattd value'''
109    if small :
110        if Form in ['f', 'F'] : ff=" {:14.6e} kg | {:12.4f} mSv | {:12.4f} mm/year "
111        if Form in ['e', 'E'] : ff=" {:14.6e} kg | {:12.4e} mSv | {:12.4e} mm/year "
112    else :
113        if Form in ['f', 'F'] : ff=" {:14.6e} kg | {:12.4f} Sv  | {:12.4f} m/year  "
114        if Form in ['e', 'E'] : ff=" {:14.6e} kg | {:12.4e} Sv  | {:12.4e} m/year  "
115    echo ( (' {:>{width}} = ' +ff).format (Desc, *var2prt(var, small, rho=rho), width=width ) )
116
117def echo (string, end='\n') :
118    '''Function to print to stdout *and* output file'''
119    print ( str(string), end=end  )
120    sys.stdout.flush ()
121    f_out.write ( str(string) + end )
122    f_out.flush ()
123
124##
125## Open history files
126## ------------------
127
128d_OCE_his = xr.open_dataset ( file_OCE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
129d_OCE_sca = xr.open_dataset ( file_OCE_sca, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
130d_ICE_his = xr.open_dataset ( file_ICE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
131
132udims = udims={'y':'y', 'x':'x'}
133d_OCE_his = nemo.unify_dims ( d_OCE_his, **udims, verbose=False )
134d_OCE_sca = nemo.unify_dims ( d_OCE_sca, **udims, verbose=False )
135d_ICE_his = nemo.unify_dims ( d_ICE_his, **udims, verbose=False )
136
137echo ( f'{file_OCE_his = }' )
138echo ( f'{file_OCE_sca = }' )
139echo ( f'{file_ICE_his = }' )
140
141## Compute run length
142## ------------------
143dtime = ( d_OCE_his.time_counter_bounds.max() - d_OCE_his.time_counter_bounds.min() )
144echo ( f'\nRun length : {(dtime/np.timedelta64(1, "D")).values:8.2f} days' )
145dtime_sec = (dtime/np.timedelta64(1, "s")).values.item() # Convert in seconds
146
147## Compute length of each period
148## -----------------------------
149dtime_per = ( d_OCE_his.time_counter_bounds[:,-1] - d_OCE_his.time_counter_bounds[:,0] )
150echo (  f'\nPeriods lengths (days) : {(dtime_per/np.timedelta64(1, "D")).values}' )
151dtime_per_sec = (dtime_per/np.timedelta64(1, "s")).values # In seconds
152dtime_per_sec = xr.DataArray (dtime_per_sec, dims=["time_counter", ], coords=[d_OCE_his.time_counter,] )
153dtime_per_sec.attrs['unit'] = 's'
154
155## Number of years
156NbYear = dtime_sec / YEAR_LENGTH
157
158## Define restart periods and file names
159## -------------------------------------
160dpar = wu.SetRestartNames ( dpar, f_out) 
161
162## Put dpar values in local namespace
163## ----------------------------------
164for Section in dpar.keys () : 
165    print ( f'\nReading [{Section}]' )
166    for VarName in dpar[Section].keys() :
167        locals()[VarName] = dpar[Section][VarName]
168        print ( f'    {VarName:21} set to : {locals()[VarName]}' )
169
170echo ( f'{tar_restart_beg = }' )
171echo ( f'{tar_restart_end = }' )
172
173echo ( f'{file_OCE_beg}' )
174echo ( f'{file_OCE_end}' )
175echo ( f'{file_ICE_beg}' )
176echo ( f'{file_ICE_end}' )
177
178liste_beg = [file_OCE_beg, file_ICE_beg ]
179liste_end = [file_ATM_end, file_ICE_end ]
180
181## Write the full configuration
182params_out = open (FullIniFile, 'w', encoding = 'utf-8')
183params = wu.dict2config ( dpar )
184params.write ( params_out )
185params_out.close ()
186
187echo ('\nExtract and rebuild OCE and ICE restarts')
188def get_ndomain (zfile) :
189    echo ( '--- get domain -- ' )
190    echo ( f'{zfile = }' )
191    #d_zfile = xr.open_dataset (zfile, decode_times=False).squeeze()
192    #ndomain_opa = d_zfile.attrs['DOMAIN_number_total']
193    #d_zfile.close ()
194    ndomain_opa = subprocess.getoutput ( f'ls {zfile}_*.nc | wc -l' ) #.format()
195    echo ( f'{ndomain_opa = }' )
196    return int (ndomain_opa)
197
198@Timer
199def extract_and_rebuild ( file_name=file_OCE_beg, tar_restart=tar_restart_end, file_dir_comp=FileDirOCE ) :
200    '''Extract restart file from tar. Rebuild ocean files if needed'''
201    echo ( '---------- extract_and_rebuild --')
202    echo ( f'{file_name = }' )
203    echo ( f'{tar_restart }' )
204    echo ( f'{file_dir_comp = }' )
205    error_count = 0
206    if os.path.exists ( file_name ) :
207        echo ( f'-- File ready : {file_name = }' )
208    else :
209        echo ( f'-- Extracting {file_name = }' )
210        base_resFile = Path (file_name).stem # basename, and remove suffix
211        # Try to extract the rebuilded file
212        if os.path.exists ( tar_restart ) :
213            command =  f'cd {file_dir_comp} ; tar xf {tar_restart} {base_resFile}.nc'
214            echo ( f'{command = }' )
215            ierr = os.system ( command )
216            if ierr != 0 :
217                if not os.path.exists ( os.path.join (FileDir, f'{base_resFile}_0000.nc') ):
218                    command =  f'cd {file_dir_comp} ; tar xf {tar_restart} {base_resFile}_*.nc'
219                    echo ( f'{command = }' )
220                    ierr = os.system ( command )
221                    if ierr == 0 :
222                        echo ( f'tar done : {base_resFile}.nc')
223                    else         :
224                        if ContinueOnError :
225                            error_count += 1
226                            echo ( f'****** Command failed : {command}' )
227                            echo ( '****** Trying to continue' )
228                            echo ( ' ')
229                        else :
230                            raise OSError ( f'command failed : {command}' )
231                    echo ( 'extract ndomain' )
232                ndomain_opa = get_ndomain ( os.path.join (file_dir_comp, f'{base_resFile}') )
233                command = f'cd {file_dir_comp} ; {rebuild} {base_resFile} {ndomain_opa} ; mv {base_resFile}.nc {FileDir}'
234                echo ( f'{command = }' )
235                ierr = os.system ( command )
236                if ierr == 0 :
237                    echo ( f'Rebuild done : {base_resFile}.nc')
238                else         :
239                    if ContinueOnError :
240                        error_count += 1
241                        echo ( f'****** Command failed : {command}' )
242                        echo ( '****** Trying to continue' )
243                        echo ( ' ')
244                    else :
245                        raise OSError ( f'command failed : {command}' )
246            else :
247                echo ( f'tar done : {base_resFile}')
248                command = f'cd {file_dir_comp} ; mv {base_resFile}.nc {FileDir}'
249                echo ( f'{command = }' )
250                ierr = os.system ( command )
251                if ierr == 0 :
252                    echo ( f'command done : {command}' )
253                else         :
254                    if ContinueOnError :
255                        error_count = 1
256                        echo ( f'****** Command failed : {command}' )
257                        echo ( '****** Trying to continue' )
258                        echo ( ' ')
259                    else :
260                        raise OSError ( f'command failed : {command = }' )
261        else :
262            echo ( f'****** Tar restart file {tar_restart = } not found ' )
263            if ContinueOnError :
264                error_count += 1
265                echo ( '****** Command failed' )
266                echo ( '****** Trying to continue' )
267                echo ( ' ')
268            else :
269                raise OSError ( f'****** tar file not found {tar_restart = } - Stopping' )
270    return error_count
271
272ErrorCount = 0
273ErrorCount += extract_and_rebuild ( file_name=file_OCE_beg, tar_restart=tar_restart_beg, file_dir_comp=FileDirOCE )
274ErrorCount += extract_and_rebuild ( file_name=file_OCE_end, tar_restart=tar_restart_end, file_dir_comp=FileDirOCE )
275ErrorCount += extract_and_rebuild ( file_name=file_ICE_beg, tar_restart=tar_restart_beg, file_dir_comp=FileDirICE )
276ErrorCount += extract_and_rebuild ( file_name=file_ICE_end, tar_restart=tar_restart_end, file_dir_comp=FileDirICE )
277
278##-- Exit in case of error in the opening file phase
279if ErrorCount > 0 :
280    echo ( '  ' )
281    raise RuntimeError ( f'**** Some files missing - Stopping - {ErrorCount = }' )
282
283echo ('Opening OCE and ICE restart files')
284if NEMO == 3.6 :
285    d_OCE_beg = xr.open_dataset ( os.path.join (FileDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
286    d_OCE_end = xr.open_dataset ( os.path.join (FileDir, file_OCE_end), decode_times=False, decode_cf=True).squeeze()
287    d_ICE_beg = xr.open_dataset ( os.path.join (FileDir, file_ICE_beg), decode_times=False, decode_cf=True).squeeze()
288    d_ICE_end = xr.open_dataset ( os.path.join (FileDir, file_ICE_end), decode_times=False, decode_cf=True).squeeze()
289if NEMO in [ 4.0, 4.2 ] :
290    d_OCE_beg = xr.open_dataset ( os.path.join (FileDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
291    d_OCE_end = xr.open_dataset ( os.path.join (FileDir, file_OCE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
292    d_ICE_beg = xr.open_dataset ( os.path.join (FileDir, file_ICE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
293    d_ICE_end = xr.open_dataset ( os.path.join (FileDir, file_ICE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
294
295# Get mask and surfaces
296
297dpar, OCE = wu.ComputeGridOCE ( dpar, d_OCE_his, nperio=nperio )
298       
299# sos = d_OCE_his ['sos'][0].squeeze()
300# OCE_msk = nemo.lbc_mask ( xr.where ( sos>0., 1., 0. ), cd_type = 'T', nperio=nperio, sval = 0. )
301
302# so = sos = d_OCE_his ['sos'][0].squeeze()
303# OCE_msk3 = nemo.lbc_mask ( xr.where ( so>0., 1., 0. ), cd_type = 'T', nperio=nperio, sval = 0. )
304
305# # lbc_mask removes the duplicate points (periodicity and north fold)
306# OCE.OCE_aire = nemo.lbc_mask ( d_OCE_his ['area'] * OCE_msk, cd_type = 'T', nperio=nperio, sval = 0.0 )
307# OCE.ICE_aire = OCE_aire
308
309@Timer
310def OCE_stock_int (stock) :
311    '''Integrate stock on ocean grid'''
312    return wu.P1sum ( stock * OCE.OCE_aire )
313
314@Timer
315def ONE_stock_int (stock) :
316    '''Sum stock'''
317    return wu.P1sum ( stock )
318
319@Timer
320def OCE_flux_int (flux) :
321    '''Integrate flux on oce grid'''
322    return wu.P1sum  ( flux * OCE.OCE_aire * dtime_per_sec )
323
324@Timer
325def ONE_flux_int (flux) :
326    '''Integrate flux on oce grid'''
327    return wu.P1sum ( flux * dtime_per_sec )
328
329#OCE.OCE_aire_tot = ONE_stock_int ( OCE.OCE_aire )
330#OCE.ICE_aire_tot = ONE_stock_int ( OCE.ICE_aire )
331
332echo ( '\n------------------------------------------------------------------------------------' )
333echo ( '-- NEMO change in stores (for the records)' )
334#-- Note that the total number of days of the run should be diagnosed rather than assumed
335#-- Here the result is in Sv
336#
337#-- Change in ocean volume in freshwater equivalent
338
339OCE.OCE_ssh_beg = d_OCE_beg['sshn']
340OCE.OCE_ssh_end = d_OCE_end['sshn']
341
342OCE.OCE_sum_ssh_beg = OCE_stock_int ( OCE.OCE_ssh_beg )
343OCE.OCE_sum_ssh_end = OCE_stock_int ( OCE.OCE_ssh_end )
344
345if NEMO == 3.6 :
346    OCE.OCE_e3tn_beg = d_OCE_beg['fse3t_n']
347    OCE.OCE_e3tn_end = d_OCE_end['fse3t_n']
348    OCE.OCE_sum_e3tn_beg = OCE_stock_int ( OCE.OCE_e3tn_beg * OCE.OCE_msk3)
349    OCE.OCE_sum_e3tn_end = OCE_stock_int ( OCE.OCE_e3tn_end * OCE.OCE_msk3)
350
351echo ( f'OCE.OCE_sum_ssh_beg = {OCE.OCE_sum_ssh_beg:12.6e} m^3  - OCE.OCE_sum_ssh_end = {OCE.OCE_sum_ssh_end:12.6e} m^3' )
352OCE.OCE_diff_ssh_vol = OCE.OCE_sum_ssh_end - OCE.OCE_sum_ssh_beg
353OCE.OCE_diff_ssh_mas = OCE.OCE_diff_ssh_vol * OCE_RHO_LIQ
354
355if NEMO == 3.6 :
356    echo ( f'OCE.OCE_sum_e3tn_beg = {OCE.OCE_sum_e3tn_beg:12.6e} m^3  - OCE.OCE_sum_e3tn_end = {OCE.OCE_sum_e3tn_end:12.6e} m^3' )
357    OCE.OCE_diff_e3tn_vol = OCE.OCE_sum_e3tn_end - OCE.OCE_sum_e3tn_beg
358    OCE.OCE_diff_e3tn_mas = OCE.OCE_diff_e3tn_vol * OCE_RHO_LIQ
359
360OCE.OCE_diff_vol_wat = OCE.OCE_diff_ssh_vol ; OCE.OCE_diff_mas_wat = OCE.OCE_diff_ssh_mas
361
362echo ( f'dOCE vol    = {OCE.OCE_diff_vol_wat             :12.3e} m^3' )
363echo ( f'dOCE ssh    = {OCE.OCE_diff_vol_wat/OCE.OCE_aire_tot:12.3e} m  ' )
364prtFlux ( 'dOCE mass ', OCE.OCE_diff_mas_wat, 'e' )
365
366if NEMO == 3.6 :
367    echo ( f'dOCE e3tn   vol    = {OCE.OCE_diff_e3tn_vol:12.3e} m^3' )
368    prtFlux ( 'dOCE e3tn   mass', OCE.OCE_diff_e3tn_mas, 'e' )
369
370## Glace et neige
371if NEMO == 3.6 :
372    OCE.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']
373    OCE.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']
374
375    OCE.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']
376    OCE.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']
377
378    OCE.ICE_pnd_beg = 0.0 ; OCE.ICE_pnd_end = 0.0 ; OCE.ICE_fzl_beg = 0.0 ; OCE.ICE_fzl_end = 0.0
379
380    OCE.ICE_mas_wat_beg = OCE.ICE_ice_beg*ICE_RHO_ICE + OCE.ICE_sno_beg*ICE_RHO_SNO
381    OCE.ICE_mas_wat_end = OCE.ICE_ice_end*ICE_RHO_ICE + OCE.ICE_sno_end*ICE_RHO_SNO
382
383if NEMO in [ 4.0, 4.2 ] :
384    OCE.ICE_ice_beg = d_ICE_beg['v_i']  ; OCE.ICE_ice_end = d_ICE_end['v_i']
385    OCE.ICE_sno_beg = d_ICE_beg['v_s']  ; OCE.ICE_sno_end = d_ICE_end['v_s']
386    OCE.ICE_pnd_beg = d_ICE_beg['v_ip'] ; OCE.ICE_pnd_end = d_ICE_end['v_ip'] # Ice ponds
387    OCE.ICE_fzl_beg = d_ICE_beg['v_il'] ; OCE.ICE_fzl_end = d_ICE_end['v_il'] # Frozen Ice Ponds
388
389    OCE.ICE_mas_wat_beg =  OCE_stock_int ( d_ICE_beg['snwice_mass'] )
390    OCE.ICE_mas_wat_end =  OCE_stock_int ( d_ICE_end['snwice_mass'] )
391
392OCE.ICE_vol_ice_beg = OCE_stock_int ( OCE.ICE_ice_beg )
393OCE.ICE_vol_ice_end = OCE_stock_int ( OCE.ICE_ice_end )
394
395OCE.ICE_vol_sno_beg = OCE_stock_int ( OCE.ICE_sno_beg )
396OCE.ICE_vol_sno_end = OCE_stock_int ( OCE.ICE_sno_end )
397
398OCE.ICE_vol_pnd_beg = OCE_stock_int ( OCE.ICE_pnd_beg )
399OCE.ICE_vol_pnd_end = OCE_stock_int ( OCE.ICE_pnd_end )
400
401OCE.ICE_vol_fzl_beg = OCE_stock_int ( OCE.ICE_fzl_beg )
402OCE.ICE_vol_fzl_end = OCE_stock_int ( OCE.ICE_fzl_end )
403
404#-- Converting to freswater volume
405OCE.ICE_diff_vol_ice = OCE.ICE_vol_ice_end - OCE.ICE_vol_ice_beg
406OCE.ICE_diff_mas_ice = OCE.ICE_diff_vol_ice * ICE_RHO_ICE
407
408OCE.ICE_diff_vol_sno = OCE.ICE_vol_sno_end - OCE.ICE_vol_sno_beg
409OCE.ICE_diff_mas_sno = OCE.ICE_diff_vol_sno * ICE_RHO_SNO
410
411OCE.ICE_diff_vol_pnd = OCE.ICE_vol_pnd_end - OCE.ICE_vol_pnd_beg
412OCE.ICE_diff_mas_pnd = OCE.ICE_diff_vol_pnd * ICE_RHO_PND
413
414OCE.ICE_diff_vol_fzl= OCE.ICE_vol_fzl_end - OCE.ICE_vol_fzl_beg
415OCE.ICE_diff_mas_fzl = OCE.ICE_diff_vol_fzl * ICE_RHO_PND
416
417if NEMO == 3.6 :
418    OCE.ICE_diff_mas_wat = OCE.ICE_diff_mas_ice + OCE.ICE_diff_mas_sno
419    OCE.OCE_diff_SEA_mas_wat = OCE.OCE_diff_mas_wat + OCE.ICE_diff_mas_ice + OCE.ICE_diff_mas_sno
420
421if NEMO in [4.0, 4.2 ] :
422    OCE.ICE_diff_mas_wat = OCE.ICE_mas_wat_end - OCE.ICE_mas_wat_beg
423    OCE.OCE_diff_SEA_mas_wat = OCE.OCE_diff_mas_wat + OCE.ICE_diff_mas_wat
424
425echo ( f'OCE.ICE_vol_ice_beg = {OCE.ICE_vol_ice_beg:12.6e} m^3 | OCE.ICE_vol_ice_end = {OCE.ICE_vol_ice_end:12.6e} m^3' )
426echo ( f'OCE.ICE_vol_sno_beg = {OCE.ICE_vol_sno_beg:12.6e} m^3 | OCE.ICE_vol_sno_end = {OCE.ICE_vol_sno_end:12.6e} m^3' )
427echo ( f'OCE.ICE_vol_pnd_beg = {OCE.ICE_vol_pnd_beg:12.6e} m^3 | OCE.ICE_vol_pnd_end = {OCE.ICE_vol_pnd_end:12.6e} m^3' )
428echo ( f'OCE.ICE_vol_fzl_beg = {OCE.ICE_vol_fzl_beg:12.6e} m^3 | OCE.ICE_vol_fzl_end = {OCE.ICE_vol_fzl_end:12.6e} m^3' )
429
430echo ( f'OCE.ICE_diff_vol_ice   = {OCE.ICE_diff_vol_ice:12.3e} m^3' )
431echo ( f'OCE.ICE_diff_vol_sno   = {OCE.ICE_diff_vol_sno:12.3e} m^3' )
432echo ( f'OCE.ICE_diff_vol_pnd   = {OCE.ICE_diff_vol_pnd:12.3e} m^3' )
433echo ( f'OCE.ICE_diff_mas_ice   = {OCE.ICE_diff_mas_ice:12.3e} m^3' )
434echo ( f'OCE.ICE_diff_mas_sno   = {OCE.ICE_diff_mas_sno:12.3e} m^3' )
435echo ( f'OCE.ICE_diff_mas_pnd   = {OCE.ICE_diff_mas_pnd:12.3e} m^3' )
436echo ( f'OCE.ICE_diff_mas_fzl   = {OCE.ICE_diff_mas_fzl:12.3e} m^3' )
437
438echo ( '\n------------------------------------------------------------')
439echo ( 'Change in water content (ocean + ice) ' )
440prtFlux ( 'dMass (ocean)', OCE.OCE_diff_SEA_mas_wat, 'e', True )
441
442
443###
444### And now, working on fluxes !!
445
446# if coupled:
447# emp_oce = evap - precip (including blowing snow) - calving
448# emp_ice = evap - precip (excluding blowing snow)
449# emp_ice = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0)
450# runoffs = rivers + icebergs
451# empmr = emp_oce - wfx_ice - wfx_snw - wfx_pnd(v4.0.6) - wfx_err_sub - runoffs
452# doce+ice = - evap + precip + calving (emp_oce)
453#            + rivers + icebergs       (friver+iceberg ou runoffs)
454#            + iceshelf                (iceshelf)
455#            - emp_ice                 (emp_ice)
456# dice = - emp_ice - wfx_snw - wfx_ice - wfx_pnd(v4.0.6) - wfx_err_sub
457
458#OCE.OCE_emp = evap - precip (including blowing snow) - calving
459#OCE.ICE_emp = wfx_spr(<0) + wfx_sub(>0) + wfx_snw_sub(v4.0.6) - wfx_err_sub(<0)
460
461echo ( '\n------------------------------------------------------------------------------------' )
462echo ( '-- Checks in NEMO - from budget_modipsl.sh (Clément Rousset)' )
463
464# Read variable and computes integral over space and time
465OCE.OCE_empmr      = rprec (d_OCE_his['wfo']     )    ; OCE.OCE_mas_empmr    = OCE_flux_int ( OCE.OCE_empmr    )
466OCE.OCE_wfob       = rprec (d_OCE_his['wfob']    )    ; OCE.OCE_mas_wfob     = OCE_flux_int ( OCE.OCE_wfob     )
467OCE.OCE_emp_oce    = rprec (d_OCE_his['emp_oce'] )    ; OCE.OCE_mas_emp_oce  = OCE_flux_int ( OCE.OCE_emp_oce  )
468OCE.OCE_emp_ice    = rprec (d_OCE_his['emp_ice'] )    ; OCE.OCE_mas_emp_ice  = OCE_flux_int ( OCE.OCE_emp_ice  )
469OCE.OCE_iceshelf   = rprec (d_OCE_his['iceshelf'])    ; OCE.OCE_mas_iceshelf = OCE_flux_int ( OCE.OCE_iceshelf )
470OCE.OCE_calving    = rprec (d_OCE_his['calving'] )    ; OCE.OCE_mas_calving  = OCE_flux_int ( OCE.OCE_calving  )
471OCE.OCE_iceberg    = rprec (d_OCE_his['iceberg'] )    ; OCE.OCE_mas_iceberg  = OCE_flux_int ( OCE.OCE_iceberg  )
472OCE.OCE_friver     = rprec (d_OCE_his['friver']  )    ; OCE.OCE_mas_friver   = OCE_flux_int ( OCE.OCE_friver   )
473OCE.OCE_runoffs    = rprec (d_OCE_his['runoffs'] )    ; OCE.OCE_mas_runoffs  = OCE_flux_int ( OCE.OCE_runoffs  )
474if NEMO in [ 4.0, 4.2 ] :
475    OCE.OCE_wfxice     = rprec (d_OCE_his['vfxice']) ; OCE.OCE_mas_wfxice   = OCE_flux_int ( OCE.OCE_wfxice )
476    OCE.OCE_wfxsnw     = rprec (d_OCE_his['vfxsnw']) ; OCE.OCE_mas_wfxsnw   = OCE_flux_int ( OCE.OCE_wfxsnw )
477    OCE.OCE_wfxsub     = rprec (d_OCE_his['vfxsub']) ; OCE.OCE_mas_wfxsub   = OCE_flux_int ( OCE.OCE_wfxsub )
478if NEMO == 3.6 :
479    OCE.OCE_wfxice     = rprec (d_OCE_his['vfxice'])/nemo.RDAY*ICE_RHO_ICE ; OCE.OCE_mas_wfxice   = OCE_flux_int ( OCE.OCE_wfxice )
480    OCE.OCE_wfxsnw     = rprec (d_OCE_his['vfxsnw'])/nemo.RDAY*ICE_RHO_SNO ; OCE.OCE_mas_wfxsnw   = OCE_flux_int ( OCE.OCE_wfxsnw )
481    OCE.OCE_wfxsub     = rprec (d_OCE_his['vfxsub'])/nemo.RDAY*ICE_RHO_SNO ; OCE.OCE_mas_wfxsub   = OCE_flux_int ( OCE.OCE_wfxsub )
482# Additional checks
483OCE.OCE_evap_oce   = rprec (d_OCE_his['evap_ao_cea']) ; OCE.OCE_mas_evap_oce   = OCE_flux_int ( OCE.OCE_evap_oce )
484OCE.ICE_evap_ice   = rprec (d_OCE_his['subl_ai_cea']) ; OCE.ICE_mas_evap_ice   = OCE_flux_int ( OCE.ICE_evap_ice )
485OCE.OCE_snow_oce   = rprec (d_OCE_his['snow_ao_cea']) ; OCE.OCE_mas_snow_oce   = OCE_flux_int ( OCE.OCE_snow_oce )
486OCE.OCE_snow_ice   = rprec (d_OCE_his['snow_ai_cea']) ; OCE.OCE_mas_snow_ice   = OCE_flux_int ( OCE.OCE_snow_ice )
487OCE.OCE_rain       = rprec (d_OCE_his['rain']       ) ; OCE.OCE_mas_rain       = OCE_flux_int ( OCE.OCE_rain     )
488OCE.ICE_wfxsub_err = rprec (d_ICE_his['vfxsub_err'] ) ; OCE.ICE_mas_wfxsub_err = OCE_flux_int ( OCE.ICE_wfxsub_err )
489if NEMO in [ 4.0, 4.2 ] :
490    OCE.ICE_wfxpnd     = rprec (d_ICE_his['vfxpnd']    ) ; OCE.ICE_mas_wfxpnd     = OCE_flux_int ( OCE.ICE_wfxpnd     )
491    OCE.ICE_wfxsnw_sub = rprec (d_ICE_his['vfxsnw_sub']) ; OCE.ICE_mas_wfxsnw_sub = OCE_flux_int ( OCE.ICE_wfxsnw_sub )
492    OCE.ICE_wfxsnw_pre = rprec (d_ICE_his['vfxsnw_pre']) ; OCE.ICE_mas_wfxsnw_pre = OCE_flux_int ( OCE.ICE_wfxsnw_pre )
493if NEMO == 3.6 :
494    OCE.ICE_wfxpnd = 0.0 ; OCE.ICE_mas_wfxpnd = 0.0
495    OCE.ICE_wfxsnw_sub = rprec (d_ICE_his['vfxsub'])/nemo.RDAY*ICE_RHO_SNO  ; OCE.ICE_mas_wfxsnw_sub = OCE_flux_int ( OCE.ICE_wfxsnw_sub )
496    OCE.ICE_wfxsnw_pre = rprec (d_ICE_his['vfxspr'])/nemo.RDAY*ICE_RHO_SNO  ; OCE.ICE_mas_wfxsnw_pre = OCE_flux_int ( OCE.ICE_wfxsnw_pre )
497
498OCE.OCE_wfcorr    = rprec (d_OCE_his['wfcorr']) ; OCE.OCE_mas_wfcorr  = OCE_flux_int ( OCE.OCE_wfcorr )
499if OCE_relax  :
500    # ssr and fwb are included in emp=>empmr but not in emp_oce (outputed by sea-ice)
501    OCE.OCE_vflx_fwb = rprec (d_OCE_his['vflx_fwb']) ; OCE.OCE_mas_vflx_fwb   = OCE_flux_int ( OCE.OCE_vflx_fwb )
502    OCE.OCE_vflx_ssr = rprec (d_OCE_his['vflx_ssr']) ; OCE.OCE_mas_vflx_ssr   = OCE_flux_int ( OCE.OCE_vflx_ssr )
503else :
504    OCE.OCE_fwb = 0.0 ; OCE.OCE_mas_fwb = 0.0
505    OCE.OCE_ssr = 0.0 ; OCE.OCE_mas_ssr = 0.0
506if OCE_icb :
507    OCE.OCE_berg_icb    = rprec (d_OCE_his['berg_floating_melt']) ; OCE.OCE_mas_berg_icb = OCE_flux_int ( OCE.OCE_berg_icb    )
508    OCE.OCE_calving_icb = rprec (d_OCE_his['calving_icb']       ) ; OCE.OCE_mas_calv_icb = OCE_flux_int ( OCE.OCE_calving_icb )
509else :
510    OCE.OCE_berg_icb = 0. ; OCE.OCE_mas_berg_icb = 0.
511    OCE.OCE_calv_icb = 0. ; OCE.OCE_mas_calv_icb = 0.
512
513OCE.OCE_mas_emp = OCE.OCE_mas_emp_oce - OCE.OCE_mas_wfxice - OCE.OCE_mas_wfxsnw - OCE.ICE_mas_wfxpnd - OCE.ICE_mas_wfxsub_err
514OCE.OCE_mas_all = OCE.OCE_mas_emp_oce + OCE.OCE_mas_emp_ice - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceshelf
515
516echo ('\n-- Fields:' )
517prtFlux ('OCE+ICE budget ', OCE.OCE_mas_all       , 'e', True)
518prtFlux ('  EMPMR        ', OCE.OCE_mas_empmr     , 'e', True)
519prtFlux ('  WFOB         ', OCE.OCE_mas_wfob      , 'e', True)
520prtFlux ('  EMP_OCE      ', OCE.OCE_mas_emp_oce   , 'e', True)
521prtFlux ('  EMP_ICE      ', OCE.OCE_mas_emp_ice   , 'e', True)
522prtFlux ('  EMP          ', OCE.OCE_mas_emp       , 'e', True)
523prtFlux ('  ICEBERG      ', OCE.OCE_mas_iceberg   , 'e', True)
524prtFlux ('  ICESHELF     ', OCE.OCE_mas_iceshelf  , 'e', True)
525prtFlux ('  CALVING      ', OCE.OCE_mas_calving   , 'e', True)
526prtFlux ('  FRIVER       ', OCE.OCE_mas_friver    , 'e', True)
527prtFlux ('  RUNOFFS      ', OCE.OCE_mas_runoffs   , 'e', True)
528prtFlux ('  WFXICE       ', OCE.OCE_mas_wfxice    , 'e', True)
529prtFlux ('  WFXSNW       ', OCE.OCE_mas_wfxsnw    , 'e', True)
530prtFlux ('  WFXSUB       ', OCE.OCE_mas_wfxsub    , 'e', True)
531prtFlux ('  WFXPND       ', OCE.ICE_mas_wfxpnd    , 'e', True)
532prtFlux ('  WFXSNW_SUB   ', OCE.ICE_mas_wfxsnw_sub, 'e', True)
533prtFlux ('  WFXSNW_PRE   ', OCE.ICE_mas_wfxsnw_pre, 'e', True)
534prtFlux ('  WFXSUB_ERR   ', OCE.ICE_mas_wfxsub_err, 'e', True)
535prtFlux ('  EVAP_OCE     ', OCE.OCE_mas_evap_oce  , 'e'      )
536prtFlux ('  EVAP_ICE     ', OCE.ICE_mas_evap_ice  , 'e', True)
537prtFlux ('  SNOW_OCE     ', OCE.OCE_mas_snow_oce  , 'e', True)
538prtFlux ('  SNOW_ICE     ', OCE.OCE_mas_snow_ice  , 'e', True)
539prtFlux ('  RAIN         ', OCE.OCE_mas_rain      , 'e'      )
540prtFlux ('  FWB          ', OCE.OCE_mas_fwb       , 'e', True)
541prtFlux ('  SSR          ', OCE.OCE_mas_ssr       , 'e', True)
542prtFlux ('  WFCORR       ', OCE.OCE_mas_wfcorr    , 'e', True)
543prtFlux ('  BERG_ICB     ', OCE.OCE_mas_berg_icb  , 'e', True)
544prtFlux ('  CALV_ICB     ', OCE.OCE_mas_calv_icb  , 'e', True)
545
546echo (' ')
547if Coupled :
548    prtFlux ( 'Bilan ocean :', -OCE.OCE_mas_emp_oce - OCE.OCE_mas_emp_ice + OCE.OCE_mas_runoffs + OCE.OCE_mas_iceshelf, 'e', True )
549else :
550    prtFlux ( 'Bilan ocean :', -OCE.OCE_mas_emp_oce - OCE.OCE_mas_emp_ice + OCE.OCE_mas_runoffs + OCE.OCE_mas_iceberg + OCE.OCE_mas_calving + OCE.OCE_mas_iceshelf, 'e', True )
551
552
553echo     ('\n===>  Comparing ===>' )
554echo     ('  WFX OCE                     = -empmr + iceshelf                                            = {:12.5e} (kg) '.format ( -OCE.OCE_mas_empmr + OCE.OCE_mas_iceshelf) )
555echo     ('     versus d OCE                                                                            = {:12.5e} (kg) '.format ( OCE.OCE_diff_mas_wat) )
556echo     ('  WFX ICE+SNW+PND 1           = emp_ice - wfxice - wfxsnw - wfxpnd - wfxsub_err              = {:12.5e} (kg) '.format ( -OCE.OCE_mas_emp_ice - OCE.OCE_mas_wfxice - OCE.OCE_mas_wfxsnw - OCE.ICE_mas_wfxpnd - OCE.ICE_mas_wfxsub_err) )
557echo     ('  WFX ICE+SNW+PND 2           = -emp_ice + empmr - emp_oce + runoffs                         = {:12.5e} (kg) '.format ( -OCE.OCE_mas_emp_ice + OCE.OCE_mas_empmr - OCE.OCE_mas_emp_oce + OCE.OCE_mas_runoffs ))
558echo     ('     versus d ICE+SNW+PND                                                                    = {:12.5e} (kg) '.format ( OCE.ICE_diff_mas_wat))  # Manque PND ?
559if Coupled :
560    echo ('  WFX OCE+ICE+SNW+PND         = -emp_oce - emp_ice + runoffs + iceshelf                      = {:12.5e} (kg) '.format ( -OCE.OCE_mas_emp_oce - OCE.OCE_mas_emp_ice + OCE.OCE_mas_runoffs + OCE.OCE_mas_iceshelf))
561else :
562    echo ('  WFX OCE+ICE+SNW+PND         = -emp_oce - emp_ice + runoffs + iceberg + calving + iceshelf  = {:12.5e} (kg) '.format ( -OCE.OCE_mas_emp_oce - OCE.OCE_mas_emp_ice + OCE.OCE_mas_runoffs + OCE.OCE_mas_iceberg + OCE.OCE_mas_calving + OCE.OCE_mas_iceshelf))
563echo     ('     versus d OCE+ICE+SNW+PND                                                                = {:12.5e} (kg) '.format ( OCE.OCE_diff_SEA_mas_wat  )) # Manque PND
564
565echo ('\n===> Leaks ===>')
566echo ('   Leak OCE             = OCE.OCE_diff_mas_wat + empmr - iceshelf                                                 = {:12.3e} (kg) '.format ( OCE.OCE_diff_mas_wat + OCE.OCE_mas_empmr - OCE.OCE_mas_iceshelf) )
567echo ('                        = (OCE.OCE_diff_mas_wat + empmr - iceshelf)/abs(OCE.OCE_diff_mas_wat)                             = {:12.1e} (-)  '.format ( (OCE.OCE_diff_mas_wat + OCE.OCE_mas_empmr - OCE.OCE_mas_iceshelf )  / abs (OCE.OCE_diff_mas_wat)  ) )
568echo ('   Leak ICE+SNW+PND 1   = OCE.ICE_diff_mas_wat + emp_ice + wfxice + wfxsnw + wfxpnd + wfxsub_err                  = {:12.3e} (kg) '.format ( OCE.ICE_diff_mas_wat + OCE.OCE_mas_emp_ice + OCE.OCE_mas_wfxice + OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxpnd + OCE.ICE_mas_wfxsub_err ) )
569echo ('                        = (OCE.ICE_diff_mas_wat + emp_ice + wfxice + wfxsnw + wfxpnd + wfxsub_err )/OCE.ICE_diff_mas_wat  = {:12.1e} (-)  '.format ( (OCE.ICE_diff_mas_wat + OCE.OCE_mas_emp_ice + OCE.OCE_mas_wfxice + OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxpnd + OCE.ICE_mas_wfxsub_err)/abs(OCE.ICE_diff_mas_wat)) )
570echo ('   Leak ICE+SNW+PND 2   = OCE.ICE_diff_mas_wat + emp_ice - empmr + emp_oce - runoffs                              = {:12.3e} (kg) '.format ( OCE.ICE_diff_mas_wat + OCE.OCE_mas_emp_ice - OCE.OCE_mas_empmr + OCE.OCE_mas_emp_oce - OCE.OCE_mas_runoffs ))
571echo ('                        = (OCE.ICE_diff_mas_wat - empmr  + emp_oce - runoffs)/abs(OCE.ICE_diff_mas_wat)                   = {:12.1e} (-)  '.format ( (OCE.ICE_diff_mas_wat - OCE.OCE_mas_empmr  + OCE.OCE_mas_emp_oce - OCE.OCE_mas_runoffs)/abs(OCE.ICE_diff_mas_wat)) )
572echo ('   Leak OCE+ICE+SNW+PND =  d(ICE+OCE)_mas_wat + emp_oce + emp_ice - runoffs - iceshelf                    = {:12.3e} (kg) '.format ( OCE.OCE_diff_SEA_mas_wat + OCE.OCE_mas_emp_oce +OCE.OCE_mas_emp_ice - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceshelf ))
573echo ('                        = (OCE.OCE_diff_SEA_mas_wat + emp_oce + emp_ice - runoffs - iceshelf)*/abs(OCE.OCE_diff_SEA_mas_wat)      = {:12.1e} (-)  '.format ( (OCE.OCE_diff_SEA_mas_wat + OCE.OCE_mas_emp_oce + OCE.OCE_mas_emp_ice - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceshelf)/abs(OCE.OCE_diff_SEA_mas_wat) ) )
574
575prtFlux ('   Leak OCE             ', ( OCE.OCE_diff_mas_wat + OCE.OCE_mas_empmr - OCE.OCE_mas_iceshelf) , 'e', True )
576prtFlux ('   Leak ICE+SNW+PND     ', ( OCE.ICE_diff_mas_wat + OCE.OCE_mas_emp_ice + OCE.OCE_mas_wfxice + OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxpnd + OCE.ICE_mas_wfxsub_err ) , 'e', True )
577prtFlux ('   Leak OCE+ICE+SNW+PND ',  ( OCE.OCE_diff_SEA_mas_wat + OCE.OCE_mas_emp_oce +OCE.OCE_mas_emp_ice - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceshelf ) , 'e', True )
578
579# check if emp     = emp_ice + emp_oce - calving
580#          emp_ice = wfxsub + wfxsnw_sub + wfxsnw_pre - wfxsub_err
581
582echo     ('\n===> Checks ===>' )
583echo     ('   Check EMPMR           = empmr - emp_oce + runoffs + wfxice + wfxsnw + wfxpnd + wfxsub_err = {:12.5e} (kg) '.format ( OCE.OCE_mas_empmr - OCE.OCE_mas_emp_oce + OCE.OCE_mas_runoffs + OCE.OCE_mas_wfxice + OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxpnd + OCE.ICE_mas_wfxsub_err ))
584if Coupled :
585    echo ('   Check EMP_OCE         = emp_oce + fwb + ssr - evap_oce + rain + snow_oce + calving        = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce + OCE.OCE_mas_fwb + OCE.OCE_mas_ssr - OCE.OCE_mas_evap_oce + OCE.OCE_mas_rain + OCE.OCE_mas_snow_oce + OCE.OCE_mas_calving ))
586else :
587    echo ('   Check EMP_OCE         = emp_oce + ssr + fwb - evap_oce + rain + snow_oce                  = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce + OCE.OCE_mas_ssr + OCE.OCE_mas_fwb - OCE.OCE_mas_evap_oce + OCE.OCE_mas_rain + OCE.OCE_mas_snow_oce ))
588echo     ('   Check EMP_ICE         = emp_ice - evap_ice + snow_ice                                     = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_ice - OCE.ICE_mas_evap_ice + OCE.OCE_mas_snow_ice ))
589echo     ('   Check EMP_ICE vs WFX  = emp_ice - wfxsub - wfxsnw_sub - wfxsnw_pre + wfxsub_err           = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_ice - OCE.OCE_mas_wfxsub - OCE.ICE_mas_wfxsnw_sub - OCE.ICE_mas_wfxsnw_pre + OCE.ICE_mas_wfxsub_err ))
590
591echo ( '\n------------------------------------------------------------------------------------' )
592echo ( '-- Computations in the PDF note of Clément Rousset')
593echo ( 'Freshwater budget of the ice-ocean system          = emp_oce + emp_ice - runoffs - iceberg - iceshelf                = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce + OCE.OCE_mas_emp_ice - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceberg - OCE.OCE_mas_iceshelf ))
594echo ( 'Freshwater budget of the ice-ocean system          = emp_oce + emp_ice - friver  - iceberg - iceshelf                = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce + OCE.OCE_mas_emp_ice - OCE.OCE_mas_friver  - OCE.OCE_mas_iceberg - OCE.OCE_mas_iceshelf ))
595echo ( 'Freshwater budget in the ocean = ocean mass change = emp_oce - vfxice - ( vfxsnw + vfxsub_err ) - runoffs - iceshelf = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce - OCE.OCE_mas_wfxice - ( OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxsub_err ) - OCE.OCE_mas_runoffs - OCE.OCE_mas_iceshelf ))
596echo ( 'Freshwater budget in the ocean = ocean mass change = emp_oce - vfxice - ( vfxsnw + vfxsub_err ) - friver  - iceshelf = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce - OCE.OCE_mas_wfxice - ( OCE.OCE_mas_wfxsnw + OCE.ICE_mas_wfxsub_err ) - OCE.OCE_mas_friver  - OCE.OCE_mas_iceshelf ))
597echo ( 'Freshwater budget in the ice = ice mass change     = vfxice + ( vfxsnw + vfxsub + vfxspr )                           = {:12.5e} (kg) '.format ( OCE.OCE_mas_wfxice  + OCE.OCE_mas_wfxsnw + OCE.OCE_mas_wfxsub + OCE.ICE_mas_wfxsnw_pre ))
598echo ( 'Freshwater flux at the interface [ice/snow]-ocean  = vfxice + ( vfxsnw + vfxsub_err )                                = {:12.5e} (kg) '.format ( OCE.OCE_mas_wfxsub  + OCE.ICE_mas_wfxsnw_pre ))
599echo ( 'Freshwater flux at the interface [ice/snow]-atm    = ( vfxsub + vfxspr )                                             = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_ice + OCE.ICE_mas_wfxsub_err ))
600echo ( 'Freshwater flux at the interface [ice/snow]-atm    = emp_ice + vfxsub_err                                            = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_ice + OCE.ICE_mas_wfxsub_err ))
601echo ( 'Freshwater flux at the interface ocean-atm         = emp_oce + calving - vfxsub_err                                  = {:12.5e} (kg) '.format ( OCE.OCE_mas_emp_oce + OCE.OCE_mas_calving - OCE.ICE_mas_wfxsub_err ))
602
603echo ( "scsshtot   : global_average_sea_level_change                            = {:12.3e} (m) ".format ( np.sum (d_OCE_sca['scsshtot']  ).values  ) )
604echo ( "scsshtot   : global_average_sea_level_change                            = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['scsshtot']  ).values  * OCE.OCE_aire_tot*OCE_RHO_LIQ  ) )
605echo ( "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  ) )
606echo ( "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  ) )
607echo ( "bgfrcvol   : global mean volume from forcing                            = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['bgfrcvol']  ).values  * 1e9 * OCE_RHO_LIQ  ) )
608echo ( "ibgvol_tot : global mean ice volume                                     = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvol_tot']).values  * 1e9 * OCE_RHO_LIQ  ) )
609echo ( "sbgvol_tot : global mean snow volume                                    = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['sbgvol_tot']).values  * 1e9 * OCE_RHO_LIQ  ) )
610echo ( "ibgvolume  : drift in ice/snow volume (equivalent ocean volume)         = {:12.3e} (kg)".format ( np.sum (d_OCE_sca['ibgvolume'] ).values  * 1e9 * OCE_RHO_LIQ  ) )
611
612echo ( ' ' )
613echo ( f'{Title = }' )
614
615echo ( 'SVN Information' )
616for kk in SVN.keys():
617    print ( SVN[kk] )
618
619## Write the full configuration
620params_out = open (FullIniFile, 'w', encoding = 'utf-8')
621params = wu.dict2config ( dpar )
622params.write ( params_out )
623params_out.close ()
Note: See TracBrowser for help on using the repository browser.