Index: trunk/tools/model_graphics.bash
===================================================================
--- trunk/tools/model_graphics.bash	(revision 845)
+++ trunk/tools/model_graphics.bash	(revision 846)
@@ -1,94 +1,35 @@
-#!/bin/bash -x
-main='WRF+LMDZ_graphics.bash'
+#!/bin/bash
+# L. Fita, June 2016. Generic script to plot model outputs
+
+main='model_graphics.bash'
 errormsg='ERROR -- error -- ERROR -- error'
-HOMEpy=/home/lfita/etudes/WRF_LMDZ/svn/LMDZ_WRF/tools
-
-function variables_values(){
-## Function to provide values to plot the different variables
-#    return:
-#      1: var name
-#      2: std name
-#      3: minimum 
-#      4: maximum
-#      5: long name ('|' for spaces)
-#      6: units
-#      7: color palette (following: 
-#        http://matplotlib.org/1.3.1/examples/color/colormaps_reference.html)
-#
-#    $ variables_values 'WRFght'
-#    zg geopotential_height 0. 80000. geopotential|height m2s-2 rainbow
-
-  fname='variables_values'
-
-  variablesfile=${HOME}/bats/variables.inf
-
-  if test ! -f ${variablesfile}; then
+warnmsg='ERROR -- error -- ERROR -- error'
+
+function uploadvars() {
+# Function to upload variables to the system from an ASCII file as:
+#   [varname] = [value]
+  fileval=$1
+  errormsg='ERROR -- error -- ERROR -- error'
+
+  if test ! -f ${fileval}; then
     echo ${errormsg}
-    echo "  "${fname}": variables file '"${variablesfile}"' does not exist !!!"
-  fi
-
-  case $1 in
-    'a_tht'|'LA_THT') varname='a_tht' ;;
-    'bils'|'LBILS') varname='bils' ;;
-    'clt'|'CLT'|'cldt'|'Total cloudiness') varname='clt' ;;
-    'cll'|'cldl'|'Low-level cloudiness') varname='cll' ;;
-    'clm'|'cldm'|'Mid-level cloudiness') varname='clm' ;;
-    'clh'|'cldh'|'High-level cloudiness') varname='clh' ;;
-    'dtcon'|'LDTCON') varname='dtcon' ;;
-    'evspsbl'|'QFX'|'evap'|'LEVAP') varname='evspsbl' ;;
-    'hfls'|'LH'|'flat'|'LFLAT') varname='hfls' ;;
-    'hfss'|'sens'|'LSENS') varname='hfss' ;;
-    'hus'|'WRFrh'|'LMDZrh') varname='hus' ;;
-    'huss'|'WRFrhs'|'LMDZrhs') varname='huss' ;;
-    'lat'|'XLAT') varname='lat' ;;
-    'lon'|'XLONG') varname='lon' ;;
-    'pr'|'RAINTOT'|'precip'|'Precip Totale liq+sol') varname='pr' ;;
-    'pracc'|'ACRAINTOT') varname='pracc' ;;
-    'prc'|'WRFprc'|'LPLUC'|'pluc') varname='prc' ;;
-    'pres'|'presnivs'|'pressure') varname='pres' ;;
-    'prls'|'WRFprls'|'LPLUL'|'plul') varname='prls' ;;
-    'prw'|'WRFprw') varname='prw' ;;
-    'ps'|'psfc'|'PSFC'|'psol'|'Surface Pressure') varname='ps' ;;
-    'q_th') varname='q_th' ;;
-    'r'|'QVAPOR') varname='r' ;;
-    'rsds'|'SWdnSFC'|'SWdn at surface'|'SWDOWN') varname='rsds' ;;
-    'rsdsacc') varname='rsdsacc' ;;
-    's_pblh'|'LS_PBLH') varname='zmla' ;;
-    's_pblt'|'LS_PBLT') varname='tmla' ;;
-    's_therm'|'LS_THERM') varname='s_therm' ;;
-    'ta'|'WRFt'|'temp'|'Air temperature') varname='ta' ;;
-    'tmlap'|'LS_PBLT'|'s_pblt') varname='tmla' ;;
-    'tas'|'T2'|'t2m'|'Temperature 2m') varname='tas' ;;
-    'time'|'time_counter') varname='time' ;;
-    'ua'|'vitu'|'U'|'Zonal wind') varname='ua' ;;
-    'uas'|'u10m'|'U10'|'Vent zonal 10m') varname='uas' ;;
-    'va'|'vitv'|'V'|'Meridional wind') varname='va' ;;
-    'vas'|'v10m'|'V10'|'Vent meridien 10m') varname='vas' ;;
-    'wake_h'|'LWAKE_H') varname='wakeh' ;;
-    'wake_s'|'LWAKE_S') varname='wakes' ;;
-    'wss'|'SPDUV') varname='wss' ;;
-    'xtime'|'XTIME') varname='xtime' ;;
-    'zg'|'WRFght'|'Geopotential height') varname='zg' ;;
-    'zmax_th'|'LZMAX_TH') varname='zmax_th' ;;
-    'zmla'|'LS_PBLH'|'s_pblh') varname='zmla' ;;
-    *)
-      echo $errormsg
-      echo "  "${fname}": variable '"$1"' not defined !!!"
-      exit
-    ;;
-  esac
-
-  varvals=`cat ${variablesfile} | grep ' '${varname}' ' | tr '@' ' '`
-  varvalsT=`cat ${variablesfile} | grep ' '${varname}' ' | tr ' ' '#'`
-  Lvarvals=`expr length ${varvalsT}'0'`
-
-  if test ${Lvarvals} -le 1; then
-    echo ${errormsg}
-    echo "  "${fname}": variable name '"${varname}"' not defined in file '"          \
-      ${variablesfile}"' !!!"
+    echo "  "${fname}": file '"${fileval}"' does not exist!!"
     exit
   fi
