Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/copy_hist.sh
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/copy_hist.sh	(revision 4100)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/copy_hist.sh	(revision 4100)
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# This script should be exexcuted from the directory containing storedir/ and yearXX for a certain experiment
+# First create a simlink STORE to where you want to archive that experiment
+# It will then copy storedir/yearXX/FILE.nc as STORE/FILE.XX.nc
+
+function log()
+{
+    echo $*
+    time $*
+}
+
+for year in 01 02 03 04 05 06 07 08 09 10 ; do
+    for typ in day hf mth mth_icosa ; do
+	log cp -n storedir/year$year/hist${typ}.nc STORE/hist${typ}.${year}.nc
+    done
+    log cp -n storedir/year$year/logs.tgz STORE/logs.${year}.tgz
+done
+
+ls -lRh STORE/
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/diagflux.sh
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/diagflux.sh	(revision 4100)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/diagflux.sh	(revision 4100)
@@ -0,0 +1,13 @@
+#!/bin/bash
+module purge
+module load nco
+
+# cdi ne gere pas >4 dimensions => passer par nco
+# ncwa est tres gourmand en memoire et ne gere un fichier entree
+# => moyenne temporelle par ncra puis zonale par ncwa
+
+INFILES=$(for x in 02 03 04 05 ; do echo histmth_icosa.$x.nc; done)
+set -x
+time ncra $INFILES tmp.nc
+time ncwa -a time_counter,lon_dom_out,lon_dom_144_142 tmp.nc diagflux.nc
+rm -f tmp.nc
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/figs_fluxes.py
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/figs_fluxes.py	(revision 4100)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/figs_fluxes.py	(revision 4100)
@@ -0,0 +1,67 @@
+import numpy as np
+import netCDF4 as cdf
+# select non-interactive backend, cf http://stackoverflow.com/questions/4931376/generating-matplotlib-graphs-without-a-running-x-server
+import matplotlib
+matplotlib.use('Agg') 
+import matplotlib.pyplot as plt
+
+def getdims(nc, *names): return [len(nc.dimensions[name]) for name in names]
+def getvars(nc, *names): return [nc.variables[name] for name in names]
+
+#--------------------------- MAIN ----------------------------
+
+infile = 'diagflux.nc'
+nc = cdf.Dataset(infile, "r")
+print nc
+llm, nlat = getdims(nc, 'lev','lat_dom_out')
+Lv, Cpd, kappa, g, perim = 2.5e6, 1004.5, 0.2857143, 9.80616, 4e7
+
+(lat,p,qflux,q,epotflux,epot,
+ ekinflux,ekin,cpTflux,cpT,mass,mflux) = getvars(nc,
+                                                'lat_dom_out','p','qflux_lat','qmass_t','epotflux_lat','epot_t','ekinflux_lat','ekin_t',
+                                                'enthalpyflux_lat','enthalpy_t','mass_t','massflux_lat')
+
+lat,p,epotflux,epot,ekinflux,ekin,cpTflux,cpT,mass,mflux = [ x[:] for x in lat,p,epotflux,epot,ekinflux,ekin,cpTflux,cpT,mass,mflux ] # read data from file
+qflux,q = qflux[0,:,:], q[0,:,:]
+
+perim = 4e7*np.cos(lat*np.pi/180.) # geometric factor
+stream = mflux.cumsum(axis=0)
+for i in range(lat.size):
+    stream[:,i]=stream[:,i]*perim[i]
+p=p.mean(axis=1)
+
+print qflux.shape, q.shape, stream.shape
+# cpT est en (J/m^2)
+# cpTflux est en (J/m^2)*(m/s)
+
+cpTflux = cpTflux - (cpT/mass)*mflux # flux "turbulents"
+qflux = qflux - (q/mass)*mflux # flux "turbulents"
+
+qflux,cpTflux,mass = [ x.sum(axis=0) for x in qflux,cpTflux,mass ] # somme sur la verticale
+# cpTflux est en (J/m^2)*(m/s)=W/m
+
+print cpTflux.shape, p.shape
+
+cpTflux = cpTflux*perim
+qflux   = qflux*perim
+# cpTflux est en W
+
+plt.figure()
+plt.plot(lat,cpTflux)
+plt.title('Meridional enthalpy flux (W)')
+plt.savefig('enthalpy_flux.png')
+plt.close()
+
+plt.figure()
+plt.plot(lat,Lv*qflux)
+plt.title('Meridional latent heat flux (W)')
+plt.savefig('latent_heat_flux.png')
+plt.close()
+
+plt.figure()
+plt.contourf(lat,p,stream,20)
+plt.ylim(1e5, 0)
+plt.title('Meridional stream function (kg/s)')
+plt.colorbar()
+plt.savefig('stream.png')
+plt.close()
