source: palm/trunk/SCRIPTS/NCL/profiles.ncl @ 593

Last change on this file since 593 was 593, checked in by heinze, 14 years ago

Bugfix: enable plot of combined profiles when data is of kind double

File size: 170.1 KB
Line 
1load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4
5;***************************************************
6; load .ncl.config or .ncl.config.default
7;***************************************************
8
9function which_script()
10local script
11begin
12   script="profiles"
13   return(script)
14end
15   
16if (isfilepresent("$PALM_BIN/../../.ncl.config")) then
17   loadscript("$PALM_BIN/../../.ncl.config")
18else
19  if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then
20     loadscript( "$PALM_BIN/NCL/.ncl.config.default")
21  else
22      palm_bin_path = getenv("PALM_BIN")
23      print(" ")
24      print("Neither the personal configuration file '.ncl.config' exists in")
25      print("~/palm/current_version")
26      print("nor the default configuration file '.ncl.config.default' "+\
27            "exists in")
28      print(palm_bin_path + "/NCL")
29      print(" ")
30      exit
31   end if
32end if   
33
34   
35begin
36
37   ;***************************************************
38   ; Retrieving the NCL version used
39   ;***************************************************
40   
41   ncl_version_ch = systemfunc("ncl -V")
42   ncl_version    = stringtofloat(ncl_version_ch)
43
44   ;***************************************************
45   ; Retrieving the double quote character
46   ;***************************************************
47   
48   dq=str_get_dq()
49
50   ;***************************************************
51   ; set up default parameter values and strings
52   ;***************************************************
53
54   if (no_files .LT. 1 .OR. no_files .GT. 6) then
55      print(" ")
56      print("Assign 'no_files' between 1 and 6") 
57      print(" ")
58      exit
59   end if
60   
61   file_in   = new(no_files,string)
62   file_in_1 = new(no_files,logical)
63   start_f_t = new(no_files,integer)
64   end_f_t   = new(no_files,integer)
65   
66   if (file_1 .EQ. "File in") then
67      print(" ")
68      print("Declare 1st input file 'file_1=' in '.ncl.config' or prompt")
69      print(" ")
70      exit
71   else
72      file_in(0) = file_1   
73   end if     
74   file_in_1(0) = False
75   if (isStrSubset(file_in(0), ".nc"))then
76      start_f = -2
77      end_f = -2
78      file_in_1(0) = True     
79   end if 
80   if (start_f .EQ. -1)then
81      print(" ")
82      print("'start_f' must be one of the cyclic numbers (at least 0) "+\
83            "of your input file(s)")
84      print(" ") 
85      exit
86   end if
87   if (end_f .EQ. -1)then
88      print(" ")
89      print("'end_f' must be one of the cyclic numbers (at least 0) of "+\
90            "your input file(s)")
91      print(" ") 
92      exit
93   end if           
94   start_f_t(0) = start_f
95   end_f_t(0) = end_f   
96 
97   if (no_files .GT. 1) then
98      if (file_2 .EQ. "File in") then
99         print(" ")
100         print("Declare 2nd input file 'file_2=' in '.ncl.config' or prompt")
101         print(" ")
102         exit
103      else
104         file_in(1) = file_2   
105      end if     
106      file_in_1(1) = False
107      if (isStrSubset(file_in(1), ".nc"))then
108         start_f_2 = -2
109         end_f_2 = -2
110         file_in_1(1) = True     
111      end if
112      if (start_f_2 .EQ. -1)then
113         print(" ")
114         print("'start_f_2' must be one of the cyclic numbers (at least 0) "+\
115              "of your input file(s)")
116         print(" ") 
117         exit
118      end if
119      if (end_f_2 .EQ. -1)then
120         print(" ")
121         print("'end_f_2' must be one of the cyclic numbers (at least 0) "+\
122               "of your input file(s)")
123         print(" ") 
124         exit
125      end if     
126      start_f(1) = start_f_2
127      end_f(1) = end_f_2   
128   end if   
129   
130   if (no_files .GT. 2) then
131      if (file_3 .EQ. "File in") then
132         print(" ")
133         print("Declare 3rd input file 'file_3=' in '.ncl.config' or prompt")
134         print(" ")
135         exit
136      else
137         file_in(2) = file_3   
138      end if     
139      file_in_1(2) = False
140      if (isStrSubset(file_in(2), ".nc"))then
141         start_f_3 = -2
142         end_f_3 = -2
143         file_in_1(2) = True     
144      end if
145      if (start_f_3 .EQ. -1)then
146         print(" ")
147         print("'start_f_3' must be one of the cyclic numbers (at least 0) "+\
148               "of your input file(s)")
149         print(" ") 
150         exit
151      end if
152      if (end_f_3 .EQ. -1)then
153         print(" ")
154         print("'end_f_3' must be one of the cyclic numbers (at least 0) "+\
155               "of your input file(s)")
156         print(" ") 
157         exit
158      end if     
159      start_f(2) = start_f_3
160      end_f(2) = end_f_3 
161   end if
162   
163   if (no_files .GT. 3) then
164      if (file_4 .EQ. "File in") then
165         print(" ")
166         print("Declare 4th input file 'file_4=' in '.ncl.config' or prompt")
167         print(" ")
168         exit
169      else
170         file_in(3) = file_4   
171      end if     
172      file_in_1(3) = False
173      if (isStrSubset(file_in(3), ".nc"))then
174         start_f_4 = -2
175         end_f_4 = -2
176         file_in_1(3) = True     
177      end if
178      if (start_f_4 .EQ. -1)then
179         print(" ")
180         print("'start_f_4' must be one of the cyclic numbers (at least 0) "+\
181               "of your input file(s)")
182         print(" ") 
183         exit
184      end if
185      if (end_f_4 .EQ. -1)then
186         print(" ")
187         print("'end_f_4' must be one of the cyclic numbers (at least 0) "+\
188               "of your input file(s)")
189         print(" ") 
190         exit
191      end if     
192      start_f(3) = start_f_4
193      end_f(3) = end_f_4
194   end if
195   
196   if (no_files .GT. 4) then
197      if (file_5 .EQ. "File in") then
198         print(" ")
199         print("Declare 5th input file 'file_5=' in '.ncl.config' or prompt")
200         print(" ")
201         exit
202      else
203         file_in(4) = file_5   
204      end if     
205      file_in_1(4) = False
206      if (isStrSubset(file_in(4), ".nc"))then
207         start_f_5 = -2
208         end_f_5 = -2
209         file_in_1(4) = True     
210      end if
211      if (start_f_5 .EQ. -1)then
212         print(" ")
213         print("'start_f_5' must be one of the cyclic numbers (at least 0) "+\
214               "of your input file(s)")
215         print(" ") 
216         exit
217      end if
218      if (end_f_5 .EQ. -1)then
219         print(" ")
220         print("'end_f_5' must be one of the cyclic numbers (at least 0) "+\
221               "of your input file(s)")
222         print(" ") 
223         exit
224      end if     
225      start_f(4) = start_f_5
226      end_f(4) = end_f_5   
227   end if
228   
229   if (no_files .GT. 5) then
230      if (file_6 .EQ. "File in") then
231         print(" ")
232         print("Declare 6th input file 'file_6=' in '.ncl.config' or prompt")
233         print(" ")
234         exit
235      else
236         file_in(5) = file_6   
237      end if     
238      file_in_1(5) = False
239      if (isStrSubset(file_in(5), ".nc"))then
240         start_f_6 = -2
241         end_f_6 = -2
242         file_in_1(5) = True     
243      end if
244      if (start_f_6 .EQ. -1)then
245         print(" ")
246         print("'start_f_6' must be one of the cyclic numbers (at least 0) "+\
247               "of your input file(s)")
248         print(" ") 
249         exit
250      end if
251      if (end_f_6 .EQ. -1)then
252         print(" ")
253         print("'end_f_6' must be one of the cyclic numbers (at least 0) "+\
254               "of your input file(s)")
255         print(" ") 
256         exit
257      end if     
258      start_f(5) = start_f_6
259      end_f(5) = end_f_6   
260   end if
261
262   
263   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND.  \
264      format_out .NE. "eps" .AND. format_out .NE. "ps" .AND.    \
265      format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \
266      format_out .NE. "png")then
267      print(" ")
268      print("'format_out = "+format_out+"' is invalid and set to'x11'")
269      print(" ")
270      format_out="x11"
271   end if 
272
273   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
274      print(" ")
275      print("Output of png files not available")
276      print("png output is avaiable with NCL version 5.2.0 and higher ")
277      print("NCL version used: " + ncl_version_ch)
278      print(" ")
279      exit
280   end if
281
282   if (over .NE. 0 .AND. over .NE. 1) then
283      print(" ")
284      print("'over'= "+over+" is invalid and set to 0")
285      print(" ")
286      over = 0
287   end if
288   if (no_files .GT. 1) then
289      over = 0
290      print(" ")
291      print("If you have more than one input file - you cannot overlay "+\
292            "variables: over is set to 0")
293      print(" ")
294   end if
295   
296   if (combine .NE. 0 .AND. combine .NE. 1)then
297      print(" ")
298      print("Your 'combine'= "+combine+" is invalid and set to 0")
299      print(" ")
300      combine = 0
301   end if
302   if (no_files .GT. 1) then
303      combine = 0
304      print(" ")
305      print("If you have more than one input file you cannot combine "+\
306            "variables: combine is set to 0")
307      print(" ")
308   end if   
309   if (combine .EQ. 1 .AND. number_comb .EQ. -1) then
310      print(" ")
311      print("Set 'number_comb' to 2 or 3 or combine to 0")
312      print(" ")
313      exit
314   end if
315   if (combine .EQ. 1)then
316      if (number_comb .EQ. -1) then
317         print(" ")
318         print("Set 'number_comb' to 2 or 3 or combine to 0")
319         print(" ")
320         exit
321      end if
322      if (number_comb .NE. 2 .AND. number_comb .NE. 3) then
323         print(" ")
324         print("Set 'number_comb' to 2 or 3 or combine to 0")
325         print(" ")
326         exit
327      end if
328   end if 
329   if (combine .EQ. 1 .AND. c_var .EQ. "c_variables") then
330      print(" ")
331      print("Select variables for overlaying ('c_var') or set combine to 0")
332      print(" ")
333      exit
334   end if
335
336   if (log_z .NE. 0 .AND. log_z .NE. 1)then
337      print(" ")
338      print("'log_z'= "+log_z+" is invalid and set to 0")
339      print(" ")
340      log_z = 0
341   end if   
342 
343   if (norm_z .EQ. 0) then
344      print(" ")
345      print("Normalising with 0 is not allowed, 'norm_z' is set to 1.0")
346      print(" ")
347      norm_z = 1.0
348   end if
349
350   ;***************************************************
351   ; open input file
352   ;***************************************************
353
354   do nof=0,no_files-1
355
356   files=new(end_f_t(nof)-start_f_t(nof)+1,string)
357   if (file_in_1(nof))then
358      if (isfilepresent(file_in(nof)))then
359         files(0)=file_in(nof)
360      else
361         print(" ")
362         print("1st input file: '"+file_in(nof)+"' does not exist")
363         print(" ")
364         exit
365      end if
366   else
367      if (start_f_t(nof) .EQ. 0)then
368         if (isfilepresent(file_in(nof)+".nc"))then
369            files(0)=file_in(nof)+".nc"
370            do i=1,end_f_t(nof)
371               if (isfilepresent(file_in(nof)+"."+i+".nc"))then   
372                  files(i)=file_in(nof)+"."+i+".nc"
373               else
374                  print(" ")
375                  print("Input file: '"+file_in(nof)+"."+i+".nc' does not "+\
376                        "exist")
377                  print(" ")
378                  exit 
379               end if       
380            end do         
381         else
382            print(" ")
383            print("Input file: '"+file_in(nof)+".nc' does not exist")
384            print(" ")
385            exit
386         end if
387      else
388         do i=start_f_t(nof),end_f_t(nof)
389            if (isfilepresent(file_in(nof)+"."+i+".nc"))then   
390               files(i-start_f_t(nof))=file_in(nof)+"."+i+".nc"
391            else
392               print(" ")
393               print("Input file: '"+file_in(nof)+"."+i+".nc' does not exist")
394               print(" ")
395               exit 
396            end if
397         end do
398      end if
399   end if
400
401   f=addfiles(files,"r")
402   f_att=addfile(files(0),"r")
403   ListSetType(f,"cat")
404   
405   vNam  = getfilevarnames(f_att)
406   vType = getfilevartypes(f_att,vNam)
407
408   if ((all(vType .eq. "double"))) then ;distinction if data is double or float
409      check_vType = True
410   else
411      check_vType = False
412   end if
413   
414   if (nof .EQ. 0)then
415      vNam0=vNam
416   end if
417   if (nof .NE. 0)then
418      if (dim0 .NE. dim)then
419         print(" ")
420         print("There are 'no_files'="+no_files+" input files but they do "+\
421               "not contain the same variables")
422         print(" ")
423         exit
424      else
425         do i=0,dim0-1
426            if (vNam0(i) .NE. vNam(i))then
427               print(" ")
428               print("There are 'no_files'="+no_files+" input files but "+\
429                     "they do not contain the same variables")
430               print(" ")
431               exit
432            end if
433         end do
434      end if
435   end if
436   nof=nof+1
437   print(" ")
438   print("Variables in input file "+nof+":")
439   print("- "+ vNam)
440   print(" ")
441   nof=nof-1
442   dim = dimsizes(vNam)
443   dim0=dim
444 
445   if (dim .EQ. 0) then
446      print(" ")
447      print("There is no data on file")
448      print(" ")
449   end if
450   
451   prof3d = 0
452   do varn = dim-1,0,1
453      if ( isStrSubset( vNam(varn), "zu_3d") .OR. \
454           isStrSubset( vNam(varn), "zw_3d")) then
455         prof3d = 1
456         break
457      end if
458   end do
459 
460   if (var .NE. "all") then
461      ;rearrange the order of the variables in vNam so that the variables
462      ;specified by "var" are in the top of vNam
463
464      vNam_static = new((/dim/),string)
465      vNam_temp   = new((/dim/),string)
466
467      var_char    = stringtocharacter(var)
468      no_char     = dimsizes(var_char)
469      comma       = 0
470       
471      do j=0,no_char-1
472         if(var_char(j) .eq. ",")
473            comma = comma + 1
474         end if
475      end do
476
477      if(comma .le. 1)
478          print(" ")
479          print("The variables 'var="+var+"'" )
480          print("do not exist on your input file;")
481          print("be sure to have one comma before and after each variable")
482          print(" ")
483          exit
484      end if
485
486      if(comma .gt. dim)
487          print(" ")
488          print("The variables 'var="+var+"'" )
489          print("do not exist on your input file;")
490          print("be sure to have one comma before and after each variable")
491          print(" ")
492          exit
493      end if
494
495      indices = new((/comma/),integer)
496      comma   = 0
497       
498      do j=0,no_char-1
499         if(var_char(j) .eq. ",")
500           indices(comma) = j
501           comma          = comma + 1
502         end if
503      end do
504
505      do j=0,comma-2
506         vNam_temp(j) = charactertostring(\
507                                   var_char(indices(j)+1:indices(j+1)-1))
508      end do
509
510      do j=0,comma-2
511        count_check = 0
512        do varn=0,dim-1
513           if(vNam_temp(j) .ne. vNam(varn))
514             count_check=count_check+1
515           end if
516        end do   
517
518        if(count_check .eq. dim)
519            print(" ")
520            print("The variables 'var="+var+"'" )
521            print("do not exist on your input file;")
522            print("be sure to have one comma before and after each variable")
523            print(" ")
524            exit
525        end if
526
527        vNam_static(j) = vNam_temp(comma - 2 - j)
528      end do
529
530      vNam_temp   = vNam_static
531      vNam_static = ""
532
533      if (prof3d .EQ. 0) then
534         i = 0
535         do j=0,dim-1,2
536            vNam_static(j)   = vNam_temp(i)
537            vNam_static(j+1) = "z" + vNam_static(j)
538            i = i+1
539            if(i .eq. comma-1)
540                break
541            end if
542         end do
543
544         delete(vNam_temp)
545         count_variable = 2*(comma-1)
546      else
547         i = 0
548          do j=0,dim-1,1
549             vNam_static(j) = vNam_temp(i)
550             i = i+1
551             if(i .eq. comma-1)
552                 break
553             end if
554          end do
555
556          delete(vNam_temp)
557          count_variable = comma-1
558      end if
559
560      counter  = 0
561      counter2 = 0
562      do j=0,dim-1
563         counter = 0
564         do i = 0, count_variable - 1       
565            if(vNam_static(i) .ne. vNam(j))
566               counter = counter + 1
567            end if
568         end do
569     
570         if (counter .eq. count_variable)
571            vNam_static(count_variable + counter2) = vNam(j)
572            counter2 = counter2 + 1
573         end if
574      end do
575     
576      vNam = vNam_static
577      delete(vNam_static)
578    end if
579
580   ;---------below steps only for first file -> nof=0
581   if (nof .EQ. 0) then
582
583      plot = new(dim,graphic)
584      plot_ = new(dim,graphic)
585      if (no_files .GT. 1) then
586         multi_plot = new((/no_files,dim/),graphic)
587         max_nof = new((/no_files,dim/),float)
588         min_nof = new((/no_files,dim/),float)
589         name    = new((/no_files,dim/),string)
590         unit_   = new((/no_files,dim/),string)
591      end if
592
593   if (prof3d .EQ. 0) then
594 
595   do varn=0,dim-1
596      if ( isStrSubset( vNam(varn), "time") .OR. \
597           isStrSubset( vNam(varn), "NORM")) then
598         continue
599      end if
600      if (vNam(varn) .EQ. "u" .OR. isStrSubset(vNam(varn), "u_"))then
601         z_u = f_att->$vNam(varn+1)$
602         break
603      else
604         if (vNam(varn) .EQ. "v" .OR. isStrSubset(vNam(varn), "v_"))then 
605            z_u = f_att->$vNam(varn+1)$
606            break
607         else
608            if(vNam(varn) .EQ. "pt" .OR. isStrSubset(vNam(varn), "pt_"))then
609               z_u = f_att->$vNam(varn+1)$
610               break
611            else
612               if(vNam(varn) .EQ. "vpt" .OR. isStrSubset(vNam(varn), "vpt_"))then
613                  z_u = f_att->$vNam(varn+1)$
614                  break
615               else
616                  if(vNam(varn) .EQ. "lpt" .OR. isStrSubset(vNam(varn), "lpt_"))then
617                     z_u = f_att->$vNam(varn+1)$
618                     break
619                  else   
620                     if(vNam(varn) .EQ. "q" .OR. isStrSubset(vNam(varn), "q_") )then
621                        z_u = f_att->$vNam(varn+1)$
622                        break
623                     else
624                        if(vNam(varn) .EQ. "qv" .OR. isStrSubset(vNam(varn), "qv_"))then
625                           z_u = f_att->$vNam(varn+1)$
626                           break
627                        else
628                           if(vNam(varn) .EQ. "ql" .OR. isStrSubset(vNam(varn), "ql_"))then
629                              z_u = f_att->$vNam(varn+1)$
630                              break
631                           else
632                              if(vNam(varn) .EQ. "rho" .OR. isStrSubset(vNam(varn), "rho_"))then
633                                 z_u = f_att->$vNam(varn+1)$
634                                 break
635                              else
636                                 if(vNam(varn) .EQ. "s" .OR. isStrSubset(vNam(varn), "s_") )then
637                                    z_u = f_att->$vNam(varn+1)$
638                                    break
639                                 else
640                                    if(vNam(varn) .EQ. "sa" .OR. isStrSubset(vNam(varn), "sa_"))then
641                                       z_u = f_att->$vNam(varn+1)$
642                                       break
643                                    else
644                                       if(vNam(varn) .EQ. "e" .OR. isStrSubset(vNam(varn), "e_"))then
645                                         
646                                          z_u = f_att->$vNam(varn+1)$
647                                          break
648                                       else
649                                          if(vNam(varn) .EQ. "es" .OR. \
650                                           isStrSubset(vNam(varn), "es_") .OR. vNam(varn) .EQ. "e*" .OR. isStrSubset(vNam(varn), "e*_"))then
651                                             z_u = f_att->$vNam(varn+1)$
652                                             break
653                                          else
654                                             if(vNam(varn) .EQ. "km" .OR. isStrSubset(vNam(varn), "km_"))then
655                                                z_u = f_att->$vNam(varn+1)$
656                                                break
657                                             else
658                                                if(vNam(varn) .EQ. "kh" .OR. isStrSubset(vNam(varn), "kh_"))then
659                                                   z_u = f_att->$vNam(varn+1)$
660                                                   break
661                                                else
662                                                   if(vNam(varn) .EQ. "l" .OR. isStrSubset(vNam(varn), "l_"))then
663                                                      z_u = f_att->$vNam(varn+1)$
664                                                      break
665                                                   else
666                                                      if(vNam(varn) .EQ. "us2" .OR. isStrSubset(vNam(varn), "us2_")\
667                                                         .OR. vNam(varn) .EQ. "u*2" .OR. isStrSubset(vNam(varn), "u*2_"))then
668                                                         z_u = f_att->$vNam(varn+1)$
669                                                         break
670                                                      else
671                                                         if(vNam(varn) .EQ. "vs2" .OR. isStrSubset(vNam(varn), "vs2_")\
672                                                            .OR. vNam(varn) .EQ. "v*2" .OR. isStrSubset(vNam(varn), "v*2_"))then
673                                                            z_u = f_att->$vNam(varn+1)$
674                                                            break
675                                                         else
676                                                            if(vNam(varn) .EQ. "pts2" .OR. isStrSubset(vNam(varn), "pts2_")\
677                                                               .OR. vNam(varn) .EQ. "pt*2" .OR. isStrSubset(vNam(varn), "pt*2_"))then
678                                                               z_u = f_att->$vNam(varn+1)$
679                                                               break
680                                                            else
681                                                               if(vNam(varn) .EQ. "wsususodz" .OR. isStrSubset(vNam(varn), "wsususodz_")\
682                                                                  .OR. vNam(varn) .EQ. "w*u*u*:dz" .OR. isStrSubset(vNam(varn), "w*u*u*:dz_"))then
683                                                                  z_u = f_att->$vNam(varn+1)$
684                                                                  break
685                                                               else
686                                                                  if(vNam(varn) .EQ. "wspsodz" .OR. isStrSubset(vNam(varn), "wspsodz_")\
687                                                                     .OR. vNam(varn) .EQ. "w*p*:dz" .OR. isStrSubset(vNam(varn), "w*p*:dz_"))then
688                                                                     z_u = f_att->$vNam(varn+1)$
689                                                                     break
690                                                                  else
691                                                                     if(vNam(varn) .EQ. "wpeodz" .OR. isStrSubset(vNam(varn), "wpeodz_")\
692                                                                        .OR. vNam(varn) .EQ. "w"+dq+"e:dz" .OR. isStrSubset(vNam(varn), "w"+dq+"e:dz_"))then
693                                                                        z_u = f_att->$vNam(varn+1)$
694                                                                        break                                                                       
695                                                                     end if
696                                                                  end if
697                                                               end if
698                                                            end if
699                                                         end if
700                                                      end if
701                                                   end if
702                                                end if
703                                             end if
704                                          end if
705                                       end if
706                                    end if
707                                 end if
708                              end if
709                           end if
710                        end if
711                     end if
712                  end if
713               end if
714            end if
715         end if
716      end if
717   end do
718
719   do varn=0,dim-1
720      if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
721         continue
722      end if
723      if (vNam(varn) .EQ. "w" .OR. isStrSubset(vNam(varn), "w_"))then
724         z_w = f_att->$vNam(varn+1)$
725         break
726      else
727         if (vNam(varn) .EQ. "wpup" .OR. isStrSubset(vNam(varn), "wpup_")\
728            .OR. vNam(varn) .EQ. "w"+dq+"u"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"u"+dq+"_"))then
729            z_w = f_att->$vNam(varn+1)$
730            break
731         else
732            if(vNam(varn) .EQ. "wsus" .OR. isStrSubset(vNam(varn), "wsus_")\
733               .OR. vNam(varn) .EQ. "w*u*" .OR. isStrSubset(vNam(varn), "w*u*_"))then
734               z_w = f_att->$vNam(varn+1)$
735               break
736            else
737               if(vNam(varn) .EQ. "wu" .OR. isStrSubset(vNam(varn), "wu_"))then
738                  z_w = f_att->$vNam(varn+1)$
739                  break
740               else
741                  if(vNam(varn) .EQ. "wpvp" .OR. isStrSubset(vNam(varn), "wpvp_")\
742                     .OR. vNam(varn) .EQ. "w"+dq+"v"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"v"+dq+"_"))then
743                     z_w = f_att->$vNam(varn+1)$
744                     break
745                  else   
746                     if(vNam(varn) .EQ. "wsvs" .OR. isStrSubset(vNam(varn), "wsvs_")\
747                        .OR. vNam(varn) .EQ. "w*v*" .OR. isStrSubset(vNam(varn), "w*v*_"))then
748                        z_w = f_att->$vNam(varn+1)$
749                        break
750                     else
751                        if(vNam(varn) .EQ. "wv" .OR. isStrSubset(vNam(varn), "wv_"))then
752                           z_w = f_att->$vNam(varn+1)$
753                           break
754                        else
755                           if(vNam(varn) .EQ. "wptpp" .OR. isStrSubset(vNam(varn), "wptpp_")\
756                              .OR. vNam(varn) .EQ. "w"+dq+"pt"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"pt"+dq+"_"))then
757                              z_w = f_att->$vNam(varn+1)$
758                              break
759                           else
760                              if(vNam(varn) .EQ. "wspts" .OR. isStrSubset(vNam(varn), "wspts_")\
761                                 .OR. vNam(varn) .EQ. "w*pt*" .OR. isStrSubset(vNam(varn), "w*pt*_"))then
762                                 z_w = f_att->$vNam(varn+1)$
763                                 break
764                              else
765                                 if(vNam(varn) .EQ. "wpt" .OR. isStrSubset(vNam(varn), "wpt_"))then
766                                    z_w = f_att->$vNam(varn+1)$
767                                    break
768                                 else
769                                    if(vNam(varn) .EQ. "wsptsBC" .OR. isStrSubset(vNam(varn), "wsptsBC_")\
770                                       .OR. vNam(varn) .EQ. "w*pt*BC" .OR. isStrSubset(vNam(varn), "w*pt*BC_"))then
771                                       z_w = f_att->$vNam(varn+1)$
772                                       break
773                                    else
774                                       if(vNam(varn) .EQ. "wptBC" .OR. isStrSubset(vNam(varn), "wptBC_"))then
775                                          z_w = f_att->$vNam(varn+1)$
776                                          break
777                                       else
778                                          if(vNam(varn) .EQ. "wpvptp" .OR. isStrSubset(vNam(varn), "wpvptp_")\
779                                              .OR. vNam(varn) .EQ. "w"+dq+"vpt"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"vpt"+dq+"_"))then
780                                             z_w = f_att->$vNam(varn+1)$
781                                             break
782                                          else
783                                             if(vNam(varn) .EQ. "wsvpts" .OR. isStrSubset(vNam(varn), "wsvpts_")\
784                                               .OR. vNam(varn) .EQ. "w*vpt*" .OR. isStrSubset(vNam(varn), "w*vpt*_"))then
785                                                z_w = f_att->$vNam(varn+1)$
786                                                break
787                                             else
788                                                if(vNam(varn) .EQ. "wvpt" .OR. isStrSubset(vNam(varn), "wvpt_"))then
789                                                   z_w = f_att->$vNam(varn+1)$
790                                                   break
791                                                else
792                                                   if(vNam(varn) .EQ. "wpqp" .OR. isStrSubset(vNam(varn), "wpqp_")\
793                                                      .OR. vNam(varn) .EQ. "w"+dq+"q"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"q"+dq+"_"))then
794                                                      z_w = f_att->$vNam(varn+1)$
795                                                      break
796                                                   else
797                                                      if(vNam(varn) .EQ. "wsqs" .OR. isStrSubset(vNam(varn), "wsqs_")\
798                                                         .OR. vNam(varn) .EQ. "w*q*" .OR. isStrSubset(vNam(varn), "w*q*_"))then
799                                                         z_w = f_att->$vNam(varn+1)$
800                                                         break
801                                                      else
802                                                         if(vNam(varn) .EQ. "wq" .OR. isStrSubset(vNam(varn), "wq_"))then
803                                                            z_w = f_att->$vNam(varn+1)$
804                                                            break
805                                                         else
806                                                            if(vNam(varn) .EQ. "wpqvp" .OR. isStrSubset(vNam(varn), "wpqvp_")\
807                                                               .OR. vNam(varn) .EQ. "w"+dq+"qv"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"qv"+dq+"_"))then
808                                                               z_w = f_att->$vNam(varn+1)$
809                                                               break
810                                                            else
811                                                               if(vNam(varn) .EQ. "wsqvs" .OR. isStrSubset(vNam(varn), "wsqvs_")\
812                                                                  .OR. vNam(varn) .EQ. "w*qv*" .OR. isStrSubset(vNam(varn), "w*qv*_"))then
813                                                                  z_w = f_att->$vNam(varn+1)$
814                                                                  break
815                                                               else
816                                                                  if(vNam(varn) .EQ. "wqv" .OR. isStrSubset(vNam(varn), "wqv_"))then
817                                                                     z_w = f_att->$vNam(varn+1)$
818                                                                     break
819                                                                  else
820                                                                     if(vNam(varn) .EQ. "wpsp" .OR. isStrSubset(vNam(varn), "wpsp_")\
821                                                                        .OR. vNam(varn) .EQ. "w"+dq+"s"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"s"+dq+"_"))then
822                                                                        z_w = f_att->$vNam(varn+1)$
823                                                                        break
824                                                                     else
825                                                                        if(vNam(varn) .EQ. "wsss" .OR. isStrSubset(vNam(varn), "wsss_")\
826                                                                            .OR. vNam(varn) .EQ. "w*s*" .OR. isStrSubset(vNam(varn), "w*s*_"))then
827                                                                           z_w = f_att->$vNam(varn+1)$
828                                                                           break
829                                                                        else
830                                                                           if(vNam(varn) .EQ. "ws" .OR. isStrSubset(vNam(varn), "ws_"))then
831                                                                              z_w = f_att->$vNam(varn+1)$
832                                                                              break
833                                                                           else
834                                                                              if(vNam(varn) .EQ. "wpsap" .OR. isStrSubset(vNam(varn), "wpsap_")\
835                                                                                  .OR. vNam(varn) .EQ. "w"+dq+"sa"+dq .OR. isStrSubset(vNam(varn), "w"+dq+"sa"+dq+"_"))then
836                                                                                 z_w = f_att->$vNam(varn+1)$
837                                                                                 break
838                                                                              else
839                                                                                 if(vNam(varn) .EQ. "wssas" .OR. isStrSubset(vNam(varn), "wssas_")\
840                                                                                     .OR. vNam(varn) .EQ. "w*sa*" .OR. isStrSubset(vNam(varn), "w*sa*_"))then
841                                                                                    z_w = f_att->$vNam(varn+1)$
842                                                                                    break
843                                                                                 else
844                                                                                    if(vNam(varn) .EQ. "wsa" .OR. isStrSubset(vNam(varn), "wsa_"))then
845                                                                                       z_w = f_att->$vNam(varn+1)$
846                                                                                       break
847                                                                                    else
848                                                                                       if(vNam(varn) .EQ. "wses" .OR. isStrSubset(vNam(varn), "wses_")\
849                                                                                          .OR. vNam(varn) .EQ. "w*e*" .OR. isStrSubset(vNam(varn), "w*e*_"))then
850                                                                                          z_w = f_att->$vNam(varn+1)$
851                                                                                          break
852                                                                                       else
853                                                                                          if(vNam(varn) .EQ. "ws2" .OR. isStrSubset(vNam(varn), "ws2_")\
854                                                                                             .OR. vNam(varn) .EQ. "w*2" .OR. isStrSubset(vNam(varn), "w*2_"))then
855                                                                                             z_w = f_att->$vNam(varn+1)$
856                                                                                             break
857                                                                                          else
858                                                                                             if(vNam(varn) .EQ. "ws3" .OR. isStrSubset(vNam(varn), "ws3_")\
859                                                                                                .OR. vNam(varn) .EQ. "w*3" .OR. isStrSubset(vNam(varn), "w*3_"))then
860                                                                                                z_w = f_att->$vNam(varn+1)$
861                                                                                                break
862                                                                                             else
863                                                                                                if(vNam(varn) .EQ. "Sw" .OR. isStrSubset(vNam(varn), "Sw_"))then
864                                                                                                   z_w = f_att->$vNam(varn+1)$
865                                                                                                   break
866                                                                                                else
867                                                                                                   if(vNam(varn) .EQ. "ws2pts".OR. isStrSubset(vNam(varn), "ws2pts_")\
868                                                                                                      .OR. vNam(varn) .EQ. "w*2pt*" .OR. isStrSubset(vNam(varn), "w*2pt*_"))then
869                                                                                                      z_w = f_att->$vNam(varn+1)$
870                                                                                                      break
871                                                                                                   else
872                                                                                                      if(vNam(varn) .EQ. "wspts2" .OR. isStrSubset(vNam(varn), "wspts2_")\
873                                                                                                         .OR. vNam(varn) .EQ. "w*pt*2" .OR. isStrSubset(vNam(varn), "w*pt*2_"))then
874                                                                                                         z_w = f_att->$vNam(varn+1)$
875                                                                                                         break                                           
876                                                                                                      end if
877                                                                                                   end if
878                                                                                                end if
879                                                                                             end if
880                                                                                          end if
881                                                                                       end if
882                                                                                    end if
883                                                                                 end if
884                                                                              end if
885                                                                           end if
886                                                                        end if   
887                                                                     end if
888                                                                  end if
889                                                               end if
890                                                            end if
891                                                         end if
892                                                      end if
893                                                   end if
894                                                end if
895                                             end if
896                                          end if
897                                       end if
898                                    end if
899                                 end if
900                              end if
901                           end if
902                        end if
903                     end if
904                  end if
905               end if
906            end if
907         end if
908      end if
909   end do
910   
911   if (.not. isvar("z_u") .AND. .not. isvar ("z_w")) then
912      co=0
913      do varn=0,dim-1     
914         if ( isStrSubset( vNam(varn), "time") .OR. \
915              isStrSubset( vNam(varn), "NORM")) then
916            check = False
917         else
918            check = True
919            if (var .NE. "all") then
920               check = isStrSubset( var,","+vNam(varn)+"," )
921            end if         
922         end if
923         if (check)then
924            co=co+1
925            z = f_att->$vNam(varn+1)$
926            if (getvardims(z) .EQ. "zu")then
927               z_u = z
928            else
929               if (getvardims(z) .EQ. "zw")then
930                  z_w = z
931               end if
932            end if
933            dimz = dimsizes(z)
934            break
935         end if   
936      end do
937      if (co .EQ. 0) then
938         print(" ")
939         print("The variables 'var="+var+"'" )
940         print("do not exist on your input file;")
941         print("be sure to have one comma before and after each variable")
942         print(" ")
943         exit           
944      end if
945   end if
946
947   if (isvar("z_u") ) then
948      dimz  = dimsizes(z_u)
949   else
950      if (isvar("z_w"))then
951         dimz  = dimsizes(z_w)
952      end if
953   end if
954
955   else
956
957      do varn = dim-1,0,1
958         if (vNam(varn) .EQ. "zu_3d")then
959            z_u = f_att->zu_3d 
960            dimz  = dimsizes(z_u)         
961         else
962            if (vNam(varn) .EQ. "zw_3d")then
963               z_w = f_att->zw_3d
964               dimz  = dimsizes(z_w)
965            end if
966         end if
967         if (vNam(varn) .EQ. "x")then
968            x = f_att->x
969            dimx=dimsizes(x)
970         else
971            if (vNam(varn) .EQ. "xu")then
972               x = f_att->xu
973               dimx=dimsizes(x)
974            end if
975         end if
976         if (vNam(varn) .EQ. "y")then
977            y = f_att->y
978            dimy=dimsizes(y)
979         else
980            if (vNam(varn) .EQ. "yv")then
981               y = f_att->yv
982               dimy=dimsizes(y)
983            end if
984         end if
985      end do
986
987   end if
988   
989   if(.not. isvar("z_u") .AND. .not. isvar("z_w"))then
990      print(" ")
991      print("Program aborts - there are no z-variables available")
992      print("Be sure if 'plot_3d' is set correctly")
993      print(" ")
994      exit
995   end if
996 
997
998   t_all = f[:]->time
999   nt    = dimsizes(t_all)
1000
1001   
1002   if (nt .EQ. 1)then
1003      delta_t=t_all(nt-1)/nt
1004   else
1005      delta_t=(t_all(nt-1)-t_all(0))/(nt-1)
1006   end if
1007
1008   ; ****************************************************       
1009   ; start of time step and different types of mistakes that could be done
1010   ; ****************************************************
1011   
1012   if (start_time_step .EQ. -1.) then           
1013      start_time_step=t_all(0)/3600     
1014   else
1015      if (start_time_step .GT. t_all(nt-1)/3600)then
1016         print(" ")
1017         print("'start_time_step' = "+ start_time_step +"h is greater "+\
1018               "than last time step = " \
1019               + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
1020         print(" ")
1021         print("Select another 'start_time_step'")
1022         print(" ")
1023         exit
1024      end if
1025      if (start_time_step .LT. t_all(0)/3600)then
1026         print(" ")
1027         print("'start_time_step' = "+ start_time_step +"h is lower "+\
1028               "than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h")
1029         print(" ")
1030         exit
1031      end if
1032   end if
1033
1034   do i=0,nt-1   
1035      if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND.\
1036          start_time_step .LT. (t_all(i)+delta_t/2)/3600)then
1037         st=i
1038         break
1039      end if
1040   end do
1041   if (.not. isvar("st"))then
1042      print(" ")
1043      print("'start_time_step' = "+ start_time_step +"h is invalid")
1044      print(" ")
1045      print("Select another 'start_time_step'")
1046      print(" ")
1047      exit
1048   end if
1049   
1050   ; ****************************************************
1051   ; end of time step and different types of mistakes that could be done
1052   ; ****************************************************
1053
1054   if (end_time_step .EQ. -1.) then             
1055      end_time_step = t_all(nt-1)/3600 
1056   else
1057      if (end_time_step .GT. t_all(nt-1)/3600)then
1058         print(" ")
1059         print("'end_time_step' = "+ end_time_step +"h is greater "+\
1060               "than last time step = " +\
1061                t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
1062         print(" ")
1063         print("Select another 'end_time_step'") 
1064         print(" ")
1065         exit
1066      end if
1067      if (end_time_step .LT. start_time_step/3600)then
1068         print(" ")
1069         print("'end_time_step' = "+ end_time_step +"h is lower "+\
1070               "than 'start_time_step' = "+start_time_step+"h")
1071         print(" ")
1072         print("Select another 'start_time_step' or 'end_time_step'")
1073         print(" ")
1074         exit
1075      end if
1076   end if
1077
1078   do i=0,nt-1     
1079      if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND.\
1080          end_time_step .LT. (t_all(i)+delta_t/2)/3600)then
1081         et=i
1082         break
1083      end if
1084   end do
1085   if (.not. isvar("et"))then
1086      print(" ")
1087      print("'end_time_step' = "+ end_time_step +"h is invalid")
1088      print(" ")
1089      print("Select another 'end_time_step'")
1090      print(" ")
1091      exit
1092   end if   
1093
1094   delete(start_time_step)
1095   start_time_step=round(st,3)
1096   delete(end_time_step)
1097   end_time_step=round(et,3)
1098
1099   no_time = end_time_step-start_time_step+1
1100   
1101   ; ****************************************************
1102   ; time_stride and different types of mistakes that could be done
1103   ; ****************************************************
1104 
1105   if (time_stride .LT. 1) then
1106      print(" ")
1107      print("'time_stride' has to be positive and is set to 1")
1108      print(" ")
1109      time_stride = 1
1110   end if
1111
1112   if (time_stride .GE. no_time) then
1113      print(" ")
1114      print("'time_stride' is greater equal than number of available "+\
1115           "time steps,")
1116      print("=> 'time_stride' is set to 1")
1117      time_stride = 1
1118   end if
1119
1120   ti_in = ispan(start_time_step,end_time_step,time_stride) ;ti_in contents
1121                                                            ;the time indices
1122                                                            ;to plot
1123   np    = dimsizes(ti_in) 
1124
1125   print(" ")
1126   print("Output of time steps from "+t_all(start_time_step)/3600+\
1127         " h = "+t_all(start_time_step)+" s => index = "+start_time_step)
1128   print("                     till "+t_all(ti_in(np-1))/3600+" h = "\
1129        +t_all(ti_in(np-1))+" s => index = "+end_time_step)
1130   print("                     with temporal stride = "+time_stride)
1131   print(" ")
1132
1133
1134   ; ****************************************************
1135   ; set up legend and colors
1136   ; ****************************************************
1137   
1138   legend_label=new(np,string)
1139   do p=0, np-1
1140      legend_label(p)=sprintf("%6.2f", t_all(ti_in(p))/3600)
1141   end do
1142
1143   ; ***************************************************
1144   ; set up recourses
1145   ; ***************************************************
1146
1147   res                         = True
1148   res@gsnDraw                 = False
1149   res@gsnFrame                = False
1150   res@txFont                  = "helvetica"
1151   res@tiMainFont              = "helvetica"
1152   res@tiXAxisFont             = "helvetica"
1153   res@tiYAxisFont             = "helvetica"
1154   res@tmXBLabelFont           = "helvetica"
1155   res@tmYLLabelFont           = "helvetica"
1156   res@lgLabelFont             = "helvetica"
1157   res@tmLabelAutoStride       = True
1158   if (legend .EQ. 1)then
1159      res@pmLegendDisplayMode     = "Always"
1160   end if
1161   res@pmLegendSide            = "Top"
1162   res@xyExplicitLegendLabels  = legend_label
1163   res@pmLegendParallelPosF    = 1.15
1164   res@pmLegendOrthogonalPosF  = -1.0
1165   res@pmLegendWidthF          = 0.12
1166   res@pmLegendHeightF         = 0.05*np
1167   res@lgLabelFontHeightF     = font_size
1168   res@lgTitleString      = "Time (h)"
1169   res@lgTitleFontHeightF = font_size   
1170   res@txFontHeightF      = font_size
1171   res@tiXAxisFontHeightF = font_size
1172   res@tiYAxisFontHeightF = font_size
1173   res@tmXBLabelFontHeightF = font_size
1174   res@tmYLLabelFontHeightF = font_size
1175   res@tiXAxisString      = " "
1176   if ( black .eq. 0 ) then 
1177      res@xyLineColors = -(ispan(-237,-2,235/np))
1178   end if
1179   if (norm_z .EQ. 1)then
1180      res@tiYAxisString      = "Height (m)"
1181   else   
1182      res@tiYAxisString      = "Height / "+norm_z+" (m)"
1183   end if
1184   
1185   if (log_z .EQ. 1) then
1186      res@trYLog = True
1187   end if
1188
1189   if (dash .EQ. 0 ) then
1190      res@xyMonoDashPattern       = True
1191   else
1192      res@xyMonoDashPattern       = False
1193      if (no_files .GT. 1)
1194         res@xyMonoDashPattern       = True 
1195         print(" ")
1196         print("If you use more than one file, patterns for different "+\
1197               "timesteps cannot be used")
1198         print(" ")
1199      end if       
1200   end if
1201
1202   res@tmXBMinorPerMajor = 4
1203   res@tmYLMinorPerMajor = 4
1204
1205   resP                        = True
1206   resP@txFont                 = "helvetica"
1207   resP@txString               = f_att@title
1208   resP@txFuncCode             = "~"
1209   resP@txFontHeightF          = 0.015
1210
1211   ; ***************************************************
1212   ; set up graphics for plot
1213   ; ***************************************************
1214
1215   if (combine .EQ. 1) then
1216      plot_o = new(number_comb,graphic)   
1217      label=new(number_comb,string)
1218      color_o=new(number_comb,integer)
1219
1220      if (check_vType) then
1221        mini=new(number_comb,double)
1222        maxi=new(number_comb,double)
1223      else
1224        mini=new(number_comb,float)
1225        maxi=new(number_comb,float)
1226      end if
1227   end if
1228 
1229   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
1230      format_out@wkPaperSize = "A4"
1231   end if
1232   if ( format_out .EQ. "png" ) then
1233      format_out@wkWidth  = 1000
1234      format_out@wkHeight = 1000
1235   end if
1236
1237   wks=gsn_open_wks(format_out,file_out)
1238   gsn_define_colormap(wks,"rainbow+white")
1239
1240   ; ***************************************************
1241   ; set up minimum and maximum height
1242   ; ***************************************************
1243
1244   if (log_z .EQ. 1)then
1245      if (min_z .EQ. -1)then
1246         if (isvar("z_u"))then
1247            min_z=z_u(1)
1248         else
1249            min_z=z_w(1)
1250         end if       
1251      else
1252         if (isvar("z_w"))then
1253            if (min_z .GE. max(z_w) ) then
1254               print(" ")
1255               print("Minimum of height ('min_z'="+min_z+") is greater "+\
1256                     "than available heights (="+max(z_w)+")")
1257               print(" ")
1258               exit
1259            end if         
1260         else
1261            if (min_z .GE. max(z_u) ) then
1262               print(" ")
1263               print("Minimum of height ('min_z'="+min_z+") is greater "+\
1264                     "than available heights (="+max(z_u)+")")
1265               print(" ")
1266               exit
1267            end if
1268         end if
1269         if (isvar("z_u"))then   
1270            if (min_z .LT. z_u(1) ) then
1271               print(" ")
1272               print("Begin height 'min_z' at least at level k=1 (="+\
1273                     z_u(1)+"m) due to the logarithmic scale of the y-axis")
1274               print(" ")
1275               exit
1276            end if
1277         else
1278            if (min_z .LT. z_w(1) ) then
1279               print(" ")
1280               print("Begin height 'min_z' at least at level k=1 (="+\
1281                     z_w(1)+"m) due to the logarithmic scale of the y-axis")
1282               print(" ")
1283               exit
1284            end if   
1285         end if
1286      end if
1287   else
1288      if (isvar("z_u"))then
1289         if (min_z .EQ. -1)then
1290            min_z=z_u(0)
1291         end if
1292      else
1293         if (min_z .EQ. -1)then
1294            min_z=z_w(0)
1295         end if   
1296      end if
1297   
1298      if (isvar("z_w"))then
1299         if (min_z .GE. max(z_w) ) then
1300            print(" ")
1301            print("Minimum of height ('min_z'="+min_z+") is greater than "+\
1302                  "available heights (="+max(z_w)+")")
1303            print(" ")
1304            exit
1305         end if
1306      else
1307         if (min_z .EQ. -1)then
1308            min_z=z_u(0)
1309         end if
1310         if (min_z .GE. max(z_u) ) then
1311            print(" ")
1312            print("Minimum of height ('min_z'="+min_z+") is greater than "+\
1313                  "available heights (="+max(z_u)+")")
1314            print(" ")
1315            exit
1316         end if
1317      end if
1318   end if
1319   
1320   if (isvar("z_w"))then
1321      if (max_z .EQ. -1)then
1322         max_z=max(z_w)
1323      end if
1324   else
1325      if (max_z .EQ. -1)then
1326         max_z=max(z_u)
1327      end if   
1328   end if
1329   
1330   if (isvar("z_w"))then
1331      if (max_z .GT. max(z_w) ) then
1332         print(" ")
1333         print("Maximum of height ('max_z'="+max_z+") is greater than "+\
1334               "available heights (="+max(z_w)+")")
1335         print(" ")
1336         exit
1337      end if
1338   end if
1339
1340   min_z=min_z/norm_z
1341   max_z=max_z/norm_z
1342
1343   ; ***************************************************
1344   ; read data and create plots
1345   ; ***************************************************
1346     
1347   do ti =0,np-1
1348      if( t_all(ti_in(ti)) .lt. 10^36) then
1349         start_time_step = ti
1350         break
1351      end if
1352   end do 
1353   
1354   if (log_z .EQ. 1) then     
1355      if (check_vType) then
1356         data   = new((/dim,np,dimz-1/),double)
1357         data_0 = new((/np,dimz-1/),double)
1358      else
1359         data   = new((/dim,np,dimz-1/),float)
1360         data_0 = new((/np,dimz-1/),float)
1361      end if
1362      data@_FillValue=9.96921e+36
1363      data_0 = 0.1
1364      t      = new((/np,dimz-1/),float)
1365      t      = 0.0
1366      unit   = new(dim,string)
1367      if (isvar("z_u"))then
1368         if (typeof(z_u) .EQ. "double")then
1369            z_v    = new((/dim,dimz/),double)
1370            z_     = new((/dim,dimz-1/),double)
1371         else
1372            if (typeof(z_u) .EQ. "float")then
1373               z_v    = new((/dim,dimz/),float)
1374               z_     = new((/dim,dimz-1/),float)
1375            end if
1376         end if
1377      else
1378         if (isvar("z_w"))then
1379            if (typeof(z_w) .EQ. "double")then
1380               z_v    = new((/dim,dimz/),double)
1381               z_     = new((/dim,dimz-1/),double)
1382            else
1383               if (typeof(z_w) .EQ. "float")then
1384                  z_v    = new((/dim,dimz/),float)
1385                  z_     = new((/dim,dimz-1/),float)
1386               end if
1387            end if
1388         end if
1389      end if
1390   else
1391      if (check_vType) then
1392         data   = new((/dim,np,dimz/),double)
1393         data_0 = new((/np,dimz/),double)
1394      else
1395         data   = new((/dim,np,dimz/),float)
1396         data_0 = new((/np,dimz/),float)
1397      end if
1398      data@_FillValue=9.96921e+36     
1399      data_0 = 0.0
1400      t      = new((/np,dimz/),float)
1401      t      = 0.0
1402      unit   = new(dim,string)
1403      if (isvar("z_u"))then
1404         if (typeof(z_u) .EQ. "double")then
1405            z_v    = new((/dim,dimz/),double)
1406            z_     = new((/dim,dimz/),double)
1407         else
1408            if (typeof(z_u) .EQ. "float")then
1409               z_v    = new((/dim,dimz/),float)
1410               z_     = new((/dim,dimz/),float)
1411            end if
1412         end if
1413      else
1414         if (isvar("z_w"))then
1415            if (typeof(z_w) .EQ. "double")then
1416               z_v    = new((/dim,dimz/),double)
1417               z_     = new((/dim,dimz/),double)
1418            else
1419               if (typeof(z_w) .EQ. "float")then
1420                  z_v    = new((/dim,dimz/),float)
1421                  z_     = new((/dim,dimz/),float)
1422               end if
1423            end if
1424         end if
1425      end if
1426   end if
1427
1428   end if
1429   ;-------above steps only for first file
1430
1431   ; ***************************************************
1432   ; indicate plot number
1433   ; ***************************************************
1434   
1435   if (combine .EQ. 1) then
1436      n = 1
1437   else
1438      n = 0
1439   end if
1440
1441   if (over .EQ. 1) then
1442      plot_u         = gsn_csm_xy(wks,t,data_0(:,:),res)
1443      plot_v         = gsn_csm_xy(wks,t,data_0(:,:),res)
1444      plot_w         = gsn_csm_xy(wks,t,data_0(:,:),res)
1445      plot_pt        = gsn_csm_xy(wks,t,data_0(:,:),res)     
1446      plot_vpt       = gsn_csm_xy(wks,t,data_0(:,:),res)
1447      plot_lpt       = gsn_csm_xy(wks,t,data_0(:,:),res)
1448      plot_q         = gsn_csm_xy(wks,t,data_0(:,:),res)
1449      plot_qv        = gsn_csm_xy(wks,t,data_0(:,:),res)
1450      plot_ql        = gsn_csm_xy(wks,t,data_0(:,:),res)
1451      plot_rho       = gsn_csm_xy(wks,t,data_0(:,:),res)
1452      plot_s         = gsn_csm_xy(wks,t,data_0(:,:),res)
1453      plot_sa        = gsn_csm_xy(wks,t,data_0(:,:),res)
1454      plot_e         = gsn_csm_xy(wks,t,data_0(:,:),res)
1455      plot_es        = gsn_csm_xy(wks,t,data_0(:,:),res)
1456      plot_km        = gsn_csm_xy(wks,t,data_0(:,:),res)
1457      plot_kh        = gsn_csm_xy(wks,t,data_0(:,:),res)
1458      plot_l         = gsn_csm_xy(wks,t,data_0(:,:),res)     
1459      plot_wpup      = gsn_csm_xy(wks,t,data_0(:,:),res)
1460      plot_wsus      = gsn_csm_xy(wks,t,data_0(:,:),res)
1461      plot_wu        = gsn_csm_xy(wks,t,data_0(:,:),res)
1462      plot_wpvp      = gsn_csm_xy(wks,t,data_0(:,:),res)
1463      plot_wsvs      = gsn_csm_xy(wks,t,data_0(:,:),res)
1464      plot_wv        = gsn_csm_xy(wks,t,data_0(:,:),res)
1465      plot_wpptp     = gsn_csm_xy(wks,t,data_0(:,:),res)
1466      plot_wspts     = gsn_csm_xy(wks,t,data_0(:,:),res)
1467      plot_wpt       = gsn_csm_xy(wks,t,data_0(:,:),res)
1468      plot_wsptsBC   = gsn_csm_xy(wks,t,data_0(:,:),res)
1469      plot_wptBC     = gsn_csm_xy(wks,t,data_0(:,:),res)
1470      plot_wpvptp    = gsn_csm_xy(wks,t,data_0(:,:),res)
1471      plot_wsvpts    = gsn_csm_xy(wks,t,data_0(:,:),res)
1472      plot_wvpt      = gsn_csm_xy(wks,t,data_0(:,:),res)
1473      plot_wpqp      = gsn_csm_xy(wks,t,data_0(:,:),res)
1474      plot_wsqs      = gsn_csm_xy(wks,t,data_0(:,:),res)
1475      plot_wq        = gsn_csm_xy(wks,t,data_0(:,:),res)
1476      plot_wpqvp     = gsn_csm_xy(wks,t,data_0(:,:),res)
1477      plot_wsqvs     = gsn_csm_xy(wks,t,data_0(:,:),res)
1478      plot_wqv       = gsn_csm_xy(wks,t,data_0(:,:),res)
1479      plot_wpsp      = gsn_csm_xy(wks,t,data_0(:,:),res)
1480      plot_wsss      = gsn_csm_xy(wks,t,data_0(:,:),res)
1481      plot_ws        = gsn_csm_xy(wks,t,data_0(:,:),res)
1482      plot_wpsap     = gsn_csm_xy(wks,t,data_0(:,:),res)
1483      plot_wssas     = gsn_csm_xy(wks,t,data_0(:,:),res)
1484      plot_wsa       = gsn_csm_xy(wks,t,data_0(:,:),res)
1485      plot_wses      = gsn_csm_xy(wks,t,data_0(:,:),res)
1486      plot_us2       = gsn_csm_xy(wks,t,data_0(:,:),res)
1487      plot_vs2       = gsn_csm_xy(wks,t,data_0(:,:),res)
1488      plot_ws2       = gsn_csm_xy(wks,t,data_0(:,:),res)
1489      plot_pts2      = gsn_csm_xy(wks,t,data_0(:,:),res)
1490      plot_ws3       = gsn_csm_xy(wks,t,data_0(:,:),res)
1491      plot_Sw        = gsn_csm_xy(wks,t,data_0(:,:),res)
1492      plot_ws2pts    = gsn_csm_xy(wks,t,data_0(:,:),res)
1493      plot_wspts2    = gsn_csm_xy(wks,t,data_0(:,:),res)
1494      plot_wsususodz = gsn_csm_xy(wks,t,data_0(:,:),res)
1495      plot_wspsodz   = gsn_csm_xy(wks,t,data_0(:,:),res)
1496      plot_wpeodz    = gsn_csm_xy(wks,t,data_0(:,:),res)
1497 
1498      if (check_vType) then
1499        miniu         =  100000.d
1500        maxiu         = -100000.d
1501        miniv         =  100000.d
1502        maxiv         = -100000.d
1503        miniw         =  100000.d
1504        maxiw         = -100000.d
1505        minipt        =  100000.d
1506        maxipt        = -100000.d
1507        minivpt       =  100000.d
1508        maxivpt       = -100000.d
1509        minilpt       =  100000.d
1510        maxilpt       = -100000.d
1511        miniq         =  100000.d
1512        maxiq         = -100000.d
1513        miniqv        =  100000.d
1514        maxiqv        = -100000.d
1515        miniql        =  100000.d
1516        maxiql        = -100000.d
1517        minie         =  100000.d
1518        maxie         = -100000.d
1519        minies        =  100000.d
1520        maxies        = -100000.d
1521        minikm        =  100000.d
1522        maxikm        = -100000.d
1523        minikh        =  100000.d
1524        maxikh        = -100000.d
1525        miniwpup      =  100000.d
1526        maxiwpup      = -100000.d
1527        miniwsus      =  100000.d
1528        maxiwsus      = -100000.d
1529        miniwu        =  100000.d
1530        maxiwu        = -100000.d
1531        miniwpvp      =  100000.d
1532        maxiwpvp      = -100000.d
1533        miniwsvs      =  100000.d
1534        maxiwsvs      = -100000.d
1535        miniwv        =  100000.d
1536        maxiwv        = -100000.d
1537        miniwpptp     =  100000.d
1538        maxiwpptp     = -100000.d
1539        miniwspts     =  100000.d
1540        maxiwspts     = -100000.d
1541        miniwpt       =  100000.d
1542        maxiwpt       = -100000.d
1543        miniwsptsBC   =  100000.d
1544        maxiwsptsBC   = -100000.d
1545        miniwptBC     =  100000.d
1546        maxiwptBC     = -100000.d
1547        miniwpvptp    =  100000.d
1548        maxiwpvptp    = -100000.d
1549        miniwsvpts    =  100000.d
1550        maxiwsvpts    = -100000.d
1551        miniwvpt      =  100000.d
1552        maxiwvpt      = -100000.d
1553        miniwpqp      =  100000.d
1554        maxiwpqp      = -100000.d
1555        miniwsqs      =  100000.d
1556        maxiwsqs      = -100000.d
1557        miniwq        =  100000.d
1558        maxiwq        = -100000.d
1559        miniwpqvp     =  100000.d
1560        maxiwpqvp     = -100000.d
1561        miniwsqvs     =  100000.d
1562        maxiwsqvs     = -100000.d
1563        miniwqv       =  100000.d
1564        maxiwqv       = -100000.d
1565        miniwpsp      =  100000.d
1566        maxiwpsp      = -100000.d
1567        miniwsss      =  100000.d
1568        maxiwsss      = -100000.d
1569        miniws        =  100000.d
1570        maxiws        = -100000.d
1571        miniwpsap     =  100000.d
1572        maxiwpsap     = -100000.d
1573        miniwssas     =  100000.d
1574        maxiwssas     = -100000.d
1575        miniwsa       =  100000.d
1576        maxiwsa       = -100000.d
1577        minius2       =  100000.d
1578        maxius2       = -100000.d
1579        minivs2       =  100000.d
1580        maxivs2       = -100000.d
1581        miniws2       =  100000.d
1582        maxiws2       = -100000.d
1583        miniwsususodz =  100000.d
1584        maxiwsususodz = -100000.d
1585        miniwspsodz   =  100000.d
1586        maxiwspsodz   = -100000.d
1587        miniwpeodz    =  100000.d
1588        maxiwpeodz    = -100000.d
1589      else
1590        miniu         =  100000.
1591        maxiu         = -100000.
1592        miniv         =  100000.
1593        maxiv         = -100000.
1594        miniw         =  100000.
1595        maxiw         = -100000.
1596        minipt        =  100000.
1597        maxipt        = -100000.
1598        minivpt       =  100000.
1599        maxivpt       = -100000.
1600        minilpt       =  100000.
1601        maxilpt       = -100000.
1602        miniq         =  100000.
1603        maxiq         = -100000.
1604        miniqv        =  100000.
1605        maxiqv        = -100000.
1606        miniql        =  100000.
1607        maxiql        = -100000.
1608        minie         =  100000.
1609        maxie         = -100000.
1610        minies        =  100000.
1611        maxies        = -100000.
1612        minikm        =  100000.
1613        maxikm        = -100000.
1614        minikh        =  100000.
1615        maxikh        = -100000.
1616        miniwpup      =  100000.
1617        maxiwpup      = -100000.
1618        miniwsus      =  100000.
1619        maxiwsus      = -100000.
1620        miniwu        =  100000.
1621        maxiwu        = -100000.
1622        miniwpvp      =  100000.
1623        maxiwpvp      = -100000.
1624        miniwsvs      =  100000.
1625        maxiwsvs      = -100000.
1626        miniwv        =  100000.
1627        maxiwv        = -100000.
1628        miniwpptp     =  100000.
1629        maxiwpptp     = -100000.
1630        miniwspts     =  100000.
1631        maxiwspts     = -100000.
1632        miniwpt       =  100000.
1633        maxiwpt       = -100000.
1634        miniwsptsBC   =  100000.
1635        maxiwsptsBC   = -100000.
1636        miniwptBC     =  100000.
1637        maxiwptBC     = -100000.
1638        miniwpvptp    =  100000.
1639        maxiwpvptp    = -100000.
1640        miniwsvpts    =  100000.
1641        maxiwsvpts    = -100000.
1642        miniwvpt      =  100000.
1643        maxiwvpt      = -100000.
1644        miniwpqp      =  100000.
1645        maxiwpqp      = -100000.
1646        miniwsqs      =  100000.
1647        maxiwsqs      = -100000.
1648        miniwq        =  100000.
1649        maxiwq        = -100000.
1650        miniwpqvp     =  100000.
1651        maxiwpqvp     = -100000.
1652        miniwsqvs     =  100000.
1653        maxiwsqvs     = -100000.
1654        miniwqv       =  100000.
1655        maxiwqv       = -100000.
1656        miniwpsp      =  100000.
1657        maxiwpsp      = -100000.
1658        miniwsss      =  100000.
1659        maxiwsss      = -100000.
1660        miniws        =  100000.
1661        maxiws        = -100000.
1662        miniwpsap     =  100000.
1663        maxiwpsap     = -100000.
1664        miniwssas     =  100000.
1665        maxiwssas     = -100000.
1666        miniwsa       =  100000.
1667        maxiwsa       = -100000.
1668        minius2       =  100000.
1669        maxius2       = -100000.
1670        minivs2       =  100000.
1671        maxivs2       = -100000.
1672        miniws2       =  100000.
1673        maxiws2       = -100000.
1674        miniwsususodz =  100000.
1675        maxiwsususodz = -100000.
1676        miniwspsodz   =  100000.
1677        maxiwspsodz   = -100000.
1678        miniwpeodz    =  100000.
1679        maxiwpeodz    = -100000.
1680      end if
1681
1682   end if
1683
1684   if (prof3d .EQ. 1)then
1685
1686   if (end_x .EQ. -1) then
1687      end_x=dimx-2
1688   end if
1689   if (end_y .EQ. -1)then
1690      end_y=dimy-2
1691   end if
1692   if (start_x .LT. 0)then
1693      print(" ")
1694      print("'start_x' is lower than 0 and set to 0")
1695      print(" ")
1696      start_x=0
1697   end if
1698   if (start_x .GT. dimx-1)then
1699      print(" ")
1700      print("'start_x' is greater than available x-range and set to "+\
1701            "maximum of x-range (excluding ghostpoint)")
1702      print(" ")
1703      start_x=dimx-2
1704   end if
1705   if (end_x .EQ. dimx-1)then
1706      print(" ")
1707      print("'end_x' = "+end_x+" and includes the ghostpoint")
1708      print(" ")
1709   end if
1710   if (end_x .GT. dimx-1)then
1711      print(" ")
1712      print("'end_x' = "+end_x+" is greater than available x-range and set "+\
1713            "to maximum of x-range (excluding ghostpoint)")
1714      print(" ")
1715      end_x=dimx-2
1716   end if
1717   if (end_x .LT. start_x)then
1718      print(" ")
1719      print("'end_x' = "+end_x+" is lower than 'start_x' = "+start_x+\
1720            " and set to maximum of x-range (excluding ghostpoint)")
1721      print(" ")
1722      end_x=dimx-2
1723   end if
1724   if (start_y .LT. 0)then
1725      print(" ")
1726      print("'start_y' is lower than 0 and set to 0")
1727      print(" ")
1728      start_y=0
1729   end if
1730   if (start_y .GT. dimy-1)then
1731      print(" ")
1732      print("'start_y' is greater than available y-range and set to "+\
1733            "maximum of y-range (excluding ghostpoint)")
1734      print(" ")
1735      start_x=dimy-2
1736   end if
1737   if (end_y .EQ. dimy-1)then
1738      print(" ")
1739      print("'end_y' = "+end_y+" and includes the ghostpoint")
1740      print(" ")
1741   end if
1742   if (end_y .GT. dimy-1)then
1743      print(" ")
1744      print("'end_y' = "+end_y+" is greater than available y-range and "+\
1745            "set to maximum of y-range (excluding ghostpoint)")
1746      print(" ")
1747      end_x=dimy-2
1748   end if
1749   if (end_y .LT. start_y)then
1750      print(" ")
1751      print("'end_y' = "+end_y+" is lower than 'start_y' = "+start_y+\
1752            " and set to maximum of y-range (excluding ghostpoint)")
1753      print(" ")
1754      end_y=dimy-2
1755   end if
1756   
1757   end if
1758 
1759   n_o=0
1760   count_var=0
1761
1762   res@xyDashPattern = 1*nof
1763
1764   over_remind = False
1765   if ( over .eq. 1)then
1766     over_remind = True
1767   end if
1768   
1769   do varn = 0,dim-1
1770
1771      check = True
1772     
1773      if (prof3d .EQ. 0) then
1774         if ( isStrSubset( vNam(varn), "time") .OR. \
1775              isStrSubset( vNam(varn), "NORM")) then
1776            check = False
1777         end if
1778      else
1779         if ( isStrSubset( vNam(varn), "time") .OR.  \
1780              isStrSubset( vNam(varn), "zusi") .OR.  \
1781              isStrSubset( vNam(varn), "zwwi") .OR.  \
1782              isStrSubset( vNam(varn), "x") .OR.     \
1783              isStrSubset( vNam(varn), "xu") .OR.    \
1784              isStrSubset( vNam(varn), "y") .OR.     \
1785              isStrSubset( vNam(varn), "yv") .OR.    \
1786              isStrSubset( vNam(varn), "zu_3d") .OR. \
1787              isStrSubset( vNam(varn), "zw_3d")) then
1788            check = False
1789         end if
1790      end if
1791
1792      if (var .NE. "all") then
1793         check = isStrSubset( var,","+vNam(varn)+"," )
1794      end if
1795
1796      if (combine .EQ. 1) then         
1797         com=isStrSubset(c_var,","+vNam(varn)+"," )     
1798         if (com) then     
1799            if (prof3d .EQ. 0) then                 
1800               temp     = f[:]->$vNam(varn)$         
1801               temp_att = f_att->$vNam(varn)$
1802               if (log_z .EQ. 1) then
1803                  do j=0,np-1
1804                     data(varn,j,:) = temp(ti_in(j),1:dimz-1)
1805                  end do
1806               else
1807                  do j=0,np-1
1808                     data(varn,j,:) = temp(ti_in(j),0:dimz-1)
1809                  end do
1810               end if
1811            else
1812               if (log_z .EQ. 1) then
1813                  do i=1,dimz-1
1814                     do j=0,np-1
1815                        temp = f[:]->$vNam(varn)$
1816                        temp_att = f_att->$vNam(varn)$
1817                        data_temp = temp(ti_in(j),i,\
1818                                         start_y:end_y,start_x:end_x)
1819                        data(varn,j,i-1) = dim_avg_Wrap(\
1820                                                   dim_avg_Wrap(data_temp))
1821                     end do
1822                  end do
1823               else
1824                  do i=0,dimz-1
1825                     do j=0,np-1
1826                        temp = f[:]->$vNam(varn)$
1827                        temp_att = f_att->$vNam(varn)$
1828                        data_temp = temp(ti_in(j),i,\
1829                                            start_y:end_y,start_x:end_x)
1830                        data(varn,j,i) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1831                     end do
1832                  end do
1833               end if
1834               print(" ")
1835               print("Variable for combine '"+vNam(varn)+"' is read")
1836               print(" ")
1837            end if                 
1838            unit(varn) = temp_att@units
1839            if (n_o .GT. number_comb-1) then
1840               print(" ")
1841               print("Set 'number_comb' to the number of overlaying "+\
1842                     "variables ('c_var' = "+c_var+")")
1843               print(" ")
1844               exit
1845            end if
1846            if (abs(min(data(varn,:,:))) .GT. 10)then
1847               min_value = abs(0.01*min(data(varn,:,:)))
1848               max_value = abs(0.01*max(data(varn,:,:)))
1849            else
1850               if (abs(min(data(varn,:,:))) .LT. 0.01 .AND. \
1851                   abs(max(data(varn,:,:))) .GT. 0.01)then
1852                  min_value = abs(0.1*max(data(varn,:,:)))
1853                  max_value = abs(0.1*max(data(varn,:,:)))
1854               else
1855                  if (abs(max(data(varn,:,:))) .LT. 0.01 .AND. \
1856                      abs(min(data(varn,:,:))) .GT. 0.01)then
1857                     min_value = abs(0.1*min(data(varn,:,:)))
1858                     max_value = abs(0.1*min(data(varn,:,:)))
1859                  else
1860                     min_value = abs(0.1*min(data(varn,:,:)))
1861                     max_value = abs(0.1*max(data(varn,:,:)))
1862                  end if
1863               end if
1864            end if
1865            if (min(data(varn,:,:)) .EQ. 0 .AND. \
1866                max(data(varn,:,:)) .EQ. 0)then
1867               min_value = 0.1
1868               max_value = 0.1
1869            end if
1870            mini(n_o)=min(data(varn,:,:))
1871            maxi(n_o)=max(data(varn,:,:))
1872            n_o=n_o+1
1873         end if
1874      end if
1875
1876      if(check) then
1877         
1878         count_var=count_var+1
1879
1880         if (prof3d .EQ. 0) then         
1881            temp = f[:]->$vNam(varn)$
1882            temp_att = f_att->$vNam(varn)$
1883         else
1884             if (log_z .EQ. 1) then
1885               do i=1,dimz-1
1886                  do j=0,np-1
1887                     temp= f[:]->$vNam(varn)$
1888                     temp_att = f_att->$vNam(varn)$
1889                     data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1890                     data(varn,j,i-1) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1891                     delete(data_temp)
1892                  end do
1893               end do
1894            else
1895               do i=0,dimz-1
1896                  do j=0,np-1
1897                     temp= f[:]->$vNam(varn)$
1898                     temp_att = f_att->$vNam(varn)$
1899                     data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1900                     data_temp!0 = "t"
1901                     data_temp!1 = "z"
1902                     data(varn,j,i) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1903                     delete(data_temp)
1904                  end do
1905               end do
1906            end if
1907            print(" ")
1908            print("Variable '"+vNam(varn)+"' is read")
1909            print(" ")
1910            unit(varn) = temp_att@units
1911            a=getvardims(temp_att)
1912            b=dimsizes(a)
1913         end if
1914
1915         if (prof3d .EQ. 0) then
1916            if (log_z .EQ. 1) then
1917               z = f_att->$vNam(varn+1)$(1:dimz-1)
1918               unit(varn) = temp_att@units
1919               do j=0,np-1
1920                  data(varn,j,:) = temp(ti_in(j),1:dimz-1)
1921               end do
1922            else
1923               z = f_att->$vNam(varn+1)$
1924               unit(varn) = temp_att@units
1925               do j=0,np-1
1926                  data(varn,j,:) = temp(ti_in(j),:)
1927               end do
1928            end if
1929         else
1930            do i=0,b-1           
1931               if (isStrSubset( a(i),"zu_3d" ))then
1932                  z_v(varn,:) = z_u
1933                  if (log_z .EQ. 1) then
1934                     z = z_v(varn,1:dimz-1)
1935                  else
1936                     z = z_v(varn,:)
1937                  end if
1938               else
1939                  if (isStrSubset( a(i),"zw_3d" ))then
1940                     z_v(varn,:) = z_w
1941                     if (log_z .EQ. 1) then
1942                        z = z_v(varn,1:dimz-1)
1943                     else
1944                        z = z_v(varn,:)
1945                     end if
1946                  end if                   
1947               end if
1948            end do           
1949         end if
1950
1951         if (isStrSubset(data@long_name," SR " ) ) then
1952           over = 0
1953         end if
1954         
1955         if (nof .EQ. 0) then
1956            z_(n,:)=z/norm_z
1957            z    = z_(n,:)
1958         else
1959            z=z/norm_z
1960         end if
1961
1962         delta_z = z(1) - z(0)
1963
1964         max_z_int=doubletoint(max_z/delta_z)
1965         min_z_int=doubletoint(min_z/delta_z)
1966
1967         if(max_z_int .eq. min_z_int)
1968             print(" ")
1969             print("Please increase 'max_z' or decrease 'min_z' so that "+\
1970                   "there are")
1971             print("at least two layers for the z-axis to plot")
1972             print(" ")
1973             exit
1974         end if
1975
1976         if(min_z_int .gt. max_z_int)
1977            print(" ")
1978            print("'min_z' is greater than 'max_z',")
1979            print("please change this")
1980            print(" ")
1981            exit
1982         end if
1983
1984         if (max_z_int .ge. dimz-1)
1985            max_z_int = dimz-1
1986            if (log_z .EQ. 1) then
1987             max_z_int = max_z_int - 1
1988            end if
1989         end if
1990
1991         if (min_z_int .lt. 0)
1992            min_z_int = 0
1993            if (log_z .EQ. 1) then
1994              min_z_int = min_z_int + 1
1995            end if
1996         end if         
1997
1998         if (abs(min(data(varn,:,min_z_int:max_z_int))) .GT. 10)then
1999            min_value = abs(0.001*min(data(varn,:,min_z_int:max_z_int)))
2000            max_value = abs(0.001*max(data(varn,:,min_z_int:max_z_int)))
2001         else
2002            if (abs(min(data(varn,:,min_z_int:max_z_int))) .LT. 0.01 .AND. \
2003                abs(max(data(varn,:,min_z_int:max_z_int))) .GT. 0.01)then
2004               min_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
2005               max_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
2006            else
2007               if (abs(max(data(varn,:,min_z_int:max_z_int))) .LT. 0.01 .AND.\
2008                   abs(min(data(varn,:,min_z_int:max_z_int))) .GT. 0.01)then
2009                  min_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
2010                  max_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
2011               else
2012                  min_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
2013                  max_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
2014               end if
2015            end if
2016         end if
2017       
2018         if (min(data(varn,:,min_z_int:max_z_int)) .EQ. 0 .AND. \
2019             max(data(varn,:,min_z_int:max_z_int)) .EQ. 0)then
2020            min_value = 0.1
2021            max_value = 0.1
2022         end if       
2023
2024         if (over .EQ. 0) then 
2025            res@gsnLeftString      = vNam(varn)
2026            res@tiXAxisString      = "("+unit(varn)+")"
2027            res@gsnRightString     = " "
2028            res@trYMinF            = min_z
2029            res@trYMaxF            = max_z
2030            if (xs .EQ. -1) then
2031               res@trXMinF            = min(data(varn,:,min_z_int:max_z_int))-\
2032                                                                      min_value
2033            else
2034               res@trXMinF            = xs     
2035            end if
2036            if (xe .EQ. -1) then
2037               res@trXMaxF            = max(data(varn,:,min_z_int:max_z_int))+\
2038                                                                      max_value
2039            else
2040               res@trXMaxF            = xe 
2041            end if         
2042            plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
2043         end if
2044 
2045     
2046         if (vNam(varn) .EQ. "u" ) then
2047               miniu=min(data(varn,:,min_z_int:max_z_int))-min_value
2048               maxiu=max(data(varn,:,min_z_int:max_z_int))+max_value
2049               if (over .EQ. 1) then
2050                  res@xyDashPattern  = 0
2051                  plot_u = gsn_csm_xy(wks,data(varn,:,:),z,res)
2052               else
2053                  res@gsnLeftString      = vNam(varn)
2054                  res@tiXAxisString      = "("+unit(varn)+")"
2055                  res@gsnRightString     = " "                 
2056                  if (xs .EQ. -1) then 
2057                     res@trXMinF            = miniu
2058                  else
2059                     res@trXMinF            = xs
2060                  end if
2061                  if (xe .EQ. -1) then       
2062                     res@trXMaxF            = maxiu
2063                  else
2064                     res@trXMaxF            = xe 
2065                  end if               
2066                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
2067               end if
2068            end if
2069            if (vNam(varn) .EQ. "v") then
2070               miniv=min(data(varn,:,min_z_int:max_z_int))-min_value
2071               maxiv=max(data(varn,:,min_z_int:max_z_int))+max_value
2072               if (over .EQ. 1) then
2073                  res@xyMonoDashPattern = True
2074                  res@xyDashPattern  = 1
2075                  plot_v = gsn_csm_xy(wks,data(varn,:,:),z,res)
2076               else
2077                  res@gsnLeftString      = vNam(varn)
2078                  res@tiXAxisString      = "("+unit(varn)+")"
2079                  res@gsnRightString     = " "                 
2080                  if (xs .EQ. -1) then
2081                     res@trXMinF            = miniv
2082                  else
2083                     res@trXMinF            = xs
2084                  end if
2085                  if (xe .EQ. -1) then
2086                     res@trXMaxF            = maxiv
2087                  else
2088                     res@trXMaxF            = xe 
2089                  end if               
2090                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2091               end if 
2092            end if
2093            if (vNam(varn) .EQ. "w") then
2094               miniw=min(data(varn,:,min_z_int:max_z_int))-min_value
2095               maxiw=max(data(varn,:,min_z_int:max_z_int))+max_value
2096               if (over .EQ. 1) then
2097                  res@xyDashPattern = 2
2098                  plot_w = gsn_csm_xy(wks,data(varn,:,:),z,res)
2099               else
2100                  res@gsnLeftString      = vNam(varn)
2101                  res@tiXAxisString      = "("+unit(varn)+")"
2102                  res@gsnRightString     = " "
2103                  if (xs .EQ. -1) then
2104                     res@trXMinF            = miniw
2105                  else
2106                     res@trXMinF            = xs
2107                  end if
2108                  if (xe .EQ. -1) then
2109                     res@trXMaxF            = maxiw
2110                  else
2111                     res@trXMaxF            = xe 
2112                  end if           
2113                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2114               end if   
2115            end if
2116
2117            if (vNam(varn) .EQ. "pt") then
2118               minipt=min(data(varn,:,min_z_int:max_z_int))-min_value
2119               maxipt=max(data(varn,:,min_z_int:max_z_int))+max_value
2120               if (over .EQ. 1) then
2121                  res@xyDashPattern  = 0
2122                  plot_pt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2123               else
2124                  res@gsnLeftString      = vNam(varn)
2125                  res@tiXAxisString      = "("+unit(varn)+")"
2126                  res@gsnRightString     = " "
2127                  if (xs .EQ. -1) then
2128                     res@trXMinF            = minipt
2129                  else
2130                     res@trXMinF            = xs
2131                  end if
2132                  if (xe .EQ. -1) then       
2133                     res@trXMaxF            = maxipt
2134                  else
2135                     res@trXMaxF            = xe 
2136                  end if
2137                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2138               end if 
2139            end if
2140            if (vNam(varn) .EQ. "vpt") then
2141               minivpt=min(data(varn,:,min_z_int:max_z_int))-min_value
2142               maxivpt=max(data(varn,:,min_z_int:max_z_int))+max_value
2143               if (over .EQ. 1) then
2144                  res@xyDashPattern  = 1
2145                  plot_vpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2146               else
2147                  res@gsnLeftString      = vNam(varn)
2148                  res@tiXAxisString      = "("+unit(varn)+")"
2149                  res@gsnRightString     = " "
2150                  if (xs .EQ. -1) then
2151                     res@trXMinF            = minivpt
2152                  else
2153                     res@trXMinF            = xs
2154                  end if
2155                  if (xe .EQ. -1) then       
2156                     res@trXMaxF            = maxivpt
2157                  else
2158                     res@trXMaxF            = xe 
2159                  end if
2160                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2161               end if
2162            end if
2163            if (vNam(varn) .EQ. "lpt") then
2164               minilpt=min(data(varn,:,min_z_int:max_z_int))-min_value
2165               maxilpt=max(data(varn,:,min_z_int:max_z_int))+max_value
2166               if (over .EQ. 1) then
2167                  res@xyDashPattern  = 2
2168                  plot_lpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2169               else
2170                  res@gsnLeftString      = vNam(varn)
2171                  res@tiXAxisString      = "("+unit(varn)+")"
2172                  res@gsnRightString     = " "
2173                  if (xs .EQ. -1) then
2174                     res@trXMinF            = minilpt
2175                  else
2176                     res@trXMinF            = xs
2177                  end if
2178                  if (xe .EQ. -1) then       
2179                     res@trXMaxF            = maxilpt
2180                  else
2181                     res@trXMaxF            = xe 
2182                  end if
2183                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2184               end if
2185            end if
2186
2187            if (vNam(varn) .EQ. "q") then
2188               miniq=min(data(varn,:,min_z_int:max_z_int))-min_value
2189               maxiq=max(data(varn,:,min_z_int:max_z_int))+max_value
2190               if (over .EQ. 1) then
2191                  res@xyDashPattern  = 0
2192                  plot_q = gsn_csm_xy(wks,data(varn,:,:),z,res)
2193               else
2194                  res@gsnLeftString      = vNam(varn)
2195                  res@tiXAxisString      = "("+unit(varn)+")"
2196                  res@gsnRightString     = " "
2197                  if (xs .EQ. -1) then
2198                     res@trXMinF            = miniq
2199                  else
2200                     res@trXMinF            = xs
2201                  end if
2202                  if (xe .EQ. -1) then       
2203                     res@trXMaxF            = maxiq
2204                  else
2205                     res@trXMaxF            = xe 
2206                  end if
2207                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2208               end if
2209            end if
2210            if (vNam(varn) .EQ. "qv") then
2211               miniqv=min(data(varn,:,min_z_int:max_z_int))-min_value
2212               maxiqv=max(data(varn,:,min_z_int:max_z_int))+max_value
2213               if (over .EQ. 1) then
2214                  res@xyDashPattern  = 1
2215                  plot_qv = gsn_csm_xy(wks,data(varn,:,:),z,res)
2216               else
2217                  res@gsnLeftString      = vNam(varn)
2218                  res@tiXAxisString      = "("+unit(varn)+")"
2219                  res@gsnRightString     = " "
2220                  if (xs .EQ. -1) then
2221                     res@trXMinF            = miniqv
2222                  else
2223                     res@trXMinF            = xs
2224                  end if
2225                  if (xe .EQ. -1) then         
2226                     res@trXMaxF            = maxiqv
2227                  else
2228                     res@trXMaxF            = xe 
2229                  end if
2230                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2231               end if
2232            end if
2233            if (vNam(varn) .EQ. "ql") then
2234               miniql=min(data(varn,:,min_z_int:max_z_int))-min_value
2235               maxiql=max(data(varn,:,min_z_int:max_z_int))+max_value
2236               if (over .EQ. 1) then
2237                  res@xyDashPattern  = 2
2238                  plot_ql = gsn_csm_xy(wks,data(varn,:,:),z,res)
2239               else
2240                  res@gsnLeftString      = vNam(varn)
2241                  res@tiXAxisString      = "("+unit(varn)+")"
2242                  res@gsnRightString     = " "
2243                  if (xs .EQ. -1) then
2244                     res@trXMinF            = miniql
2245                  else
2246                     res@trXMinF            = xs
2247                  end if
2248                  if (xe .EQ. -1) then       
2249                     res@trXMaxF            = maxiql
2250                  else
2251                     res@trXMaxF            = xe 
2252                  end if
2253                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2254               end if
2255            end if
2256
2257            if (vNam(varn) .EQ. "e") then
2258               minie=min(data(varn,:,min_z_int:max_z_int))-min_value
2259               maxie=max(data(varn,:,min_z_int:max_z_int))+max_value
2260               if (over .EQ. 1) then
2261                  res@xyDashPattern  = 0
2262                  plot_e = gsn_csm_xy(wks,data(varn,:,:),z,res)
2263               else
2264                  res@gsnLeftString      = vNam(varn)
2265                  res@tiXAxisString      = "("+unit(varn)+")"
2266                  res@gsnRightString     = " "
2267                  if (xs .EQ. -1) then
2268                     res@trXMinF            = minie
2269                  else
2270                     res@trXMinF            = xs
2271                  end if
2272                  if (xe .EQ. -1) then       
2273                     res@trXMaxF            = maxie
2274                  else
2275                     res@trXMaxF            = xe 
2276                  end if
2277                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2278               end if
2279            end if
2280            if (vNam(varn) .EQ. "es" .OR. vNam(varn) .EQ. "e*") then
2281               minies=min(data(varn,:,min_z_int:max_z_int))-min_value
2282               maxies=max(data(varn,:,min_z_int:max_z_int))+max_value
2283               if (over .EQ. 1) then
2284                  res@xyDashPattern  = 1
2285                  plot_es = gsn_csm_xy(wks,data(varn,:,:),z,res)
2286               else
2287                  res@gsnLeftString      = vNam(varn)
2288                  res@tiXAxisString      = "("+unit(varn)+")"
2289                  res@gsnRightString     = " "
2290                  if (xs .EQ. -1) then
2291                     res@trXMinF            = minies
2292                  else
2293                     res@trXMinF            = xs
2294                  end if
2295                  if (xe .EQ. -1) then       
2296                     res@trXMaxF            = maxies
2297                  else
2298                     res@trXMaxF            = xe 
2299                  end if
2300                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2301               end if
2302            end if
2303
2304            if (vNam(varn) .EQ. "km") then
2305               minikm=min(data(varn,:,min_z_int:max_z_int))-min_value
2306               maxikm=max(data(varn,:,min_z_int:max_z_int))+max_value
2307               if (over .EQ. 1) then
2308                  res@xyDashPattern  = 0
2309                  plot_km = gsn_csm_xy(wks,data(varn,:,:),z,res)
2310               else
2311                  res@gsnLeftString      = vNam(varn)
2312                  res@tiXAxisString      = "("+unit(varn)+")"
2313                  res@gsnRightString     = " "
2314                  if (xs .EQ. -1) then
2315                     res@trXMinF            = minikm
2316                  else
2317                     res@trXMinF            = xs
2318                  end if
2319                  if (xe .EQ. -1) then     
2320                     res@trXMaxF            = maxikm
2321                  else
2322                     res@trXMaxF            = xe 
2323                  end if
2324                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2325               end if
2326            end if
2327            if (vNam(varn) .EQ. "kh") then
2328               minikh=min(data(varn,:,min_z_int:max_z_int))-min_value
2329               maxikh=max(data(varn,:,min_z_int:max_z_int))+max_value
2330               if (over .EQ. 1) then
2331                  res@xyDashPattern  = 1
2332                  plot_kh = gsn_csm_xy(wks,data(varn,:,:),z,res)
2333               else
2334                  res@gsnLeftString      = vNam(varn)
2335                  res@tiXAxisString      = "("+unit(varn)+")"
2336                  res@gsnRightString     = " "
2337                  if (xs .EQ. -1) then
2338                     res@trXMinF            = minikh
2339                  else
2340                     res@trXMinF            = xs
2341                  end if
2342                  if (xe .EQ. -1) then     
2343                     res@trXMaxF            = maxikh
2344                  else
2345                     res@trXMaxF            = xe 
2346                  end if
2347                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2348               end if
2349            end if
2350
2351            if (vNam(varn) .EQ. "wpup" .OR. vNam(varn) .EQ. "w"+dq+"u"+dq) then
2352               miniwpup=min(data(varn,:,min_z_int:max_z_int))-min_value
2353               maxiwpup=max(data(varn,:,min_z_int:max_z_int))+max_value
2354               if (over .EQ. 1) then
2355                  res@xyDashPattern  = 0
2356                  plot_wpup = gsn_csm_xy(wks,data(varn,:,:),z,res)
2357               else
2358                  res@gsnLeftString      = vNam(varn)
2359                  res@tiXAxisString      = "("+unit(varn)+")"
2360                  res@gsnRightString     = " "
2361                  if (xs .EQ. -1) then
2362                     res@trXMinF            = miniwpup
2363                  else
2364                     res@trXMinF            = xs
2365                  end if
2366                  if (xe .EQ. -1) then
2367                     res@trXMaxF            = maxiwpup
2368                  else
2369                     res@trXMaxF            = xe 
2370                  end if
2371                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2372               end if
2373            end if
2374            if (vNam(varn) .EQ. "wsus" .OR. vNam(varn) .EQ. "w*u*") then
2375               miniwsus=min(data(varn,:,min_z_int:max_z_int))-min_value
2376               maxiwsus=max(data(varn,:,min_z_int:max_z_int))+max_value
2377               if (over .EQ. 1) then
2378                  res@xyDashPattern  = 1
2379                  plot_wsus = gsn_csm_xy(wks,data(varn,:,:),z,res)
2380               else
2381                  res@gsnLeftString      = vNam(varn)
2382                  res@tiXAxisString      = "("+unit(varn)+")"
2383                  res@gsnRightString     = " "
2384                  if (xs .EQ. -1) then
2385                     res@trXMinF            = miniwsus
2386                  else
2387                     res@trXMinF            = xs
2388                  end if
2389                  if (xe .EQ. -1) then     
2390                     res@trXMaxF            = maxiwsus
2391                  else
2392                     res@trXMaxF            = xe 
2393                  end if
2394                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2395               end if
2396            end if
2397            if (vNam(varn) .EQ. "wu") then
2398               miniwu=min(data(varn,:,min_z_int:max_z_int))-min_value
2399               maxiwu=max(data(varn,:,min_z_int:max_z_int))+max_value
2400               if (over .EQ. 1) then
2401                  res@xyDashPattern  = 2
2402                  plot_wu = gsn_csm_xy(wks,data(varn,:,:),z,res)
2403               else
2404                  res@gsnLeftString      = vNam(varn)
2405                  res@tiXAxisString      = "("+unit(varn)+")"
2406                  res@gsnRightString     = " "
2407                  if (xs .EQ. -1) then
2408                     res@trXMinF            = miniwu
2409                  else
2410                     res@trXMinF            = xs
2411                  end if
2412                  if (xe .EQ. -1) then
2413                     res@trXMaxF            = maxiwu
2414                  else
2415                     res@trXMaxF            = xe 
2416                  end if
2417                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2418               end if
2419            end if
2420
2421            if (vNam(varn) .EQ. "wpvp" .OR. vNam(varn) .EQ. "w"+dq+"v"+dq) then
2422               miniwpvp=min(data(varn,:,min_z_int:max_z_int))-min_value
2423               maxiwpvp=max(data(varn,:,min_z_int:max_z_int))+max_value
2424               if (over .EQ. 1) then
2425                  res@xyDashPattern  = 0
2426                  plot_wpvp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2427               else
2428                  res@gsnLeftString      = vNam(varn)
2429                  res@tiXAxisString      = "("+unit(varn)+")"
2430                  res@gsnRightString     = " "
2431                  if (xs .EQ. -1) then
2432                     res@trXMinF            = miniwpvp
2433                  else
2434                     res@trXMinF            = xs
2435                  end if
2436                  if (xe .EQ. -1) then     
2437                     res@trXMaxF            = maxiwpvp
2438                  else
2439                     res@trXMaxF            = xe 
2440                  end if
2441                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2442               end if
2443            end if
2444            if (vNam(varn) .EQ. "wsvs" .OR. vNam(varn) .EQ. "w*v*") then
2445               miniwsvs=min(data(varn,:,min_z_int:max_z_int))-min_value
2446               maxiwsvs=max(data(varn,:,min_z_int:max_z_int))+max_value
2447               if (over .EQ. 1) then
2448                  res@xyDashPattern  = 1
2449                  plot_wsvs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2450               else
2451                  res@gsnLeftString      = vNam(varn)
2452                  res@tiXAxisString      = "("+unit(varn)+")"
2453                  res@gsnRightString     = " "
2454                  if (xs .EQ. -1) then
2455                     res@trXMinF            = miniwsvs
2456                  else
2457                     res@trXMinF            = xs
2458                  end if
2459                  if (xe .EQ. -1) then     
2460                     res@trXMaxF            = maxiwsvs
2461                  else
2462                     res@trXMaxF            = xe 
2463                  end if
2464                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2465               end if
2466            end if
2467            if (vNam(varn) .EQ. "wv") then
2468               miniwv=min(data(varn,:,min_z_int:max_z_int))-min_value
2469               maxiwv=max(data(varn,:,min_z_int:max_z_int))+max_value
2470               if (over .EQ. 1) then
2471                  res@xyDashPattern  = 2
2472                  plot_wv = gsn_csm_xy(wks,data(varn,:,:),z,res)
2473               else
2474                  res@gsnLeftString      = vNam(varn)
2475                  res@tiXAxisString      = "("+unit(varn)+")"
2476                  res@gsnRightString     = " "
2477                  if (xs .EQ. -1) then
2478                     res@trXMinF            = miniwv
2479                  else
2480                     res@trXMinF            = xs
2481                  end if
2482                  if (xe .EQ. -1) then       
2483                     res@trXMaxF            = maxiwv
2484                  else
2485                     res@trXMaxF            = xe 
2486                  end if
2487                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2488               end if
2489            end if
2490
2491            if (vNam(varn) .EQ. "wpptp" .OR. vNam(varn) \
2492               .EQ. "w"+dq+"pt"+dq) then
2493               miniwpptp=min(data(varn,:,min_z_int:max_z_int))-min_value
2494               maxiwpptp=max(data(varn,:,min_z_int:max_z_int))+max_value
2495               if (over .EQ. 1) then
2496                  res@xyDashPattern  = 0
2497                  plot_wpptp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2498               else
2499                  res@gsnLeftString      = vNam(varn)
2500                  res@tiXAxisString      = "("+unit(varn)+")"
2501                  res@gsnRightString     = " "
2502                  if (xs .EQ. -1) then
2503                     res@trXMinF            = miniwpptp
2504                  else
2505                     res@trXMinF            = xs
2506                  end if
2507                  if (xe .EQ. -1) then       
2508                     res@trXMaxF            = maxiwpptp
2509                  else
2510                     res@trXMaxF            = xe 
2511                  end if
2512                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2513               end if
2514            end if
2515            if (vNam(varn) .EQ. "wspts" .OR. vNam(varn) .EQ. "w*pt*") then
2516               miniwspts=min(data(varn,:,min_z_int:max_z_int))-min_value
2517               maxiwspts=max(data(varn,:,min_z_int:max_z_int))+max_value
2518               if (over .EQ. 1) then
2519                  res@xyDashPattern  = 1
2520                  plot_wspts = gsn_csm_xy(wks,data(varn,:,:),z,res)
2521               else
2522                  res@gsnLeftString      = vNam(varn)
2523                  res@tiXAxisString      = "("+unit(varn)+")"
2524                  res@gsnRightString     = " "
2525                  if (xs .EQ. -1) then
2526                     res@trXMinF            = miniwspts
2527                  else
2528                     res@trXMinF            = xs
2529                  end if
2530                  if (xe .EQ. -1) then       
2531                     res@trXMaxF            = maxiwspts
2532                  else
2533                     res@trXMaxF            = xe 
2534                  end if
2535                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2536               end if
2537            end if
2538            if (vNam(varn) .EQ. "wpt") then       
2539               miniwpt=min(data(varn,:,min_z_int:max_z_int))-min_value
2540               maxiwpt=max(data(varn,:,min_z_int:max_z_int))+max_value
2541               if (over .EQ. 1) then
2542                  res@xyDashPattern  = 2
2543                  plot_wpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2544               else
2545                  res@gsnLeftString      = vNam(varn)
2546                  res@tiXAxisString      = "("+unit(varn)+")"
2547                  res@gsnRightString     = " "
2548                  if (xs .EQ. -1) then
2549                     res@trXMinF            = miniwpt
2550                  else
2551                     res@trXMinF            = xs
2552                  end if
2553                  if (xe .EQ. -1) then       
2554                     res@trXMaxF            = maxiwpt
2555                  else
2556                     res@trXMaxF            = xe 
2557                  end if
2558                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2559               end if
2560            end if
2561
2562            if (vNam(varn) .EQ. "wsptsBC".OR. vNam(varn) .EQ. "w*pt*BC" ) then
2563               miniwsptsBC=min(data(varn,:,min_z_int:max_z_int))-min_value
2564               maxiwsptsBC=max(data(varn,:,min_z_int:max_z_int))+max_value
2565               if (over .EQ. 1) then
2566                  res@xyDashPattern  = 0
2567                  plot_wsptsBC = gsn_csm_xy(wks,data(varn,:,:),z,res)
2568               else
2569                  res@gsnLeftString      = vNam(varn)
2570                  res@tiXAxisString      = "("+unit(varn)+")"
2571                  res@gsnRightString     = " "
2572                  if (xs .EQ. -1) then
2573                     res@trXMinF            = miniwsptsBC
2574                  else
2575                     res@trXMinF            = xs
2576                  end if
2577                  if (xe .EQ. -1) then       
2578                     res@trXMaxF            = maxiwsptsBC
2579                  else
2580                     res@trXMaxF            = xe 
2581                  end if
2582                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2583               end if
2584            end if             
2585            if (vNam(varn) .EQ. "wptBC") then
2586               miniwptBC=min(data(varn,:,min_z_int:max_z_int))-min_value
2587               maxiwptBC=max(data(varn,:,min_z_int:max_z_int))+max_value
2588               if (over .EQ. 1) then
2589                  res@xyDashPattern  = 1
2590                  plot_wptBC = gsn_csm_xy(wks,data(varn,:,:),z,res)
2591               else
2592                  res@gsnLeftString      = vNam(varn)
2593                  res@tiXAxisString      = "("+unit(varn)+")"
2594                  res@gsnRightString     = " "
2595                  if (xs .EQ. -1) then
2596                     res@trXMinF            = miniwptBC
2597                  else
2598                     res@trXMinF            = xs
2599                  end if
2600                  if (xe .EQ. -1) then       
2601                     res@trXMaxF            = maxiwptBC
2602                  else
2603                     res@trXMaxF            = xe 
2604                  end if
2605                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2606               end if
2607            end if
2608
2609            if (vNam(varn) .EQ. "wpvptp" .OR. vNam(varn) \
2610                .EQ. "w"+dq+"vpt"+dq) then
2611               miniwpvptp=min(data(varn,:,min_z_int:max_z_int))-min_value
2612               maxiwpvptp=max(data(varn,:,min_z_int:max_z_int))+max_value
2613               if (over .EQ. 1) then
2614                  res@xyDashPattern  = 0
2615                  plot_wpvptp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2616               else
2617                  res@gsnLeftString      = vNam(varn)
2618                  res@tiXAxisString      = "("+unit(varn)+")"
2619                  res@gsnRightString     = " "
2620                  if (xs .EQ. -1) then
2621                     res@trXMinF            = miniwpvptp
2622                  else
2623                     res@trXMinF            = xs
2624                  end if
2625                  if (xe .EQ. -1) then       
2626                     res@trXMaxF            = maxiwpvptp
2627                  else
2628                     res@trXMaxF            = xe 
2629                  end if
2630                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2631               end if
2632            end if
2633            if (vNam(varn) .EQ. "wsvpts" .OR. vNam(varn) .EQ. "w*vpt*") then
2634               miniwsvpts=min(data(varn,:,min_z_int:max_z_int))-min_value
2635               maxiwsvpts=max(data(varn,:,min_z_int:max_z_int))+max_value
2636               if (over .EQ. 1) then
2637                  res@xyDashPattern  = 1
2638                  plot_wsvpts = gsn_csm_xy(wks,data(varn,:,:),z,res)
2639               else
2640                  res@gsnLeftString      = vNam(varn)
2641                  res@tiXAxisString      = "("+unit(varn)+")"
2642                  res@gsnRightString     = " "
2643                  if (xs .EQ. -1) then
2644                     res@trXMinF            = miniwsvpts
2645                  else
2646                     res@trXMinF            = xs
2647                  end if
2648                  if (xe .EQ. -1) then       
2649                     res@trXMaxF            = maxiwsvpts
2650                  else
2651                     res@trXMaxF            = xe 
2652                  end if
2653                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2654               end if
2655            end if
2656            if (vNam(varn) .EQ. "wvpt") then
2657               miniwvpt=min(data(varn,:,min_z_int:max_z_int))-min_value
2658               maxiwvpt=max(data(varn,:,min_z_int:max_z_int))+max_value
2659               if (over .EQ. 1) then
2660                  res@xyDashPattern  = 2
2661                  plot_wvpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2662               else
2663                  res@gsnLeftString      = vNam(varn)
2664                  res@tiXAxisString      = "("+unit(varn)+")"
2665                  res@gsnRightString     = " "
2666                  if (xs .EQ. -1) then
2667                     res@trXMinF            = miniwvpt
2668                  else
2669                     res@trXMinF            = xs
2670                  end if
2671                  if (xe .EQ. -1) then       
2672                     res@trXMaxF            = maxiwvpt
2673                  else
2674                     res@trXMaxF            = xe 
2675                  end if
2676                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2677               end if
2678            end if
2679
2680            if (vNam(varn) .EQ. "wpqp" .OR. vNam(varn) .EQ. "w"+dq+"q"+dq) then
2681               miniwpqp=min(data(varn,:,min_z_int:max_z_int))-min_value
2682               maxiwpqp=max(data(varn,:,min_z_int:max_z_int))+max_value
2683               if (over .EQ. 1) then
2684                  res@xyDashPattern  = 0
2685                  plot_wpqp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2686               else
2687                  res@gsnLeftString      = vNam(varn)
2688                  res@tiXAxisString      = "("+unit(varn)+")"
2689                  res@gsnRightString     = " "
2690                  if (xs .EQ. -1) then
2691                     res@trXMinF            = miniwpqp
2692                  else
2693                     res@trXMinF            = xs
2694                  end if
2695                  if (xe .EQ. -1) then       
2696                     res@trXMaxF            = maxiwpqp
2697                  else
2698                     res@trXMaxF            = xe 
2699                  end if
2700                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2701               end if
2702            end if
2703            if (vNam(varn) .EQ. "wsqs".OR. vNam(varn) .EQ. "w*s*" ) then
2704               miniwsqs=min(data(varn,:,min_z_int:max_z_int))-min_value
2705               maxiwsqs=max(data(varn,:,min_z_int:max_z_int))+max_value
2706               if (over .EQ. 1) then
2707                  res@xyDashPattern  = 1
2708                  plot_wsqs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2709               else
2710                  res@gsnLeftString      = vNam(varn)
2711                  res@tiXAxisString      = "("+unit(varn)+")"
2712                  res@gsnRightString     = " "
2713                  if (xs .EQ. -1) then
2714                     res@trXMinF            = miniwsqs
2715                  else
2716                     res@trXMinF            = xs
2717                  end if
2718                  if (xe .EQ. -1) then       
2719                     res@trXMaxF            = maxiwsqs
2720                  else
2721                     res@trXMaxF            = xe 
2722                  end if
2723                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2724               end if
2725            end if
2726            if (vNam(varn) .EQ. "wq") then
2727               miniwq=min(data(varn,:,min_z_int:max_z_int))-min_value
2728               maxiwq=max(data(varn,:,min_z_int:max_z_int))+max_value
2729               if (over .EQ. 1) then
2730                  res@xyDashPattern  = 2
2731                  plot_wq = gsn_csm_xy(wks,data(varn,:,:),z,res)
2732               else
2733                  res@gsnLeftString      = vNam(varn)
2734                  res@tiXAxisString      = "("+unit(varn)+")"
2735                  res@gsnRightString     = " "
2736                  if (xs .EQ. -1) then
2737                     res@trXMinF            = miniwq
2738                  else
2739                     res@trXMinF            = xs
2740                  end if
2741                  if (xe .EQ. -1) then       
2742                     res@trXMaxF            = maxiwq
2743                  else
2744                     res@trXMaxF            = xe 
2745                  end if
2746                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2747               end if
2748            end if
2749
2750            if (vNam(varn) .EQ. "wpqvp" .OR. \
2751               vNam(varn) .EQ. "w"+dq+"qv"+dq) then
2752               miniwpqvp=min(data(varn,:,min_z_int:max_z_int))-min_value
2753               maxiwpqvp=max(data(varn,:,min_z_int:max_z_int))+max_value
2754               if (over .EQ. 1) then
2755                  res@xyDashPattern  = 0
2756                  plot_wpqvp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2757               else
2758                  res@gsnLeftString      = vNam(varn)
2759                  res@tiXAxisString      = "("+unit(varn)+")"
2760                  res@gsnRightString     = " "
2761                  if (xs .EQ. -1) then
2762                     res@trXMinF            = miniwpqvp
2763                  else
2764                     res@trXMinF            = xs
2765                  end if
2766                  if (xe .EQ. -1) then       
2767                     res@trXMaxF            = maxiwpqvp
2768                  else
2769                     res@trXMaxF            = xe 
2770                  end if
2771                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2772               end if
2773            end if
2774            if (vNam(varn) .EQ. "wsqvs" .OR. vNam(varn) .EQ. "w*qv*") then
2775               miniwsqvs=min(data(varn,:,min_z_int:max_z_int))-min_value
2776               maxiwsqvs=max(data(varn,:,min_z_int:max_z_int))+max_value
2777               if (over .EQ. 1) then
2778                  res@xyDashPattern  = 1
2779                  plot_wsqvs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2780               else
2781                  res@gsnLeftString      = vNam(varn)
2782                  res@tiXAxisString      = "("+unit(varn)+")"
2783                  res@gsnRightString     = " "
2784                  if (xs .EQ. -1) then
2785                     res@trXMinF            = miniwsqvs
2786                  else
2787                     res@trXMinF            = xs
2788                  end if
2789                  if (xe .EQ. -1) then       
2790                     res@trXMaxF            = maxiwsqvs
2791                  else
2792                     res@trXMaxF            = xe 
2793                  end if
2794                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2795               end if
2796            end if
2797            if (vNam(varn) .EQ. "wqv") then
2798               miniwqv=min(data(varn,:,min_z_int:max_z_int))-min_value
2799               maxiwqv=max(data(varn,:,min_z_int:max_z_int))+max_value
2800               if (over .EQ. 1) then
2801                  res@xyDashPattern  = 2
2802                  plot_wqv = gsn_csm_xy(wks,data(varn,:,:),z,res)
2803               else
2804                  res@gsnLeftString      = vNam(varn)
2805                  res@tiXAxisString      = "("+unit(varn)+")"
2806                  res@gsnRightString     = " "
2807                  if (xs .EQ. -1) then
2808                     res@trXMinF            = miniwqv
2809                  else
2810                     res@trXMinF            = xs
2811                  end if
2812                  if (xe .EQ. -1) then       
2813                     res@trXMaxF            = maxiwqv
2814                  else
2815                     res@trXMaxF            = xe 
2816                  end if
2817                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2818               end if
2819            end if
2820
2821            if (vNam(varn) .EQ. "wpsp" .OR. vNam(varn) .EQ. "w"+dq+"s"+dq) then
2822               miniwpsp=min(data(varn,:,min_z_int:max_z_int))-min_value
2823               maxiwpsp=max(data(varn,:,min_z_int:max_z_int))+max_value
2824               if (over .EQ. 1) then
2825                  res@xyDashPattern  = 0
2826                  plot_wpsp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2827               else
2828                  res@gsnLeftString      = vNam(varn)
2829                  res@tiXAxisString      = "("+unit(varn)+")"
2830                  res@gsnRightString     = " "
2831                  if (xs .EQ. -1) then
2832                     res@trXMinF            = miniwpsp
2833                  else
2834                     res@trXMinF            = xs
2835                  end if
2836                  if (xe .EQ. -1) then       
2837                     res@trXMaxF            = maxiwpsp
2838                  else
2839                     res@trXMaxF            = xe 
2840                  end if
2841                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2842               end if
2843            end if
2844            if (vNam(varn) .EQ. "wsss" .OR. vNam(varn) .EQ. "w*s*" ) then
2845               miniwsss=min(data(varn,:,min_z_int:max_z_int))-min_value
2846               maxiwsss=max(data(varn,:,min_z_int:max_z_int))+max_value
2847               if (over .EQ. 1) then
2848                  res@xyDashPattern  = 1
2849                  plot_wsss = gsn_csm_xy(wks,data(varn,:,:),z,res)
2850               else
2851                  res@gsnLeftString      = vNam(varn)
2852                  res@tiXAxisString      = "("+unit(varn)+")"
2853                  res@gsnRightString     = " "
2854                  if (xs .EQ. -1) then
2855                     res@trXMinF            = miniwsss
2856                  else
2857                     res@trXMinF            = xs
2858                  end if
2859                  if (xe .EQ. -1) then       
2860                     res@trXMaxF            = maxiwsss
2861                  else
2862                     res@trXMaxF            = xe 
2863                  end if
2864                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2865               end if
2866            end if
2867            if (vNam(varn) .EQ. "ws") then
2868               miniws=min(data(varn,:,min_z_int:max_z_int))-min_value
2869               maxiws=max(data(varn,:,min_z_int:max_z_int))+max_value
2870               if (over .EQ. 1) then
2871                  res@xyDashPattern  = 2
2872                  plot_ws = gsn_csm_xy(wks,data(varn,:,:),z,res)
2873               else
2874                  res@gsnLeftString      = vNam(varn)
2875                  res@tiXAxisString      = "("+unit(varn)+")"
2876                  res@gsnRightString     = " "
2877                  if (xs .EQ. -1) then
2878                     res@trXMinF            = miniws
2879                  else
2880                     res@trXMinF            = xs
2881                  end if
2882                  if (xe .EQ. -1) then       
2883                     res@trXMaxF            = maxiws
2884                  else
2885                     res@trXMaxF            = xe 
2886                  end if
2887                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2888               end if
2889            end if
2890
2891            if (vNam(varn) .EQ. "wpsap" .OR. \
2892                vNam(varn) .EQ. "w"+dq+"sa"+dq) then
2893               miniwpsap=min(data(varn,:,min_z_int:max_z_int))-min_value
2894               maxiwpsap=max(data(varn,:,min_z_int:max_z_int))+max_value
2895               if (over .EQ. 1) then
2896                  res@xyDashPattern  = 0
2897                  plot_wpsap = gsn_csm_xy(wks,data(varn,:,:),z,res)
2898               else
2899                  res@gsnLeftString      = vNam(varn)
2900                  res@tiXAxisString      = "("+unit(varn)+")"
2901                  res@gsnRightString     = " "
2902                  if (xs .EQ. -1) then
2903                     res@trXMinF            = miniwpsap
2904                  else
2905                     res@trXMinF            = xs
2906                  end if
2907                  if (xe .EQ. -1) then       
2908                     res@trXMaxF            = maxiwpsap
2909                  else
2910                     res@trXMaxF            = xe 
2911                  end if
2912                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2913               end if
2914            end if
2915            if (vNam(varn) .EQ. "wssas" .OR. vNam(varn) .EQ. "w*sa*") then
2916               miniwssas=min(data(varn,:,min_z_int:max_z_int))-min_value
2917               maxiwssas=max(data(varn,:,min_z_int:max_z_int))+max_value
2918               if (over .EQ. 1) then
2919                  res@xyDashPattern  = 1
2920                  plot_wssas = gsn_csm_xy(wks,data(varn,:,:),z,res)
2921               else
2922                  res@gsnLeftString      = vNam(varn)
2923                  res@tiXAxisString      = "("+unit(varn)+")"
2924                  res@gsnRightString     = " "
2925                  if (xs .EQ. -1) then
2926                     res@trXMinF            = miniwssas
2927                  else
2928                     res@trXMinF            = xs
2929                  end if
2930                  if (xe .EQ. -1) then       
2931                     res@trXMaxF            = maxiwssas
2932                  else
2933                     res@trXMaxF            = xe 
2934                  end if
2935                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2936               end if
2937            end if
2938            if (vNam(varn) .EQ. "wsa") then
2939               miniwsa=min(data(varn,:,min_z_int:max_z_int))-min_value
2940               maxiwsa=max(data(varn,:,min_z_int:max_z_int))+max_value
2941               if (over .EQ. 1) then
2942                  res@xyDashPattern  = 2
2943                  plot_wsa = gsn_csm_xy(wks,data(varn,:,:),z,res)
2944               else
2945                  res@gsnLeftString      = vNam(varn)
2946                  res@tiXAxisString      = "("+unit(varn)+")"
2947                  res@gsnRightString     = " "
2948                  if (xs .EQ. -1) then
2949                     res@trXMinF            = miniwsa
2950                  else
2951                     res@trXMinF            = xs
2952                  end if
2953                  if (xe .EQ. -1) then       
2954                     res@trXMaxF            = maxiwsa
2955                  else
2956                     res@trXMaxF            = xe 
2957                  end if
2958                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2959               end if
2960            end if
2961
2962            if (vNam(varn) .EQ. "us2" .OR. vNam(varn) .EQ. "u*2") then
2963               minius2=min(data(varn,:,min_z_int:max_z_int))-min_value
2964               maxius2=max(data(varn,:,min_z_int:max_z_int))+max_value
2965               if (over .EQ. 1) then
2966                  res@xyDashPattern  = 0
2967                  plot_us2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
2968               else
2969                  res@gsnLeftString      = vNam(varn)
2970                  res@tiXAxisString      = "("+unit(varn)+")"
2971                  res@gsnRightString     = " "
2972                  if (xs .EQ. -1) then
2973                     res@trXMinF            = minius2
2974                  else
2975                     res@trXMinF            = xs
2976                  end if
2977                  if (xe .EQ. -1) then       
2978                     res@trXMaxF            = maxius2
2979                  else
2980                     res@trXMaxF            = xe 
2981                  end if
2982                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2983               end if
2984            end if
2985            if (vNam(varn) .EQ. "vs2" .OR. vNam(varn) .EQ. "v*2") then
2986               minivs2=min(data(varn,:,min_z_int:max_z_int))-min_value
2987               maxivs2=max(data(varn,:,min_z_int:max_z_int))+max_value
2988               if (over .EQ. 1) then
2989                  res@xyDashPattern  = 1
2990                  plot_vs2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
2991               else
2992                  res@gsnLeftString      = vNam(varn)
2993                  res@tiXAxisString      = "("+unit(varn)+")"
2994                  res@gsnRightString     = " "
2995                  if (xs .EQ. -1) then
2996                     res@trXMinF            = minivs2
2997                  else
2998                     res@trXMinF            = xs
2999                  end if
3000                  if (xe .EQ. -1) then       
3001                     res@trXMaxF            = maxivs2
3002                  else
3003                     res@trXMaxF            = xe 
3004                  end if
3005                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
3006               end if
3007            end if
3008            if (vNam(varn) .EQ. "ws2" .OR. vNam(varn) .EQ. "w*2") then
3009               miniws2=min(data(varn,:,min_z_int:max_z_int))-min_value
3010               maxiws2=max(data(varn,:,min_z_int:max_z_int))+max_value
3011               if (over .EQ. 1) then
3012                  res@xyDashPattern  = 2
3013                  plot_ws2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
3014               else
3015                  res@gsnLeftString      = vNam(varn)
3016                  res@tiXAxisString      = "("+unit(varn)+")"
3017                  res@gsnRightString     = " "
3018                  if (xs .EQ. -1) then
3019                     res@trXMinF            = miniws2
3020                  else
3021                     res@trXMinF            = xs
3022                  end if
3023                  if (xe .EQ. -1) then       
3024                     res@trXMaxF            = maxiws2
3025                  else
3026                     res@trXMaxF            = xe 
3027                  end if
3028                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
3029               end if
3030            end if
3031
3032            if (vNam(varn) .EQ. "wsususodz" .OR. \
3033                vNam(varn) .EQ. "w*u*u*:dz") then
3034               miniwsususodz=min(data(varn,:,min_z_int:max_z_int))-min_value
3035               maxiwsususodz=max(data(varn,:,min_z_int:max_z_int))+max_value
3036               if (over .EQ. 1) then
3037                  res@xyDashPattern  = 0
3038                  plot_wsususodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
3039               else
3040                  res@gsnLeftString      = vNam(varn)
3041                  res@tiXAxisString      = "("+unit(varn)+")"
3042                  res@gsnRightString     = " "
3043                  if (xs .EQ. -1) then
3044                     res@trXMinF            = miniwsususodz
3045                  else
3046                     res@trXMinF            = xs
3047                  end if
3048                  if (xe .EQ. -1) then       
3049                     res@trXMaxF            = maxiwsususodz
3050                  else
3051                     res@trXMaxF            = xe 
3052                  end if
3053                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
3054               end if 
3055            end if
3056            if (vNam(varn) .EQ. "wspsodz" .OR. vNam(varn) .EQ. "w*p*:dz") then
3057               miniwspsodz=min(data(varn,:,min_z_int:max_z_int))-min_value
3058               maxiwspsodz=max(data(varn,:,min_z_int:max_z_int))+max_value
3059               if (over .EQ. 1) then
3060                  res@xyDashPattern  = 1
3061                  plot_wspsodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
3062               else
3063                  res@gsnLeftString      = vNam(varn)
3064                  res@tiXAxisString      = "("+unit(varn)+")"
3065                  res@gsnRightString     = " "
3066                  if (xs .EQ. -1) then
3067                     res@trXMinF            = miniwspsodz
3068                  else
3069                     res@trXMinF            = xs
3070                  end if
3071                  if (xe .EQ. -1) then       
3072                     res@trXMaxF            = maxiwspsodz
3073                  else
3074                     res@trXMaxF            = xe 
3075                  end if
3076                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
3077               end if
3078            end if
3079            if (vNam(varn) .EQ. "wpeodz" .OR. \
3080                vNam(varn) .EQ. "w"+dq+"p:dz") then
3081               miniwpeodz=min(data(varn,:,min_z_int:max_z_int))-min_value
3082               maxiwpeodz=max(data(varn,:,min_z_int:max_z_int))+max_value
3083               if (over .EQ. 1) then
3084                  res@xyDashPattern  = 2
3085                  plot_wpeodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
3086               else
3087                  res@gsnLeftString      = vNam(varn)
3088                  res@tiXAxisString      = "("+unit(varn)+")"
3089                  res@gsnRightString     = " "
3090                  if (xs .EQ. -1) then
3091                     res@trXMinF            = miniwpeodz
3092                  else
3093                     res@trXMinF            = xs
3094                  end if
3095                  if (xe .EQ. -1) then       
3096                     res@trXMaxF            = maxiwpeodz
3097                  else
3098                     res@trXMaxF            = xe 
3099                  end if
3100                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
3101               end if
3102            end if
3103         if (no_files .GT. 1) then
3104            print("nof="+nof+" und n="+n)
3105            multi_plot(nof,n)=plot(n)
3106            max_nof(nof,n)=max(data(varn,:,min_z_int:max_z_int))
3107            min_nof(nof,n)=min(data(varn,:,min_z_int:max_z_int))
3108            name(nof,n)   =vNam(varn)
3109            unit_(nof,n)  =unit(varn)
3110         end if
3111         if (over .EQ. 0) then
3112            n=n+1 
3113         end if 
3114         if (prof3d .EQ. 0)then   
3115            varn=varn+1
3116         end if
3117         delete(temp)
3118         delete(temp_att)
3119      end if         
3120   end do
3121   if (no_files .GT. 1) then
3122      delete(vNam)
3123      delete(files)
3124   end if
3125   
3126   end do
3127   ;#########ENDE DO LOOP FOR no_files GT 1#############
3128
3129   if (isStrSubset(data@long_name," SR " ) .and. over_remind) then
3130      print(" ")
3131      print("If you have outputs of statistic regions you cannot overlay "+\
3132            "variables;")
3133      print("'over' is set to 0" )
3134      print(" ")
3135      over = 0
3136   end if
3137
3138   if (count_var .EQ. 0) then
3139      print(" ")
3140      print("The variables 'var="+var+"'" )
3141      print("do not exist on your input file;")
3142      print("be sure to have one comma before and after each variable")
3143      print(" ")
3144      exit       
3145   end if
3146   
3147   if (no_files .GT. 1) then
3148      multi_legend=new(6,string)
3149      string_len=new(6,integer)
3150      multi_dash=new(no_files,string)
3151      multi_legend(0)="  "+name_legend_1
3152      string_len(0)=strlen(multi_legend(0))
3153      multi_legend(1)="  "+name_legend_2
3154      string_len(1)=strlen(multi_legend(1))
3155      multi_legend(2)="  "+name_legend_3
3156      string_len(2)=strlen(multi_legend(2))
3157      multi_legend(3)="  "+name_legend_4
3158      string_len(3)=strlen(multi_legend(3))
3159      multi_legend(4)="  "+name_legend_5
3160      string_len(4)=strlen(multi_legend(4))
3161      multi_legend(5)="  "+name_legend_6
3162      string_len(5)=strlen(multi_legend(5))
3163      do ml=1,no_files
3164         multi_dash(ml-1)=ml-1
3165      end do
3166      delete(plot)
3167      plot = new(dim,graphic)
3168      do pl=0,n-1
3169         plot0 = new(1,graphic)
3170         res@trXMinF = min(min_nof(:,pl))
3171         res@trXMaxF = max(max_nof(:,pl))
3172         res@gsnLeftString  = name(0,pl)
3173         res@gsnRightString = unit_(0,pl)
3174         
3175         data_0(:,:) = min(min_nof(:,pl))
3176         plot0 = gsn_csm_xy(wks,data_0(:,:),z_(pl,:),res)
3177
3178         ; ***************************************************
3179         ; legend for combined plot
3180         ; ***************************************************
3181
3182         lgres                    = True
3183         lgMonoDashIndex          = False
3184         lgres@lgLabelFont        = "helvetica"   
3185         lgres@lgLabelFontHeightF = font_size_legend           
3186         lgres@vpWidthF           = max(string_len)*0.015           
3187         lgres@vpHeightF          = 0.03*no_files         
3188         lgres@lgDashIndexes      = multi_dash(no_files-1:0)
3189         lbid = gsn_create_legend(\
3190                            wks,no_files,multi_legend(no_files-1:0),lgres)
3191
3192         amres = True
3193         amres@amParallelPosF   = max(string_len)*0.012+0.78               
3194         amres@amOrthogonalPosF = -0.0315*no_files+0.431         
3195         annoid1 = gsn_add_annotation(plot0,lbid,amres)
3196
3197         do plo=0,no_files-1
3198            overlay(plot0,multi_plot(plo,pl))
3199            plot(pl)=plot0
3200         end do
3201         delete(plot0)
3202      end do
3203   end if
3204
3205   if (count_var .EQ. 0) then
3206      print(" ")
3207      print("Select a variable 'var=' or use the default value")
3208      print(" ")
3209      print("Your selection '"+var+"' does not exist on the input file")
3210      print(" ")
3211      exit
3212   end if
3213
3214   if (over .EQ. 1 ) then
3215
3216      overlay(plot_u,plot_v)
3217      overlay(plot_u,plot_w)
3218      u=0
3219      overlay(plot_pt,plot_vpt)
3220      overlay(plot_pt,plot_lpt)
3221      pt=0
3222      overlay(plot_q,plot_qv)
3223      overlay(plot_q,plot_ql)
3224      q=0
3225      overlay(plot_e,plot_es)
3226      e=0
3227      overlay(plot_km,plot_kh)
3228      km=0
3229      overlay(plot_wpup,plot_wsus)
3230      overlay(plot_wpup,plot_wu)
3231      wpup=0
3232      overlay(plot_wpvp,plot_wsvs)
3233      overlay(plot_wpvp,plot_wv)
3234      wpvp=0
3235      overlay(plot_wpptp,plot_wspts)
3236      overlay(plot_wpptp,plot_wpt)
3237      wpptp=0
3238      overlay(plot_wsptsBC,plot_wptBC)
3239      wsptsBC=0
3240      overlay(plot_wpvptp,plot_wsvpts)
3241      overlay(plot_wpvptp,plot_wvpt)
3242      wpvptp=0
3243      overlay(plot_wpqp,plot_wsqs)
3244      overlay(plot_wpqp,plot_wq)
3245      wpqp=0
3246      overlay(plot_wpqvp,plot_wsqvs)
3247      overlay(plot_wpqvp,plot_wqv)
3248      wpqvp=0
3249      overlay(plot_wpsp,plot_wsss)
3250      overlay(plot_wpsp,plot_ws)
3251      wpsp=0
3252      overlay(plot_wpsap,plot_wssas)
3253      overlay(plot_wpsap,plot_wsa)
3254      wpsap=0
3255      overlay(plot_us2,plot_vs2)
3256      overlay(plot_us2,plot_ws2)
3257      us2=0
3258      overlay(plot_wsususodz,plot_wspsodz)
3259      overlay(plot_wsususodz,plot_wpeodz)
3260      wsususodz=0
3261
3262   end if
3263
3264   if (over .EQ. 1) then
3265   
3266      do varn = 0,dim-1   
3267         
3268         check = True
3269     
3270         if (prof3d .EQ. 0) then
3271            if ( isStrSubset( vNam(varn), "time") .OR. \
3272                 isStrSubset( vNam(varn), "NORM")) then
3273               check = False
3274            end if
3275         else
3276            if ( isStrSubset( vNam(varn), "time") .OR.  \
3277                 isStrSubset( vNam(varn), "zusi") .OR.  \
3278                 isStrSubset( vNam(varn), "zwwi") .OR.  \
3279                 isStrSubset( vNam(varn), "x") .OR.     \
3280                 isStrSubset( vNam(varn), "xu") .OR.    \
3281                 isStrSubset( vNam(varn), "y") .OR.     \
3282                 isStrSubset( vNam(varn), "yv") .OR.    \
3283                 isStrSubset( vNam(varn), "zu_3d") .OR. \
3284                 isStrSubset( vNam(varn), "zw_3d")) then
3285               check = False
3286            end if
3287         end if
3288
3289         if (var .NE. "all") then     
3290            check = isStrSubset( var,","+vNam(varn)+"," )
3291         end if     
3292
3293         if (check)then
3294
3295            if (prof3d .EQ. 0) then
3296               if (log_z .EQ. 1) then
3297                  z = f_att->$vNam(varn+1)$(1:dimz-1)
3298               else
3299                  z = f_att->$vNam(varn+1)$               
3300               end if
3301            else
3302               do i=0,b-1           
3303                  if (isStrSubset( a(i),"zu_3d" ))then
3304                     z_v(varn,:) = z_u
3305                     if (log_z .EQ. 1) then
3306                        z = z_v(varn,1:dimz-1)
3307                     else
3308                        z = z_v(varn,:)
3309                     end if
3310                  else
3311                     if (isStrSubset( a(i),"zw_3d" ))then
3312                        z_v(varn,:) = z_w
3313                        if (log_z .EQ. 1) then
3314                           z = z_v(varn,1:dimz-1)
3315                        else
3316                           z = z_v(varn,:)
3317                        end if
3318                     end if                   
3319                  end if
3320               end do           
3321            end if
3322
3323            z=z/norm_z
3324           
3325            if (abs(min(data(varn,:,min_z_int:max_z_int))) .GT. 10)then
3326               min_value = abs(0.01*min(data(varn,:,min_z_int:max_z_int)))
3327               max_value = abs(0.01*max(data(varn,:,min_z_int:max_z_int)))
3328            else
3329               if (abs(min(data(varn,:,min_z_int:max_z_int))) .LT. 0.01 .AND. \
3330                   abs(max(data(varn,:,min_z_int:max_z_int))) .GT. 0.01)then
3331                  min_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
3332                  max_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
3333               else
3334                  if (abs(max(data(varn,:,:))) .LT. 0.01 .AND. \
3335                      abs(min(data(varn,:,min_z_int:max_z_int))) .GT. 0.01)then
3336                     min_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
3337                     max_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
3338                  else
3339                     min_value = abs(0.1*min(data(varn,:,min_z_int:max_z_int)))
3340                     max_value = abs(0.1*max(data(varn,:,min_z_int:max_z_int)))
3341                  end if
3342               end if
3343            end if
3344            if (min(data(varn,:,min_z_int:max_z_int)) .EQ. 0 .AND.\
3345                max(data(varn,:,min_z_int:max_z_int)) .EQ. 0)then
3346               min_value = 0.1
3347               max_value = 0.1
3348            end if
3349
3350            res@gsnLeftString      = vNam(varn)
3351            res@tiXAxisString      = "("+unit(varn)+")"
3352            res@gsnRightString     = " "
3353            res@trYMinF            = min_z
3354            res@trYMaxF            = max_z 
3355            res@xyDashPattern = 0
3356
3357            if (xs .EQ. -1) then
3358               res@trXMinF = min(data(varn,:,min_z_int:max_z_int))-min_value
3359            else
3360               res@trXMinF = xs
3361            end if
3362            if (xe .EQ. -1) then
3363               res@trXMaxF = max(data(varn,:,min_z_int:max_z_int))+max_value
3364            else
3365               res@trXMaxF = xe 
3366            end if
3367            plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
3368           
3369            if (vNam(varn) .EQ. "u" .OR. vNam(varn) .EQ. "v" .OR. \
3370                vNam(varn) .EQ. "w") then
3371               if (u .EQ. 0) then
3372                  res@gsnLeftString      = "u, v and w"
3373                  res@tiXAxisString      = "("+unit(varn)+")"
3374                  res@gsnRightString     = " "
3375                  if (xs .EQ. -1) then
3376                     res@trXMinF = min((/miniu,miniv,miniw/))
3377                  else
3378                     res@trXMinF = xs
3379                  end if
3380                  if (xe .EQ. -1) then
3381                     res@trXMaxF = max((/maxiu,maxiv,maxiw/))
3382                  else
3383                     res@trXMaxF = xe 
3384                  end if 
3385                  if (vNam(varn) .EQ. "v")then
3386                     res@xyDashPattern = 1
3387                  end if
3388                  if (vNam(varn) .EQ. "w")then
3389                     res@xyDashPattern = 2
3390                  end if
3391                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3392
3393                  ; ***************************************************
3394                  ; legend for overlaid plot
3395                  ; ***************************************************
3396     
3397                  lgres                    = True
3398                  lgMonoDashIndex          = False
3399                  lgres@lgLabelFont        = "helvetica"   
3400                  lgres@lgLabelFontHeightF = font_size_legend           
3401                  lgres@vpWidthF           = 0.07           
3402                  lgres@vpHeightF          = 0.12         
3403                  lgres@lgDashIndexes      = (/0,1,2/)
3404                  lbid = gsn_create_legend(wks,3,(/"u","v","w"/),lgres)       
3405
3406                  amres = True
3407                  amres@amParallelPosF   = 0.88             
3408                  amres@amOrthogonalPosF = 0.33           
3409                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3410                  overlay(plot(n),plot_u)
3411                  u=1
3412               else
3413                  if (prof3d .EQ. 0)then
3414                     varn=varn+1
3415                  end if
3416                  continue
3417               end if       
3418            end if 
3419     
3420            if (vNam(varn) .EQ. "pt" .OR. vNam(varn) .EQ. "vpt" .OR. \
3421                vNam(varn) .EQ. "lpt") then
3422               if (pt .EQ. 0) then
3423                  res@gsnLeftString      = "pt, vpt and lpt"
3424                  res@tiXAxisString      = "("+unit(varn)+")"
3425                  res@gsnRightString     = " "
3426                  if (xs .EQ. -1) then
3427                     res@trXMinF = min((/minipt,minivpt,minilpt/))
3428                  else
3429                     res@trXMinF = xs
3430                  end if
3431                  if (xe .EQ. -1) then
3432                     res@trXMaxF = max((/maxipt,maxivpt,maxilpt/))
3433                  else
3434                     res@trXMaxF = xe 
3435                  end if
3436                  if (vNam(varn) .EQ. "vpt")then
3437                     res@xyDashPattern = 1
3438                  end if
3439                  if (vNam(varn) .EQ. "lpt")then
3440                     res@xyDashPattern = 2
3441                  end if
3442                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3443
3444                  ; ***************************************************
3445                  ; legend for overlaid plot
3446                  ; ***************************************************
3447     
3448                  lgres                    = True
3449                  lgMonoDashIndex          = False
3450                  lgres@lgLabelFont        = "helvetica"   
3451                  lgres@lgLabelFontHeightF = font_size_legend         
3452                  lgres@vpWidthF           = 0.07           
3453                  lgres@vpHeightF          = 0.12         
3454                  lgres@lgDashIndexes      = (/0,1,2/)
3455                  lbid = gsn_create_legend(wks,3,(/"pt","vpt","lpt"/),lgres)
3456                  amres = True
3457                  amres@amParallelPosF   = 0.88     
3458                  amres@amOrthogonalPosF = 0.33           
3459                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3460                  overlay(plot(n),plot_pt)
3461                  pt=1
3462               else
3463                  if (prof3d .EQ. 0)then
3464                     varn=varn+1
3465                  end if
3466                  continue       
3467               end if
3468            end if           
3469            if (vNam(varn) .EQ. "q" .OR. vNam(varn) .EQ. "qv" .OR. \
3470                vNam(varn) .EQ. "ql") then
3471               if (q .EQ. 0) then
3472                  res@gsnLeftString      = "q, qv and ql"
3473                  res@tiXAxisString      = "("+unit(varn)+")"
3474                  res@gsnRightString     = " "
3475                  if (xs .EQ. -1) then
3476                     res@trXMinF = min((/miniq,miniqv,miniql/))
3477                  else
3478                     res@trXMinF = xs
3479                  end if
3480                  if (xe .EQ. -1) then
3481                     res@trXMaxF = max((/maxiq,maxiqv,maxiql/))
3482                  else
3483                     res@trXMaxF = xe 
3484                  end if
3485                  if (vNam(varn) .EQ. "qv")then
3486                     res@xyDashPattern = 1
3487                  end if
3488                  if (vNam(varn) .EQ. "ql")then
3489                     res@xyDashPattern = 2
3490                  end if
3491                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3492
3493                  ; ***************************************************
3494                  ; legend for overlaid plot
3495                  ; ***************************************************
3496     
3497                  lgres                    = True
3498                  lgMonoDashIndex          = False
3499                  lgres@lgLabelFont        = "helvetica"   
3500                  lgres@lgLabelFontHeightF = font_size_legend           
3501                  lgres@vpWidthF           = 0.07         
3502                  lgres@vpHeightF          = 0.12         
3503                  lgres@lgDashIndexes      = (/0,1,2/)
3504                  lbid = gsn_create_legend(wks,3,(/"q","qv","ql"/),lgres)
3505
3506                  amres = True
3507                  amres@amParallelPosF   = 0.88             
3508                  amres@amOrthogonalPosF = 0.33           
3509                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3510                  overlay(plot(n),plot_q)
3511                  q=1
3512               else
3513                  if (prof3d .EQ. 0)then
3514                     varn=varn+1
3515                  end if
3516                  continue   
3517               end if
3518            end if   
3519           
3520            if (vNam(varn) .EQ. "e" .OR. vNam(varn) .EQ. "es" .OR. \
3521                vNam(varn) .EQ. "e*" ) then
3522               if (e .EQ. 0) then
3523                  res@gsnLeftString      = "e and e*"
3524                  res@tiXAxisString      = "("+unit(varn)+")"
3525                  res@gsnRightString     = " "
3526                  if (xs .EQ. -1) then
3527                     res@trXMinF = min((/minie,minies/))
3528                  else
3529                     res@trXMinF = xs
3530                  end if
3531                  if (xe .EQ. -1) then
3532                     res@trXMaxF = max((/maxie,maxies/))
3533                  else
3534                     res@trXMaxF = xe 
3535                  end if
3536                  if (vNam(varn) .EQ. "es")then
3537                     res@xyDashPattern = 1
3538                  end if
3539                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3540
3541                  ; ***************************************************
3542                  ; legend for overlaid plot
3543                  ; ***************************************************
3544     
3545                  lgres                    = True
3546                  lgMonoDashIndex          = False
3547                  lgres@lgLabelFont        = "helvetica"   
3548                  lgres@lgLabelFontHeightF = font_size_legend           
3549                  lgres@vpWidthF           = 0.07           
3550                  lgres@vpHeightF          = 0.08         
3551                  lgres@lgDashIndexes      = (/0,1,2/)
3552                  lbid = gsn_create_legend(wks,2,(/"e","e*"/),lgres)       
3553
3554                  amres = True
3555                  amres@amParallelPosF   = 0.88             
3556                  amres@amOrthogonalPosF = 0.365           
3557                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3558                  overlay(plot(n),plot_e)
3559                  e=1
3560               else
3561                  if (prof3d .EQ. 0)then
3562                     varn=varn+1
3563                  end if
3564                  continue   
3565               end if
3566            end if           
3567            if (vNam(varn) .EQ. "km" .OR. vNam(varn) .EQ. "kh") then
3568               if (km .EQ. 0) then
3569                  res@gsnLeftString      = "km and kh"
3570                  res@tiXAxisString      = "("+unit(varn)+")"
3571                  res@gsnRightString     = " "
3572                  if (xs .EQ. -1) then
3573                     res@trXMinF = min((/minikm,minikh/))
3574                  else
3575                     res@trXMinF = xs
3576                  end if
3577                  if (xe .EQ. -1) then
3578                     res@trXMaxF = max((/maxikm,maxikh/))
3579                  else
3580                     res@trXMaxF = xe 
3581                  end if
3582                  if (vNam(varn) .EQ. "kh")then
3583                     res@xyDashPattern = 1
3584                  end if
3585                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3586
3587                  ; ***************************************************
3588                  ; legend for overlaid plot
3589                  ; ***************************************************
3590     
3591                  lgres                    = True
3592                  lgMonoDashIndex          = False
3593                  lgres@lgLabelFont        = "helvetica"   
3594                  lgres@lgLabelFontHeightF = font_size_legend           
3595                  lgres@vpWidthF           = 0.07           
3596                  lgres@vpHeightF          = 0.08         
3597                  lgres@lgDashIndexes      = (/0,1,2/)
3598                  lbid = gsn_create_legend(wks,2,(/"km","kh"/),lgres)       
3599
3600                  amres = True
3601                  amres@amParallelPosF   = 0.88             
3602                  amres@amOrthogonalPosF = 0.365           
3603                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3604                  overlay(plot(n),plot_km)
3605                  km=1
3606               else
3607                  if (prof3d .EQ. 0)then
3608                     varn=varn+1
3609                  end if
3610                  continue   
3611               end if
3612            end if           
3613           
3614            if (vNam(varn) .EQ. "wpup" .OR. vNam(varn) .EQ. "wsus" .OR.      \
3615                vNam(varn) .EQ. "wu" .OR. vNam(varn) .EQ. "w"+dq+"u"+dq .OR. \
3616                vNam(varn) .EQ. "w*u*") then
3617               if (wpup .EQ. 0) then
3618                  res@gsnLeftString      = "w"+dq+"u"+dq+", w*u* and wu"
3619                  res@tiXAxisString      = "("+unit(varn)+")"
3620                  res@gsnRightString     = " "
3621                  if (xs .EQ. -1) then
3622                     res@trXMinF = min((/miniwpup,miniwsus,miniwu/))
3623                  else
3624                     res@trXMinF = xs
3625                  end if
3626                  if (xe .EQ. -1) then
3627                     res@trXMaxF = max((/maxiwpup,maxiwsus,maxiwu/))
3628                  else
3629                     res@trXMaxF = xe 
3630                  end if 
3631                  if (vNam(varn) .EQ. "wsus")then
3632                     res@xyDashPattern = 1
3633                  end if
3634                  if (vNam(varn) .EQ. "wu")then
3635                     res@xyDashPattern = 2
3636                  end if
3637                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3638
3639                  ; ***************************************************
3640                  ; legend for overlaid plot
3641                  ; ***************************************************
3642     
3643                  lgres                    = True
3644                  lgMonoDashIndex          = False
3645                  lgres@lgLabelFont        = "helvetica"   
3646                  lgres@lgLabelFontHeightF = font_size_legend           
3647                  lgres@vpWidthF           = 0.08           
3648                  lgres@vpHeightF          = 0.12         
3649                  lgres@lgDashIndexes      = (/0,1,2/)
3650                  lbid = gsn_create_legend(\
3651                                wks,3,(/"w"+dq+"u"+dq,"w*u*","wu"/),lgres)
3652
3653                  amres = True
3654                  amres@amParallelPosF   = 0.88             
3655                  amres@amOrthogonalPosF = 0.33           
3656                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3657                  overlay(plot(n),plot_wpup)
3658                  wpup=1
3659               else
3660                  if (prof3d .EQ. 0)then
3661                     varn=varn+1
3662                  end if
3663                  continue   
3664               end if
3665            end if
3666            if (vNam(varn) .EQ. "wpvp" .OR. vNam(varn) .EQ. "wsvs" .OR.     \
3667               vNam(varn) .EQ. "wv" .OR. vNam(varn) .EQ. "w"+dq+"v"+dq .OR. \
3668               vNam(varn) .EQ. "w*v*") then
3669               if (wpvp .EQ. 0) then
3670                  res@gsnLeftString      = "w"+dq+"v"+dq+", w*v* and wv"
3671                  res@tiXAxisString      = "("+unit(varn)+")"
3672                  res@gsnRightString     = " "
3673                  if (xs .EQ. -1) then
3674                     res@trXMinF = min((/miniwpvp,miniwsvs,miniwv/))
3675                  else
3676                     res@trXMinF = xs
3677                  end if
3678                  if (xe .EQ. -1) then
3679                     res@trXMaxF = max((/maxiwpvp,maxiwsvs,maxiwv/))
3680                  else
3681                     res@trXMaxF = xe 
3682                  end if
3683                  if (vNam(varn) .EQ. "wsvs")then
3684                     res@xyDashPattern = 1
3685                  end if
3686                  if (vNam(varn) .EQ. "wv")then
3687                     res@xyDashPattern = 2
3688                  end if
3689                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3690
3691                  ; ***************************************************
3692                  ; legend for overlaid plot
3693                  ; ***************************************************
3694     
3695                  lgres                    = True
3696                  lgMonoDashIndex          = False
3697                  lgres@lgLabelFont        = "helvetica"   
3698                  lgres@lgLabelFontHeightF = font_size_legend           
3699                  lgres@vpWidthF           = 0.08         
3700                  lgres@vpHeightF          = 0.12         
3701                  lgres@lgDashIndexes      = (/0,1,2/)
3702                  lbid = gsn_create_legend(\
3703                             wks,3,(/"w"+dq+"v"+dq,"w*v*","wv"/),lgres)       
3704
3705                  amres = True
3706                  amres@amParallelPosF   = 0.88             
3707                  amres@amOrthogonalPosF = 0.33           
3708                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3709                  overlay(plot(n),plot_wpvp)
3710                  wpvp=1
3711               else
3712                  if (prof3d .EQ. 0)then
3713                     varn=varn+1
3714                  end if
3715                  continue   
3716               end if
3717            end if
3718            if (vNam(varn) .EQ. "wpptp" .OR. vNam(varn) .EQ. "wspts" .OR.     \
3719                vNam(varn) .EQ. "wpt" .OR. vNam(varn) .EQ. "w"+dq+"pt"+dq .OR.\
3720                vNam(varn) .EQ. "w*pt*") then
3721               if (wpptp .EQ. 0) then                 
3722                  res@gsnLeftString      = "w"+dq+"pt"+dq+", w*pt* and wpt"
3723                  res@tiXAxisString      = "("+unit(varn)+")"
3724                  res@gsnRightString     = " "
3725                  if (xs .EQ. -1) then
3726                     res@trXMinF = min((/miniwpptp,miniwspts,miniwpt/))
3727                  else
3728                     res@trXMinF = xs
3729                  end if
3730                  if (xe .EQ. -1) then
3731                     res@trXMaxF = max((/maxiwpptp,maxiwspts,maxiwpt/))
3732                  else
3733                     res@trXMaxF = xe 
3734                  end if
3735                  if (vNam(varn) .EQ. "wspts" .OR. vNam(varn) .EQ. "w*pt*")then
3736                     res@xyDashPattern = 1
3737                  end if
3738                  if (vNam(varn) .EQ. "wpt")then
3739                     res@xyDashPattern = 2
3740                  end if
3741                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3742
3743                  ; ***************************************************
3744                  ; legend for overlaid plot
3745                  ; ***************************************************
3746     
3747                  lgres                    = True
3748                  lgMonoDashIndex          = False
3749                  lgres@lgLabelFont        = "helvetica"   
3750                  lgres@lgLabelFontHeightF = font_size_legend           
3751                  lgres@vpWidthF           = 0.09           
3752                  lgres@vpHeightF          = 0.12         
3753                  lgres@lgDashIndexes      = (/0,1,2/)             
3754                  lbid = gsn_create_legend(\
3755                               wks,3,(/"w"+dq+"pt"+dq,"w*pt*","wpt"/),lgres)
3756
3757                  amres = True
3758                  amres@amParallelPosF   = 0.88             
3759                  amres@amOrthogonalPosF = 0.33           
3760                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3761                  overlay(plot(n),plot_wpptp)
3762                  wpptp=1
3763               else
3764                  if (prof3d .EQ. 0)then
3765                     varn=varn+1
3766                  end if
3767                  continue   
3768               end if
3769            end if
3770            if (vNam(varn) .EQ. "wsptsBC" .OR. vNam(varn) .EQ. "wptBC" .OR.\
3771                vNam(varn) .EQ. "w*pt*BC") then
3772               if (wsptsBC .EQ. 0) then
3773                  res@gsnLeftString      = "w*pt*BC and wptBC"
3774                  res@tiXAxisString      = "("+unit(varn)+")"
3775                  res@gsnRightString     = " "
3776                  if (xs .EQ. -1) then
3777                     res@trXMinF = min((/miniwsptsBC,miniwptBC/))
3778                  else
3779                     res@trXMinF = xs
3780                  end if
3781                  if (xe .EQ. -1) then
3782                     res@trXMaxF = max((/maxiwsptsBC,maxiwptBC/))
3783                  else
3784                     res@trXMaxF = xe 
3785                  end if
3786                  if (vNam(varn) .EQ. "wptBC")then
3787                     res@xyDashPattern = 1
3788                  end if
3789                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3790
3791                  ; ***************************************************
3792                  ; legend for overlaid plot
3793                  ; ***************************************************
3794     
3795                  lgres                    = True
3796                  lgMonoDashIndex          = False
3797                  lgres@lgLabelFont        = "helvetica"   
3798                  lgres@lgLabelFontHeightF = font_size_legend           
3799                  lgres@vpWidthF           = 0.1           
3800                  lgres@vpHeightF          = 0.12         
3801                  lgres@lgDashIndexes      = (/0,1,2/)
3802                  lbid = gsn_create_legend(\
3803                                        wks,3,(/"w*pt*BC","wptBC"/),lgres)
3804
3805                  amres = True
3806                  amres@amParallelPosF   = 0.88             
3807                  amres@amOrthogonalPosF = 0.33           
3808                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3809                  overlay(plot(n),plot_wsptsBC)
3810                  wsptsBC=1
3811               else
3812                  if (prof3d .EQ. 0)then
3813                     varn=varn+1
3814                  end if
3815                  continue   
3816               end if 
3817            end if             
3818            if (vNam(varn) .EQ. "wpvptp" .OR. vNam(varn) .EQ. "wsvpts" .OR. \
3819                vNam(varn) .EQ. "wvpt" .OR. vNam(varn) .EQ. \
3820                "w"+dq+"vpt"+dq .OR. vNam(varn) .EQ. "w*vpt*") then
3821               if (wpvptp .EQ. 0) then
3822                  res@gsnLeftString      = "w"+dq+"vpt"+dq+", w*vpt* and wvpt"
3823                  res@tiXAxisString      = "("+unit(varn)+")"
3824                  res@gsnRightString     = " "
3825                  if (xs .EQ. -1) then
3826                     res@trXMinF = min((/miniwpvptp,miniwsvpts,miniwvpt/))
3827                  else
3828                     res@trXMinF = xs
3829                  end if
3830                  if (xe .EQ. -1) then
3831                     res@trXMaxF = max((/maxiwpvptp,maxiwsvpts,maxiwvpt/))
3832                  else
3833                     res@trXMaxF = xe 
3834                  end if
3835                  if (vNam(varn) .EQ. "wsvpts")then
3836                     res@xyDashPattern = 1
3837                  end if
3838                  if (vNam(varn) .EQ. "wvpt")then
3839                     res@xyDashPattern = 2
3840                  end if
3841                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3842
3843                  ; ***************************************************
3844                  ; legend for overlaid plot
3845                  ; ***************************************************
3846     
3847                  lgres                    = True
3848                  lgMonoDashIndex          = False
3849                  lgres@lgLabelFont        = "helvetica"   
3850                  lgres@lgLabelFontHeightF = font_size_legend           
3851                  lgres@vpWidthF           = 0.1           
3852                  lgres@vpHeightF          = 0.12         
3853                  lgres@lgDashIndexes      = (/0,1,2/)
3854                  lbid = gsn_create_legend(\
3855                             wks,3,(/"w"+dq+"vpt"+dq,"w*vpt*","wvpt"/),lgres)
3856                  amres = True
3857                  amres@amParallelPosF   = 0.88             
3858                  amres@amOrthogonalPosF = 0.33           
3859                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3860                  overlay(plot(n),plot_wpvptp)
3861                  wpvptp=1
3862               else
3863                  if (prof3d .EQ. 0)then
3864                     varn=varn+1
3865                  end if
3866                  continue   
3867               end if
3868            end if
3869            if (vNam(varn) .EQ. "wpqp" .OR. vNam(varn) .EQ. "wsqs" .OR.      \
3870                vNam(varn) .EQ. "wq" .OR. vNam(varn) .EQ. "w"+dq+"q"+dq .OR. \
3871                vNam(varn) .EQ. "w*q*") then
3872               if (wpqp .EQ. 0) then
3873                  res@gsnLeftString      = "w"+dq+"q"+dq+", w*q* and wq"
3874                  res@tiXAxisString      = "("+unit(varn)+")"
3875                  res@gsnRightString     = " "
3876                  if (xs .EQ. -1) then
3877                     res@trXMinF = min((/miniwpqp,miniwsqs,miniwq/))
3878                  else
3879                     res@trXMinF = xs
3880                  end if
3881                  if (xe .EQ. -1) then
3882                     res@trXMaxF = max((/maxiwpqp,maxiwsqs,maxiwq/))
3883                  else
3884                     res@trXMaxF = xe 
3885                  end if 
3886                  if (vNam(varn) .EQ. "wsqs")then
3887                     res@xyDashPattern = 1
3888                  end if
3889                  if (vNam(varn) .EQ. "wq")then
3890                     res@xyDashPattern = 2
3891                  end if
3892                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3893
3894                  ; ***************************************************
3895                  ; legend for overlaid plot
3896                  ; ***************************************************
3897     
3898                  lgres                    = True
3899                  lgMonoDashIndex          = False
3900                  lgres@lgLabelFont        = "helvetica"   
3901                  lgres@lgLabelFontHeightF = font_size_legend           
3902                  lgres@vpWidthF           = 0.08           
3903                  lgres@vpHeightF          = 0.12         
3904                  lgres@lgDashIndexes      = (/0,1,2/)
3905                  lbid = gsn_create_legend(\
3906                             wks,3,(/"w"+dq+"q"+dq,"w*q*","wq"/),lgres)       
3907
3908                  amres = True
3909                  amres@amParallelPosF   = 0.88             
3910                  amres@amOrthogonalPosF = 0.33           
3911                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3912                  overlay(plot(n),plot_wpqp)
3913                  wpqp=1
3914               else
3915                  if (prof3d .EQ. 0)then
3916                     varn=varn+1
3917                  end if
3918                  continue   
3919               end if
3920            end if
3921            if (vNam(varn) .EQ. "wpqvp" .OR. vNam(varn) .EQ. "wsqvs" .OR.     \
3922                vNam(varn) .EQ. "wqv" .OR. vNam(varn) .EQ. "w"+dq+"qv"+dq .OR.\
3923                vNam(varn) .EQ. "w*qv*") then
3924               if (wpqvp .EQ. 0) then
3925                  res@gsnLeftString      ="w"+dq+"qv"+dq+" , w*qv* and wqv"
3926                  res@tiXAxisString      = "("+unit(varn)+")"
3927                  res@gsnRightString     = " "
3928                  if (xs .EQ. -1) then
3929                     res@trXMinF = min((/miniwpqp,miniwsqvs,miniwqv/))
3930                  else
3931                     res@trXMinF = xs
3932                  end if
3933                  if (xe .EQ. -1) then
3934                     res@trXMaxF = max((/maxiwpqp,maxiwsqvs,maxiwqv/))
3935                  else
3936                     res@trXMaxF = xe 
3937                  end if
3938                  if (vNam(varn) .EQ. "wsqvs")then
3939                     res@xyDashPattern = 1
3940                  end if
3941                  if (vNam(varn) .EQ. "wqv")then
3942                     res@xyDashPattern = 2
3943                  end if
3944                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3945
3946                  ; ***************************************************
3947                  ; legend for overlaid plot
3948                  ; ***************************************************
3949     
3950                  lgres                    = True
3951                  lgMonoDashIndex          = False
3952                  lgres@lgLabelFont        = "helvetica"   
3953                  lgres@lgLabelFontHeightF = font_size_legend           
3954                  lgres@vpWidthF           = 0.09           
3955                  lgres@vpHeightF          = 0.12         
3956                  lgres@lgDashIndexes      = (/0,1,2/)
3957                  lbid = gsn_create_legend(\
3958                                wks,3,(/"w"+dq+"qv"+dq,"w*qv*","wqv"/),lgres)
3959
3960                  amres = True
3961                  amres@amParallelPosF   = 0.88             
3962                  amres@amOrthogonalPosF = 0.33           
3963                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
3964                  overlay(plot(n),plot_wpqvp)
3965                  wpqvp=1
3966               else
3967                  if (prof3d .EQ. 0)then
3968                     varn=varn+1
3969                  end if
3970                  continue   
3971               end if
3972            end if
3973            if (vNam(varn) .EQ. "wpsp" .OR. vNam(varn) .EQ. "wsss" .OR.     \
3974                vNam(varn) .EQ. "ws" .OR. vNam(varn) .EQ. "w"+dq+"s"+dq .OR.\
3975                vNam(varn) .EQ. "w*s*") then
3976               if (wpsp .EQ. 0) then
3977                  res@gsnLeftString      = "w"+dq+"s"+dq+", w*s* and ws"
3978                  res@tiXAxisString      = "("+unit(varn)+")"
3979                  res@gsnRightString     = " "
3980                  if (xs .EQ. -1) then
3981                     res@trXMinF = min((/miniwpsp,miniwsss,miniws/))
3982                  else
3983                     res@trXMinF = xs
3984                  end if
3985                  if (xe .EQ. -1) then
3986                     res@trXMaxF = max((/maxiwpsp,maxiwsss,maxiws/))
3987                  else
3988                     res@trXMaxF = xe 
3989                  end if
3990                  if (vNam(varn) .EQ. "wsss")then
3991                     res@xyDashPattern = 1
3992                  end if
3993                  if (vNam(varn) .EQ. "ws")then
3994                     res@xyDashPattern = 2
3995                  end if
3996                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3997
3998                  ; ***************************************************
3999                  ; legend for overlaid plot
4000                  ; ***************************************************
4001     
4002                  lgres                    = True
4003                  lgMonoDashIndex          = False
4004                  lgres@lgLabelFont        = "helvetica"   
4005                  lgres@lgLabelFontHeightF = font_size_legend           
4006                  lgres@vpWidthF           = 0.08           
4007                  lgres@vpHeightF          = 0.12         
4008                  lgres@lgDashIndexes      = (/0,1,2/)
4009                  lbid = gsn_create_legend(\
4010                           wks,3,(/"w"+dq+"s"+dq,"w*s*","ws"/),lgres)       
4011
4012                  amres = True
4013                  amres@amParallelPosF   = 0.88             
4014                  amres@amOrthogonalPosF = 0.33           
4015                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
4016                  overlay(plot(n),plot_wpsp)
4017                  wpsp=1
4018               else
4019                  if (prof3d .EQ. 0)then
4020                     varn=varn+1
4021                  end if
4022                  continue   
4023               end if
4024            end if
4025            if (vNam(varn) .EQ. "wpsap" .OR.vNam(varn) .EQ. "wssas" .OR.      \
4026                vNam(varn) .EQ. "wsa" .OR. vNam(varn) .EQ. "w"+dq+"sa"+dq .OR.\
4027                vNam(varn) .EQ. "w*sa*") then
4028               if (wpsap .EQ. 0) then
4029                  res@gsnLeftString      = "w"+dq+"sa"+dq+", w*sa* and wsa"
4030                  res@tiXAxisString      = "("+unit(varn)+")"
4031                  res@gsnRightString     = " "
4032                  if (xs .EQ. -1) then
4033                     res@trXMinF = min((/miniwpsap,miniwssas,miniwsa/))
4034                  else
4035                     res@trXMinF = xs
4036                  end if
4037                  if (xe .EQ. -1) then
4038                     res@trXMaxF = max((/maxiwpsap,maxiwssas,maxiwsa/))
4039                  else
4040                     res@trXMaxF = xe 
4041                  end if
4042                  if (vNam(varn) .EQ. "wssas")then
4043                     res@xyDashPattern = 1
4044                  end if
4045                  if (vNam(varn) .EQ. "wsa")then
4046                     res@xyDashPattern = 2
4047                  end if
4048                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
4049
4050                  ; ***************************************************
4051                  ; legend for overlaid plot
4052                  ; ***************************************************
4053     
4054                  lgres                    = True
4055                  lgMonoDashIndex          = False
4056                  lgres@lgLabelFont        = "helvetica"   
4057                  lgres@lgLabelFontHeightF = font_size_legend           
4058                  lgres@vpWidthF           = 0.09           
4059                  lgres@vpHeightF          = 0.12         
4060                  lgres@lgDashIndexes      = (/0,1,2/)
4061                  lbid = gsn_create_legend(\
4062                             wks,3,(/"w"+dq+"sa"+dq,"w*sa*","wsa"/),lgres)
4063                  amres = True
4064                  amres@amParallelPosF   = 0.88             
4065                  amres@amOrthogonalPosF = 0.33           
4066                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
4067                  overlay(plot(n),plot_wpsap)
4068                  wpsap=1
4069               else
4070                  if (prof3d .EQ. 0)then
4071                     varn=varn+1
4072                  end if
4073                  continue   
4074               end if
4075            end if
4076         
4077            if (vNam(varn) .EQ. "us2" .OR. vNam(varn) .EQ. "vs2" .OR. \
4078                vNam(varn) .EQ. "ws2" .OR. vNam(varn) .EQ. "u*2" .OR. \
4079                vNam(varn) .EQ. "v*2" .OR. vNam(varn) .EQ. "w*2" ) then
4080               if (us2 .EQ. 0) then
4081                  res@gsnLeftString      = "u*2, v*2 and w*2"
4082                  res@tiXAxisString      = "("+unit(varn)+")"
4083                  res@gsnRightString     = " "
4084                  if (xs .EQ. -1) then
4085                     res@trXMinF = min((/minius2,minivs2,miniws2/))
4086                  else
4087                     res@trXMinF = xs
4088                  end if
4089                  if (xe .EQ. -1) then
4090                     res@trXMaxF = max((/maxius2,maxivs2,maxiws2/))
4091                  else
4092                     res@trXMaxF = xe 
4093                  end if
4094                  if (vNam(varn) .EQ. "vs2")then
4095                     res@xyDashPattern = 1
4096                  end if
4097                  if (vNam(varn) .EQ. "ws2")then
4098                     res@xyDashPattern = 2
4099                  end if
4100                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
4101
4102                  ; ***************************************************
4103                  ; legend for overlaid plot
4104                  ; ***************************************************
4105     
4106                  lgres                    = True
4107                  lgMonoDashIndex          = False
4108                  lgres@lgLabelFont        = "helvetica"   
4109                  lgres@lgLabelFontHeightF = font_size_legend           
4110                  lgres@vpWidthF           = 0.07           
4111                  lgres@vpHeightF          = 0.12         
4112                  lgres@lgDashIndexes      = (/0,1,2/)
4113                  lbid = gsn_create_legend(wks,3,(/"u*2","v*2","w*2"/),lgres)
4114                  amres = True
4115                  amres@amParallelPosF   = 0.88             
4116                  amres@amOrthogonalPosF = 0.33           
4117                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
4118                  overlay(plot(n),plot_us2)
4119                  us2=1
4120               else
4121                  if (prof3d .EQ. 0)then
4122                     varn=varn+1
4123                  end if
4124                  continue   
4125               end if
4126            end if
4127           
4128            if (vNam(varn) .EQ. "wsususodz" .OR. \
4129                vNam(varn) .EQ. "wspsodz" .OR.   \
4130                vNam(varn) .EQ. "wpeodz" .OR.    \
4131                vNam(varn) .EQ. "w*u*u*:dz" .OR. \
4132                vNam(varn) .EQ. "w*p*:dz" .OR.   \
4133                vNam(varn) .EQ. "w"+dq+"e:dz") then
4134               if (wsususodz .EQ. 0) then
4135                  res@gsnLeftString      = "w*u*u*:dz, w*p*:dz and w"+dq+"e:dz"
4136                  res@tiXAxisString      = "("+unit(varn)+")"
4137                  res@gsnRightString     = " "
4138                  if (xs .EQ. -1) then
4139                     res@trXMinF = min((/miniwsususodz,\
4140                                                   miniwspsodz,miniwpeodz/))
4141                  else
4142                     res@trXMinF = xs
4143                  end if
4144                  if (xe .EQ. -1) then
4145                     res@trXMaxF = max((/maxiwsususodz,maxiwspsodz,\
4146                                                               maxiwpeodz/))
4147                  else
4148                     res@trXMaxF = xe 
4149                  end if
4150                  if (vNam(varn) .EQ. "wspsodz")then
4151                     res@xyDashPattern = 1
4152                  end if
4153                  if (vNam(varn) .EQ. "wpeodz")then
4154                     res@xyDashPattern = 2
4155                  end if
4156                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
4157
4158                  ; ***************************************************
4159                  ; legend for overlaid plot
4160                  ; ***************************************************
4161     
4162                  lgres                    = True
4163                  lgMonoDashIndex          = False
4164                  lgres@lgLabelFont        = "helvetica"   
4165                  lgres@lgLabelFontHeightF = font_size_legend           
4166                  lgres@vpWidthF           = 0.12           
4167                  lgres@vpHeightF          = 0.12         
4168                  lgres@lgDashIndexes      = (/0,1,2/)
4169                  lbid = gsn_create_legend(\
4170                           wks,3,(/"w*u*u*:dz","w*p*:dz","w"+dq+"e:dz"/),lgres)
4171                  amres = True
4172                  amres@amParallelPosF   = 0.88             
4173                  amres@amOrthogonalPosF = 0.33           
4174                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)
4175                  overlay(plot(n),plot_wsususodz)
4176                  wsususodz=1
4177               else
4178                  if (prof3d .EQ. 0)then
4179                     varn=varn+1
4180                  end if
4181                  continue   
4182               end if
4183            end if     
4184            n=n+1
4185            if (prof3d .EQ. 0)then
4186               varn=varn+1
4187            end if   
4188         end if
4189      end do
4190   end if
4191   
4192   com_var_avail=new(count_var,string)   
4193
4194   if (combine .EQ. 1) then
4195      co=0     
4196      n_o=0
4197      do varn = 0,dim-1
4198 
4199         check = True
4200     
4201         if (prof3d .EQ. 0) then
4202            if ( isStrSubset( vNam(varn), "time") .OR. \
4203                 isStrSubset( vNam(varn), "NORM")) then
4204               check = False
4205            end if
4206         else
4207            if ( isStrSubset( vNam(varn), "time") .OR.  \
4208                 isStrSubset( vNam(varn), "zusi") .OR.  \
4209                 isStrSubset( vNam(varn), "zwwi") .OR.  \
4210                 isStrSubset( vNam(varn), "x") .OR.     \
4211                 isStrSubset( vNam(varn), "xu") .OR.    \
4212                 isStrSubset( vNam(varn), "y") .OR.     \
4213                 isStrSubset( vNam(varn), "yv") .OR.    \
4214                 isStrSubset( vNam(varn), "zu_3d") .OR. \
4215                 isStrSubset( vNam(varn), "zw_3d")) then
4216               check = False
4217            end if
4218         end if
4219
4220         if (var .NE. "all") then         
4221            check = isStrSubset( var,","+vNam(varn)+"," )
4222         end if     
4223
4224         if (check)then
4225           
4226            if (prof3d .EQ. 0) then
4227               if (log_z .EQ. 1) then
4228                  z = f_att->$vNam(varn+1)$(1:dimz-1)
4229               else
4230                  z = f_att->$vNam(varn+1)$               
4231               end if
4232            else
4233               do i=0,b-1           
4234                  if (isStrSubset( a(i),"zu_3d" ))then
4235                     z_v(varn,:) = z_u
4236                     if (log_z .EQ. 1) then
4237                        z = z_v(varn,1:dimz-1)
4238                     else
4239                        z = z_v(varn,:)
4240                     end if
4241                  else
4242                     if (isStrSubset( a(i),"zw_3d" ))then
4243                        z_v(varn,:) = z_w
4244                        if (log_z .EQ. 1) then
4245                           z = z_v(varn,1:dimz-1)
4246                        else
4247                           z = z_v(varn,:)
4248                        end if
4249                     end if                   
4250                  end if
4251               end do           
4252            end if
4253
4254            z=z/norm_z
4255           
4256            com_var_avail(n_o)=vNam(varn)
4257           
4258            com=isStrSubset( c_var,","+vNam(varn)+"," )
4259            if (com)then
4260               co = co+1           
4261               if (n_o .EQ. 1) then
4262                  res@xyDashPattern  = 1                                   
4263               else           
4264                  if (n_o .EQ. 2) then
4265                     res@xyDashPattern  = 2
4266                  else
4267                     res@xyDashPattern  = 0
4268                     res@gsnLeftString  = "Combined Plot of "+c_var
4269                     res@tiXAxisString      = "("+unit(varn)+")"
4270                     res@gsnRightString     = " "
4271                     if (xs .EQ. -1) then
4272                        res@trXMinF = min(mini)
4273                     else
4274                        res@trXMinF = xs
4275                     end if
4276                     if (xe .EQ. -1) then
4277                        res@trXMaxF = max(maxi)
4278                     else
4279                        res@trXMaxF = xe 
4280                     end if
4281                  end if
4282               end if
4283               label(n_o)=vNam(varn)
4284               color_o(n_o)=237
4285               plot_o(n_o)=gsn_csm_xy(wks,data(varn,:,:),z,res)
4286               n_o=n_o+1
4287            end if
4288            if (prof3d .EQ. 0)then
4289               varn=varn+1
4290            end if           
4291         end if
4292      end do
4293   
4294      if(number_comb .EQ. 2)then
4295         if (co .EQ. 2)then
4296            overlay(plot_o(0),plot_o(1))
4297         else
4298            print(" ")
4299            print("combining is not possible,")
4300            print("'c_var'(= "+c_var+") must include two variables of "+\
4301                  "the general plots = ")
4302            print("- "+com_var_avail)
4303            print("be sure to have one comma before and after the variable")
4304            print(" ")
4305            exit 
4306         end if
4307      end if
4308      if(number_comb .EQ. 3)then
4309         if (co .EQ. 3)then
4310            overlay(plot_o(0),plot_o(1))
4311            overlay(plot_o(0),plot_o(2))
4312         else
4313            print(" ")
4314            print("combining is not possible,")
4315            print("'c_var'(= "+c_var+") must include three variables of "+\
4316                  "the general plots = ")
4317            print("- "+com_var_avail)
4318            print("be sure to have one comma before and after the variable")
4319            print(" ")
4320            exit
4321         end if
4322      end if
4323
4324      ; ***************************************************
4325      ; legend for combined plot
4326      ; ***************************************************
4327     
4328      lgres                    = True
4329      lgMonoDashIndex          = False
4330      lgres@lgDashIndexes      = (/0,1,2/)
4331      lgres@lgLabelFont        = "helvetica"   
4332      lgres@lgLabelFontHeightF = font_size_legend           
4333      lgres@vpWidthF           = 0.12           
4334      lgres@vpHeightF          = 0.1           
4335 
4336      lbid = gsn_create_legend(wks,number_comb,label,lgres)       
4337
4338      amres = True
4339      amres@amParallelPosF   = 0.65                 
4340      amres@amOrthogonalPosF = -0.2           
4341      annoid1 = gsn_add_annotation(plot_o(0),lbid,amres)
4342   
4343      plot(0) = plot_o(0)
4344
4345   end if
4346
4347   ; ***************************************************
4348   ; merge plots onto one page
4349   ; ***************************************************
4350
4351   do m=0,n-1
4352      plot_(m)=plot(n-1-m)
4353   end do
4354
4355   no_frames = 0
4356
4357   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \
4358       n .gt. no_rows*no_columns) then
4359      gsn_panel(wks,plot_,(/n,1/),resP)
4360      print(" ")
4361      print("Outputs to .eps or .epsi have only one frame")
4362      print(" ")
4363   else   
4364      do i = 0,n-1, no_rows*no_columns
4365         if( (i+no_rows*no_columns) .gt. (n-1)) then
4366            gsn_panel(wks,plot_(i:n-1),(/no_rows,no_columns/),resP)
4367            no_frames = no_frames + 1 
4368         else
4369            gsn_panel(wks,plot_(i:i+no_rows*no_columns-1),\
4370                                                (/no_rows,no_columns/),resP)
4371            no_frames = no_frames + 1 
4372         end if
4373      end do
4374   end if
4375
4376    if (format_out .EQ. "png" ) then
4377     png_output = new((/no_frames/), string)
4378     j = 0
4379     do i=0, no_frames-1
4380       j = i + 1
4381       if (j .LE. 9) then
4382         png_output(i) = file_out+".00000"+j+".png"
4383       end if
4384       if (j .GT. 9 .AND. j .LE. 99) then
4385         png_output(i) = file_out+".0000"+j+".png"
4386       end if
4387       if (j .GT. 99 .AND. j .LE. 999) then
4388         png_output(i) = file_out+".000"+j+".png"
4389       end if
4390       if (j .GT. 999) then
4391         png_output(i) = file_out+".00"+j+".png"
4392       end if
4393
4394       ;using imagemagick's convert for reducing the white
4395       ;space around the plot
4396       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
4397              png_output(i) + " " + png_output(i)
4398       system(cmd)
4399     end do
4400
4401     print(" ")
4402     print("Output to: "+ png_output)
4403     print(" ")
4404   else
4405     print(" ")
4406     print("Output to: " + file_out +"."+ format_out)
4407     print(" ")
4408   end if
4409
4410end
Note: See TracBrowser for help on using the repository browser.