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

Last change on this file since 959 was 959, checked in by hoffmann, 12 years ago

bugfixes in palmplot and cross_profiles

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