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

David Brown dbrown at ucar.edu
Mon Jul 18 15:32:25 MDT 2016


Hi Hoffman,

This problem has been fixed for the next release of NCL. Let us know
if you would like to test this out prior to the release.
 -dave

On Tue, Jul 12, 2016 at 4:08 PM, David Brown <dbrown at ucar.edu> wrote:
> Hi Hoffman,
> I am looking into this issue now. Thank you for providing scripts that
> illustrate the problem perfectly without the need for any data files.
> My apologies for taking so long to respond.
>  -dave
>
> On Tue, Jul 5, 2016 at 1:56 PM, Hoffman Cheung <hoffmancheung at gmail.com> wrote:
>> 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
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>


More information about the ncl-talk mailing list