source: palm/tags/release-3.5/SCRIPTS/NCL/profiles.ncl @ 2977

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