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

Last change on this file since 723 was 624, checked in by heinze, 13 years ago

Calculation of q*2 added

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