Index: palm/trunk/SCRIPTS/NCL/ncl_preferences.ncl
===================================================================
--- palm/trunk/SCRIPTS/NCL/ncl_preferences.ncl	(revision 336)
+++ palm/trunk/SCRIPTS/NCL/ncl_preferences.ncl	(revision 342)
@@ -195,5 +195,5 @@
       ; data type: string 
       ; 
-      ; example: var = ",u,v,w"
+      ; example: var = ",u,v,w,"
       ;
       ; default:   "all" (all available variables are plotted)
@@ -788,5 +788,5 @@
       ; data type: string 
       ; 
-      ; example: var = ",u,v,w"; 
+      ; example: var = ",u,v,w,"; 
       ;
       ; default:   "all" (all available variables are plotted)
@@ -1726,5 +1726,5 @@
       ; data type: string 
       ; 
-      ; example: var = ",u,v,w"
+      ; example: var = ",u,v,w,"
       ;
       ; default:   "all" (all available variables are plotted)
@@ -2141,5 +2141,5 @@
       ; data type: string 
       ; 
-      ; example: var = ",u,v,w"
+      ; example: var = ",u,v,w,"
       ;
       ; default:   "all" (all available variables are plotted)
Index: palm/trunk/SCRIPTS/NCL/profiles.ncl
===================================================================
--- palm/trunk/SCRIPTS/NCL/profiles.ncl	(revision 336)
+++ palm/trunk/SCRIPTS/NCL/profiles.ncl	(revision 342)
@@ -357,5 +357,5 @@
    ListSetType(f,"cat")
    
-   vNam = getfilevarnames(f_att) 
+   vNam = getfilevarnames(f_att)    
    
    if (nof .EQ. 0)then
@@ -401,4 +401,98 @@
       end if
    end do
+  
+   if (var .NE. "all") then
+      ;rearrange the order of the variables in vNam so that the variables 
+      ;specified by "var" are in the top of vNam
+
+      vNam_static = new((/dim/),string)
+      vNam_temp   = new((/dim/),string)
+      
+      var_char    = stringtocharacter(var)
+      no_char     = dimsizes(var_char)
+      comma       = 0
+       
+      do j=0,no_char-1
+         if(var_char(j) .eq. ",")
+            comma = comma + 1
+         end if
+      end do
+
+      if(comma .le. 1)
+          print(" ")
+          print("The variables 'var="+var+"'" )
+          print("do not exist on your input file;")
+          print("be sure to have one comma before and after each variable")
+          print(" ")
+          exit
+      end if
+
+      indices = new((/comma/),integer)
+      comma   = 0
+        
+      do j=0,no_char-1
+         if(var_char(j) .eq. ",")
+           indices(comma) = j
+           comma          = comma + 1
+         end if
+      end do
+
+      do j=0,comma-2
+         vNam_temp(j) = charactertostring(var_char(indices(j)+1:indices(j+1)-1))
+      end do
+
+      do j=0,comma-2
+         vNam_static(j) = vNam_temp(comma - 2 - j)
+      end do
+
+      vNam_temp   = vNam_static
+      vNam_static = ""
+
+      if (prof3d .EQ. 0) then
+         i = 0
+         do j=0,dim-1,2
+            vNam_static(j)   = vNam_temp(i)
+            vNam_static(j+1) = "z" + vNam_static(j)
+            i = i+1
+            if(i .eq. comma-1)
+                break
+            end if
+         end do
+
+         delete(vNam_temp)
+         count_variable = 2*(comma-1) 
+      else
+         i = 0
+          do j=0,dim-1,1
+             vNam_static(j) = vNam_temp(i)
+             i = i+1
+             if(i .eq. comma-1)
+                 break
+             end if
+          end do
+
+          delete(vNam_temp)
+          count_variable = comma-1 
+      end if
+
+      counter  = 0
+      counter2 = 0
+      do j=0,dim-1
+         counter = 0
+         do i = 0, count_variable - 1        
+            if(vNam_static(i) .ne. vNam(j))
+               counter = counter + 1
+            end if
+         end do
+      
+         if (counter .eq. count_variable)
+            vNam_static(count_variable + counter2) = vNam(j)
+            counter2 = counter2 + 1
+         end if
+      end do
+     
+      vNam = vNam_static 
+      delete(vNam_static)
+    end if
 
    ;-----------------------------------------------------below steps only for first file -> nof=0
