Re: Segmentation fault when trying to use named subscripting on file list returned by addfiles

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Sat May 12 2012 - 09:36:24 MDT

Jiapeng,

Below is probably what you want.

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

---------------------
;Create two simple data files
 system("rm -f a.nc b.nc")
 f = addfile("a.nc", "c")

 dim = (/0, 1, 2, 3/);
 f->dim = dim
 f->var = (/1, 2, 3, 4/)
 f->var!0 = "dim"
 delete(f)

 system("cp a.nc b.nc")

 fs = addfiles((/"a.nc", "b.nc"/), "r")
;Two integers read
 var0 = fs[:]->var((/0, 2/))
 print(var0)

 nf = ListCount(fs)
;print(nf)

 ncl_join = ispan(0, nf-1, 1)
;print(ncl_join)

 dim0 = dim(::2)
 print(dim0)

;NO Segmentation fault now
 var1 = fs[:]->var(dim0)
 print(var1)

 ListSetType(fs, "join")

;Four integers read
 var2 = fs[:]->var(:, (/0, 2/))
 print(var2)

;NO Segmentation fault now
 var3 = fs[:]->var(ncl_join, dim0)
 print(var3)

On May 12, 2012, at 5:39 AM, 李嘉鹏 wrote:

> $ ncl seg_fault.ncl
> Copyright (C) 1995-2011 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> rm: remove regular file ‘a.nc’? y
> cp: overwrite ‘b.nc’? y
>
>
> Variable: var0
> Type: integer
> Total Size: 8 bytes
> 2 values
> Number of Dimensions: 1
> Dimensions and sizes: [dim0 | 2]
> Coordinates:
> Number Of Attributes: 0
> (0) 1
> (1) 3
> Segmentation fault
>
> On two machines:
> Linux xxx 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
>
> Linux xxx 3.3.5-3-uksm #1 SMP PREEMPT Thu May 10 23:07:07 CST 2012 x86_64 AMD Phenom(tm) 9150e Quad-Core Processor AuthenticAMD GNU/Linux
>
> Are there possible ways to use named subscripting at situations like this? to make the code a little more self-documented
>
>
> <seg_fault.ncl>_______________________________________________
> 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 Sat May 12 09:36:39 2012

This archive was generated by hypermail 2.1.8 : Thu May 17 2012 - 13:42:02 MDT