Dave,
I can not reproduce your problem.
I only added:
system ("chmod +w " + outfile)
after system call in your script (as the original file is write protected).
and it runs fine.
I tested on Mac, with osx 10.8.3.
Here is the full script I tested:
; 2013-apr-01 Test program reduced from era-update.ncl.
; Demonstrates seg fault when trying to overwrite global
; attributes in a Netcdf-4 classic file.
; By Dave Allured, NOAA/PSD/CIRES Climate Analysis Branch.
begin
outfile = "out.nc"
; system ("cp ozone.master.nc " + outfile) ; create fresh writable copy
system ("cat ozone.master.nc > " + outfile) ; create fresh writable copy
system ("chmod +w " + outfile) ; create fresh writable copy
out = addfile (outfile, "w")
out@last_update = systemfunc ("date")
out@last_update_program = "demo.global-atts.ncl version 2013-apr-01"
out@last_update_source_file = "ei.ozone.1979010106.nc"
print ("Update complete.")
end
and part of ncdump -h out.nc:
// global attributes:
:title = "ERA-Interim Ozone mass mixing ratio, 4 times daily" ;
:history = "Mon Apr 1 17:14:49 MDT 2013:\n",
"Initial file made by era-create.ncl version 2013-apr-01 TEST" ;
:dataset = "ERA-Interim" ;
:version = "2.0" ;
:references = "http://www.ecmwf.int/research/era/do/get/era-interim;\n",
"D. P. Dee et al (2011), The ERA-Interim reanalysis:\n",
" configuration and performance of the data assimilation system,\n",
" Q.J.R. Meteorol. Soc., Vol. 137: 553-597, DOI: 10.1002/qj.828" ;
:center = "European Center for Medium-Range Weather Forecasts (RSMC)" ;
:metadata_source_file = "../ei.oper.an.pl.regn128sc.1979010100" ;
:Conventions = "CF-1.6" ;
:last_update = "Mon Apr 1 21:28:20 MDT 2013" ;
:last_update_program = "demo.global-atts.ncl version 2013-apr-01" ;
:last_update_source_file = "ei.ozone.1979010106.nc" ;
}
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
On Apr 1, 2013, at 8:41 PM, Dave Allured - NOAA Affiliate <dave.allured@noaa.gov> wrote:
> NCL support team,
>
> This program results in a seg fault error on program exit, after
> attempting to overwrite some global attributes in a Netcdf-4 classic
> file with HDF5 compression. Note that all three global attributes
> exist previously in the target file, before running the test program.
>
> After the error, the target file is corrupted. This error is
> strangely sensitive to the number and string lengths of the attributes
> to be written. Can you please tell me what the problem is? Thank
> you.
>
> begin
> outfile = "out.nc"
> system ("cat ozone.master.nc > " + outfile) ; create fresh writable copy
>
> out = addfile (outfile, "w")
> out@last_update = systemfunc ("date")
> out@last_update_program = "demo.global-atts.ncl version 2013-apr-01"
> out@last_update_source_file = "ei.ozone.1979010106.nc"
> print ("Update complete.")
> end
>
> I get the same results with NCL versions 6.0.0 and 6.1.2. My system
> is Mac OS 10.8.3 on a 64-bit Intel Mac desktop. Here is the console
> output:
>
> mac56:~/ncl/bugs/3-atts/401i 491> ncl demo.global-atts.ncl
> Copyright (C) 1995-2013 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.2
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) Update complete.
> Segmentation fault
>
> mac56:~/ncl/bugs/3-atts/401i 492> ls -trgo
> total 44136
> -r--r--r-- 1 11294147 Apr 1 17:14 ozone.master.nc
> -rw-r--r-- 1 570 Apr 1 19:51 demo.global-atts.ncl
> -rw-r--r-- 1 11294201 Apr 1 20:16 out.nc
>
> mac56:~/ncl/bugs/3-atts/401i 493> ncdump -k ozone.master.nc
> netCDF-4 classic model
>
> mac56:~/ncl/bugs/3-atts/401i 494> ncdump -k out.nc
> ncdump: out.nc: NetCDF: Can't open HDF5 attribute
>
> mac56:~/ncl/bugs/3-atts/401i 495> uname -a
> Darwin mac56 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10
> PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
>
> I uploaded the program and original Netcdf file (11 Mbytes) to
> ftp.cgd.ucar.edu/incoming, as
> "demo.global-atts.dave_allured.0401.zip". The original Netcdf file
> was also made by NCL 6.1.2 and a different script. I can also send a
> copy of the generating script and its input file, if you need it.
> Please let me know. Thanks for taking a look at this.
>
> --Dave A.
> NOAA/PSD/CIRES Climate Analysis Branch
> _______________________________________________
> 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 Mon Apr 1 21:36:16 2013
This archive was generated by hypermail 2.1.8 : Tue Apr 02 2013 - 21:23:48 MDT