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

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

ncl_preferences is renamed .ncl.config.default

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