source: TOOLS/WATER_BUDGET/waterbudget.py @ 6264

Last change on this file since 6264 was 6264, checked in by omamce, 21 months ago

O.M. : TOOLS/WATER_BUDGET
Add python scripts working on restarts

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 33.2 KB
Line 
1#!/usr/bin/env python3
2###
3### Script to check water conservation in the IPSL coupled model
4###
5##  Warning, to install, configure, run, use any of included software or
6##  to read the associated documentation you'll need at least one (1)
7##  brain in a reasonably working order. Lack of this implement will
8##  void any warranties (either express or implied).  Authors assumes
9##  no responsability for errors, omissions, data loss, or any other
10##  consequences caused directly or indirectly by the usage of his
11##  software by incorrectly or partially configured personal
12##
13##
14## SVN information
15#  $Author$
16#  $Date$
17#  $Revision$
18#  $Id$
19#  $HeadURL$
20
21
22## Define Experiment
23if True : 
24    JobName="TEST-CM72-SIMPLE-ROUTING.12" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" 
25    Freq = 'MO' ; YearBegin = 1970 ; YearEnd = 1979 ; PackFrequency = 10
26    ORCA = 'eORCA1.2' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False
27    ATM = 'ICO40' ; Routing = 'SIMPLE'
28
29if False :
30    JobName="TEST-CM72-SIMPLE-ROUTING.10" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" 
31    Freq = 'MO' ; YearBegin = 1860 ; YearEnd = 1869 ; PackFrequency = 10
32    ORCA = 'eORCA1.2' ; ATM = 'ICO40' ; Routing = 'SIMPLE' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False
33
34if False : 
35    JobName="VALID-CM622-LR.01" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" 
36    Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10
37    ORCA = 'eORCA1.2' ; ATM = 'LMD144142' ; Routing = 'ORCHIDEE' ; NEMO=3.6 ; OCE_relax = False ; OCE_icb = False
38   
39if False :
40    JobName="CM65v420-LR-SKL-pi-05" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p48ethe" ; Project="gencmip6" 
41    Freq = 'MO' ;  YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10
42    ORCA = 'eORCA1.2'  ; ATM = 'LMD144142' ; Routing = 'ORCHIDEE' ; NEMO=4.2 ; OCE_relax = False ; OCE_icb = False ; Coupled = True
43   
44Coupled = True
45
46import numpy as np
47##-- Some physical constants
48#-- Earth Radius
49Ra = 40.e6 / (2. * np.pi)
50#-- Gravity
51g = 9.81
52#-- Ice density (kg/m3) in LIM3
53ICE_rho_ice = 917.0
54#-- Snow density (kg/m3) in LIM3
55ICE_rho_sno = 330.0
56#-- Ocean water density (kg/m3) in NEMO
57OCE_rho_liq = 1026.
58#-- Water density in ice pounds in SI3
59ICE_rho_pnd = 1000.
60
61###
62ICO  = False
63if 'ICO' in ATM : ICO  = True
64LMDZ = False
65if 'LMD' in ATM : LMDZ = True
66
67###
68## Import system modules
69import sys, os, shutil, subprocess
70
71# Where do we run ?
72TGCC = False ; IDRIS = False
73SysName, NodeName, Release, Version, Machine = os.uname()
74if 'irene'   in NodeName : TGCC  = True
75if 'jeanzay' in NodeName : IDRIS = True
76
77## Set site specific libIGCM directories, and other specific stuff
78if TGCC :
79    CPU = subprocess.getoutput ( 'lscpu | grep "Model name"' )
80    if "Intel(R) Xeon(R) Platinum" in CPU : Machine = 'irene'
81    if "AMD"                       in CPU : Machine = 'irene-amd'
82       
83    ARCHIVE     = subprocess.getoutput ( f'ccc_home --cccstore   -d {Project} -u {User}' )
84    STORAGE     = subprocess.getoutput ( f'ccc_home --cccwork    -d {Project} -u {User}' )
85    SCRATCHDIR  = subprocess.getoutput ( f'ccc_home --cccscratch -d {Project} -u {User}' )
86    R_IN        = os.path.join ( subprocess.getoutput ( f'ccc_home --cccwork -d igcmg -u igcmg' ), 'IGCM')
87    rebuild     = os.path.join ( subprocess.getoutput ( f'ccc_home --ccchome -d igcmg -u igcmg' ), 'Tools', Machine, 'rebuild_nemo', 'bin', 'rebuild_nemo' )
88
89    ## Specific to run at TGCC.
90    # Needed before importing a NetCDF library (netCDF4, xarray, cmds, etc ...)
91    import mpi4py
92    mpi4py.rc.initialize = False
93       
94    ## Access to the nemo and lmdz module
95    sys.path.append ( os.path.join (subprocess.getoutput ( f'ccc_home -u p86mart' ), 'Python', 'Library'))
96
97    ## Creates output directory
98    TmpDir = os.path.join ( subprocess.getoutput ( 'ccc_home --cccscratch' ), f'WATER_{JobName}_{YearBegin}_{YearEnd}' )
99
100if IDRIS :
101    raise Exception("Pour IDRIS : repertoires et chemins a definir") 
102
103## Import specific module
104import nemo, lmdz
105## Now import needed scientific modules
106import xarray as xr
107   
108# Output file
109FileOut = f'CPL_waterbudget_{JobName}_{YearBegin}_{YearEnd}.out'
110f_out = open ( FileOut, mode = 'w' )
111
112# Function to print to stdout *and* output file
113def echo (string) :
114    print ( string  )
115    f_out.write ( string + '\n' )
116    f_out.flush ()
117    return None
118   
119## Set libIGCM directories
120R_OUT       = os.path.join ( ARCHIVE   , 'IGCM_OUT')
121R_BUF       = os.path.join ( SCRATCHDIR, 'IGCM_OUT')
122
123L_EXP = os.path.join (TagName, SpaceName, ExperimentName, JobName)
124R_SAVE      = os.path.join ( R_OUT, L_EXP )
125R_BUFR      = os.path.join ( R_BUF, L_EXP )
126POST_DIR    = os.path.join ( R_BUF, L_EXP, 'Out' )
127REBUILD_DIR = os.path.join ( R_BUF, L_EXP, 'REBUILD' )
128R_BUF_KSH   = os.path.join ( R_BUFR, 'Out' )
129R_FIGR      = os.path.join ( STORAGE, 'IGCM_OUT', L_EXP )
130
131#if os.path.isdir (TmpDir) : shutil.rmtree ( TmpDir )
132if not os.path.isdir (TmpDir) : os.mkdir (TmpDir)
133TmpDirOCE = os.path.join (TmpDir, 'OCE')
134TmpDirICE = os.path.join (TmpDir, 'ICE')
135if not os.path.exists (TmpDirOCE) : os.mkdir (TmpDirOCE )
136if not os.path.exists (TmpDirICE) : os.mkdir (TmpDirICE )
137
138echo ( f'Working in TMPDIR : {TmpDir}' )
139
140echo ( f'\nDealing with {L_EXP}' )
141
142#-- Model output directories
143if Freq == "MO" : FreqDir =  os.path.join ('Output' , 'MO' )
144if Freq == "SE" : FreqDir =  os.path.join ('Analyse', 'SE' )
145dir_ATM_his = os.path.join ( R_SAVE, "ATM", FreqDir )
146dir_OCE_his = os.path.join ( R_SAVE, "OCE", FreqDir )
147dir_ICE_his = os.path.join ( R_SAVE, "ICE", FreqDir )
148dir_SRF_his = os.path.join ( R_SAVE, "SRF", FreqDir )
149
150#-- Atmosphere grid file
151file_DYN_grid = os.path.join ( R_IN, 
152
153echo ( f'The analysis relies on files from the following model output directories : ' )
154echo ( f'{dir_ATM_his}' )
155echo ( f'{dir_OCE_his}' )
156echo ( f'{dir_ICE_his}' )
157echo ( f'{dir_SRF_his}' )
158
159#-- Files Names
160if Freq == 'MO' : File = f'{JobName}_{YearBegin}0101_{YearEnd}1231_1M'
161if Freq == 'SE' : File = f'{JobName}_SE_{YearBegin}0101_{YearEnd}1231_1M'
162
163echo ('\nOpen history files' )
164file_ATM_his = os.path.join (  dir_ATM_his, f'{File}_histmth.nc' )
165file_OCE_his = os.path.join (  dir_OCE_his, f'{File}_grid_T.nc' )
166file_OCE_sca = os.path.join (  dir_OCE_his, f'{File}_scalar.nc' )
167file_ICE_his = os.path.join (  dir_ICE_his, f'{File}_icemod.nc' )
168file_SRF_his = os.path.join (  dir_SRF_his, f'{File}_sechiba_history.nc' )
169file_OCE_srf = os.path.join (  dir_OCE_his, f'{File}_grid_T.nc' )
170
171d_ATM_his = xr.open_dataset ( file_ATM_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
172d_OCE_his = xr.open_dataset ( file_OCE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
173d_OCE_sca = xr.open_dataset ( file_OCE_sca, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
174d_ICE_his = xr.open_dataset ( file_ICE_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
175if NEMO == 3.6 :d_ICE_his = d_ICE_his.rename ( {'y_grid_T':'y', 'x_grid_T':'x'} )
176d_SRF_his = xr.open_dataset ( file_SRF_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
177d_OCE_srf = xr.open_dataset ( file_OCE_srf, use_cftime=True, decode_times=True, decode_cf=True ).squeeze()
178
179echo ( file_ATM_his )
180echo ( file_OCE_his )
181echo ( file_OCE_sca )
182echo ( file_ICE_his )
183echo ( file_SRF_his )
184
185## Compute run length
186dtime = ( d_ATM_his.time_counter_bounds.max() - d_ATM_his.time_counter_bounds.min() )
187echo ('\nRun length : {:8.2f} days'.format ( (dtime/np.timedelta64(1, "D")).values ) )
188dtime_sec = (dtime/np.timedelta64(1, "s")).values.item() # Convert in seconds
189
190## Compute length of each period
191dtime_per = (d_ATM_his.time_counter_bounds[:,-1] -  d_ATM_his.time_counter_bounds[:,0] )
192echo ('\nPeriods lengths (days) : {:} days'.format ( (dtime_per/np.timedelta64(1, "D")).values ) )
193dtime_per_sec = (dtime_per/np.timedelta64(1, "s")).values # In seconds
194dtime_per_sec = xr.DataArray (dtime_per_sec, dims=["time_counter", ], coords=[d_ATM_his.time_counter,] )
195
196#-- Open restart files
197YearRes = YearBegin - 1        # Year of the restart of beginning of simulation
198YearPre = YearBegin - PackFrequency  # Year to find the tarfile of the restart of beginning of simulation
199
200echo (f'Restart dates - Start : {YearRes}-12-31  /  End : {YearEnd}-12-31 ')
201
202file_restart_beg = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearPre}0101_{YearRes}1231_restart.tar' )
203file_restart_end = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearBegin}0101_{YearEnd}1231_restart.tar' )
204
205echo ( f'{file_restart_beg}' )
206echo ( f'{file_restart_end}' )
207
208file_OCE_beg = f'OCE_{JobName}_{YearRes}1231_restart.nc'
209file_OCE_end = f'OCE_{JobName}_{YearEnd}1231_restart.nc'
210file_ICE_beg = f'ICE_{JobName}_{YearRes}1231_restart_icemod.nc'
211file_ICE_end = f'ICE_{JobName}_{YearEnd}1231_restart_icemod.nc'
212
213echo ( f'{file_OCE_beg}' )
214echo ( f'{file_OCE_end}' )
215echo ( f'{file_ICE_beg}' )
216echo ( f'{file_ICE_end}' )
217
218file_ATM_beg = f'ATM_{JobName}_{YearRes}1231_restartphy.nc'
219file_ATM_end = f'ATM_{JobName}_{YearEnd}1231_restartphy.nc'
220if LMDZ :
221    file_DYN_beg = f'ATM_{JobName}_{YearRes}1231_restart.nc'
222    file_DYN_end = f'ATM_{JobName}_{YearEnd}1231_restart.nc'
223if ICO :
224    file_DYN_beg = f'ICO_{JobName}_{YearRes}1231_restart.nc'
225    file_DYN_end = f'ICO_{JobName}_{YearEnd}1231_restart.nc'
226file_SRF_beg = f'SRF_{JobName}_{YearRes}1231_sechiba_rest.nc'
227file_SRF_end = f'SRF_{JobName}_{YearEnd}1231_sechiba_rest.nc'
228liste_beg = [file_ATM_beg, file_DYN_beg, file_SRF_beg, ]
229liste_end = [file_ATM_end, file_DYN_end, file_SRF_end, ]
230echo ( f'{file_ATM_beg}')
231echo ( f'{file_ATM_end}')
232echo ( f'{file_SRF_beg}')
233echo ( f'{file_SRF_end}')
234
235if Routing == 'SIMPLE' : 
236    file_RUN_beg = f'SRF_{JobName}_{YearRes}1231_routing_restart.nc'
237    file_RUN_end = f'SRF_{JobName}_{YearEnd}1231_routing_restart.nc'
238    liste_beg.append ( file_RUN_beg )
239    liste_end.append ( file_RUN_end )
240    echo ( f'{file_RUN_beg}')
241    echo ( f'{file_RUN_end}')
242
243echo ('\nExtract restart files from tar : ATM, ICO and SRF')
244for resFile in liste_beg :
245    if not os.path.exists ( os.path.join (TmpDir, resFile) ) :
246        command =  f'cd {TmpDir} ; tar xf {file_restart_beg} {resFile}'
247        echo ( command )
248        os.system ( command )
249       
250for resFile in liste_end :
251    if not os.path.exists ( os.path.join (TmpDir, resFile) ) :
252        command =  f'cd {TmpDir} ; tar xf {file_restart_end} {resFile}'
253        echo ( command )
254        os.system ( command )
255
256echo ('\nOpening ATM SRF and ICO restart files')
257d_ATM_beg = xr.open_dataset ( os.path.join (TmpDir, file_ATM_beg), decode_times=False, decode_cf=True).squeeze()
258d_ATM_end = xr.open_dataset ( os.path.join (TmpDir, file_ATM_end), decode_times=False, decode_cf=True).squeeze()
259d_SRF_beg = xr.open_dataset ( os.path.join (TmpDir, file_SRF_beg), decode_times=False, decode_cf=True).squeeze()
260d_SRF_end = xr.open_dataset ( os.path.join (TmpDir, file_SRF_end), decode_times=False, decode_cf=True).squeeze()
261d_DYN_beg = xr.open_dataset ( os.path.join (TmpDir, file_DYN_beg), decode_times=False, decode_cf=True).squeeze()
262d_DYN_end = xr.open_dataset ( os.path.join (TmpDir, file_DYN_end), decode_times=False, decode_cf=True).squeeze()
263
264for var in d_SRF_beg.variables :
265    #d_SRF_beg[var].attrs['_FillValue'] = 1.e20
266    #d_SRF_end[var].attrs['_FillValue'] = 1.e20
267    d_SRF_beg[var] = d_SRF_beg[var].where (  d_SRF_beg[var]<1.e20, 0.)
268    d_SRF_end[var] = d_SRF_end[var].where (  d_SRF_end[var]<1.e20, 0.)
269
270if ICO :
271    d_RUN_beg = xr.open_dataset ( os.path.join (TmpDir, file_RUN_beg), decode_times=False, decode_cf=True).squeeze()
272    d_RUN_end = xr.open_dataset ( os.path.join (TmpDir, file_RUN_end), decode_times=False, decode_cf=True).squeeze()
273
274echo ('\nExtract and rebuild OCE and ICE restarts')
275def get_ndomain (zfile) :
276    #d_zfile = xr.open_dataset (zfile, decode_times=False).squeeze()
277    #ndomain_opa = d_zfile.attrs['DOMAIN_number_total']
278    #d_zfile.close ()
279    ndomain_opa = subprocess.getoutput ( f'ls {zfile}_*.nc | wc -l' ).format()
280    return int (ndomain_opa)
281
282
283if not os.path.exists ( os.path.join (TmpDir, file_OCE_beg) ) :
284    if not os.path.exists ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearRes}1231_restart_0000.nc') ):
285        command =  f'cd {TmpDirOCE} ; tar xf {file_restart_beg}  OCE_{JobName}_{YearRes}1231_restart_*.nc'
286        echo ( command )
287        os.system ( command )
288    ndomain_opa = get_ndomain ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearRes}1231_restart') )
289    command = f'cd {TmpDirOCE} ; {rebuild} OCE_{JobName}_{YearRes}1231_restart {ndomain_opa} ; mv {file_OCE_beg} {TmpDir}'
290    echo ( command )
291    os.system ( command )
292    echo ( f'Rebuild done : {file_OCE_beg}')
293   
294if not os.path.exists ( os.path.join (TmpDir, file_OCE_end) ) :
295    if not os.path.exists ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearEnd}1231_restart_0000.nc') ):
296        command =  f'cd {TmpDirOCE} ; tar xf {file_restart_end}  OCE_{JobName}_{YearEnd}1231_restart_*.nc'
297        echo ( command )
298        os.system ( command )
299    ndomain_opa = get_ndomain ( os.path.join (TmpDirOCE, f'OCE_{JobName}_{YearEnd}1231_restart') )
300    command = f'cd {TmpDirOCE} ; {rebuild} OCE_{JobName}_{YearEnd}1231_restart {ndomain_opa} ; mv {file_OCE_end} {TmpDir}'
301    echo ( command )
302    os.system ( command )
303    echo ( f'Rebuild done : {file_OCE_end}')
304
305if not os.path.exists ( os.path.join (TmpDir, file_ICE_beg) ) :
306    if not os.path.exists ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod') ):
307        command =  f'cd {TmpDirICE} ; tar xf {file_restart_beg}  ICE_{JobName}_{YearRes}1231_restart_icemod_*.nc'
308        echo ( command )
309        os.system ( command )
310    ndomain_opa = get_ndomain ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod') )
311    command = f'cd {TmpDirICE} ; {rebuild} ICE_{JobName}_{YearRes}1231_restart_icemod {ndomain_opa} ; mv {file_ICE_beg} {TmpDir} '
312    echo ( command )
313    os.system ( command )
314    echo ( f'Rebuild done : {file_OCE_beg}')
315   
316if not os.path.exists ( os.path.join (TmpDir, file_ICE_end) ) :
317    if not os.path.exists ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearEnd}1231_restart_icemod') ):
318        command =  f'cd {TmpDirICE} ; tar xf {file_restart_end} ICE_{JobName}_{YearEnd}1231_restart_icemod_*.nc'
319        echo ( command )
320        os.system ( command )
321    ndomain_opa = get_ndomain ( os.path.join (TmpDirICE, f'ICE_{JobName}_{YearRes}1231_restart_icemod') )
322    command = f'cd {TmpDirICE} ; {rebuild} ICE_{JobName}_{YearEnd}1231_restart_icemod {ndomain_opa} ; mv {file_ICE_end} {TmpDir}'
323    echo ( command )
324    os.system ( command )
325    echo ( f'Rebuild done : {file_ICE_end}')
326
327echo ('Opening OCE and ICE restart files')
328if NEMO == 3.6 : 
329    d_OCE_beg = xr.open_dataset ( os.path.join (TmpDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
330    d_OCE_end = xr.open_dataset ( os.path.join (TmpDir, file_OCE_end), decode_times=False, decode_cf=True).squeeze()
331    d_ICE_beg = xr.open_dataset ( os.path.join (TmpDir, file_ICE_beg), decode_times=False, decode_cf=True).squeeze()
332    d_ICE_end = xr.open_dataset ( os.path.join (TmpDir, file_ICE_end), decode_times=False, decode_cf=True).squeeze()
333if NEMO == 4.0 or NEMO == 4.2 : 
334    d_OCE_beg = xr.open_dataset ( os.path.join (TmpDir, file_OCE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
335    d_OCE_end = xr.open_dataset ( os.path.join (TmpDir, file_OCE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
336    d_ICE_beg = xr.open_dataset ( os.path.join (TmpDir, file_ICE_beg), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
337    d_ICE_end = xr.open_dataset ( os.path.join (TmpDir, file_ICE_end), decode_times=False, decode_cf=True, drop_variables=['y', 'x']).squeeze()
338   
339echo ( file_ATM_beg )
340echo ( file_ATM_end )
341echo ( file_DYN_beg )
342echo ( file_DYN_end )
343echo ( file_SRF_beg )
344echo ( file_SRF_end )
345if Routing == 'SIMPLE' :
346    echo ( file_RUN_beg )
347    echo ( file_RUN_end )
348echo ( file_OCE_beg )
349echo ( file_OCE_end )
350echo ( file_ICE_beg )
351echo ( file_ICE_end )
352
353# ATM grid with cell surfaces
354if ICO : 
355    ATM_aire = d_ATM_his ['aire'][0]
356    ATM_fsea = d_ATM_his ['fract_oce'][0] + d_ATM_his ['fract_sic'][0]
357    ATM_fter = d_ATM_his ['fract_ter'][0]
358if LMDZ :
359    ATM_aire = lmdz.geo2point ( d_ATM_his ['aire'][0] )
360    ATM_fsea = lmdz.geo2point ( d_ATM_his ['fract_oce'][0] + d_ATM_his ['fract_sic'][0] )
361    ATM_fter = lmdz.geo2point ( d_ATM_his ['fract_ter'][0]  )
362    ATM_aire[0]  = np.sum ( d_ATM_his ['aire'][0, 0] )
363    ATM_aire[-1] = np.sum ( d_ATM_his ['aire'][0,-1] )
364
365SRF_aire = ATM_aire * ATM_fter
366
367if ICO :
368    file_DYN_aire = os.path.join ( R_IN, 'ATM', 'GRID', ATM+'_grid.nc' )
369    d_DYN_aire = xr.open_dataset ( file_DYN_aire, decode_times=False).squeeze()
370    d_DYN_aire = d_DYN_aire.rename( {'cell':'cell_mesh'})
371    DYN_aire   = d_DYN_aire['aire']
372if LMDZ :
373    DYN_aire = ATM_aire
374
375#if LMDZ :
376#    d_ATM_beg = d_ATM_beg.assign ( coords={'lon':d_ATM_beg.lon*180./np.pi} )
377
378# Get mask and surfaces
379sos = d_OCE_his ['sos'][0].squeeze()
380OCE_msk = nemo.lbc_mask ( xr.where ( sos>0, 1., 0.0 ), cd_type = 'T' )
381so = sos = d_OCE_his ['sos'][0].squeeze()
382OCE_msk3 = nemo.lbc_mask ( xr.where ( so>0., 1., 0. ), cd_type = 'T', sval = 0. )
383
384#so = d_OCE_beg ['so'].squeeze()
385#OCE_msk3 = nemo.lbc_mask ( xr.where ( so>0., 1., 0. ), cd_type = 'T', sval = 0. )
386#OCE_msk  = OCE_msk3[0]
387
388# lbc_mask removes the duplicate points (periodicity and north fold)
389OCE_aire = nemo.lbc_mask ( d_OCE_his ['area'] * OCE_msk, cd_type = 'T', sval = 0.0 )
390ICE_aire = OCE_aire
391
392ATM_aire_tot = np.sum (ATM_aire).values.item()
393OCE_aire_tot = np.sum (OCE_aire).values.item()
394ICE_aire_tot = np.sum (ICE_aire).values.item()
395
396echo ( '\n------------------------------------------------------------------------------------' )
397echo ( '-- NEMO change in stores (for the records)' )
398#-- Note that the total number of days of the run should be diagnosed rather than assumed
399#-- Here the result is in Sv
400#
401#-- Change in ocean volume in freshwater equivalent
402
403OCE_ssh_beg = d_OCE_beg['sshn']
404OCE_ssh_end = d_OCE_end['sshn']
405OCE_sum_ssh_beg = np.sum ( OCE_ssh_beg * OCE_aire ).values.item()
406OCE_sum_ssh_end = np.sum ( OCE_ssh_end * OCE_aire ).values.item()
407
408OCE_mas_wat_beg = OCE_sum_ssh_beg * OCE_rho_liq
409OCE_mas_wat_end = OCE_sum_ssh_end * OCE_rho_liq
410
411echo ( 'OCE_sum_ssh_beg = {:12.6e} m^3  - OCE_sum_ssh_end = {:12.6e} m^3'.format (OCE_sum_ssh_beg, OCE_sum_ssh_end) )
412dOCE_vol_liq = ( OCE_sum_ssh_end - OCE_sum_ssh_beg )
413dOCE_mas_liq = dOCE_vol_liq * OCE_rho_liq
414dOCE_mas_wat = dOCE_mas_liq
415
416echo ( 'dOCE vol    = {:12.3e} m^3'.format (dOCE_vol_liq) )
417echo ( 'dOCE ssh    = {:12.3e} m  '.format (dOCE_vol_liq/OCE_aire_tot) )
418echo ( 'dOCE mass   = {:12.3e} kg '.format (dOCE_mas_liq) )
419echo ( 'dOCE mass   = {:12.3e} Sv '.format (dOCE_mas_liq/dtime_sec*1E-6/OCE_rho_liq) )
420
421## Glace et neige
422if NEMO == 3.6 :
423    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']
424    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']
425
426    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']
427    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']
428   
429    ICE_pnd_beg = 0.0 ; ICE_pnd_end = 0.0
430    ICE_fzl_beg = 0.0 ; ICE_fzl_end = 0.0
431
432    ICE_mas_wat_beg = np.sum ( (ICE_ice_beg*ICE_rho_ice + ICE_sno_beg*ICE_rho_sno)*ICE_aire ).values.item()
433    ICE_mas_wat_end = np.sum ( (ICE_ice_end*ICE_rho_ice + ICE_sno_end*ICE_rho_sno)*ICE_aire ).values.item()
434   
435if NEMO == 4.0 or NEMO == 4.2 :
436    ICE_ice_beg = d_ICE_beg 'v_i']   ; ICE_ice_end = d_ICE_end ['v_i']
437    ICE_sno_beg = d_ICE_beg ['v_s']  ; ICE_sno_end = d_ICE_end ['v_s']
438    ICE_pnd_beg = d_ICE_beg ['v_ip'] ; ICE_pnd_end = d_ICE_end ['v_ip']
439    ICE_fzl_beg = d_ICE_beg ['v_il'] ; ICE_fzl_end = d_ICE_end ['v_il']
440   
441    ICE_mas_wat_beg = np.sum ( d_ICE_beg['snwice_mass']*ICE_aire ).values.item()
442    ICE_mas_wat_end = np.sum ( d_ICE_end['snwice_mass']*ICE_aire ).values.item()
443   
444   
445ICE_vol_ice_beg = np.sum ( ICE_ice_beg*ICE_aire ).values.item()
446ICE_vol_ice_end = np.sum ( ICE_ice_end*ICE_aire ).values.item()
447
448ICE_vol_sno_beg = np.sum ( ICE_sno_beg*ICE_aire ).values.item()
449ICE_vol_sno_end = np.sum ( ICE_sno_end*ICE_aire ).values.item()
450
451ICE_vol_pnd_beg = np.sum ( ICE_pnd_beg*ICE_aire ).values.item()
452ICE_vol_pnd_end = np.sum ( ICE_pnd_end*ICE_aire ).values.item()
453
454ICE_vol_fzl_beg = np.sum ( ICE_fzl_beg*ICE_aire ).values.item()
455ICE_vol_fzl_end = np.sum ( ICE_fzl_end*ICE_aire ).values.item()
456
457#-- Converting to freswater volume
458dICE_vol_ice = ICE_vol_ice_end - ICE_vol_ice_beg
459dICE_mas_ice = dICE_vol_ice * ICE_rho_ice
460
461dICE_vol_sno = ICE_vol_sno_end - ICE_vol_sno_beg
462dICE_mas_sno = dICE_vol_sno * ICE_rho_sno
463
464dICE_vol_pnd = ICE_vol_pnd_end - ICE_vol_pnd_beg
465dICE_mas_pnd = dICE_vol_pnd * ICE_rho_pnd
466
467dICE_vol_fzl= ICE_vol_fzl_end - ICE_vol_fzl_beg
468dICE_mas_fzl = dICE_vol_fzl * ICE_rho_pnd
469
470if NEMO == 3.6 :
471    dICE_mas_wat = dICE_mas_ice + dICE_mas_sno
472    dSEA_mas_wat = dOCE_mas_wat + dICE_mas_ice + dICE_mas_sno
473
474if NEMO == 4.0 or NEMO == 4.2 :
475    dICE_mas_wat = ICE_mas_wat_end - ICE_mas_wat_beg
476    dSEA_mas_wat = dOCE_mas_wat + dICE_mas_wat
477
478echo ( 'ICE_vol_ice_beg = {:12.6e} m^3 - ICE_vol_ice_end = {:12.6e} m^3'.format (ICE_vol_ice_beg, ICE_vol_ice_end) )
479echo ( 'ICE_vol_sno_beg = {:12.6e} m^3 - ICE_vol_sno_end = {:12.6e} m^3'.format (ICE_vol_sno_beg, ICE_vol_sno_end) )
480echo ( 'ICE_vol_pnd_beg = {:12.6e} m^3 - ICE_vol_pnd_end = {:12.6e} m^3'.format (ICE_vol_pnd_beg, ICE_vol_pnd_end) )
481echo ( 'ICE_vol_fzl_beg = {:12.6e} m^3 - ICE_vol_fzl_end = {:12.6e} m^3'.format (ICE_vol_fzl_beg, ICE_vol_fzl_end) )
482
483echo ( 'dICE_vol_ice   = {:12.3e} m^3'.format (dICE_vol_ice) )
484echo ( 'dICE_vol_sno   = {:12.3e} m^3'.format (dICE_vol_sno) )
485echo ( 'dICE_vol_pnd   = {:12.3e} m^3'.format (dICE_vol_pnd) )
486echo ( 'dICE_mas_ice   = {:12.3e} m^3'.format (dICE_mas_ice) )
487echo ( 'dICE_mas_sno   = {:12.3e} m^3'.format (dICE_mas_sno) ) 
488echo ( 'dICE_mas_pnd   = {:12.3e} m^3'.format (dICE_mas_pnd) ) 
489echo ( 'dICE_mas_fzl   = {:12.3e} m^3'.format (dICE_mas_fzl) ) 
490echo ( 'dICE_mas_wat   = {:12.3e} m^3'.format (dICE_mas_wat) ) 
491
492
493SEA_mas_wat_beg = OCE_mas_wat_beg + ICE_mas_wat_beg
494SEA_mas_wat_end = OCE_mas_wat_end + ICE_mas_wat_end
495
496echo ( '\n------------------------------------------------------------')
497echo ( 'Variation du contenu en eau ocean + glace ' )
498echo ( 'dMass(ocean)   = {:12.6e} kg '.format(dSEA_mas_wat) )
499echo ( 'dVol (ocean)   = {:12.3e} Sv '.format(dSEA_mas_wat/dtime_sec*1E-6/OCE_rho_liq) )
500echo ( 'dVol (ocean)   = {:12.3e} m  '.format(dSEA_mas_wat*1E-3/OCE_aire_tot) )
501
502
503echo ( '\n------------------------------------------------------------------------------------' )
504echo ( '-- LMDZ changes in stores ' )
505
506#-- Change in precipitable water from the atmosphere daily and monthly files
507#-- Compute sum weighted by gridcell area (kg/m2) then convert to Sv
508
509# ATM vertical grid
510ATM_Ahyb = d_ATM_his['Ahyb'].squeeze()
511ATM_Bhyb = d_ATM_his['Bhyb'].squeeze()
512klevp1 = ATM_Ahyb.shape[0]
513
514# Surface pressure
515if ICO : 
516    ATM_ps_beg = d_DYN_beg['ps']
517    ATM_ps_end = d_DYN_end['ps']
518   
519if LMDZ : 
520    ATM_ps_beg =  lmdz.geo2point ( d_DYN_beg['ps'].isel(rlonv=slice(0,-1)) )
521    ATM_ps_end =  lmdz.geo2point ( d_DYN_end['ps'].isel(rlonv=slice(0,-1)) )
522   
523# 3D Pressure
524ATM_p_beg = ATM_Ahyb + ATM_Bhyb * ATM_ps_beg
525ATM_p_end = ATM_Ahyb + ATM_Bhyb * ATM_ps_end
526
527# Layer thickness
528ATM_sigma_beg = ATM_p_beg[0:-1]*0.
529ATM_sigma_end = ATM_p_end[0:-1]*0. 
530
531for k in np.arange (klevp1-1) :
532    ATM_sigma_beg[k,:] = (ATM_p_beg[k,:] - ATM_p_beg[k+1,:]) / g
533    ATM_sigma_end[k,:] = (ATM_p_end[k,:] - ATM_p_end[k+1,:]) / g
534
535ATM_sigma_beg = ATM_sigma_beg.rename ( {'klevp1':'sigs'} )
536ATM_sigma_end = ATM_sigma_end.rename ( {'klevp1':'sigs'} )
537
538##-- Vertical and horizontal integral, and sum of liquid, solid and vapor water phases
539if LMDZ :
540    try : 
541        ATM_wat_beg = lmdz.geo3point ( (d_DYN_beg['H2Ov'] + d_DYN_beg['H2Ol'] + d_DYN_beg['H2Oi']).isel(rlonv=slice(0,-1) ) )
542        ATM_wat_end = lmdz.geo3point ( (d_DYN_end['H2Ov'] + d_DYN_end['H2Ol'] + d_DYN_end['H2Oi']).isel(rlonv=slice(0,-1) ) )
543    except :
544        ATM_wat_beg = lmdz.geo3point ( (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s']).isel(rlonv=slice(0,-1) ) )
545        ATM_wat_end = lmdz.geo3point ( (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s']).isel(rlonv=slice(0,-1) ) )
546if ICO :
547    ATM_wat_beg = ( d_DYN_beg['q'][0:4] ).sum (dim = ['nq',] ).rename ( {'lev':'sigs'} )
548    ATM_wat_end = ( d_DYN_end['q'][0:4] ).sum (dim = ['nq',] ).rename ( {'lev':'sigs'} )
549   
550ATM_mas_wat_beg = np.sum (ATM_sigma_beg * ATM_wat_beg * ATM_aire).values.item()
551ATM_mas_wat_end = np.sum (ATM_sigma_end * ATM_wat_end * ATM_aire).values.item()
552
553dATM_mas_wat = ATM_mas_wat_end - ATM_mas_wat_beg
554
555echo ( '\nVariation du contenu en eau atmosphere ' )
556echo ( 'ATM_mass_beg = {:12.6e} kg - ATM_mass_end = {:12.6e} kg'.format (ATM_mas_wat_beg, ATM_mas_wat_end) )
557echo ( 'dMass(atm)   = {:12.3e} kg '.format (dATM_mas_wat) )
558echo ( 'dMass(atm)   = {:12.3e} Sv '.format (dATM_mas_wat/dtime_sec*1.E-9) )
559echo ( 'dMass(atm)   = {:12.3e}m   '.format (dATM_mas_wat/OCE_aire_tot*1E-3) )
560
561LIC_sno_beg = d_ATM_beg['SNOW01']*d_ATM_beg['FTER']+d_ATM_beg['SNOW02']*d_ATM_beg['FLIC']+d_ATM_beg['SNOW03']*d_ATM_beg['FOCE']+d_ATM_beg['SNOW04']*d_ATM_beg['FSIC']
562LIC_sno_end = d_ATM_end['SNOW01']*d_ATM_end['FTER']+d_ATM_end['SNOW02']*d_ATM_end['FLIC']+d_ATM_end['SNOW03']*d_ATM_end['FOCE']+d_ATM_end['SNOW04']*d_ATM_end['FSIC']
563if ICO :
564   LIC_sno_beg = LIC_sno_beg.rename ( {'points_physiques':'cell_mesh'} )
565   LIC_sno_end = LIC_sno_end.rename ( {'points_physiques':'cell_mesh'} )
566
567LIC_mas_sno_beg = np.sum ( LIC_sno_beg * ATM_aire ).values.item()
568LIC_mas_sno_end = np.sum ( LIC_sno_end * ATM_aire ).values.item()
569
570dLIC_mas_sno = LIC_mas_sno_end - LIC_mas_sno_beg
571
572echo ( '\nVariation du contenu en neige atmosphere (calottes)' )
573echo ( 'LIC_mas_sno_beg  = {:12.6e} kg  - LIC_mas_sno_end  = {:12.6e} kg'.format (LIC_mas_sno_beg, LIC_mas_sno_end) )
574echo ( 'dMass(neige atm) = {:12.3e} kg '.format (dLIC_mas_sno ) )
575echo ( 'dMass(neige atm) = {:12.3e} Sv '.format (dLIC_mas_sno/dtime_sec*1E-6/ICE_rho_ice) )
576echo ( 'dMass(neige atm) = {:12.3e} m  '.format (dLIC_mas_sno/OCE_aire_tot*1E-3) )
577
578echo ( '\nVariation du contenu en eau+neige atmosphere ' )
579echo ( 'dMass(eau + neige atm) = {:12.3e} kg '.format (  dATM_mas_wat + dLIC_mas_sno) )
580echo ( 'dMass(eau + neige atm) = {:12.3e} Sv '.format ( (dATM_mas_wat + dLIC_mas_sno)/dtime_sec*1E-9) )
581echo ( 'dMass(eau + neige atm) = {:12.3e} m  '.format ( (dATM_mas_wat + dLIC_mas_sno)/OCE_aire_tot*1E-3) )
582
583echo ( '\n------------------------------------------------------------------------------------' )
584echo ( '-- SRF changes ' )
585
586if Routing == 'SIMPLE' :
587    RUN_mas_wat_beg = np.sum ( d_RUN_beg ['fast_reservoir'] +  d_RUN_beg ['slow_reservoir'] +  d_RUN_beg ['stream_reservoir']).values.item()
588    RUN_mas_wat_end = np.sum ( d_RUN_end ['fast_reservoir'] +  d_RUN_end ['slow_reservoir'] +  d_RUN_end ['stream_reservoir']).values.item()
589
590if Routing == 'ORCHIDEE' : 
591    RUN_mas_wat_beg = np.sum ( d_SRF_beg['fastres']  + d_SRF_beg['slowres'] + d_SRF_beg['streamres'] \
592                             + d_SRF_beg['floodres'] + d_SRF_beg['lakeres'] + d_SRF_beg['pondres'] ) .values.item()
593    RUN_mas_wat_end = np.sum ( d_SRF_end['fastres']  + d_SRF_end['slowres'] + d_SRF_end['streamres'] \
594                             + d_SRF_end['floodres'] + d_SRF_end['lakeres'] + d_SRF_end['pondres'] ) .values.item()
595
596dRUN_mas_wat = RUN_mas_wat_end - RUN_mas_wat_beg
597   
598echo ( '\nWater content in routing ' )
599echo ( 'RUN_mas_wat_beg = {:12.6e} kg - RUN_mas_wat_end = {:12.6e} kg '.format (RUN_mas_wat_end, RUN_mas_wat_end) )
600echo ( 'dMass(routing)  = {:12.3e} kg '.format(dRUN_mas_wat) )
601echo ( 'dMass(routing)  = {:12.3e} Sv '.format(dRUN_mas_wat/dtime_sec*1E-9) )
602echo ( 'dMass(routing)  = {:12.3e} m  '.format(dRUN_mas_wat/OCE_aire_tot*1E-3) )
603
604tot_watveg_beg  = d_SRF_beg['tot_watveg_beg']  ; tot_watveg_beg  = tot_watveg_beg .where (tot_watveg_beg < 1E10, 0.)
605tot_watsoil_beg = d_SRF_beg['tot_watsoil_beg'] ; tot_watsoil_beg = tot_watsoil_beg.where (tot_watsoil_beg< 1E10, 0.)
606snow_beg        = d_SRF_beg['snow_beg']        ; snow_beg        = snow_beg       .where (snow_beg       < 1E10, 0.)
607
608tot_watveg_end  = d_SRF_end['tot_watveg_beg']  ; tot_watveg_end  = tot_watveg_end .where (tot_watveg_end < 1E10, 0.)
609tot_watsoil_end = d_SRF_end['tot_watsoil_beg'] ; tot_watsoil_end = tot_watsoil_end.where (tot_watsoil_end< 1E10, 0.)
610snow_end        = d_SRF_end['snow_beg']        ; snow_end        = snow_end       .where (snow_end       < 1E10, 0.)
611
612SRF_mas_wat_beg = tot_watveg_beg + tot_watsoil_beg + snow_beg
613SRF_mas_wat_end = tot_watveg_end + tot_watsoil_end + snow_end
614
615#SRF_mas_wat_beg = d_SRF_beg['tot_watveg_beg']+d_SRF_beg['tot_watsoil_beg'] + d_SRF_beg['snow_beg']
616#SRF_mas_wat_end = d_SRF_end['tot_watveg_beg']+d_SRF_end['tot_watsoil_beg'] + d_SRF_end['snow_beg']
617
618if LMDZ :
619    tot_watveg_beg  = tot_watveg_beg .rename ( {'y':'points_phyiques'} )
620    tot_watsoil_beg = tot_watsoil_beg.rename ( {'y':'points_phyiques'} )
621    snow_beg        = snow_beg       .rename ( {'y':'points_phyiques'} )
622    tot_watveg_end  = tot_watveg_end .rename ( {'y':'points_phyiques'} )
623    tot_watsoil_end = tot_watsoil_end.rename ( {'y':'points_phyiques'} )
624    snow_end        = snow_end       .rename ( {'y':'points_phyiques'} )
625    SRF_mas_wat_beg = SRF_mas_wat_beg.rename ( {'y':'points_phyiques'} )
626    SRF_mas_wat_end = SRF_mas_wat_end.rename ( {'y':'points_phyiques'} )
627if ICO :
628    tot_watveg_beg  = tot_watveg_beg .rename ( {'y':'cell_mesh'} )
629    tot_watsoil_beg = tot_watsoil_beg.rename ( {'y':'cell_mesh'} )
630    snow_beg        = snow_beg       .rename ( {'y':'cell_mesh'} )
631    tot_watveg_end  = tot_watveg_end .rename ( {'y':'cell_mesh'} )
632    tot_watsoil_end = tot_watsoil_end.rename ( {'y':'cell_mesh'} )
633    snow_end        = snow_end       .rename ( {'y':'cell_mesh'} )
634    SRF_mas_wat_end = SRF_mas_wat_end.rename ( {'y':'cell_mesh'} )
635    SRF_mas_wat_end = SRF_mas_wat_end.rename ( {'y':'cell_mesh'} ) 
636
637SRF_mas_watveg_beg  = np.sum ( tot_watveg_beg  * SRF_aire).values.item()
638SRF_mas_watsoil_beg = np.sum ( tot_watsoil_beg * SRF_aire).values.item()
639SRF_mas_snow_beg    = np.sum ( snow_beg        * SRF_aire).values.item()
640SRF_mas_watveg_end  = np.sum ( tot_watveg_end  * SRF_aire).values.item()
641SRF_mas_watsoil_end = np.sum ( tot_watsoil_end * SRF_aire).values.item()
642SRF_mas_snow_end    = np.sum ( snow_end        * SRF_aire).values.item()
643
644dSRF_mas_watveg  = SRF_mas_watveg_end  - SRF_mas_watveg_beg
645dSRF_mas_watsoil = SRF_mas_watsoil_end - SRF_mas_watsoil_beg
646dSRF_mas_snow    = SRF_mas_snow_end    - SRF_mas_snow_beg
647
648echo ('\nLes differents reservoirs')
649echo ( 'SRF_mas_watveg_beg   = {:12.6e} kg - SRF_mas_watveg_end   = {:12.6e} kg '.format (SRF_mas_watveg_beg , SRF_mas_watveg_end) )
650echo ( 'SRF_mas_watsoil_beg  = {:12.6e} kg - SRF_mas_watsoil_end  = {:12.6e} kg '.format (SRF_mas_watsoil_beg, SRF_mas_watsoil_end) )
651echo ( 'SRF_mas_snow_beg     = {:12.6e} kg - SRF_mas_snow_end     = {:12.6e} kg '.format (SRF_mas_snow_beg    , SRF_mas_snow_end) )
652
653echo ( 'dMass(watveg)  = {:12.3e} kg '.format (dSRF_mas_watveg) )
654echo ( 'dMass(watsoil) = {:12.3e} kg '.format (dSRF_mas_watsoil) )
655echo ( 'dMass(sno)     = {:12.3e} kg '.format (dSRF_mas_snow) )
656
657
658SRF_mas_wat_beg = np.sum ( SRF_mas_wat_beg * SRF_aire).values.item()
659SRF_mas_wat_end = np.sum ( SRF_mas_wat_end * SRF_aire).values.item()
660
661dSRF_mas_wat = SRF_mas_wat_end - SRF_mas_wat_beg
662
663echo ( '\nWater content in surface ' )
664echo ( 'SRF_mas_wat_beg  = {:12.6e} kg - SRF_mas_wat_end  = {:12.6e} kg '.format (SRF_mas_wat_beg, SRF_mas_wat_end) )
665echo ( 'dMass(water srf) = {:12.3e} kg '.format (dSRF_mas_wat) )
666echo ( 'dMass(water srf) = {:12.3e} Sv '.format (dSRF_mas_wat/dtime_sec*1E-9) )
667echo ( 'dMass(water srf) = {:12.3e} m  '.format (dSRF_mas_wat/OCE_aire_tot*1E-3) )
668
669echo ( '\nWater content in  ATM + SRF + RUN ' )
670echo ( 'mas_wat_beg              = {:12.6e} kg '.format (ATM_mas_wat_beg + LIC_mas_sno_beg + RUN_mas_wat_beg + SRF_mas_wat_beg) )
671echo ( 'mas_wat_end              = {:12.6e} kg '.format (ATM_mas_wat_end + LIC_mas_sno_end + RUN_mas_wat_end + SRF_mas_wat_end) )
672echo ( 'dMass(water atm+srf+run) = {:12.6e} kg '.format ( dATM_mas_wat   + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat) )
673echo ( 'dMass(water atm+srf+run) = {:12.3e} Sv '.format ((dATM_mas_wat   + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat)/dtime_sec*1E-9) )
674echo ( 'dMass(water atm+srf+run) = {:12.3e} m  '.format ((dATM_mas_wat   + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat)/OCE_aire_tot*1E-3) )
675
676echo ( '\n------------------------------------------------------------------------------------' )
677echo ( '-- Change in all components' )
678echo ( 'mas_wat_beg              = {:12.6e} kg '.format (SEA_mas_wat_beg + ATM_mas_wat_beg + LIC_mas_sno_beg + RUN_mas_wat_beg + SRF_mas_wat_beg) )
679echo ( 'mas_wat_end              = {:12.6e} kg '.format (SEA_mas_wat_end + ATM_mas_wat_end + LIC_mas_sno_end + RUN_mas_wat_end + SRF_mas_wat_end) )
680echo ( 'dMass(water CPL)         = {:12.3e} kg '.format ( dSEA_mas_wat   + dATM_mas_wat    + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat) )
681echo ( 'dMass(water CPL)         = {:12.3e} Sv '.format ((dSEA_mas_wat   + dATM_mas_wat    + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat)/dtime_sec*1E-9) )
682echo ( 'dMass(water CPL)         = {:12.3e} m  '.format ((dSEA_mas_wat   + dATM_mas_wat    + dLIC_mas_sno    + dRUN_mas_wat    + dSRF_mas_wat)/OCE_aire_tot*1E-3) )
683
684
Note: See TracBrowser for help on using the repository browser.