Index: trunk/UTIL/PYTHON/gcm.py
===================================================================
--- trunk/UTIL/PYTHON/gcm.py	(revision 372)
+++ trunk/UTIL/PYTHON/gcm.py	(revision 377)
@@ -15,5 +15,5 @@
     from os import system
     from planetoplot import planetoplot
-    
+    from myscript import getparseroptions
     import numpy as np
 
@@ -21,55 +21,8 @@
     ### Get options and variables
     parser = OptionParser()
-    parser.add_option('-f', '--file',   action='append',dest='namefile', type="string",  default=None,  help='[NEEDED] name of WRF file (append). Plot files separated by comas in the same figure')
-    parser.add_option('-l', '--level',  action='store',dest='nvert',     type="string",  default="0",   help='level or start,stop,step (def=0)(-i 2: p,mbar)(-i 3,4: z,km)')
-    parser.add_option('-p', '--proj',   action='store',dest='proj',      type="string",  default=None,  help='projection')
-    parser.add_option('-b', '--back',   action='store',dest='back',      type="string",  default=None,  help='background image (def: None)')
-    parser.add_option('-t', '--target', action='store',dest='target',    type="string",  default=None,  help='destination folder')
-    parser.add_option('-s', '--stride', action='store',dest='stride',    type="int",     default=3,     help='stride vectors (def=3)')
-    parser.add_option('-v', '--var',    action='append',dest='var',      type="string",  default=None,  help='variable color-shaded (append)')
-    parser.add_option('-n', '--num',    action='store',dest='numplot',   type="int",     default=None,  help='plot number (def=2)(<0: plot LT -*numplot*)')
-    parser.add_option('-i', '--interp', action='store',dest='interp',    type="int",     default=None,  help='interpolation (2: p, 3: z-amr, 4:z-als)')
-    parser.add_option('-c', '--color',  action='store',dest='colorb',    type="string",  default="def", help='change colormap (nobar: no colorbar)')
-    parser.add_option('-x', '--no-vect',action='store_false',dest='winds',               default=True,  help='no wind vectors')
-    parser.add_option('-m', '--min',    action='append',dest='vmin',     type="float",   default=None,  help='bounding minimum value (append)')    
-    parser.add_option('-M', '--max',    action='append',dest='vmax',     type="float",   default=None,  help='bounding maximum value (append)') 
-    parser.add_option('-T', '--tiled',  action='store_true',dest='tile',                 default=False, help='draw a tiled plot (no blank zone)')
-    parser.add_option('-z', '--zoom',   action='store',dest='zoom',      type="float",   default=None,  help='zoom factor in %')
-    parser.add_option('-N', '--no-api', action='store_true',dest='nocall',               default=False, help='do not recreate api file')
-    parser.add_option('-d', '--display',action='store_false',dest='display',             default=True,  help='do not pop up created images')
-    parser.add_option('-e', '--itstep', action='store',dest='itstep',    type="int",     default=None,  help='stride time (def=4)')
-    parser.add_option('-H', '--hole',   action='store_true',dest='hole',                 default=False, help='holes above max and below min')
-    parser.add_option('-S', '--save',   action='store',dest='save',      type="string",  default="gui", help='save mode (png,eps,svg,pdf or gui)(def=gui)')
-    parser.add_option('-a', '--anomaly',action='store_true',dest='anomaly',              default=False, help='compute and plot relative anomaly in %')
-    parser.add_option('-w', '--with',   action='store',dest='var2',      type="string",  default=None,  help='variable contoured')
-    parser.add_option('--div',          action='store',dest='ndiv',      type="int",     default=10,    help='number of divisions in colorbar (def: 10)')
-    parser.add_option('-F', '--first',  action='store',dest='first',     type="int",     default=1,     help='first subscript to plot (def: 1)')
-    parser.add_option('--mult',         action='store',dest='mult',      type="float",   default=1.,    help='a multiplicative factor to plotted field')
-    parser.add_option('--title',        action='store',dest='zetitle',   type="string",  default="fill",help='customize the whole title')
-    #parser.add_option('-V', action='store', dest='comb',        type="float",   default=None,  help='a defined combination of variables')
+    getparseroptions(parser)
+    (opt,args) = parser.parse_args()
 
