Re: reading a lot of variables

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 09 2012 - 13:23:51 MST

Hi Ahmed,
When you get a subscript out of range statement, it usually refers to an
instance where you are calling for an index number that is beyond the
range of your array.

For instance, if you did this:
*var1=new(72,"string")*
*do i=1,72*
*var1(i)="EVAPORAT_GDS0_SFC_acc"+i+"h"*
*lsp = wrf->$var1(i)$
print("Now done with i = "+i)
*
*end do

*That would result in an error message when NCL tries to access
var1(72), as var1 is of size 72 with indices ranging from var1(0) to
var1(71). (NCL is a 0-based indexing language.)
Hope that helps.. Adam

On 01/09/2012 01:11 PM, ahmed lasheen wrote:
> thanks for your help
> here is the output
> (0)Now done with i = 2
> (0)Now done with i = 3
> (0)Now done with i = 4
> (0)Now done with i = 5
> (0)Now done with i = 6
> (0)Now done with i = 7
> (0)Now done with i = 8
> (0)Now done with i = 9
> (0)Now done with i = 10
> (0)Now done with i = 11
> (0)Now done with i = 12
> (0)Now done with i = 13
> (0)Now done with i = 14
> (0)Now done with i = 15
> (0)Now done with i = 16
> (0)Now done with i = 17
> (0)Now done with i = 18
> (0)Now done with i = 19
> (0)Now done with i = 20
> (0)Now done with i = 21
> (0)Now done with i = 22
> (0)Now done with i = 23
> (0)Now done with i = 24
> (0)Now done with i = 25
> (0)Now done with i = 26
> (0)Now done with i = 27
> (0)Now done with i = 28
> (0)Now done with i = 29
> (0)Now done with i = 30
> (0)Now done with i = 31
> (0)Now done with i = 32
> (0)Now done with i = 33
> (0)Now done with i = 34
> (0)Now done with i = 35
> (0)Now done with i = 36
> (0)Now done with i = 37
> (0)Now done with i = 38
> (0)Now done with i = 39
> (0)Now done with i = 40
> (0)Now done with i = 41
> (0)Now done with i = 42
> (0)Now done with i = 43
> (0)Now done with i = 44
> (0)Now done with i = 45
> (0)Now done with i = 46
> (0)Now done with i = 47
> (0)Now done with i = 48
> (0)Now done with i = 49
> (0)Now done with i = 50
> (0)Now done with i = 51
> (0)Now done with i = 52
> (0)Now done with i = 53
> (0)Now done with i = 54
> (0)Now done with i = 55
> (0)Now done with i = 56
> (0)Now done with i = 57
> (0)Now done with i = 58
> (0)Now done with i = 59
> (0)Now done with i = 60
> (0)Now done with i = 61
> (0)Now done with i = 62
> (0)Now done with i = 63
> (0)Now done with i = 64
> (0)Now done with i = 65
> (0)Now done with i = 66
> (0)Now done with i = 67
> (0)Now done with i = 68
> (0)Now done with i = 69
> (0)Now done with i = 70
> fatal:Subscript out of range, error in subscript #0
> fatal:Execute: Error occurred at or near line 84 in file cosmo.ncl
>
> the line 84 is
> var1(i)="RAIN_GSP_GDS0_SFC_acc"+i+"h"
>
> thanks in advance
>
> On Mon, Jan 9, 2012 at 9:44 PM, Adam Phillips <asphilli@ucar.edu
> <mailto:asphilli@ucar.edu>> wrote:
>
> Hi Ahmed,
> I think you meant to say this:
> *var1(i)="EVAPORAT_GDS0_SFC_acc"+i+"h"*
>
> Although I don't see how that would cause your error. Try
> inserting a print statement:
>
> *var1=new(18,"string")*
> *do i=1,17*
> *var1(i)="EVAPORAT_GDS0_SFC_acc"+i+"h"*
> *lsp = wrf->$var1(i)$
> print("Now done with i = "+i)
> *
> *end do *
> *
> *to see if that helps identify where the do loop is
> crashing.**Hope that helps.. Adam*
> *
>
>
> On 01/09/2012 12:36 PM, ahmed lasheen wrote:
>> Hello
>> i have a file grib contains alot of variable which have the
>> following names
>> EVAPORAT_GDS0_SFC_acc1h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc2h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc3h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc4h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc5h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc6h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc7h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc8h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc9h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc10h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc11h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc12h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc13h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc14h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc15h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc16h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc17h ( g0_lat_1, g0_lon_2 )
>> EVAPORAT_GDS0_SFC_acc18h ( g0_lat_1, g0_lon_2 )
>>
>> i wrote ncl code to read it in do loop but i got error
>>
>> *var1=new(18,"string")*
>> *do i=1,17*
>> *var1(i)="EVAPORAT_GDS0_SFC_acc1h"+i+"h"*
>> *lsp = wrf->$var1(i)$ *
>> *end do *
>> *
>> *
>> but i got error ,fatal:Subscript out of range, error in subscript #0
>> could anybody told me how can i read all this variable in do loop.
>> thanks in advance
>>
>>
>>
>>
>> --
>> ===============
>> Ahmed Lasheen
>> Junior researcher at Cairo Numerical Weather Prediction Center
>> (CNWPC)
>> Egyptian Meteorological Authority(EMA)
>> Cairo,Egypt
>> ===============
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillipsasphilli@ucar.edu <mailto:asphilli@ucar.edu>
> NCAR/Climate and Global Dynamics Division (303) 497-1726
> P.O. Box 3000
> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> ===============
> Ahmed Lasheen
> Junior researcher at Cairo Numerical Weather Prediction Center (CNWPC)
> Egyptian Meteorological Authority(EMA)
> Cairo,Egypt
> ===============
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 9 13:24:01 2012

This archive was generated by hypermail 2.1.8 : Wed Jan 18 2012 - 09:21:55 MST