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

Last change on this file since 353 was 353, checked in by heinze, 15 years ago

small adjustments of plotting area

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