source: TOOLS/WATER_BUDGET/waterbudget.py @ 6652

Last change on this file since 6652 was 6265, checked in by omamce, 19 months ago

O.M. : WATER_BUDGET :

Add nemo and lmdz libraries.
Small changes in routines : ATM water budget still not correct
OCE water budget matches fluxes for NEMO 4.2

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