Re: "Dimension sizes of left hand and right hand side ofassignment do not match"

From: Shaw, Michael <MICHAEL.SHAW_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 11 2010 - 11:18:39 MST

Thank you. The problem arises with other filenames ("fname", e.g.), also.

________________________________

From: ncl-talk-bounces@ucar.edu on behalf of Wei Huang
Sent: Thu 3/11/2010 10:13 AM
To: Shaw, Michael
Cc: ncl-talk@ucar.edu
Subject: Re: "Dimension sizes of left hand and right hand side ofassignment do not match"

Michael,

With your sample file, you may try the following code.
The main problem with your code is that "file" is a reserved word in NCL.

Regards,

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

-----------------------
do i=0,0
   ii=i+1
   ic=new((/1/),string)
   ic=ii

   fl="f"+ic
   vars = asciiread(fl,-1,"string")
   print(vars)
   strs = str_get_field(vars, 2, " ")
   print(strs)
   var_of_interest = stringtofloat(strs)
   print(var_of_interest)
   delete(strs)
   delete(var_of_interest)

   strs = str_get_cols(vars, 24, 25)
   print(strs)
   var_of_interest = stringtofloat(strs)
   print(var_of_interest)
   delete(vars)
   delete(strs)
   delete(var_of_interest)
end do

On Mar 11, 2010, at 10:58 AM, Shaw, Michael wrote:

        
        
        Hello.

         

        I'm using ncl 5.1.1. In a do loop that updates file names ("file" here) and reads from those files, I am trying to

         

        vars = asciiread(file,-1,"string")
        var_of_interest=stringtofloat(str_get_cols(vars,beg_col,end_col))

         

        However, I get the "Dimension sizes of left hand and right hand side of assignment do not match" at the line number for the "vars=asciiread..." after the first do loop iteration. It looks like this kind of thing is a pretty common problem to stumble upon (via googling for this), but when I try and implement the suggested fixes, they don't seem to work (e.g., deleting used arrays after they've been used, i.e., after the "var_of_interest=..." line, trying to do different things with the dimensioning/sizing of the vars, etc.).

         

        Any suggestions?

         

        Sample code:

         

        "do i=0,9-1
         
        ii=i+1
        ic=new((/1/),string)
        ic=ii
         
        file="/home/"+ic
        vars = asciiread(file,-1,"string")
        var_of_interest = stringtofloat(str_get_cols(vars,28,30))
        print(var_of_interest)
        ;delete(vars)
        ;delete(var_of_interest)
        end do"
         
        And it might be working on ascii files like one called "1" looking like:
         
        "Bogus ascii file
        blahblahblah 123
        blahblahblah 321"
         
        There might be 9 of these files, called "1" through "9".

         

        Thanks!
        _______________________________________________
        ncl-talk mailing list
        List instructions, subscriber options, unsubscribe:
        http://mailman.ucar.edu/mailman/listinfo/ncl-talk
        

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 11 11:20:18 2010

This archive was generated by hypermail 2.1.8 : Fri Mar 12 2010 - 09:11:56 MST