@@ -417,7 +511,6 @@
    if (prof3d .EQ. 0) then
  
-   do varn = dim-1,0,1
+   do varn=0,dim-1
       if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
-         varn=varn-1
          continue
       end if
@@ -531,10 +624,8 @@
          end if
       end if
-      varn=varn-1
    end do
 
-   do varn=dim-1,0,1
+   do varn=0,dim-1
       if ( isStrSubset( vNam(varn), "time") .OR. isStrSubset( vNam(varn), "NORM")) then
-         varn=varn-1
          continue
       end if 
@@ -703,5 +794,4 @@
          end if
       end if
-      varn=varn-1
    end do
    
@@ -733,8 +823,9 @@
       if (co .EQ. 0) then
          print(" ")
-         print("The variables 'var="+var+"' do not exist on your input file;")
-	 print("be sure to have one comma berfore and after each variable")
-         print(" ")
-         exit
+         print("The variables 'var="+var+"'" )
+         print("do not exist on your input file;")
+         print("be sure to have one comma before and after each variable")
+         print(" ")
+         exit           
       end if
    end if
@@ -789,5 +880,5 @@
       exit
    end if
-   
+  
    if (prof3d .EQ. 1)then
       t_all = f[:]->time
@@ -876,6 +967,4 @@
    do i=0,nt-1     
       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
-         print((t_all(i)-delta_t/2)/3600)
-	 print((t_all(i)+delta_t/2)/3600) 
          et=i
          break
@@ -896,7 +985,4 @@
    end_time_step=round(et,3)
    
-   print(start_time_step)
-   print(end_time_step)
-
    print(" ")
    print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+t_all(start_time_step)+" s => index = "+start_time_step)
@@ -1054,4 +1140,5 @@
          end if    
       end if
+   
       if (isvar("z_w"))then
          if (min_z .GE. max(z_w) ) then
@@ -1496,16 +1583,10 @@
 
       if(check) then
-         if (isStrSubset(vNam(varn),"_0" ))then
-            print(" ")
-            print("If you have Outputs of statistic regions you cannot overlay variables; 'over' is set to 0")
-            print(" ")
-            over = 0
-         end if
-        
+         
          count_var=count_var+1
 
          if (prof3d .EQ. 0) then
 	    if (t_null)then
-               temp = f[:]->$vNam(varn)$(1:,:)
+               temp = f[:]->$vNam(varn)$(1:,:) 
 	    else
 	       temp = f[:]->$vNam(varn)$
@@ -1520,4 +1601,5 @@
 		     data_temp = temp(j,i,start_y:end_y,start_x:end_x)
                      data(varn,j-start_time_step,i-1) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
+                     delete(data_temp)
                   end do
                end do
@@ -1531,4 +1613,5 @@
 		     data_temp!1 = "z"
                      data(varn,j-start_time_step,i) = dim_avg_Wrap(dim_avg_Wrap(data_temp))
+                     delete(data_temp)
                   end do
                end do
@@ -2701,8 +2784,17 @@
    if (count_var .EQ. 0) then
       print(" ")
-      print("The variables 'var="+var+"' do not exist on your input file;")
-      print("be sure to have one comma berfore and after each variable")
-      print(" ")
-      exit
+      print("The variables 'var="+var+"'" )
+      print("do not exist on your input file;")
+      print("be sure to have one comma before and after each variable")
+      print(" ")
+      exit        
+   end if
+
+   if (isStrSubset(data@long_name," SR " ))then
+      print(" ")
+      print("If you have outputs of statistic regions you cannot overlay variables;")
+      print("'over' is set to 0" )
+      print(" ")
+      over = 0
    end if
    
@@ -3762,5 +3854,4 @@
 	    
             com=isStrSubset( c_var,","+vNam(varn)+"," )
-        
             if (com)then 
                co = co+1           
@@ -3806,5 +3897,5 @@
             print("'c_var'(= "+c_var+") must include two variables of the general plots = ")
 	    print("- "+com_var_avail)
-	    print("be sure to have one comma berfore and after the variable")
+	    print("be sure to have one comma before and after the variable")
             print(" ")
             exit  
@@ -3820,5 +3911,5 @@
             print("'c_var'(= "+c_var+") must include three variables of the general plots = ")
 	    print("- "+com_var_avail)
-	    print("be sure to have one comma berfore and after the variable")
+	    print("be sure to have one comma before and after the variable")
             print(" ")
             exit