-  
-  echo ${varvals}
+
+  Nlin=`wc -l ${fileval} | awk '{print $1}'`
+
+  ilin=1
+  while test ${ilin} -le ${Nlin}; do
+    line=`head -n ${ilin} ${fileval} | tail -n 1`
+    varname=`echo ${line} | tr '=' ' ' | awk '{print $1}'`
+    value=`echo ${line} | tr '=' ' ' | awk '{print $2}'`
+    Lvarname=`expr length ${varname}'0'`
+
+    if test ${Lvarname} -gt 1 && test ! ${varname:0:1} = '#'; then
+      export ${varname}=${value}
+    fi
+    ilin=`expr ${ilin} + 1`
+  done
 }
 
@@ -111,72 +52,14 @@
     #######
 
-ifold='/bdd/PCER/workspace/lfita/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-#ofold='/san0/lflmd/etudes/WRF_LMDZ/WaquaL/LMDZ'
-ofold='/bdd/PCER/workspace/lfita/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-
-experiments='AR40:NPv31'
-#varkinds='mean:sfc:diag'
-varkinds='sfc'
-
-mean_variables='dim2mean|WRFt:dim2mean|U:dim2mean|V:dim2mean|WRFght:dim2mean|WRFrh'
-
-# Variables to compute longitudinal means for a Hovmoeller
-sfc_variables='dim2mean|T2:dim2mean|U10:dim2mean|V10:dim2mean|PSFC:dim2mean|RAINTOT:'
-sfc_variables=${sfc_variables}'dim2mean|SWDOWN:dim2mean|WRFprw:dim2mean|WRFrhs:'
-sfc_variables=${sfc_variables}'dim2mean|HFX:dim2mean|LH:dim2mean|Q2:'
-sfc_variables=${sfc_variables}'dim2mean|PBLH:dim2mean|QFX:'
-sfc_variables='dim2mean|RAINTOT'
-sfc_variables_AR40=${sfc_variables}
-sfc_variables_NPv31=${sfc_variables}':dim2mean|LWAKE_S:dim2mean|LWAKE_H:dim2mean|LS_THERM:'
-sfc_variables_NPv31=${sfc_variables_NPv31}'dim2mean|LZMAX_TH'
-
-# Variables to get from the diagnostics
-diag_variables='dim2mean|clt:dim2mean|cllmh:'
-diag_variables=${diag_variables}'dim2mean|WRFprc:dim2mean|WRFprls:'
-#diag_variables=${diag_variables}'dim2mean|WRFbils'
-
-# Variables to compute temporal means on a 2D map
-#var2Dtmeans_AR40='WRFprc:WRFprls:PBLH:QFX:HFX:LH:WRFbils'
-var2Dtmeans_AR40='WRFprc:WRFprls:PBLH:QFX:HFX:LH'
-var2Dtmeans_AR40='WRFprc:WRFprls:PBLH:QFX:HFX:LH:WRFbils:RAINTOT:U10:V10:T2:'
-var2Dtmeans_AR40=${var2Dtmeans_AR40}'PSFC:clt:cll:clm:clh:cllmh:WRFprw:Q2:pr:prw'
-
-var2Dtmeans_NPv31=${var2Dtmeans_AR40}':LWAKE_S:LWAKE_H:LS_THERM:LZMAX_TH'
-
-#inst_variables='mclt_lmdz:pr_lmdz:mwss'
-graph_couples_mean='hus@ta:va@ua'
-graph_couples_sfc='tas@ps:uas@vas:pr@rsds:prw@huss:prls@prc:'
-#graph_couples_sfc=${graph_couples_sfc}'hfls@hfss:evspsbl@bils'
-graph_couples_sfc=${graph_couples_sfc}'hfls@hfss'
-graph_couples_sfc_AR40=${graph_couples_sfc}
-graph_couples_sfc_NPv31=${graph_couples_sfc}':zmaxth@stherm:wakeh@wakes:zmaxth@stherm'
-graph_couples_diag='prls@prc:clt@cll:clh@clm'
-#graph_couples_z='dtcon@pluc'
-
-#graph_couples_diag='prls@prc'
-
-lon2DZsecvars='WRFt:U:V:WRFrh:WRFght'
-lon2DZsecpts=9:15:21
-
-# Differences between experiments
-diffkinds='diffZ:diffH'
-diffZvars='ua:va:ta:hus'
-diffHvars='uas:vas:ps:pr'
-
-filenmean='vertical_interpolation_WRFp.nc'
-#ifoldmean='/media/data1/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-ifoldmean='/bdd/PCER/workspace/lfita/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-
-filensfc='wrfout_d01_1980-03-01_00:00:00'
-#ifoldsfc='/media/data1/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-ifoldsfc='/bdd/PCER/workspace/lfita/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
-
-filendiag='diagnostics.nc'
-ifolddiag='/bdd/PCER/workspace/lfita/etudes/WRF_LMDZ/WaquaL/WRF_LMDZ'
+# Uploading environment
+uploadvars model_graphics.dat
+
+export 
+exit
+
 
 timeval='tstep'
 zval='null'
 dimval='lon,lat,pressure,time'
-kindval='pdf'
 
 compute=0
@@ -186,13 +69,4 @@
 lonZsec=false
 differences=true
-
-plevels='100000.,97500.,95000.,92500.,90000.,85000.,80000.,75000.,70000.,'
-plevels=${plevels}'65000.,60000.,55000.,50000.,45000.,40000.,35000.,30000.,'
-plevels=${plevels}'25000.,20000.,15000.,10000.,5000.,2500.,1000.,'
-plevels=${plevels}'500.,250.'
-
-# Couples to draw on a 2D map
-coup2D_AR40='prls@prc::zmla@tmla:hfls@hfss:evspsbl@bils'
-coup2D_NPv31=${coup2D_AR40}':wakeh@wakes:zmaxth@stherm'
 
 combosfile=${HOMEpy}/diagnostics.inf
