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

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

New parameter time_stride is in profiles.ncl available.

File size: 151.8 KB
Line 
1load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4
5;***************************************************
6; load ncl_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   
1527   
1528   do varn = 0,dim-1
1529
1530      check = True
1531     
1532      if (prof3d .EQ. 0) then
1533         if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
1534            check = False
1535         end if
1536      else
1537         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
1538            check = False
1539         end if
1540      end if
1541
1542      if (var .NE. "all") then
1543         check = isStrSubset( var,","+vNam(varn)+"," )
1544      end if
1545
1546      if (combine .EQ. 1) then         
1547         com=isStrSubset(c_var,","+vNam(varn)+"," )     
1548         if (com) then     
1549            if (prof3d .EQ. 0) then                 
1550               temp     = f[:]->$vNam(varn)$         
1551               temp_att = f_att->$vNam(varn)$
1552               if (log_z .EQ. 1) then
1553                  do j=0,np-1
1554                     data(varn,j,:) = temp(ti_in(j),1:dimz-1)
1555                  end do
1556               else
1557                  do j=0,np-1
1558                     data(varn,j,:) = temp(ti_in(j),0:dimz-1)
1559                  end do
1560               end if
1561            else
1562               if (log_z .EQ. 1) then
1563                  do i=1,dimz-1
1564                     do j=0,np-1
1565                        temp= f[:]->$vNam(varn)$
1566                        temp_att = f_att->$vNam(varn)$
1567                        data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1568                        data(varn,j,i-1) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1569                     end do
1570                  end do
1571               else
1572                  do i=0,dimz-1
1573                     do j=0,np-1
1574                        temp= f[:]->$vNam(varn)$
1575                        temp_att = f_att->$vNam(varn)$
1576                        data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1577                        data(varn,j,i) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1578                     end do
1579                  end do
1580               end if
1581               print(" ")
1582               print("Variable for combine '"+vNam(varn)+"' is read")
1583               print(" ")
1584            end if                 
1585            unit(varn) = temp_att@units
1586            if (n_o .GT. number_comb-1) then
1587               print(" ")
1588               print("Set 'number_comb' to the number of overlaying variables ('c_var' = "+c_var+")")
1589               print(" ")
1590               exit
1591            end if
1592            if (abs(min(data(varn,:,:))) .GT. 10)then
1593               min_value = abs(0.01*min(data(varn,:,:)))
1594               max_value = abs(0.01*max(data(varn,:,:)))
1595            else
1596               if (abs(min(data(varn,:,:))) .LT. 0.01 .AND. abs(max(data(varn,:,:))) .GT. 0.01)then
1597                  min_value = abs(0.1*max(data(varn,:,:)))
1598                  max_value = abs(0.1*max(data(varn,:,:)))
1599               else
1600                  if (abs(max(data(varn,:,:))) .LT. 0.01 .AND. abs(min(data(varn,:,:))) .GT. 0.01)then
1601                     min_value = abs(0.1*min(data(varn,:,:)))
1602                     max_value = abs(0.1*min(data(varn,:,:)))
1603                  else
1604                     min_value = abs(0.1*min(data(varn,:,:)))
1605                     max_value = abs(0.1*max(data(varn,:,:)))
1606                  end if
1607               end if
1608            end if
1609            if (min(data(varn,:,:)) .EQ. 0 .AND. max(data(varn,:,:)) .EQ. 0)then
1610               min_value = 0.1
1611               max_value = 0.1
1612            end if
1613            mini(n_o)=min(data(varn,:,:))
1614            maxi(n_o)=max(data(varn,:,:))
1615            n_o=n_o+1
1616         end if
1617      end if
1618
1619      if(check) then
1620         
1621         count_var=count_var+1
1622
1623         if (prof3d .EQ. 0) then         
1624            temp = f[:]->$vNam(varn)$
1625            temp_att = f_att->$vNam(varn)$
1626         else
1627             if (log_z .EQ. 1) then
1628               do i=1,dimz-1
1629                  do j=0,np-1
1630                     temp= f[:]->$vNam(varn)$
1631                     temp_att = f_att->$vNam(varn)$
1632                     data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1633                     data(varn,j,i-1) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1634                     delete(data_temp)
1635                  end do
1636               end do
1637            else
1638               do i=0,dimz-1
1639                  do j=0,np-1
1640                     temp= f[:]->$vNam(varn)$
1641                     temp_att = f_att->$vNam(varn)$
1642                     data_temp = temp(ti_in(j),i,start_y:end_y,start_x:end_x)
1643                     data_temp!0 = "t"
1644                     data_temp!1 = "z"
1645                     data(varn,j,i) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
1646                     delete(data_temp)
1647                  end do
1648               end do
1649            end if
1650            print(" ")
1651            print("Variable '"+vNam(varn)+"' is read")
1652            print(" ")
1653            unit(varn) = temp_att@units
1654            a=getvardims(temp_att)
1655            b=dimsizes(a)
1656         end if
1657
1658         if (prof3d .EQ. 0) then
1659            if (log_z .EQ. 1) then
1660               z = f_att->$vNam(varn+1)$(1:dimz-1)
1661               unit(varn) = temp_att@units
1662               do j=0,np-1
1663                  data(varn,j,:) = temp(ti_in(j),1:dimz-1)
1664               end do
1665            else
1666               z = f_att->$vNam(varn+1)$
1667               unit(varn) = temp_att@units
1668               do j=0,np-1
1669                  data(varn,j,:) = temp(ti_in(j),:)
1670               end do
1671            end if
1672         else
1673            do i=0,b-1           
1674               if (isStrSubset( a(i),"zu_3d" ))then
1675                  z_v(varn,:) = z_u
1676                  if (log_z .EQ. 1) then
1677                     z = z_v(varn,1:dimz-1)
1678                  else
1679                     z = z_v(varn,:)
1680                  end if
1681               else
1682                  if (isStrSubset( a(i),"zw_3d" ))then
1683                     z_v(varn,:) = z_w
1684                     if (log_z .EQ. 1) then
1685                        z = z_v(varn,1:dimz-1)
1686                     else
1687                        z = z_v(varn,:)
1688                     end if
1689                  end if                   
1690               end if
1691            end do           
1692         end if
1693         
1694         if (nof .EQ. 0) then
1695            z_(n,:)=z/norm_z
1696            z    = z_(n,:)
1697         else
1698            z=z/norm_z
1699         end if
1700         
1701         if (abs(min(data(varn,:,:))) .GT. 10)then
1702            min_value = abs(0.01*min(data(varn,:,:)))
1703            max_value = abs(0.01*max(data(varn,:,:)))
1704         else
1705            if (abs(min(data(varn,:,:))) .LT. 0.01 .AND. abs(max(data(varn,:,:))) .GT. 0.01)then
1706               min_value = abs(0.1*max(data(varn,:,:)))
1707               max_value = abs(0.1*max(data(varn,:,:)))
1708            else
1709               if (abs(max(data(varn,:,:))) .LT. 0.01 .AND. abs(min(data(varn,:,:))) .GT. 0.01)then
1710                  min_value = abs(0.1*min(data(varn,:,:)))
1711                  max_value = abs(0.1*min(data(varn,:,:)))
1712               else
1713                  min_value = abs(0.1*min(data(varn,:,:)))
1714                  max_value = abs(0.1*max(data(varn,:,:)))
1715               end if
1716            end if
1717         end if
1718         if (min(data(varn,:,:)) .EQ. 0 .AND. max(data(varn,:,:)) .EQ. 0)then
1719            min_value = 0.1
1720            max_value = 0.1
1721         end if
1722   
1723         if (over .EQ. 0) then 
1724            res@gsnLeftString      = vNam(varn)
1725            res@tiXAxisString      = "["+unit(varn)+"]"
1726            res@gsnRightString     = " "
1727            res@trYMinF            = min_z
1728            res@trYMaxF            = max_z
1729            if (xs .EQ. -1) then
1730               res@trXMinF            = min(data(varn,:,:))-min_value
1731            else
1732               res@trXMinF            = xs
1733            end if
1734            if (xe .EQ. -1) then
1735               res@trXMaxF            = max(data(varn,:,:))+max_value
1736            else
1737               res@trXMaxF            = xe 
1738            end if         
1739            plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
1740         end if 
1741
1742            if (vNam(varn) .EQ. "u") then
1743               miniu=min(data(varn,:,:))-min_value
1744               maxiu=max(data(varn,:,:))+max_value
1745               if (over .EQ. 1) then
1746                  res@xyDashPattern  = 0
1747                  plot_u = gsn_csm_xy(wks,data(varn,:,:),z,res)
1748               else
1749                  res@gsnLeftString      = vNam(varn)
1750                  res@tiXAxisString      = "["+unit(varn)+"]"
1751                  res@gsnRightString     = " "                 
1752                  if (xs .EQ. -1) then 
1753                     res@trXMinF            = miniu
1754                  else
1755                     res@trXMinF            = xs
1756                  end if
1757                  if (xe .EQ. -1) then       
1758                     res@trXMaxF            = maxiu
1759                  else
1760                     res@trXMaxF            = xe 
1761                  end if               
1762                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
1763               end if
1764            end if
1765            if (vNam(varn) .EQ. "v") then
1766               miniv=min(data(varn,:,:))-min_value
1767               maxiv=max(data(varn,:,:))+max_value
1768               if (over .EQ. 1) then
1769                  res@xyMonoDashPattern = True
1770                  res@xyDashPattern  = 1
1771                  plot_v = gsn_csm_xy(wks,data(varn,:,:),z,res)
1772               else
1773                  res@gsnLeftString      = vNam(varn)
1774                  res@tiXAxisString      = "["+unit(varn)+"]"
1775                  res@gsnRightString     = " "                 
1776                  if (xs .EQ. -1) then
1777                     res@trXMinF            = miniv
1778                  else
1779                     res@trXMinF            = xs
1780                  end if
1781                  if (xe .EQ. -1) then
1782                     res@trXMaxF            = maxiv
1783                  else
1784                     res@trXMaxF            = xe 
1785                  end if               
1786                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1787               end if 
1788            end if
1789            if (vNam(varn) .EQ. "w") then
1790               miniw=min(data(varn,:,:))-min_value
1791               maxiw=max(data(varn,:,:))+max_value
1792               if (over .EQ. 1) then
1793                  res@xyDashPattern = 2
1794                  plot_w = gsn_csm_xy(wks,data(varn,:,:),z,res)
1795               else
1796                  res@gsnLeftString      = vNam(varn)
1797                  res@tiXAxisString      = "["+unit(varn)+"]"
1798                  res@gsnRightString     = " "
1799                  if (xs .EQ. -1) then
1800                     res@trXMinF            = miniw
1801                  else
1802                     res@trXMinF            = xs
1803                  end if
1804                  if (xe .EQ. -1) then
1805                     res@trXMaxF            = maxiw
1806                  else
1807                     res@trXMaxF            = xe 
1808                  end if           
1809                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1810               end if   
1811            end if
1812
1813            if (vNam(varn) .EQ. "pt") then
1814               minipt=min(data(varn,:,:))-min_value
1815               maxipt=max(data(varn,:,:))+max_value
1816               if (over .EQ. 1) then
1817                  res@xyDashPattern  = 0
1818                  plot_pt = gsn_csm_xy(wks,data(varn,:,:),z,res)
1819               else
1820                  res@gsnLeftString      = vNam(varn)
1821                  res@tiXAxisString      = "["+unit(varn)+"]"
1822                  res@gsnRightString     = " "
1823                  if (xs .EQ. -1) then
1824                     res@trXMinF            = minipt
1825                  else
1826                     res@trXMinF            = xs
1827                  end if
1828                  if (xe .EQ. -1) then       
1829                     res@trXMaxF            = maxipt
1830                  else
1831                     res@trXMaxF            = xe 
1832                  end if
1833                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1834               end if 
1835            end if
1836            if (vNam(varn) .EQ. "vpt") then
1837               minivpt=min(data(varn,:,:))-min_value
1838               maxivpt=max(data(varn,:,:))+max_value
1839               if (over .EQ. 1) then
1840                  res@xyDashPattern  = 1
1841                  plot_vpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
1842               else
1843                  res@gsnLeftString      = vNam(varn)
1844                  res@tiXAxisString      = "["+unit(varn)+"]"
1845                  res@gsnRightString     = " "
1846                  if (xs .EQ. -1) then
1847                     res@trXMinF            = minivpt
1848                  else
1849                     res@trXMinF            = xs
1850                  end if
1851                  if (xe .EQ. -1) then       
1852                     res@trXMaxF            = maxivpt
1853                  else
1854                     res@trXMaxF            = xe 
1855                  end if
1856                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1857               end if
1858            end if
1859            if (vNam(varn) .EQ. "lpt") then
1860               minilpt=min(data(varn,:,:))-min_value
1861               maxilpt=max(data(varn,:,:))+max_value
1862               if (over .EQ. 1) then
1863                  res@xyDashPattern  = 2
1864                  plot_lpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
1865               else
1866                  res@gsnLeftString      = vNam(varn)
1867                  res@tiXAxisString      = "["+unit(varn)+"]"
1868                  res@gsnRightString     = " "
1869                  if (xs .EQ. -1) then
1870                     res@trXMinF            = minilpt
1871                  else
1872                     res@trXMinF            = xs
1873                  end if
1874                  if (xe .EQ. -1) then       
1875                     res@trXMaxF            = maxilpt
1876                  else
1877                     res@trXMaxF            = xe 
1878                  end if
1879                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1880               end if
1881            end if
1882
1883            if (vNam(varn) .EQ. "q") then
1884               miniq=min(data(varn,:,:))-min_value
1885               maxiq=max(data(varn,:,:))+max_value
1886               if (over .EQ. 1) then
1887                  res@xyDashPattern  = 0
1888                  plot_q = gsn_csm_xy(wks,data(varn,:,:),z,res)
1889               else
1890                  res@gsnLeftString      = vNam(varn)
1891                  res@tiXAxisString      = "["+unit(varn)+"]"
1892                  res@gsnRightString     = " "
1893                  if (xs .EQ. -1) then
1894                     res@trXMinF            = minilq
1895                  else
1896                     res@trXMinF            = xs
1897                  end if
1898                  if (xe .EQ. -1) then       
1899                     res@trXMaxF            = maxilq
1900                  else
1901                     res@trXMaxF            = xe 
1902                  end if
1903                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1904               end if
1905            end if
1906            if (vNam(varn) .EQ. "qv") then
1907               miniqv=min(data(varn,:,:))-min_value
1908               maxiqv=max(data(varn,:,:))+max_value
1909               if (over .EQ. 1) then
1910                  res@xyDashPattern  = 1
1911                  plot_qv = gsn_csm_xy(wks,data(varn,:,:),z,res)
1912               else
1913                  res@gsnLeftString      = vNam(varn)
1914                  res@tiXAxisString      = "["+unit(varn)+"]"
1915                  res@gsnRightString     = " "
1916                  if (xs .EQ. -1) then
1917                     res@trXMinF            = minilqv
1918                  else
1919                     res@trXMinF            = xs
1920                  end if
1921                  if (xe .EQ. -1) then         
1922                     res@trXMaxF            = maxilqv
1923                  else
1924                     res@trXMaxF            = xe 
1925                  end if
1926                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1927               end if
1928            end if
1929            if (vNam(varn) .EQ. "ql") then
1930               miniql=min(data(varn,:,:))-min_value
1931               maxiql=max(data(varn,:,:))+max_value
1932               if (over .EQ. 1) then
1933                  res@xyDashPattern  = 2
1934                  plot_ql = gsn_csm_xy(wks,data(varn,:,:),z,res)
1935               else
1936                  res@gsnLeftString      = vNam(varn)
1937                  res@tiXAxisString      = "["+unit(varn)+"]"
1938                  res@gsnRightString     = " "
1939                  if (xs .EQ. -1) then
1940                     res@trXMinF            = miniql
1941                  else
1942                     res@trXMinF            = xs
1943                  end if
1944                  if (xe .EQ. -1) then       
1945                     res@trXMaxF            = maxiql
1946                  else
1947                     res@trXMaxF            = xe 
1948                  end if
1949                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1950               end if
1951            end if
1952
1953            if (vNam(varn) .EQ. "e") then
1954               minie=min(data(varn,:,:))-min_value
1955               maxie=max(data(varn,:,:))+max_value
1956               if (over .EQ. 1) then
1957                  res@xyDashPattern  = 0
1958                  plot_e = gsn_csm_xy(wks,data(varn,:,:),z,res)
1959               else
1960                  res@gsnLeftString      = vNam(varn)
1961                  res@tiXAxisString      = "["+unit(varn)+"]"
1962                  res@gsnRightString     = " "
1963                  if (xs .EQ. -1) then
1964                     res@trXMinF            = minie
1965                  else
1966                     res@trXMinF            = xs
1967                  end if
1968                  if (xe .EQ. -1) then       
1969                     res@trXMaxF            = maxie
1970                  else
1971                     res@trXMaxF            = xe 
1972                  end if
1973                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1974               end if
1975            end if
1976            if (vNam(varn) .EQ. "es") then
1977               minies=min(data(varn,:,:))-min_value
1978               maxies=max(data(varn,:,:))+max_value
1979               if (over .EQ. 1) then
1980                  res@xyDashPattern  = 1
1981                  plot_es = gsn_csm_xy(wks,data(varn,:,:),z,res)
1982               else
1983                  res@gsnLeftString      = vNam(varn)
1984                  res@tiXAxisString      = "["+unit(varn)+"]"
1985                  res@gsnRightString     = " "
1986                  if (xs .EQ. -1) then
1987                     res@trXMinF            = minies
1988                  else
1989                     res@trXMinF            = xs
1990                  end if
1991                  if (xe .EQ. -1) then       
1992                     res@trXMaxF            = maxies
1993                  else
1994                     res@trXMaxF            = xe 
1995                  end if
1996                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
1997               end if
1998            end if
1999
2000            if (vNam(varn) .EQ. "km") then
2001               minikm=min(data(varn,:,:))-min_value
2002               maxikm=max(data(varn,:,:))+max_value
2003               if (over .EQ. 1) then
2004                  res@xyDashPattern  = 0
2005                  plot_km = gsn_csm_xy(wks,data(varn,:,:),z,res)
2006               else
2007                  res@gsnLeftString      = vNam(varn)
2008                  res@tiXAxisString      = "["+unit(varn)+"]"
2009                  res@gsnRightString     = " "
2010                  if (xs .EQ. -1) then
2011                     res@trXMinF            = minikm
2012                  else
2013                     res@trXMinF            = xs
2014                  end if
2015                  if (xe .EQ. -1) then     
2016                     res@trXMaxF            = maxikm
2017                  else
2018                     res@trXMaxF            = xe 
2019                  end if
2020                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2021               end if
2022            end if
2023            if (vNam(varn) .EQ. "kh") then
2024               minikh=min(data(varn,:,:))-min_value
2025               maxikh=max(data(varn,:,:))+max_value
2026               if (over .EQ. 1) then
2027                  res@xyDashPattern  = 1
2028                  plot_kh = gsn_csm_xy(wks,data(varn,:,:),z,res)
2029               else
2030                  res@gsnLeftString      = vNam(varn)
2031                  res@tiXAxisString      = "["+unit(varn)+"]"
2032                  res@gsnRightString     = " "
2033                  if (xs .EQ. -1) then
2034                     res@trXMinF            = minikh
2035                  else
2036                     res@trXMinF            = xs
2037                  end if
2038                  if (xe .EQ. -1) then     
2039                     res@trXMaxF            = maxikh
2040                  else
2041                     res@trXMaxF            = xe 
2042                  end if
2043                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2044               end if
2045            end if
2046
2047            if (vNam(varn) .EQ. "wpup") then
2048               miniwpup=min(data(varn,:,:))-min_value
2049               maxiwpup=max(data(varn,:,:))+max_value
2050               if (over .EQ. 1) then
2051                  res@xyDashPattern  = 0
2052                  plot_wpup = gsn_csm_xy(wks,data(varn,:,:),z,res)
2053               else
2054                  res@gsnLeftString      = vNam(varn)
2055                  res@tiXAxisString      = "["+unit(varn)+"]"
2056                  res@gsnRightString     = " "
2057                  if (xs .EQ. -1) then
2058                     res@trXMinF            = miniwpup
2059                  else
2060                     res@trXMinF            = xs
2061                  end if
2062                  if (xe .EQ. -1) then
2063                     res@trXMaxF            = maxiwpup
2064                  else
2065                     res@trXMaxF            = xe 
2066                  end if
2067                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2068               end if
2069            end if
2070            if (vNam(varn) .EQ. "wsus") then
2071               miniwsus=min(data(varn,:,:))-min_value
2072               maxiwsus=max(data(varn,:,:))+max_value
2073               if (over .EQ. 1) then
2074                  res@xyDashPattern  = 1
2075                  plot_wsus = gsn_csm_xy(wks,data(varn,:,:),z,res)
2076               else
2077                  res@gsnLeftString      = vNam(varn)
2078                  res@tiXAxisString      = "["+unit(varn)+"]"
2079                  res@gsnRightString     = " "
2080                  if (xs .EQ. -1) then
2081                     res@trXMinF            = miniwsus
2082                  else
2083                     res@trXMinF            = xs
2084                  end if
2085                  if (xe .EQ. -1) then     
2086                     res@trXMaxF            = maxiwsus
2087                  else
2088                     res@trXMaxF            = xe 
2089                  end if
2090                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2091               end if
2092            end if
2093            if (vNam(varn) .EQ. "wu") then
2094               miniwu=min(data(varn,:,:))-min_value
2095               maxiwu=max(data(varn,:,:))+max_value
2096               if (over .EQ. 1) then
2097                  res@xyDashPattern  = 2
2098                  plot_wu = gsn_csm_xy(wks,data(varn,:,:),z,res)
2099               else
2100                  res@gsnLeftString      = vNam(varn)
2101                  res@tiXAxisString      = "["+unit(varn)+"]"
2102                  res@gsnRightString     = " "
2103                  if (xs .EQ. -1) then
2104                     res@trXMinF            = miniwu
2105                  else
2106                     res@trXMinF            = xs
2107                  end if
2108                  if (xe .EQ. -1) then
2109                     res@trXMaxF            = maxiwu
2110                  else
2111                     res@trXMaxF            = xe 
2112                  end if
2113                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2114               end if
2115            end if
2116
2117            if (vNam(varn) .EQ. "wpvp") then
2118               miniwpvp=min(data(varn,:,:))-min_value
2119               maxiwpvp=max(data(varn,:,:))+max_value
2120               if (over .EQ. 1) then
2121                  res@xyDashPattern  = 0
2122                  plot_wpvp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2123               else
2124                  res@gsnLeftString      = vNam(varn)
2125                  res@tiXAxisString      = "["+unit(varn)+"]"
2126                  res@gsnRightString     = " "
2127                  if (xs .EQ. -1) then
2128                     res@trXMinF            = miniwpvp
2129                  else
2130                     res@trXMinF            = xs
2131                  end if
2132                  if (xe .EQ. -1) then     
2133                     res@trXMaxF            = maxiwpvp
2134                  else
2135                     res@trXMaxF            = xe 
2136                  end if
2137                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2138               end if
2139            end if
2140            if (vNam(varn) .EQ. "wsvs") then
2141               miniwsvs=min(data(varn,:,:))-min_value
2142               maxiwsvs=max(data(varn,:,:))+max_value
2143               if (over .EQ. 1) then
2144                  res@xyDashPattern  = 1
2145                  plot_wsvs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2146               else
2147                  res@gsnLeftString      = vNam(varn)
2148                  res@tiXAxisString      = "["+unit(varn)+"]"
2149                  res@gsnRightString     = " "
2150                  if (xs .EQ. -1) then
2151                     res@trXMinF            = miniwsvs
2152                  else
2153                     res@trXMinF            = xs
2154                  end if
2155                  if (xe .EQ. -1) then     
2156                     res@trXMaxF            = maxiwsvs
2157                  else
2158                     res@trXMaxF            = xe 
2159                  end if
2160                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2161               end if
2162            end if
2163            if (vNam(varn) .EQ. "wv") then
2164               miniwv=min(data(varn,:,:))-min_value
2165               maxiwv=max(data(varn,:,:))+max_value
2166               if (over .EQ. 1) then
2167                  res@xyDashPattern  = 2
2168                  plot_wv = gsn_csm_xy(wks,data(varn,:,:),z,res)
2169               else
2170                  res@gsnLeftString      = vNam(varn)
2171                  res@tiXAxisString      = "["+unit(varn)+"]"
2172                  res@gsnRightString     = " "
2173                  if (xs .EQ. -1) then
2174                     res@trXMinF            = miniwv
2175                  else
2176                     res@trXMinF            = xs
2177                  end if
2178                  if (xe .EQ. -1) then       
2179                     res@trXMaxF            = maxiwv
2180                  else
2181                     res@trXMaxF            = xe 
2182                  end if
2183                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2184               end if
2185            end if
2186
2187            if (vNam(varn) .EQ. "wpptp") then
2188               miniwpptp=min(data(varn,:,:))-min_value
2189               maxiwpptp=max(data(varn,:,:))+max_value
2190               if (over .EQ. 1) then
2191                  res@xyDashPattern  = 0
2192                  plot_wpptp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2193               else
2194                  res@gsnLeftString      = vNam(varn)
2195                  res@tiXAxisString      = "["+unit(varn)+"]"
2196                  res@gsnRightString     = " "
2197                  if (xs .EQ. -1) then
2198                     res@trXMinF            = miniwpptp
2199                  else
2200                     res@trXMinF            = xs
2201                  end if
2202                  if (xe .EQ. -1) then       
2203                     res@trXMaxF            = maxiwpptp
2204                  else
2205                     res@trXMaxF            = xe 
2206                  end if
2207                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2208               end if
2209            end if
2210            if (vNam(varn) .EQ. "wspts") then
2211               miniwspts=min(data(varn,:,:))-min_value
2212               maxiwspts=max(data(varn,:,:))+max_value
2213               if (over .EQ. 1) then
2214                  res@xyDashPattern  = 1
2215                  plot_wspts = gsn_csm_xy(wks,data(varn,:,:),z,res)
2216               else
2217                  res@gsnLeftString      = vNam(varn)
2218                  res@tiXAxisString      = "["+unit(varn)+"]"
2219                  res@gsnRightString     = " "
2220                  if (xs .EQ. -1) then
2221                     res@trXMinF            = miniwspts
2222                  else
2223                     res@trXMinF            = xs
2224                  end if
2225                  if (xe .EQ. -1) then       
2226                     res@trXMaxF            = maxiwspts
2227                  else
2228                     res@trXMaxF            = xe 
2229                  end if
2230                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2231               end if
2232            end if
2233            if (vNam(varn) .EQ. "wpt") then       
2234               miniwpt=min(data(varn,:,:))-min_value
2235               maxiwpt=max(data(varn,:,:))+max_value
2236               if (over .EQ. 1) then
2237                  res@xyDashPattern  = 2
2238                  plot_wpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2239               else
2240                  res@gsnLeftString      = vNam(varn)
2241                  res@tiXAxisString      = "["+unit(varn)+"]"
2242                  res@gsnRightString     = " "
2243                  if (xs .EQ. -1) then
2244                     res@trXMinF            = miniwpt
2245                  else
2246                     res@trXMinF            = xs
2247                  end if
2248                  if (xe .EQ. -1) then       
2249                     res@trXMaxF            = maxiwpt
2250                  else
2251                     res@trXMaxF            = xe 
2252                  end if
2253                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2254               end if
2255            end if
2256
2257            if (vNam(varn) .EQ. "wsptsBC") then
2258               miniwsptsBC=min(data(varn,:,:))-min_value
2259               maxiwsptsBC=max(data(varn,:,:))+max_value
2260               if (over .EQ. 1) then
2261                  res@xyDashPattern  = 0
2262                  plot_wsptsBC = gsn_csm_xy(wks,data(varn,:,:),z,res)
2263               else
2264                  res@gsnLeftString      = vNam(varn)
2265                  res@tiXAxisString      = "["+unit(varn)+"]"
2266                  res@gsnRightString     = " "
2267                  if (xs .EQ. -1) then
2268                     res@trXMinF            = miniwsptsBC
2269                  else
2270                     res@trXMinF            = xs
2271                  end if
2272                  if (xe .EQ. -1) then       
2273                     res@trXMaxF            = maxiwsptsBC
2274                  else
2275                     res@trXMaxF            = xe 
2276                  end if
2277                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2278               end if
2279            end if             
2280            if (vNam(varn) .EQ. "wptBC") then
2281               miniwptBC=min(data(varn,:,:))-min_value
2282               maxiwptBC=max(data(varn,:,:))+max_value
2283               if (over .EQ. 1) then
2284                  res@xyDashPattern  = 1
2285                  plot_wptBC = gsn_csm_xy(wks,data(varn,:,:),z,res)
2286               else
2287                  res@gsnLeftString      = vNam(varn)
2288                  res@tiXAxisString      = "["+unit(varn)+"]"
2289                  res@gsnRightString     = " "
2290                  if (xs .EQ. -1) then
2291                     res@trXMinF            = miniwptBC
2292                  else
2293                     res@trXMinF            = xs
2294                  end if
2295                  if (xe .EQ. -1) then       
2296                     res@trXMaxF            = maxiwptBC
2297                  else
2298                     res@trXMaxF            = xe 
2299                  end if
2300                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2301               end if
2302            end if
2303
2304            if (vNam(varn) .EQ. "wpvptp") then
2305               miniwpvptp=min(data(varn,:,:))-min_value
2306               maxiwpvptp=max(data(varn,:,:))+max_value
2307               if (over .EQ. 1) then
2308                  res@xyDashPattern  = 0
2309                  plot_wpvptp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2310               else
2311                  res@gsnLeftString      = vNam(varn)
2312                  res@tiXAxisString      = "["+unit(varn)+"]"
2313                  res@gsnRightString     = " "
2314                  if (xs .EQ. -1) then
2315                     res@trXMinF            = miniwpvptp
2316                  else
2317                     res@trXMinF            = xs
2318                  end if
2319                  if (xe .EQ. -1) then       
2320                     res@trXMaxF            = maxiwpvptp
2321                  else
2322                     res@trXMaxF            = xe 
2323                  end if
2324                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2325               end if
2326            end if
2327            if (vNam(varn) .EQ. "wsvpts") then
2328               miniwsvpts=min(data(varn,:,:))-min_value
2329               maxiwsvpts=max(data(varn,:,:))+max_value
2330               if (over .EQ. 1) then
2331                  res@xyDashPattern  = 1
2332                  plot_wsvpts = gsn_csm_xy(wks,data(varn,:,:),z,res)
2333               else
2334                  res@gsnLeftString      = vNam(varn)
2335                  res@tiXAxisString      = "["+unit(varn)+"]"
2336                  res@gsnRightString     = " "
2337                  if (xs .EQ. -1) then
2338                     res@trXMinF            = miniwsvpts
2339                  else
2340                     res@trXMinF            = xs
2341                  end if
2342                  if (xe .EQ. -1) then       
2343                     res@trXMaxF            = maxiwsvpts
2344                  else
2345                     res@trXMaxF            = xe 
2346                  end if
2347                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2348               end if
2349            end if
2350            if (vNam(varn) .EQ. "wvpt") then
2351               miniwvpt=min(data(varn,:,:))-min_value
2352               maxiwvpt=max(data(varn,:,:))+max_value
2353               if (over .EQ. 1) then
2354                  res@xyDashPattern  = 2
2355                  plot_wvpt = gsn_csm_xy(wks,data(varn,:,:),z,res)
2356               else
2357                  res@gsnLeftString      = vNam(varn)
2358                  res@tiXAxisString      = "["+unit(varn)+"]"
2359                  res@gsnRightString     = " "
2360                  if (xs .EQ. -1) then
2361                     res@trXMinF            = miniwvpt
2362                  else
2363                     res@trXMinF            = xs
2364                  end if
2365                  if (xe .EQ. -1) then       
2366                     res@trXMaxF            = maxiwvpt
2367                  else
2368                     res@trXMaxF            = xe 
2369                  end if
2370                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2371               end if
2372            end if
2373
2374            if (vNam(varn) .EQ. "wpqp") then
2375               miniwpqp=min(data(varn,:,:))-min_value
2376               maxiwpqp=max(data(varn,:,:))+max_value
2377               if (over .EQ. 1) then
2378                  res@xyDashPattern  = 0
2379                  plot_wpqp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2380               else
2381                  res@gsnLeftString      = vNam(varn)
2382                  res@tiXAxisString      = "["+unit(varn)+"]"
2383                  res@gsnRightString     = " "
2384                  if (xs .EQ. -1) then
2385                     res@trXMinF            = miniwpqp
2386                  else
2387                     res@trXMinF            = xs
2388                  end if
2389                  if (xe .EQ. -1) then       
2390                     res@trXMaxF            = maxiwpqp
2391                  else
2392                     res@trXMaxF            = xe 
2393                  end if
2394                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2395               end if
2396            end if
2397            if (vNam(varn) .EQ. "wsqs") then
2398               miniwsqs=min(data(varn,:,:))-min_value
2399               maxiwsqs=max(data(varn,:,:))+max_value
2400               if (over .EQ. 1) then
2401                  res@xyDashPattern  = 1
2402                  plot_wsqs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2403               else
2404                  res@gsnLeftString      = vNam(varn)
2405                  res@tiXAxisString      = "["+unit(varn)+"]"
2406                  res@gsnRightString     = " "
2407                  if (xs .EQ. -1) then
2408                     res@trXMinF            = miniwsqs
2409                  else
2410                     res@trXMinF            = xs
2411                  end if
2412                  if (xe .EQ. -1) then       
2413                     res@trXMaxF            = maxiwsqs
2414                  else
2415                     res@trXMaxF            = xe 
2416                  end if
2417                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2418               end if
2419            end if
2420            if (vNam(varn) .EQ. "wq") then
2421               miniwq=min(data(varn,:,:))-min_value
2422               maxiwq=max(data(varn,:,:))+max_value
2423               if (over .EQ. 1) then
2424                  res@xyDashPattern  = 2
2425                  plot_wq = gsn_csm_xy(wks,data(varn,:,:),z,res)
2426               else
2427                  res@gsnLeftString      = vNam(varn)
2428                  res@tiXAxisString      = "["+unit(varn)+"]"
2429                  res@gsnRightString     = " "
2430                  if (xs .EQ. -1) then
2431                     res@trXMinF            = miniwq
2432                  else
2433                     res@trXMinF            = xs
2434                  end if
2435                  if (xe .EQ. -1) then       
2436                     res@trXMaxF            = maxiwq
2437                  else
2438                     res@trXMaxF            = xe 
2439                  end if
2440                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2441               end if
2442            end if
2443
2444            if (vNam(varn) .EQ. "wpqvp") then
2445               miniwpqvp=min(data(varn,:,:))-min_value
2446               maxiwpqvp=max(data(varn,:,:))+max_value
2447               if (over .EQ. 1) then
2448                  res@xyDashPattern  = 0
2449                  plot_wpqvp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2450               else
2451                  res@gsnLeftString      = vNam(varn)
2452                  res@tiXAxisString      = "["+unit(varn)+"]"
2453                  res@gsnRightString     = " "
2454                  if (xs .EQ. -1) then
2455                     res@trXMinF            = miniwpqvp
2456                  else
2457                     res@trXMinF            = xs
2458                  end if
2459                  if (xe .EQ. -1) then       
2460                     res@trXMaxF            = maxiwpqvp
2461                  else
2462                     res@trXMaxF            = xe 
2463                  end if
2464                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2465               end if
2466            end if
2467            if (vNam(varn) .EQ. "wsqvs") then
2468               miniwsqvs=min(data(varn,:,:))-min_value
2469               maxiwsqvs=max(data(varn,:,:))+max_value
2470               if (over .EQ. 1) then
2471                  res@xyDashPattern  = 1
2472                  plot_wsqvs = gsn_csm_xy(wks,data(varn,:,:),z,res)
2473               else
2474                  res@gsnLeftString      = vNam(varn)
2475                  res@tiXAxisString      = "["+unit(varn)+"]"
2476                  res@gsnRightString     = " "
2477                  if (xs .EQ. -1) then
2478                     res@trXMinF            = miniwsqvs
2479                  else
2480                     res@trXMinF            = xs
2481                  end if
2482                  if (xe .EQ. -1) then       
2483                     res@trXMaxF            = maxiwsqvs
2484                  else
2485                     res@trXMaxF            = xe 
2486                  end if
2487                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2488               end if
2489            end if
2490            if (vNam(varn) .EQ. "wqv") then
2491               miniwqv=min(data(varn,:,:))-min_value
2492               maxiwqv=max(data(varn,:,:))+max_value
2493               if (over .EQ. 1) then
2494                  res@xyDashPattern  = 2
2495                  plot_wqv = gsn_csm_xy(wks,data(varn,:,:),z,res)
2496               else
2497                  res@gsnLeftString      = vNam(varn)
2498                  res@tiXAxisString      = "["+unit(varn)+"]"
2499                  res@gsnRightString     = " "
2500                  if (xs .EQ. -1) then
2501                     res@trXMinF            = miniwqv
2502                  else
2503                     res@trXMinF            = xs
2504                  end if
2505                  if (xe .EQ. -1) then       
2506                     res@trXMaxF            = maxiwqv
2507                  else
2508                     res@trXMaxF            = xe 
2509                  end if
2510                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2511               end if
2512            end if
2513
2514            if (vNam(varn) .EQ. "wpsp") then
2515               miniwpsp=min(data(varn,:,:))-min_value
2516               maxiwpsp=max(data(varn,:,:))+max_value
2517               if (over .EQ. 1) then
2518                  res@xyDashPattern  = 0
2519                  plot_wpsp = gsn_csm_xy(wks,data(varn,:,:),z,res)
2520               else
2521                  res@gsnLeftString      = vNam(varn)
2522                  res@tiXAxisString      = "["+unit(varn)+"]"
2523                  res@gsnRightString     = " "
2524                  if (xs .EQ. -1) then
2525                     res@trXMinF            = miniwpsp
2526                  else
2527                     res@trXMinF            = xs
2528                  end if
2529                  if (xe .EQ. -1) then       
2530                     res@trXMaxF            = maxiwpsp
2531                  else
2532                     res@trXMaxF            = xe 
2533                  end if
2534                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2535               end if
2536            end if
2537            if (vNam(varn) .EQ. "wsss") then
2538               miniwsss=min(data(varn,:,:))-min_value
2539               maxiwsss=max(data(varn,:,:))+max_value
2540               if (over .EQ. 1) then
2541                  res@xyDashPattern  = 1
2542                  plot_wsss = gsn_csm_xy(wks,data(varn,:,:),z,res)
2543               else
2544                  res@gsnLeftString      = vNam(varn)
2545                  res@tiXAxisString      = "["+unit(varn)+"]"
2546                  res@gsnRightString     = " "
2547                  if (xs .EQ. -1) then
2548                     res@trXMinF            = miniwsss
2549                  else
2550                     res@trXMinF            = xs
2551                  end if
2552                  if (xe .EQ. -1) then       
2553                     res@trXMaxF            = maxiwsss
2554                  else
2555                     res@trXMaxF            = xe 
2556                  end if
2557                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2558               end if
2559            end if
2560            if (vNam(varn) .EQ. "ws") then
2561               miniws=min(data(varn,:,:))-min_value
2562               maxiws=max(data(varn,:,:))+max_value
2563               if (over .EQ. 1) then
2564                  res@xyDashPattern  = 2
2565                  plot_ws = gsn_csm_xy(wks,data(varn,:,:),z,res)
2566               else
2567                  res@gsnLeftString      = vNam(varn)
2568                  res@tiXAxisString      = "["+unit(varn)+"]"
2569                  res@gsnRightString     = " "
2570                  if (xs .EQ. -1) then
2571                     res@trXMinF            = miniws
2572                  else
2573                     res@trXMinF            = xs
2574                  end if
2575                  if (xe .EQ. -1) then       
2576                     res@trXMaxF            = maxiws
2577                  else
2578                     res@trXMaxF            = xe 
2579                  end if
2580                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2581               end if
2582            end if
2583
2584            if (vNam(varn) .EQ. "wpsap") then
2585               miniwpsap=min(data(varn,:,:))-min_value
2586               maxiwpsap=max(data(varn,:,:))+max_value
2587               if (over .EQ. 1) then
2588                  res@xyDashPattern  = 0
2589                  plot_wpsap = gsn_csm_xy(wks,data(varn,:,:),z,res)
2590               else
2591                  res@gsnLeftString      = vNam(varn)
2592                  res@tiXAxisString      = "["+unit(varn)+"]"
2593                  res@gsnRightString     = " "
2594                  if (xs .EQ. -1) then
2595                     res@trXMinF            = miniwpsap
2596                  else
2597                     res@trXMinF            = xs
2598                  end if
2599                  if (xe .EQ. -1) then       
2600                     res@trXMaxF            = maxiwpsap
2601                  else
2602                     res@trXMaxF            = xe 
2603                  end if
2604                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2605               end if
2606            end if
2607            if (vNam(varn) .EQ. "wssas") then
2608               miniwssas=min(data(varn,:,:))-min_value
2609               maxiwssas=max(data(varn,:,:))+max_value
2610               if (over .EQ. 1) then
2611                  res@xyDashPattern  = 1
2612                  plot_wssas = gsn_csm_xy(wks,data(varn,:,:),z,res)
2613               else
2614                  res@gsnLeftString      = vNam(varn)
2615                  res@tiXAxisString      = "["+unit(varn)+"]"
2616                  res@gsnRightString     = " "
2617                  if (xs .EQ. -1) then
2618                     res@trXMinF            = miniwssas
2619                  else
2620                     res@trXMinF            = xs
2621                  end if
2622                  if (xe .EQ. -1) then       
2623                     res@trXMaxF            = maxiwssas
2624                  else
2625                     res@trXMaxF            = xe 
2626                  end if
2627                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2628               end if
2629            end if
2630            if (vNam(varn) .EQ. "wsa") then
2631               miniwsa=min(data(varn,:,:))-min_value
2632               maxiwsa=max(data(varn,:,:))+max_value
2633               if (over .EQ. 1) then
2634                  res@xyDashPattern  = 2
2635                  plot_wsa = gsn_csm_xy(wks,data(varn,:,:),z,res)
2636               else
2637                  res@gsnLeftString      = vNam(varn)
2638                  res@tiXAxisString      = "["+unit(varn)+"]"
2639                  res@gsnRightString     = " "
2640                  if (xs .EQ. -1) then
2641                     res@trXMinF            = miniwsa
2642                  else
2643                     res@trXMinF            = xs
2644                  end if
2645                  if (xe .EQ. -1) then       
2646                     res@trXMaxF            = maxiwsa
2647                  else
2648                     res@trXMaxF            = xe 
2649                  end if
2650                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2651               end if
2652            end if
2653
2654            if (vNam(varn) .EQ. "us2") then
2655               minius2=min(data(varn,:,:))-min_value
2656               maxius2=max(data(varn,:,:))+max_value
2657               if (over .EQ. 1) then
2658                  res@xyDashPattern  = 0
2659                  plot_us2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
2660               else
2661                  res@gsnLeftString      = vNam(varn)
2662                  res@tiXAxisString      = "["+unit(varn)+"]"
2663                  res@gsnRightString     = " "
2664                  if (xs .EQ. -1) then
2665                     res@trXMinF            = minius2
2666                  else
2667                     res@trXMinF            = xs
2668                  end if
2669                  if (xe .EQ. -1) then       
2670                     res@trXMaxF            = maxius2
2671                  else
2672                     res@trXMaxF            = xe 
2673                  end if
2674                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2675               end if
2676            end if
2677            if (vNam(varn) .EQ. "vs2") then
2678               minivs2=min(data(varn,:,:))-min_value
2679               maxivs2=max(data(varn,:,:))+max_value
2680               if (over .EQ. 1) then
2681                  res@xyDashPattern  = 1
2682                  plot_vs2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
2683               else
2684                  res@gsnLeftString      = vNam(varn)
2685                  res@tiXAxisString      = "["+unit(varn)+"]"
2686                  res@gsnRightString     = " "
2687                  if (xs .EQ. -1) then
2688                     res@trXMinF            = minivs2
2689                  else
2690                     res@trXMinF            = xs
2691                  end if
2692                  if (xe .EQ. -1) then       
2693                     res@trXMaxF            = maxivs2
2694                  else
2695                     res@trXMaxF            = xe 
2696                  end if
2697                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2698               end if
2699            end if
2700            if (vNam(varn) .EQ. "ws2") then
2701               miniws2=min(data(varn,:,:))-min_value
2702               maxiws2=max(data(varn,:,:))+max_value
2703               if (over .EQ. 1) then
2704                  res@xyDashPattern  = 2
2705                  plot_ws2 = gsn_csm_xy(wks,data(varn,:,:),z,res)
2706               else
2707                  res@gsnLeftString      = vNam(varn)
2708                  res@tiXAxisString      = "["+unit(varn)+"]"
2709                  res@gsnRightString     = " "
2710                  if (xs .EQ. -1) then
2711                     res@trXMinF            = miniws2
2712                  else
2713                     res@trXMinF            = xs
2714                  end if
2715                  if (xe .EQ. -1) then       
2716                     res@trXMaxF            = maxiws2
2717                  else
2718                     res@trXMaxF            = xe 
2719                  end if
2720                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2721               end if
2722            end if
2723
2724            if (vNam(varn) .EQ. "wsususodz") then
2725               miniwsususodz=min(data(varn,:,:))-min_value
2726               maxiwsususodz=max(data(varn,:,:))+max_value
2727               if (over .EQ. 1) then
2728                  res@xyDashPattern  = 0
2729                  plot_wsususodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
2730               else
2731                  res@gsnLeftString      = vNam(varn)
2732                  res@tiXAxisString      = "["+unit(varn)+"]"
2733                  res@gsnRightString     = " "
2734                  if (xs .EQ. -1) then
2735                     res@trXMinF            = miniwsususodz
2736                  else
2737                     res@trXMinF            = xs
2738                  end if
2739                  if (xe .EQ. -1) then       
2740                     res@trXMaxF            = maxiwsususodz
2741                  else
2742                     res@trXMaxF            = xe 
2743                  end if
2744                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2745               end if 
2746            end if
2747            if (vNam(varn) .EQ. "wspsodz") then
2748               miniwspsodz=min(data(varn,:,:))-min_value
2749               maxiwspsodz=max(data(varn,:,:))+max_value
2750               if (over .EQ. 1) then
2751                  res@xyDashPattern  = 1
2752                  plot_wspsodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
2753               else
2754                  res@gsnLeftString      = vNam(varn)
2755                  res@tiXAxisString      = "["+unit(varn)+"]"
2756                  res@gsnRightString     = " "
2757                  if (xs .EQ. -1) then
2758                     res@trXMinF            = miniwspsodz
2759                  else
2760                     res@trXMinF            = xs
2761                  end if
2762                  if (xe .EQ. -1) then       
2763                     res@trXMaxF            = maxiwspsodz
2764                  else
2765                     res@trXMaxF            = xe 
2766                  end if
2767                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2768               end if
2769            end if
2770            if (vNam(varn) .EQ. "wpeodz") then
2771               miniwpeodz=min(data(varn,:,:))-min_value
2772               maxiwpeodz=max(data(varn,:,:))+max_value
2773               if (over .EQ. 1) then
2774                  res@xyDashPattern  = 2
2775                  plot_wpeodz = gsn_csm_xy(wks,data(varn,:,:),z,res)
2776               else
2777                  res@gsnLeftString      = vNam(varn)
2778                  res@tiXAxisString      = "["+unit(varn)+"]"
2779                  res@gsnRightString     = " "
2780                  if (xs .EQ. -1) then
2781                     res@trXMinF            = miniwpeodz
2782                  else
2783                     res@trXMinF            = xs
2784                  end if
2785                  if (xe .EQ. -1) then       
2786                     res@trXMaxF            = maxiwpeodz
2787                  else
2788                     res@trXMaxF            = xe 
2789                  end if
2790                  plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res)
2791               end if
2792            end if
2793         if (no_files .GT. 1) then
2794            print("nof="+nof+" und n="+n)
2795            multi_plot(nof,n)=plot(n)
2796            max_nof(nof,n)=max(data(varn,:,:))
2797            min_nof(nof,n)=min(data(varn,:,:))
2798            name(nof,n)   =vNam(varn)
2799            unit_(nof,n)  =unit(varn)
2800         end if
2801         if (over .EQ. 0) then
2802            n=n+1 
2803         end if 
2804         if (prof3d .EQ. 0)then   
2805            varn=varn+1
2806         end if
2807         delete(temp)
2808         delete(temp_att)
2809      end if         
2810   end do
2811   if (no_files .GT. 1) then
2812      delete(vNam)
2813      delete(files)
2814   end if
2815   
2816   end do
2817   ;#########ENDE DO LOOP FOR no_files GT 1#############
2818   
2819   if (count_var .EQ. 0) then
2820      print(" ")
2821      print("The variables 'var="+var+"'" )
2822      print("do not exist on your input file;")
2823      print("be sure to have one comma before and after each variable")
2824      print(" ")
2825      exit       
2826   end if
2827
2828   if (isStrSubset(data@long_name," SR " ))then
2829      print(" ")
2830      print("If you have outputs of statistic regions you cannot overlay variables;")
2831      print("'over' is set to 0" )
2832      print(" ")
2833      over = 0
2834   end if
2835   
2836   if (no_files .GT. 1) then
2837      multi_legend=new(6,string)
2838      string_len=new(6,integer)
2839      multi_dash=new(no_files,string)
2840      multi_legend(0)="  "+name_legend_1
2841      string_len(0)=strlen(multi_legend(0))
2842      multi_legend(1)="  "+name_legend_2
2843      string_len(1)=strlen(multi_legend(1))
2844      multi_legend(2)="  "+name_legend_3
2845      string_len(2)=strlen(multi_legend(2))
2846      multi_legend(3)="  "+name_legend_4
2847      string_len(3)=strlen(multi_legend(3))
2848      multi_legend(4)="  "+name_legend_5
2849      string_len(4)=strlen(multi_legend(4))
2850      multi_legend(5)="  "+name_legend_6
2851      string_len(5)=strlen(multi_legend(5))
2852      do ml=1,no_files
2853         multi_dash(ml-1)=ml-1
2854      end do
2855      delete(plot)
2856      plot = new(dim,graphic)
2857      do pl=0,n-1
2858         plot0 = new(1,graphic)
2859         res@trXMinF = min(min_nof(:,pl))
2860         res@trXMaxF = max(max_nof(:,pl))
2861         res@gsnLeftString  = name(0,pl)
2862         res@gsnRightString = unit_(0,pl)
2863         
2864         data_0(:,:) = min(min_nof(:,pl))
2865         plot0 = gsn_csm_xy(wks,data_0(:,:),z_(pl,:),res)
2866
2867         ; ***************************************************
2868         ; legend for combined plot
2869         ; ***************************************************
2870
2871         lgres                    = True
2872         lgMonoDashIndex          = False
2873         lgres@lgLabelFont        = "helvetica"   
2874         lgres@lgLabelFontHeightF = font_size_legend           
2875         lgres@vpWidthF           = max(string_len)*0.015           
2876         lgres@vpHeightF          = 0.03*no_files         
2877         lgres@lgDashIndexes      = multi_dash(no_files-1:0)
2878         lbid = gsn_create_legend(wks,no_files,multi_legend(no_files-1:0),lgres)       
2879
2880         amres = True
2881         amres@amParallelPosF   = max(string_len)*0.012+0.78               
2882         amres@amOrthogonalPosF = -0.0315*no_files+0.431         
2883         annoid1 = gsn_add_annotation(plot0,lbid,amres)
2884
2885         do plo=0,no_files-1
2886            overlay(plot0,multi_plot(plo,pl))
2887            plot(pl)=plot0
2888         end do
2889         delete(plot0)
2890      end do
2891   end if
2892
2893   if (count_var .EQ. 0) then
2894      print(" ")
2895      print("Select a variable 'var=' or use the default value")
2896      print(" ")
2897      print("Your selection '"+var+"' does not exist on the input file")
2898      print(" ")
2899      exit
2900   end if
2901
2902   if (over .EQ. 1 ) then
2903
2904      overlay(plot_u,plot_v)
2905      overlay(plot_u,plot_w)
2906      u=0
2907      overlay(plot_pt,plot_vpt)
2908      overlay(plot_pt,plot_lpt)
2909      pt=0
2910      overlay(plot_q,plot_qv)
2911      overlay(plot_q,plot_ql)
2912      q=0
2913      overlay(plot_e,plot_es)
2914      e=0
2915      overlay(plot_km,plot_kh)
2916      km=0
2917      overlay(plot_wpup,plot_wsus)
2918      overlay(plot_wpup,plot_wu)
2919      wpup=0
2920      overlay(plot_wpvp,plot_wsvs)
2921      overlay(plot_wpvp,plot_wv)
2922      wpvp=0
2923      overlay(plot_wpptp,plot_wspts)
2924      overlay(plot_wpptp,plot_wpt)
2925      wpptp=0
2926      overlay(plot_wsptsBC,plot_wptBC)
2927      wsptsBC=0
2928      overlay(plot_wpvptp,plot_wsvpts)
2929      overlay(plot_wpvptp,plot_wvpt)
2930      wpvptp=0
2931      overlay(plot_wpqp,plot_wsqs)
2932      overlay(plot_wpqp,plot_wq)
2933      wpqp=0
2934      overlay(plot_wpqvp,plot_wsqvs)
2935      overlay(plot_wpqvp,plot_wqv)
2936      wpqvp=0
2937      overlay(plot_wpsp,plot_wsss)
2938      overlay(plot_wpsp,plot_ws)
2939      wpsp=0
2940      overlay(plot_wpsap,plot_wssas)
2941      overlay(plot_wpsap,plot_wsa)
2942      wpsap=0
2943      overlay(plot_us2,plot_vs2)
2944      overlay(plot_us2,plot_ws2)
2945      us2=0
2946      overlay(plot_wsususodz,plot_wspsodz)
2947      overlay(plot_wsususodz,plot_wpeodz)
2948      wsususodz=0
2949
2950   end if
2951
2952   if (over .EQ. 1) then
2953   
2954      do varn = 0,dim-1   
2955         
2956         check = True
2957     
2958         if (prof3d .EQ. 0) then
2959            if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
2960               check = False
2961            end if
2962         else
2963            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
2964               check = False
2965            end if
2966         end if
2967
2968         if (var .NE. "all") then     
2969            check = isStrSubset( var,","+vNam(varn)+"," )
2970         end if     
2971
2972         if (check)then
2973
2974            if (prof3d .EQ. 0) then
2975               if (log_z .EQ. 1) then
2976                  z = f_att->$vNam(varn+1)$(1:dimz-1)
2977               else
2978                  z = f_att->$vNam(varn+1)$               
2979               end if
2980            else
2981               do i=0,b-1           
2982                  if (isStrSubset( a(i),"zu_3d" ))then
2983                     z_v(varn,:) = z_u
2984                     if (log_z .EQ. 1) then
2985                        z = z_v(varn,1:dimz-1)
2986                     else
2987                        z = z_v(varn,:)
2988                     end if
2989                  else
2990                     if (isStrSubset( a(i),"zw_3d" ))then
2991                        z_v(varn,:) = z_w
2992                        if (log_z .EQ. 1) then
2993                           z = z_v(varn,1:dimz-1)
2994                        else
2995                           z = z_v(varn,:)
2996                        end if
2997                     end if                   
2998                  end if
2999               end do           
3000            end if
3001
3002            z=z/norm_z
3003           
3004            if (abs(min(data(varn,:,:))) .GT. 10)then
3005               min_value = abs(0.01*min(data(varn,:,:)))
3006               max_value = abs(0.01*max(data(varn,:,:)))
3007            else
3008               if (abs(min(data(varn,:,:))) .LT. 0.01 .AND. abs(max(data(varn,:,:))) .GT. 0.01)then
3009                  min_value = abs(0.1*max(data(varn,:,:)))
3010                  max_value = abs(0.1*max(data(varn,:,:)))
3011               else
3012                  if (abs(max(data(varn,:,:))) .LT. 0.01 .AND. abs(min(data(varn,:,:))) .GT. 0.01)then
3013                     min_value = abs(0.1*min(data(varn,:,:)))
3014                     max_value = abs(0.1*min(data(varn,:,:)))
3015                  else
3016                     min_value = abs(0.1*min(data(varn,:,:)))
3017                     max_value = abs(0.1*max(data(varn,:,:)))
3018                  end if
3019               end if
3020            end if
3021            if (min(data(varn,:,:)) .EQ. 0 .AND. max(data(varn,:,:)) .EQ. 0)then
3022               min_value = 0.1
3023               max_value = 0.1
3024            end if
3025
3026            res@gsnLeftString      = vNam(varn)
3027            res@tiXAxisString      = "["+unit(varn)+"]"
3028            res@gsnRightString     = " "
3029            res@trYMinF            = min_z
3030            res@trYMaxF            = max_z 
3031            res@xyDashPattern = 0
3032
3033            if (xs .EQ. -1) then
3034               res@trXMinF = min(data(varn,:,:))-min_value
3035            else
3036               res@trXMinF = xs
3037            end if
3038            if (xe .EQ. -1) then
3039               res@trXMaxF = max(data(varn,:,:))+max_value
3040            else
3041               res@trXMaxF = xe 
3042            end if
3043            plot(n) = gsn_csm_xy(wks,data(varn,:,:),z,res) 
3044           
3045            if (vNam(varn) .EQ. "u" .OR. vNam(varn) .EQ. "v" .OR. vNam(varn) .EQ. "w") then
3046               if (u .EQ. 0) then
3047                  res@gsnLeftString      = "u, v and w"
3048                  res@tiXAxisString      = "["+unit(varn)+"]"
3049                  res@gsnRightString     = " "
3050                  if (xs .EQ. -1) then
3051                     res@trXMinF = min((/miniu,miniv,miniw/))
3052                  else
3053                     res@trXMinF = xs
3054                  end if
3055                  if (xe .EQ. -1) then
3056                     res@trXMaxF = max((/maxiu,maxiv,maxiw/))
3057                  else
3058                     res@trXMaxF = xe 
3059                  end if 
3060                  if (vNam(varn) .EQ. "v")then
3061                     res@xyDashPattern = 1
3062                  end if
3063                  if (vNam(varn) .EQ. "w")then
3064                     res@xyDashPattern = 2
3065                  end if
3066                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3067
3068                  ; ***************************************************
3069                  ; legend for combined plot
3070                  ; ***************************************************
3071     
3072                  lgres                    = True
3073                  lgMonoDashIndex          = False
3074                  lgres@lgLabelFont        = "helvetica"   
3075                  lgres@lgLabelFontHeightF = font_size_legend           
3076                  lgres@vpWidthF           = 0.06           
3077                  lgres@vpHeightF          = 0.12         
3078                  lgres@lgDashIndexes      = (/0,1,2/)
3079                  lbid = gsn_create_legend(wks,3,(/"u","v","w"/),lgres)       
3080
3081                  amres = True
3082                  amres@amParallelPosF   = 0.65             
3083                  amres@amOrthogonalPosF = -0.2           
3084                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3085                  overlay(plot(n),plot_u)
3086                  u=1
3087               else
3088                  if (prof3d .EQ. 0)then
3089                     varn=varn+1
3090                  end if
3091                  continue
3092               end if       
3093            end if 
3094     
3095            if (vNam(varn) .EQ. "pt" .OR. vNam(varn) .EQ. "vpt" .OR. vNam(varn) .EQ. "lpt") then
3096               if (pt .EQ. 0) then
3097                  res@gsnLeftString      = "pt, vpt and lpt"
3098                  res@tiXAxisString      = "["+unit(varn)+"]"
3099                  res@gsnRightString     = " "
3100                  if (xs .EQ. -1) then
3101                     res@trXMinF = min((/minipt,minivpt,minilpt/))
3102                  else
3103                     res@trXMinF = xs
3104                  end if
3105                  if (xe .EQ. -1) then
3106                     res@trXMaxF = max((/maxipt,maxivpt,maxilpt/))
3107                  else
3108                     res@trXMaxF = xe 
3109                  end if
3110                  if (vNam(varn) .EQ. "vpt")then
3111                     res@xyDashPattern = 1
3112                  end if
3113                  if (vNam(varn) .EQ. "lpt")then
3114                     res@xyDashPattern = 2
3115                  end if
3116                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3117
3118                  ; ***************************************************
3119                  ; legend for combined plot
3120                  ; ***************************************************
3121     
3122                  lgres                    = True
3123                  lgMonoDashIndex          = False
3124                  lgres@lgLabelFont        = "helvetica"   
3125                  lgres@lgLabelFontHeightF = font_size_legend         
3126                  lgres@vpWidthF           = 0.07           
3127                  lgres@vpHeightF          = 0.12         
3128                  lgres@lgDashIndexes      = (/0,1,2/)
3129                  lbid = gsn_create_legend(wks,3,(/"pt","vpt","lpt"/),lgres)       
3130
3131                  amres = True
3132                  amres@amParallelPosF   = 0.65             
3133                  amres@amOrthogonalPosF = -0.2           
3134                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3135                  overlay(plot(n),plot_pt)
3136                  pt=1
3137               else
3138                  if (prof3d .EQ. 0)then
3139                     varn=varn+1
3140                  end if
3141                  continue       
3142               end if
3143            end if           
3144            if (vNam(varn) .EQ. "q" .OR. vNam(varn) .EQ. "qv" .OR. vNam(varn) .EQ. "ql") then
3145               if (q .EQ. 0) then
3146                  res@gsnLeftString      = "q, qv and ql"
3147                  res@tiXAxisString      = "["+unit(varn)+"]"
3148                  res@gsnRightString     = " "
3149                  if (xs .EQ. -1) then
3150                     res@trXMinF = min((/miniq,miniqv,miniql/))
3151                  else
3152                     res@trXMinF = xs
3153                  end if
3154                  if (xe .EQ. -1) then
3155                     res@trXMaxF = max((/maxiq,maxiqv,maxiql/))
3156                  else
3157                     res@trXMaxF = xe 
3158                  end if
3159                  if (vNam(varn) .EQ. "qv")then
3160                     res@xyDashPattern = 1
3161                  end if
3162                  if (vNam(varn) .EQ. "ql")then
3163                     res@xyDashPattern = 2
3164                  end if
3165                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3166
3167                  ; ***************************************************
3168                  ; legend for combined plot
3169                  ; ***************************************************
3170     
3171                  lgres                    = True
3172                  lgMonoDashIndex          = False
3173                  lgres@lgLabelFont        = "helvetica"   
3174                  lgres@lgLabelFontHeightF = font_size_legend           
3175                  lgres@vpWidthF           = 0.06         
3176                  lgres@vpHeightF          = 0.12         
3177                  lgres@lgDashIndexes      = (/0,1,2/)
3178                  lbid = gsn_create_legend(wks,3,(/"q","qv","ql"/),lgres)       
3179
3180                  amres = True
3181                  amres@amParallelPosF   = 0.65             
3182                  amres@amOrthogonalPosF = -0.2           
3183                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3184                  overlay(plot(n),plot_q)
3185                  q=1
3186               else
3187                  if (prof3d .EQ. 0)then
3188                     varn=varn+1
3189                  end if
3190                  continue   
3191               end if
3192            end if   
3193           
3194            if (vNam(varn) .EQ. "e" .OR. vNam(varn) .EQ. "es") then
3195               if (e .EQ. 0) then
3196                  res@gsnLeftString      = "e and es"
3197                  res@tiXAxisString      = "["+unit(varn)+"]"
3198                  res@gsnRightString     = " "
3199                  if (xs .EQ. -1) then
3200                     res@trXMinF = min((/minie,minies/))
3201                  else
3202                     res@trXMinF = xs
3203                  end if
3204                  if (xe .EQ. -1) then
3205                     res@trXMaxF = max((/maxie,maxies/))
3206                  else
3207                     res@trXMaxF = xe 
3208                  end if
3209                  if (vNam(varn) .EQ. "es")then
3210                     res@xyDashPattern = 1
3211                  end if
3212                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3213
3214                  ; ***************************************************
3215                  ; legend for combined plot
3216                  ; ***************************************************
3217     
3218                  lgres                    = True
3219                  lgMonoDashIndex          = False
3220                  lgres@lgLabelFont        = "helvetica"   
3221                  lgres@lgLabelFontHeightF = font_size_legend           
3222                  lgres@vpWidthF           = 0.06           
3223                  lgres@vpHeightF          = 0.08         
3224                  lgres@lgDashIndexes      = (/0,1,2/)
3225                  lbid = gsn_create_legend(wks,2,(/"e","es"/),lgres)       
3226
3227                  amres = True
3228                  amres@amParallelPosF   = 0.65             
3229                  amres@amOrthogonalPosF = -0.2           
3230                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3231                  overlay(plot(n),plot_e)
3232                  e=1
3233               else
3234                  if (prof3d .EQ. 0)then
3235                     varn=varn+1
3236                  end if
3237                  continue   
3238               end if
3239            end if           
3240            if (vNam(varn) .EQ. "km" .OR. vNam(varn) .EQ. "kh") then
3241               if (km .EQ. 0) then
3242                  res@gsnLeftString      = "km and kh"
3243                  res@tiXAxisString      = "["+unit(varn)+"]"
3244                  res@gsnRightString     = " "
3245                  if (xs .EQ. -1) then
3246                     res@trXMinF = min((/minikm,minikh/))
3247                  else
3248                     res@trXMinF = xs
3249                  end if
3250                  if (xe .EQ. -1) then
3251                     res@trXMaxF = max((/maxikm,maxikh/))
3252                  else
3253                     res@trXMaxF = xe 
3254                  end if
3255                  if (vNam(varn) .EQ. "kh")then
3256                     res@xyDashPattern = 1
3257                  end if
3258                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3259
3260                  ; ***************************************************
3261                  ; legend for combined plot
3262                  ; ***************************************************
3263     
3264                  lgres                    = True
3265                  lgMonoDashIndex          = False
3266                  lgres@lgLabelFont        = "helvetica"   
3267                  lgres@lgLabelFontHeightF = font_size_legend           
3268                  lgres@vpWidthF           = 0.06           
3269                  lgres@vpHeightF          = 0.08         
3270                  lgres@lgDashIndexes      = (/0,1,2/)
3271                  lbid = gsn_create_legend(wks,2,(/"km","kh"/),lgres)       
3272
3273                  amres = True
3274                  amres@amParallelPosF   = 0.65             
3275                  amres@amOrthogonalPosF = -0.2           
3276                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3277                  overlay(plot(n),plot_km)
3278                  km=1
3279               else
3280                  if (prof3d .EQ. 0)then
3281                     varn=varn+1
3282                  end if
3283                  continue   
3284               end if
3285            end if           
3286           
3287            if (vNam(varn) .EQ. "wpup" .OR. vNam(varn) .EQ. "wsus" .OR. vNam(varn) .EQ. "wu") then
3288               if (wpup .EQ. 0) then
3289                  res@gsnLeftString      = "wpup, wsus and wu"
3290                  res@tiXAxisString      = "["+unit(varn)+"]"
3291                  res@gsnRightString     = " "
3292                  if (xs .EQ. -1) then
3293                     res@trXMinF = min((/miniwpup,miniwsus,miniwu/))
3294                  else
3295                     res@trXMinF = xs
3296                  end if
3297                  if (xe .EQ. -1) then
3298                     res@trXMaxF = max((/maxiwpup,maxiwsus,maxiwu/))
3299                  else
3300                     res@trXMaxF = xe 
3301                  end if 
3302                  if (vNam(varn) .EQ. "wsus")then
3303                     res@xyDashPattern = 1
3304                  end if
3305                  if (vNam(varn) .EQ. "wu")then
3306                     res@xyDashPattern = 2
3307                  end if
3308                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3309
3310                  ; ***************************************************
3311                  ; legend for combined plot
3312                  ; ***************************************************
3313     
3314                  lgres                    = True
3315                  lgMonoDashIndex          = False
3316                  lgres@lgLabelFont        = "helvetica"   
3317                  lgres@lgLabelFontHeightF = font_size_legend           
3318                  lgres@vpWidthF           = 0.08           
3319                  lgres@vpHeightF          = 0.12         
3320                  lgres@lgDashIndexes      = (/0,1,2/)
3321                  lbid = gsn_create_legend(wks,3,(/"wpup","wsus","wu"/),lgres)       
3322
3323                  amres = True
3324                  amres@amParallelPosF   = 0.65             
3325                  amres@amOrthogonalPosF = -0.2           
3326                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3327                  overlay(plot(n),plot_wpup)
3328                  wpup=1
3329               else
3330                  if (prof3d .EQ. 0)then
3331                     varn=varn+1
3332                  end if
3333                  continue   
3334               end if
3335            end if
3336            if (vNam(varn) .EQ. "wpvp" .OR. vNam(varn) .EQ. "wsvs" .OR.vNam(varn) .EQ. "wv") then
3337               if (wpvp .EQ. 0) then
3338                  res@gsnLeftString      = "wpvp, wsvs and wv"
3339                  res@tiXAxisString      = "["+unit(varn)+"]"
3340                  res@gsnRightString     = " "
3341                  if (xs .EQ. -1) then
3342                     res@trXMinF = min((/miniwpvp,miniwsvs,miniwv/))
3343                  else
3344                     res@trXMinF = xs
3345                  end if
3346                  if (xe .EQ. -1) then
3347                     res@trXMaxF = max((/maxiwpvp,maxiwsvs,maxiwv/))
3348                  else
3349                     res@trXMaxF = xe 
3350                  end if
3351                  if (vNam(varn) .EQ. "wsvs")then
3352                     res@xyDashPattern = 1
3353                  end if
3354                  if (vNam(varn) .EQ. "wv")then
3355                     res@xyDashPattern = 2
3356                  end if
3357                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3358
3359                  ; ***************************************************
3360                  ; legend for combined plot
3361                  ; ***************************************************
3362     
3363                  lgres                    = True
3364                  lgMonoDashIndex          = False
3365                  lgres@lgLabelFont        = "helvetica"   
3366                  lgres@lgLabelFontHeightF = font_size_legend           
3367                  lgres@vpWidthF           = 0.08         
3368                  lgres@vpHeightF          = 0.12         
3369                  lgres@lgDashIndexes      = (/0,1,2/)
3370                  lbid = gsn_create_legend(wks,3,(/"wpvp","wsvs","wv"/),lgres)       
3371
3372                  amres = True
3373                  amres@amParallelPosF   = 0.65             
3374                  amres@amOrthogonalPosF = -0.2           
3375                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3376                  overlay(plot(n),plot_wpvp)
3377                  wpvp=1
3378               else
3379                  if (prof3d .EQ. 0)then
3380                     varn=varn+1
3381                  end if
3382                  continue   
3383               end if
3384            end if
3385            if (vNam(varn) .EQ. "wpptp" .OR. vNam(varn) .EQ. "wspts" .OR. vNam(varn) .EQ. "wpt") then
3386               if (wpptp .EQ. 0) then
3387                  res@gsnLeftString      = "wpptp, wspts and wpt"
3388                  res@tiXAxisString      = "["+unit(varn)+"]"
3389                  res@gsnRightString     = " "
3390                  if (xs .EQ. -1) then
3391                     res@trXMinF = min((/miniwpptp,miniwspts,miniwpt/))
3392                  else
3393                     res@trXMinF = xs
3394                  end if
3395                  if (xe .EQ. -1) then
3396                     res@trXMaxF = max((/maxiwpptp,maxiwspts,maxiwpt/))
3397                  else
3398                     res@trXMaxF = xe 
3399                  end if
3400                  if (vNam(varn) .EQ. "wspts")then
3401                     res@xyDashPattern = 1
3402                  end if
3403                  if (vNam(varn) .EQ. "wpt")then
3404                     res@xyDashPattern = 2
3405                  end if
3406                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3407
3408                  ; ***************************************************
3409                  ; legend for combined plot
3410                  ; ***************************************************
3411     
3412                  lgres                    = True
3413                  lgMonoDashIndex          = False
3414                  lgres@lgLabelFont        = "helvetica"   
3415                  lgres@lgLabelFontHeightF = font_size_legend           
3416                  lgres@vpWidthF           = 0.09           
3417                  lgres@vpHeightF          = 0.12         
3418                  lgres@lgDashIndexes      = (/0,1,2/)
3419                  lbid = gsn_create_legend(wks,3,(/"wpptp","wspts","wpt"/),lgres)       
3420
3421                  amres = True
3422                  amres@amParallelPosF   = 0.65             
3423                  amres@amOrthogonalPosF = -0.2           
3424                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3425                  overlay(plot(n),plot_wpptp)
3426                  wpptp=1
3427               else
3428                  if (prof3d .EQ. 0)then
3429                     varn=varn+1
3430                  end if
3431                  continue   
3432               end if
3433            end if
3434            if (vNam(varn) .EQ. "wsptsBC" .OR. vNam(varn) .EQ. "wptBC") then
3435               if (wsptsBC .EQ. 0) then
3436                  res@gsnLeftString      = "wsptsBC and wptBC"
3437                  res@tiXAxisString      = "["+unit(varn)+"]"
3438                  res@gsnRightString     = " "
3439                  if (xs .EQ. -1) then
3440                     res@trXMinF = min((/miniwsptsBC,miniwptBC/))
3441                  else
3442                     res@trXMinF = xs
3443                  end if
3444                  if (xe .EQ. -1) then
3445                     res@trXMaxF = max((/maxiwsptsBC,maxiwptBC/))
3446                  else
3447                     res@trXMaxF = xe 
3448                  end if
3449                  if (vNam(varn) .EQ. "wptBC")then
3450                     res@xyDashPattern = 1
3451                  end if
3452                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3453
3454                  ; ***************************************************
3455                  ; legend for combined plot
3456                  ; ***************************************************
3457     
3458                  lgres                    = True
3459                  lgMonoDashIndex          = False
3460                  lgres@lgLabelFont        = "helvetica"   
3461                  lgres@lgLabelFontHeightF = font_size_legend           
3462                  lgres@vpWidthF           = 0.1           
3463                  lgres@vpHeightF          = 0.12         
3464                  lgres@lgDashIndexes      = (/0,1,2/)
3465                  lbid = gsn_create_legend(wks,3,(/"wsptsBC","wptBC"/),lgres)       
3466
3467                  amres = True
3468                  amres@amParallelPosF   = 0.65             
3469                  amres@amOrthogonalPosF = -0.2           
3470                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3471                  overlay(plot(n),plot_wsptsBC)
3472                  wsptsBC=1
3473               else
3474                  if (prof3d .EQ. 0)then
3475                     varn=varn+1
3476                  end if
3477                  continue   
3478               end if 
3479            end if             
3480            if (vNam(varn) .EQ. "wpvptp" .OR. vNam(varn) .EQ. "wsvpts" .OR. vNam(varn) .EQ. "wvpt") then
3481               if (wpvptp .EQ. 0) then
3482                  res@gsnLeftString      = "wpvptp, wsvpts and wvpt"
3483                  res@tiXAxisString      = "["+unit(varn)+"]"
3484                  res@gsnRightString     = " "
3485                  if (xs .EQ. -1) then
3486                     res@trXMinF = min((/miniwpvptp,miniwsvpts,miniwvpt/))
3487                  else
3488                     res@trXMinF = xs
3489                  end if
3490                  if (xe .EQ. -1) then
3491                     res@trXMaxF = max((/maxiwpvptp,maxiwsvpts,maxiwvpt/))
3492                  else
3493                     res@trXMaxF = xe 
3494                  end if
3495                  if (vNam(varn) .EQ. "wsvpts")then
3496                     res@xyDashPattern = 1
3497                  end if
3498                  if (vNam(varn) .EQ. "wvpt")then
3499                     res@xyDashPattern = 2
3500                  end if
3501                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3502
3503                  ; ***************************************************
3504                  ; legend for combined plot
3505                  ; ***************************************************
3506     
3507                  lgres                    = True
3508                  lgMonoDashIndex          = False
3509                  lgres@lgLabelFont        = "helvetica"   
3510                  lgres@lgLabelFontHeightF = font_size_legend           
3511                  lgres@vpWidthF           = 0.1           
3512                  lgres@vpHeightF          = 0.12         
3513                  lgres@lgDashIndexes      = (/0,1,2/)
3514                  lbid = gsn_create_legend(wks,3,(/"wpvptp","wsvpts","wvpt"/),lgres)       
3515
3516                  amres = True
3517                  amres@amParallelPosF   = 0.65             
3518                  amres@amOrthogonalPosF = -0.2           
3519                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3520                  overlay(plot(n),plot_wpvptp)
3521                  wpvptp=1
3522               else
3523                  if (prof3d .EQ. 0)then
3524                     varn=varn+1
3525                  end if
3526                  continue   
3527               end if
3528            end if
3529            if (vNam(varn) .EQ. "wpqp" .OR. vNam(varn) .EQ. "wsqs" .OR. vNam(varn) .EQ. "wq") then
3530               if (wpqp .EQ. 0) then
3531                  res@gsnLeftString      = "wpqp, wsqs and wq"
3532                  res@tiXAxisString      = "["+unit(varn)+"]"
3533                  res@gsnRightString     = " "
3534                  if (xs .EQ. -1) then
3535                     res@trXMinF = min((/miniwpqp,miniwsqs,miniwq/))
3536                  else
3537                     res@trXMinF = xs
3538                  end if
3539                  if (xe .EQ. -1) then
3540                     res@trXMaxF = max((/maxiwpqp,maxiwsqs,maxiwq/))
3541                  else
3542                     res@trXMaxF = xe 
3543                  end if 
3544                  if (vNam(varn) .EQ. "wsqs")then
3545                     res@xyDashPattern = 1
3546                  end if
3547                  if (vNam(varn) .EQ. "wq")then
3548                     res@xyDashPattern = 2
3549                  end if
3550                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3551
3552                  ; ***************************************************
3553                  ; legend for combined plot
3554                  ; ***************************************************
3555     
3556                  lgres                    = True
3557                  lgMonoDashIndex          = False
3558                  lgres@lgLabelFont        = "helvetica"   
3559                  lgres@lgLabelFontHeightF = font_size_legend           
3560                  lgres@vpWidthF           = 0.08           
3561                  lgres@vpHeightF          = 0.12         
3562                  lgres@lgDashIndexes      = (/0,1,2/)
3563                  lbid = gsn_create_legend(wks,3,(/"wpqp","wsqs","wq"/),lgres)       
3564
3565                  amres = True
3566                  amres@amParallelPosF   = 0.65             
3567                  amres@amOrthogonalPosF = -0.2           
3568                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3569                  overlay(plot(n),plot_wpqp)
3570                  wpqp=1
3571               else
3572                  if (prof3d .EQ. 0)then
3573                     varn=varn+1
3574                  end if
3575                  continue   
3576               end if
3577            end if
3578            if (vNam(varn) .EQ. "wpqvp" .OR. vNam(varn) .EQ. "wsqvs" .OR. vNam(varn) .EQ. "wqv") then
3579               if (wpqvp .EQ. 0) then
3580                  res@gsnLeftString      = "wpqvp, wsqvs and wqv"
3581                  res@tiXAxisString      = "["+unit(varn)+"]"
3582                  res@gsnRightString     = " "
3583                  if (xs .EQ. -1) then
3584                     res@trXMinF = min((/miniwpqp,miniwsqvs,miniwqv/))
3585                  else
3586                     res@trXMinF = xs
3587                  end if
3588                  if (xe .EQ. -1) then
3589                     res@trXMaxF = max((/maxiwpqp,maxiwsqvs,maxiwqv/))
3590                  else
3591                     res@trXMaxF = xe 
3592                  end if
3593                  if (vNam(varn) .EQ. "wsqvs")then
3594                     res@xyDashPattern = 1
3595                  end if
3596                  if (vNam(varn) .EQ. "wqv")then
3597                     res@xyDashPattern = 2
3598                  end if
3599                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3600
3601                  ; ***************************************************
3602                  ; legend for combined plot
3603                  ; ***************************************************
3604     
3605                  lgres                    = True
3606                  lgMonoDashIndex          = False
3607                  lgres@lgLabelFont        = "helvetica"   
3608                  lgres@lgLabelFontHeightF = font_size_legend           
3609                  lgres@vpWidthF           = 0.09           
3610                  lgres@vpHeightF          = 0.12         
3611                  lgres@lgDashIndexes      = (/0,1,2/)
3612                  lbid = gsn_create_legend(wks,3,(/"wpqvp","wsqvs","wqv"/),lgres)       
3613
3614                  amres = True
3615                  amres@amParallelPosF   = 0.65             
3616                  amres@amOrthogonalPosF = -0.2           
3617                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3618                  overlay(plot(n),plot_wpqvp)
3619                  wpqvp=1
3620               else
3621                  if (prof3d .EQ. 0)then
3622                     varn=varn+1
3623                  end if
3624                  continue   
3625               end if
3626            end if
3627            if (vNam(varn) .EQ. "wpsp" .OR. vNam(varn) .EQ. "wsss" .OR. vNam(varn) .EQ. "ws") then
3628               if (wpsp .EQ. 0) then
3629                  res@gsnLeftString      = "wpsp, wsss and ws"
3630                  res@tiXAxisString      = "["+unit(varn)+"]"
3631                  res@gsnRightString     = " "
3632                  if (xs .EQ. -1) then
3633                     res@trXMinF = min((/miniwpsp,miniwsss,miniws/))
3634                  else
3635                     res@trXMinF = xs
3636                  end if
3637                  if (xe .EQ. -1) then
3638                     res@trXMaxF = max((/maxiwpsp,maxiwsss,maxiws/))
3639                  else
3640                     res@trXMaxF = xe 
3641                  end if
3642                  if (vNam(varn) .EQ. "wsss")then
3643                     res@xyDashPattern = 1
3644                  end if
3645                  if (vNam(varn) .EQ. "ws")then
3646                     res@xyDashPattern = 2
3647                  end if
3648                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3649
3650                  ; ***************************************************
3651                  ; legend for combined plot
3652                  ; ***************************************************
3653     
3654                  lgres                    = True
3655                  lgMonoDashIndex          = False
3656                  lgres@lgLabelFont        = "helvetica"   
3657                  lgres@lgLabelFontHeightF = font_size_legend           
3658                  lgres@vpWidthF           = 0.08           
3659                  lgres@vpHeightF          = 0.12         
3660                  lgres@lgDashIndexes      = (/0,1,2/)
3661                  lbid = gsn_create_legend(wks,3,(/"wpsp","wsss","ws"/),lgres)       
3662
3663                  amres = True
3664                  amres@amParallelPosF   = 0.65             
3665                  amres@amOrthogonalPosF = -0.2           
3666                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3667                  overlay(plot(n),plot_wpsp)
3668                  wpsp=1
3669               else
3670                  if (prof3d .EQ. 0)then
3671                     varn=varn+1
3672                  end if
3673                  continue   
3674               end if
3675            end if
3676            if (vNam(varn) .EQ. "wpsap" .OR.vNam(varn) .EQ. "wssas" .OR. vNam(varn) .EQ. "wsa") then
3677               if (wpsap .EQ. 0) then
3678                  res@gsnLeftString      = "wpsap, wssas and wsa"
3679                  res@tiXAxisString      = "["+unit(varn)+"]"
3680                  res@gsnRightString     = " "
3681                  if (xs .EQ. -1) then
3682                     res@trXMinF = min((/miniwpsap,miniwssas,miniwsa/))
3683                  else
3684                     res@trXMinF = xs
3685                  end if
3686                  if (xe .EQ. -1) then
3687                     res@trXMaxF = max((/maxiwpsap,maxiwssas,maxiwsa/))
3688                  else
3689                     res@trXMaxF = xe 
3690                  end if
3691                  if (vNam(varn) .EQ. "wssas")then
3692                     res@xyDashPattern = 1
3693                  end if
3694                  if (vNam(varn) .EQ. "wsa")then
3695                     res@xyDashPattern = 2
3696                  end if
3697                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3698
3699                  ; ***************************************************
3700                  ; legend for combined plot
3701                  ; ***************************************************
3702     
3703                  lgres                    = True
3704                  lgMonoDashIndex          = False
3705                  lgres@lgLabelFont        = "helvetica"   
3706                  lgres@lgLabelFontHeightF = font_size_legend           
3707                  lgres@vpWidthF           = 0.09           
3708                  lgres@vpHeightF          = 0.12         
3709                  lgres@lgDashIndexes      = (/0,1,2/)
3710                  lbid = gsn_create_legend(wks,3,(/"wpsap","wssas","wsa"/),lgres)       
3711
3712                  amres = True
3713                  amres@amParallelPosF   = 0.65             
3714                  amres@amOrthogonalPosF = -0.2           
3715                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3716                  overlay(plot(n),plot_wpsap)
3717                  wpsap=1
3718               else
3719                  if (prof3d .EQ. 0)then
3720                     varn=varn+1
3721                  end if
3722                  continue   
3723               end if
3724            end if
3725         
3726            if (vNam(varn) .EQ. "us2" .OR. vNam(varn) .EQ. "vs2" .OR. vNam(varn) .EQ. "ws2") then
3727               if (us2 .EQ. 0) then
3728                  res@gsnLeftString      = "us2, vs2 and ws2"
3729                  res@tiXAxisString      = "["+unit(varn)+"]"
3730                  res@gsnRightString     = " "
3731                  if (xs .EQ. -1) then
3732                     res@trXMinF = min((/minius2,minivs2,miniws2/))
3733                  else
3734                     res@trXMinF = xs
3735                  end if
3736                  if (xe .EQ. -1) then
3737                     res@trXMaxF = max((/maxius2,maxivs2,maxiws2/))
3738                  else
3739                     res@trXMaxF = xe 
3740                  end if
3741                  if (vNam(varn) .EQ. "vs2")then
3742                     res@xyDashPattern = 1
3743                  end if
3744                  if (vNam(varn) .EQ. "ws2")then
3745                     res@xyDashPattern = 2
3746                  end if
3747                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3748
3749                  ; ***************************************************
3750                  ; legend for combined plot
3751                  ; ***************************************************
3752     
3753                  lgres                    = True
3754                  lgMonoDashIndex          = False
3755                  lgres@lgLabelFont        = "helvetica"   
3756                  lgres@lgLabelFontHeightF = font_size_legend           
3757                  lgres@vpWidthF           = 0.07           
3758                  lgres@vpHeightF          = 0.12         
3759                  lgres@lgDashIndexes      = (/0,1,2/)
3760                  lbid = gsn_create_legend(wks,3,(/"us2","vs2","ws2"/),lgres)       
3761
3762                  amres = True
3763                  amres@amParallelPosF   = 0.65             
3764                  amres@amOrthogonalPosF = -0.2           
3765                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3766                  overlay(plot(n),plot_us2)
3767                  us2=1
3768               else
3769                  if (prof3d .EQ. 0)then
3770                     varn=varn+1
3771                  end if
3772                  continue   
3773               end if
3774            end if
3775           
3776            if (vNam(varn) .EQ. "wsususodz" .OR. vNam(varn) .EQ. "wspsodz" .OR. vNam(varn) .EQ. "wpeodz" ) then
3777               if (wsususodz .EQ. 0) then
3778                  res@gsnLeftString      = "wsususodz, wspsodz and wpeodz"
3779                  res@tiXAxisString      = "["+unit(varn)+"]"
3780                  res@gsnRightString     = " "
3781                  if (xs .EQ. -1) then
3782                     res@trXMinF = min((/miniwsususodz,miniwspsodz,miniwpeodz/))
3783                  else
3784                     res@trXMinF = xs
3785                  end if
3786                  if (xe .EQ. -1) then
3787                     res@trXMaxF = max((/maxiwsususodz,maxiwspsodz,maxiwpeodz/))
3788                  else
3789                     res@trXMaxF = xe 
3790                  end if
3791                  if (vNam(varn) .EQ. "wspsodz")then
3792                     res@xyDashPattern = 1
3793                  end if
3794                  if (vNam(varn) .EQ. "wpeodz")then
3795                     res@xyDashPattern = 2
3796                  end if
3797                  plot(n) =  gsn_csm_xy(wks,data(varn,:,:),z,res)
3798
3799                  ; ***************************************************
3800                  ; legend for combined plot
3801                  ; ***************************************************
3802     
3803                  lgres                    = True
3804                  lgMonoDashIndex          = False
3805                  lgres@lgLabelFont        = "helvetica"   
3806                  lgres@lgLabelFontHeightF = font_size_legend           
3807                  lgres@vpWidthF           = 0.12           
3808                  lgres@vpHeightF          = 0.12         
3809                  lgres@lgDashIndexes      = (/0,1,2/)
3810                  lbid = gsn_create_legend(wks,3,(/"wsususodz","wspsodz","wpeodz"/),lgres)       
3811
3812                  amres = True
3813                  amres@amParallelPosF   = 0.65             
3814                  amres@amOrthogonalPosF = -0.2           
3815                  annoid1 = gsn_add_annotation(plot(n),lbid,amres)                 
3816                  overlay(plot(n),plot_wsususodz)
3817                  wsususodz=1
3818               else
3819                  if (prof3d .EQ. 0)then
3820                     varn=varn+1
3821                  end if
3822                  continue   
3823               end if
3824            end if     
3825            n=n+1
3826            if (prof3d .EQ. 0)then
3827               varn=varn+1
3828            end if   
3829         end if
3830      end do
3831   end if
3832   
3833   com_var_avail=new(count_var,string)   
3834
3835   if (combine .EQ. 1) then
3836      co=0     
3837      n_o=0
3838      do varn = 0,dim-1
3839 
3840         check = True
3841     
3842         if (prof3d .EQ. 0) then
3843            if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
3844               check = False
3845            end if
3846         else
3847            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
3848               check = False
3849            end if
3850         end if
3851
3852         if (var .NE. "all") then         
3853            check = isStrSubset( var,","+vNam(varn)+"," )
3854         end if     
3855
3856         if (check)then
3857           
3858            if (prof3d .EQ. 0) then
3859               if (log_z .EQ. 1) then
3860                  z = f_att->$vNam(varn+1)$(1:dimz-1)
3861               else
3862                  z = f_att->$vNam(varn+1)$               
3863               end if
3864            else
3865               do i=0,b-1           
3866                  if (isStrSubset( a(i),"zu_3d" ))then
3867                     z_v(varn,:) = z_u
3868                     if (log_z .EQ. 1) then
3869                        z = z_v(varn,1:dimz-1)
3870                     else
3871                        z = z_v(varn,:)
3872                     end if
3873                  else
3874                     if (isStrSubset( a(i),"zw_3d" ))then
3875                        z_v(varn,:) = z_w
3876                        if (log_z .EQ. 1) then
3877                           z = z_v(varn,1:dimz-1)
3878                        else
3879                           z = z_v(varn,:)
3880                        end if
3881                     end if                   
3882                  end if
3883               end do           
3884            end if
3885
3886            z=z/norm_z
3887           
3888            com_var_avail(n_o)=vNam(varn)
3889           
3890            com=isStrSubset( c_var,","+vNam(varn)+"," )
3891            if (com)then
3892               co = co+1           
3893               if (n_o .EQ. 1) then
3894                  res@xyDashPattern  = 1                                   
3895               else           
3896                  if (n_o .EQ. 2) then
3897                     res@xyDashPattern  = 2
3898                  else
3899                     res@xyDashPattern  = 0
3900                     res@gsnLeftString  = "Combined Plot of "+c_var
3901                     res@tiXAxisString      = "["+unit(varn)+"]"
3902                     res@gsnRightString     = " "
3903                     if (xs .EQ. -1) then
3904                        res@trXMinF = min(mini)
3905                     else
3906                        res@trXMinF = xs
3907                     end if
3908                     if (xe .EQ. -1) then
3909                        res@trXMaxF = max(maxi)
3910                     else
3911                        res@trXMaxF = xe 
3912                     end if
3913                  end if
3914               end if
3915               label(n_o)=vNam(varn)
3916               color_o(n_o)=237
3917               plot_o(n_o)=gsn_csm_xy(wks,data(varn,:,:),z,res)
3918               n_o=n_o+1
3919            end if
3920            if (prof3d .EQ. 0)then
3921               varn=varn+1
3922            end if           
3923         end if
3924      end do
3925   
3926      if(number_comb .EQ. 2)then
3927         if (co .EQ. 2)then
3928            overlay(plot_o(0),plot_o(1))
3929         else
3930            print(" ")
3931            print("combining is not possible,")
3932            print("'c_var'(= "+c_var+") must include two variables of the general plots = ")
3933            print("- "+com_var_avail)
3934            print("be sure to have one comma before and after the variable")
3935            print(" ")
3936            exit 
3937         end if
3938      end if
3939      if(number_comb .EQ. 3)then
3940         if (co .EQ. 3)then
3941            overlay(plot_o(0),plot_o(1))
3942            overlay(plot_o(0),plot_o(2))
3943         else
3944            print(" ")
3945            print("combining is not possible,")
3946            print("'c_var'(= "+c_var+") must include three variables of the general plots = ")
3947            print("- "+com_var_avail)
3948            print("be sure to have one comma before and after the variable")
3949            print(" ")
3950            exit
3951         end if
3952      end if
3953
3954      ; ***************************************************
3955      ; legend for combined plot
3956      ; ***************************************************
3957     
3958      lgres                    = True
3959      lgMonoDashIndex          = False
3960      lgres@lgDashIndexes      = (/0,1,2/)
3961      lgres@lgLabelFont        = "helvetica"   
3962      lgres@lgLabelFontHeightF = font_size_legend           
3963      lgres@vpWidthF           = 0.12           
3964      lgres@vpHeightF          = 0.1           
3965 
3966      lbid = gsn_create_legend(wks,number_comb,label,lgres)       
3967
3968      amres = True
3969      amres@amParallelPosF   = 0.65                 
3970      amres@amOrthogonalPosF = -0.2           
3971      annoid1 = gsn_add_annotation(plot_o(0),lbid,amres)
3972   
3973      plot(0) = plot_o(0)
3974
3975   end if
3976
3977   ; ***************************************************
3978   ; merge plots onto one page
3979   ; ***************************************************
3980
3981   do m=0,n-1
3982      plot_(m)=plot(n-1-m)
3983   end do
3984
3985   if (format_out .EQ. "eps" .OR. format_out .EQ. "epsi") then
3986      gsn_panel(wks,plot_,(/n,1/),resP)
3987      print(" ")
3988      print("Outputs to .eps or .epsi have only one frame")
3989      print(" ")
3990   else   
3991      do i = 0,n-1, no_rows*no_columns
3992         if( (i+no_rows*no_columns) .gt. (n-1)) then
3993            gsn_panel(wks,plot_(i:n-1),(/no_rows,no_columns/),resP)
3994         else
3995            gsn_panel(wks,plot_(i:i+no_rows*no_columns-1),(/no_rows,no_columns/),resP)
3996         end if
3997      end do
3998   end if
3999
4000   print(" ")
4001   print("Output to: " + file_out +"."+ format_out)
4002   print(" ")
4003
4004end
Note: See TracBrowser for help on using the repository browser.