-    parser.add_option('-O','--output',  action='store',dest='output',    type="string",  default=None,  help='Output file name')
-    parser.add_option('--res',          action='store',dest='res',       type="float",   default=200.,  help='Resolution for png outputs. --save png must be specified. (def=200.)')
-    parser.add_option('--operation',    action='store',dest='operation', type="string",  default=None,  help='Basic operation to perform between input file and a specified reference file. Available: addition "+", soustraction "-". Operation is done as: file1 +or- fileref. The reference file must be specified using -fref option')
-    parser.add_option('--fref',         action='store',dest='fref',     type="string",  default=None,  help='Reference namefile for the --operation option.')
-    parser.add_option('--mope',         action='store',dest='vminope', type="float",   default=0.,  help='bounding minimum value for inter-file operation')
-    parser.add_option('--Mope',         action='store',dest='vmaxope', type="float",   default=0.,  help='bounding maximum value for inter-file operation')
-    parser.add_option('--titleref',     action='store',dest='titref',  type="string",  default="fill",  help='title for the reference file. Default: title of figure (1)')
-    parser.add_option('--xmax',         action='store',dest='xmax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots. Default is max(xaxis).')                                                                                                                                   
-    parser.add_option('--ymax',         action='store',dest='ymax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots Default is max(yaxis)')
-    parser.add_option('--xmin',         action='store',dest='xmin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots. Default is min(xaxis).')
-    parser.add_option('--ymin',         action='store',dest='ymin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots Default is min(yaxis)')
-    parser.add_option('--inverty',      action='store_true',dest='inverty',             default=False, help='Force matplotlib.pyplot to revert the y-axis. Can be of use when plotting data along pressure levels. (pyplot naturally tend to plot the z-axis with increasing values)')
-    parser.add_option('--logy',         action='store_true',dest='logy',               default=False,  help='Set y-axis to logarithmic.')   
-
-    ############# T.N. changes
-    #parser.add_option('-o','--operation',action='store',dest='operation',type="string",   default=None ,help='matrix of operations between files (for now see code, sorry)')
-    parser.add_option('--lat',          action='append',dest='slat',type="string",   default=None, help='slices along latitude. One value, or two values separated by comas for averaging')
-    parser.add_option('--lon',          action='append',dest='slon', type="string",   default=None, help='slices along longitude. One value, or two values separated by comas for averaging')
-    parser.add_option('--vert',         action='append',dest='svert',type="string",   default=None, help='slices along vertical axis. One value, or two values separated by comas for averaging') # quelles coordonnees ?
-    parser.add_option('--time',         action='append',dest='stime',type="string",   default=None, help='slices along time. One value, or two values separated by comas for averaging') # quelles coordonnees ?
-
-    (opt,args) = parser.parse_args()
-    if opt.namefile is None: 
+    if opt.file is None: 
         print "I want to eat one file at least ! Use winds.py -f name_of_my_file. Or type winds.py -h"
         exit()
@@ -97,8 +50,8 @@
  
     if opt.fref is not None:
-       if opt.operation is None:
+       if opt.operat is None:
           print "you must specify an operation when using a reference file"
           exit()
-    if opt.operation is not None:
+    if opt.operat is not None:
        if opt.fref is None:
           print "you must specifiy a reference file when using inter-file operations"
@@ -107,6 +60,6 @@
     interpref=False
     if opt.fref is not None:
-       if opt.operation is not None:
-          if opt.interp is not None:
+       if opt.operat is not None:
+          if opt.itp is not None:
              interpref=True
 
@@ -114,5 +67,5 @@
 
 
-    print "namefile, length", opt.namefile, len(opt.namefile)
+    print "file, length", opt.file, len(opt.file)
 
     zeslat  = readslices(opt.slat)
@@ -125,9 +78,9 @@
     print "stime,zestime", opt.stime, zestime
 
