[ncl-talk] Segmentation fault: Read variables with different time units using addfiles

Hoffman Cheung hoffmancheung at gmail.com
Tue Jul 5 13:56:14 MDT 2016


Hello,

For some CMIP5 models, they use different time units for different files of
the same parameter (say "days since 1950-1-1" for the first file; "days
since 1960-1-1" for the second file, and so on). For data analysis, it is
convenient to use addfiles to read the parameter at different files (say,
read all summer months using one simple line).

The function addfiles works perfectly for the datasets when their files
have the same time unit. However, when I apply the same method for reading
the files have different time units, segmentation fault always occurs when
the program neither (i) read all files nor (ii) read one file.

I checked the program, and I think the following is main points:

First, when addfiles is used for reading all files, it works perfectly even
if the files have different time units. The time unit of these files would
be the same as the first file.

Example:
if the positions 10 and 11 are from two separate files, and
time(10) = 10  ; unit: days since 1950-1-1
time(11) = 0    ; unit: days since 1951-1-1

f = addfiles(filesIN,"r")
t = f[:]->time

Then, if the program prints time(10:11), then the output is
[0] 10
[1] 365

Second, when addfiles is used for reading more than one file but not all
files, the time unit would not be changed:

Same as the above example, but I use the following line to read time

t = f[:]->time(10:11)

Then, if the program prints time, then the output is:
[0] 10
[1] 0

Segmentation fault occurs when the program reads more time

I have attached two programs for simply checking how it works for reading
files with different time units. For the first program ("d01_create_file.nc"),
it generates 20 files with different time units. For the second program, it
reads the files generated from the first program. I have commented the part
that leads to segmentation fault.

Definitely, I can solve this problem by first changing the time units of
these files. Or I can use alternative methods to carry out my analyses (I
think I encountered the same problem several years ago, but I did not
report the problem). However, it will be great if this issue can be solved.

Thank you for the reply!

Best Regards,
Hoffman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160705/efbc8e54/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d01_create_file.ncl
Type: application/octet-stream
Size: 579 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160705/efbc8e54/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d02_read_file.ncl
Type: application/octet-stream
Size: 368 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160705/efbc8e54/attachment-0001.obj 


More information about the ncl-talk mailing list