Index: TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
===================================================================
--- TOOLS/ConsoGENCMIP6/bin/plot_bilan.py	(revision 2426)
+++ TOOLS/ConsoGENCMIP6/bin/plot_bilan.py	(revision 2427)
@@ -39,13 +39,19 @@
   #---------------------------------------
   def fill_data(self, filein):
-    data = np.genfromtxt(
-      filein,
-      skip_header=1,
-      converters={0: string_to_date,
-                  1: string_to_float,
-                  2: string_to_percent,
-                  3: string_to_percent},
-      missing_values="nan",
-    )
+    """
+    """
+    try:
+      data = np.genfromtxt(
+        filein,
+        skip_header=1,
+        converters={0: string_to_date,
+                    1: string_to_float,
+                    2: string_to_percent,
+                    3: string_to_percent},
+        missing_values="nan",
+      )
+    except:
+      print("Empty file {}".format(filein))
+      exit(1)
 
     for date, conso, real_use, theo_use in data:
@@ -226,22 +232,29 @@
 
 
-########################################
-def plot_save(img_name):
-  """
-  """
-  dpi = 200.
-
-  with PdfPages(img_name) as pdf:
-    pdf.savefig(dpi=dpi)
-
-    # pdf file's metadata
-    d = pdf.infodict()
-    d["Title"]   = "Conso GENCMIP6"
-    d["Author"]  = "plot_bilan.py"
-    # d["Subject"] = "Time spent over specific commands during create_ts \
-    #                 jobs at IDRIS and four configurations at TGCC"
-    # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat"
-    # d["CreationDate"] = dt.datetime(2009, 11, 13)
-    # d["ModDate"] = dt.datetime.today()
+# ########################################
+# def plot_save(img_name, titre):
+#   """
+#   """
+#   dpi = 200.
+
+#   img_in  = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name))
+
+#   with PdfPages(img_in) as pdf:
+#     pdf.savefig(dpi=dpi)
+
+#     # pdf file's metadata
+#     d = pdf.infodict()
+#     d["Title"]   = titre
+#     d["Author"]  = os.path.basename(__file__)
+#     # d["Subject"] = "Time spent over specific commands during create_ts \
+#     #                 jobs at IDRIS and four configurations at TGCC"
+#     # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat"
+#     # d["CreationDate"] = dt.datetime(2009, 11, 13)
+#     # d["ModDate"] = dt.datetime.today()
+
+#   if os.path.isdir(DIR["SAVEPLOT"]):
+#     img_out = os.path.join(DIR["SAVEPLOT"],
+#                            "{}_{}.pdf".format(img_name, today))
+#     shutil.copy(img_in, img_out)
 
 
@@ -287,5 +300,5 @@
 
   import matplotlib.pyplot as plt
-  from matplotlib.backends.backend_pdf import PdfPages
+  # from matplotlib.backends.backend_pdf import PdfPages
 
   if not args.show:
@@ -294,16 +307,7 @@
   # ... Files and directories ...
   # -----------------------------
-  file_param = get_last_file(DIR["SAVEDATA"], OUT["PARAM"])
-  file_utheo = get_last_file(DIR["SAVEDATA"], OUT["UTHEO"])
-  file_bilan = get_last_file(DIR["SAVEDATA"], OUT["BILAN"])
-
-  if file_param is None or \
-     file_utheo is None or \
-     file_bilan is None:
-    print("Missing one or more input files, we stop.")
-    print("=> PARAM: {}\n=> UTHEO: {}\n=> BILAN: {}".format(
-              file_param, file_utheo, file_bilan)
-          )
-    exit(1)
+  (file_param, file_utheo, file_data) = \
+      get_input_files(DIR["SAVEDATA"],
+                      [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]])
 
   img_name = "bilan"
@@ -313,9 +317,7 @@
     print(file_param)
     print(file_utheo)
-    print(file_bilan)
+    print(file_data)
     print(img_name)
     print(today)
-    print(DIR)
-    print(OUT)
 
   # .. Get project info ..
@@ -333,5 +335,5 @@
   # ... Extract data from file ...
   # ------------------------------
-  bilan.fill_data(file_bilan)
+  bilan.fill_data(file_data)
   # ... Compute theoratical use from known data  ...
   # ------------------------------------------------
@@ -401,11 +403,9 @@
   # ... Save figure ...
   # -------------------
-  # plot_save(os.path.join(DIR["PLOT"], img_name))
   img_in  = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name))
-  plot_save(img_in)
-  if os.path.isdir(DIR["SAVEPLOT"]):
-    img_out = os.path.join(DIR["SAVEPLOT"],
-                           "{}_{}.pdf".format(img_name, today))
-    shutil.copy(img_in, img_out)
+  img_out = os.path.join(DIR["SAVEPLOT"],
+                         "{}_{}.pdf".format(img_name, today))
+
+  plot_save(img_in, img_out, "Conso GENCMIP6")
 
   # ... Publish figure on dods ...