-    for i in range(len(opt.namefile)):
+    for i in range(len(opt.file)):
       for j in range(len(opt.var)):
 
-        zenamefiles = separatenames(opt.namefile[i])
-        print "zenamefiles", zenamefiles
+        zefiles = separatenames(opt.file[i])
+        print "zefiles", zefiles
         
         if opt.vmin is not None : zevmin  = opt.vmin[min(i,len(opt.vmin)-1)]
@@ -143,14 +96,14 @@
         print "var, zevar", opt.var, zevar
         
-        #checkcoherence(len(zenamefiles),len(opt.slat),len(opt.slon),len(opt.stime))
+        #checkcoherence(len(zefiles),len(opt.slat),len(opt.slon),len(opt.stime))
         
-        zefile = zenamefiles[0]
+        zefile = zefiles[0]
               
-        #zelevel = opt.nvert   
+        #zelevel = opt.lvl   
         stralt = None
         #[lschar,zehour,zehourin] = getlschar ( zefile )  ## getlschar from wrfout (or simply return "" if another file)
         [lschar,zehour,zehourin] = ["",0,0]  ## dummy
     
-        inputnvert = separatenames(opt.nvert)
+        inputnvert = separatenames(opt.lvl)
         if np.array(inputnvert).size == 1:
             zelevel = float(inputnvert[0])
@@ -164,6 +117,6 @@
         #####################################################
         ### Call Fortran routines for vertical interpolations  -->  zrecast for GCM ?       
-#        if opt.interp is not None:
-#            if zelevel == 0. and opt.interp == 4:  zelevel = 0.010
+#        if opt.itp is not None:
+#            if zelevel == 0. and opt.itp == 4:  zelevel = 0.010
 #            ### winds or no winds
 #            if opt.winds            :  zefields = 'uvmet'
@@ -178,5 +131,5 @@
 #                                     input_name      = zefile, \
 #                                     fields          = zefields, \
-#                                     interp_method   = opt.interp, \
+#                                     interp_method   = opt.itp, \
 #                                     interp_level    = ze_interp_levels, \
 #                                     onelevel        = zelevel, \
@@ -188,14 +141,14 @@
         ### Call Fortran routines for vertical interpolations  -->  zrecast
 
-        if opt.interp is not None:
+        if opt.itp is not None:
            interpolated_files=""
-           interpolated_files=call_zrecast(interp_mode=opt.interp,\
-                    input_name=zenamefiles,\
+           interpolated_files=call_zrecast(interp_mode=opt.itp,\
+                    input_name=zefiles,\
                     fields=zevars)
 
-           zenamefiles=interpolated_files
+           zefiles=interpolated_files
         if interpref:
            interpolated_ref=""
-           interpolated_ref=call_zrecast(interp_mode=opt.interp,\
+           interpolated_ref=call_zrecast(interp_mode=opt.itp,\
                     input_name=[opt.fref],\
                     fields=zevars)
@@ -211,15 +164,15 @@
         #############
         ### Main call
-        name = planetoplot (zenamefiles,level=int(zelevel),vertmode=opt.interp,\
-                proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=zevar,\
-                numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds,\
+        name = planetoplot (zefiles,level=int(zelevel),vertmode=opt.itp,\
+                proj=opt.proj,back=opt.back,target=opt.tgt,stride=opt.ste,var=zevar,\
+                numplot=opt.num,colorb=opt.clb,winds=opt.winds,\
                 addchar=lschar,interv=[zehour,zehourin],vmin=zevmin,vmax=zevmax,\
                 tile=opt.tile,zoom=opt.zoom,display=opt.display,\
-                itstep=opt.itstep,hole=opt.hole,save=opt.save,\
-                anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,first=opt.first,\
+                itstep=opt.it,hole=opt.hole,save=opt.save,\
+                anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,first=opt.frt,\
                 mult=opt.mult,zetitle=opt.zetitle,\
                 slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
-                outputname=opt.output,resolution=opt.res,\
-                ope=opt.operation,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\
+                outputname=opt.out,resolution=opt.res,\
+                ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\
                 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy)
         print 'Done: '+name
