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

Last change on this file since 336 was 324, checked in by weinreis, 15 years ago

modified spectra.ncl and profiles.ncl

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