[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #KPC-572697]: segmentation fault when writing



Hi Yair,

> first let me point out that i am quit new to netcdf so i probably miss some
> detail but i realy worked on that for some time now.
> 
> when trying to write to netcdf i am getting segmentation fault i will not
> post the complete code since its long but i will post all the info i can:
> 
> the operation behaves very weird since some of the times the netcdf dataset
> becomes huge before i get the fault (even 30G)
> 
> 
> i use netcdf 3.6 on a 64bit linux machine (ubuntu 10.10)
> 
> 
> the write operation is this line:
> 
> iret = nf_put_vara_real(ncid,id,start,edges,real(dum,4))

I'm not sure why the last argument is "real(dum,4)" rather than just
"dum", since that's already type real and is a 1D array.  Presumably
that array contains the values you want to write into the the 2D
netCDF variable

  float O2o(time, oceanpoint)

> the variables are:
> (idb) whatis ncid
> type = INTEGER(4)
> (idb) whatis id
> type = INTEGER(4)
> (idb) whatis start
> type = INTEGER(4)(4)
> (idb) whatis edges
> type = INTEGER(4)(4)
> (idb) whatis dum
> type = REAL(4)(219617)
> 
> and their values are:
> 
> (idb) p ncid
> $14 = 3
> (idb) p id
> $15 = 9
> (idb) p start
> $17 = {1, 1, 1, 0}
> (idb) p edges
> $16 = {1, 219617, 29, 0}

The output of ncdump uses C order for dimensions, which is row-major
order (last dimension varying fastest), unlike the Fortran convention
of column-major order (first dimension varying fastest).  So I think
for the edges array, you want to use instead:

 edges =  {219617, 1, ...}

where I don't think the 3rd or 4th value matter, because you are just
writing into a 2D netCDF variable.  That would write the 1st time, and
for writing the slab of 219617 values for the second time, you would
use the same edges, but

 start = {1, 2, ...}

and so on.
 
--Russ

> ncdump -h just before trying to write the data gives me:
> johnathan@johnathan-desktop:~/Documents/BFM_POM_1/adripom/trunk/build$
> ncdump -h bfm.nc
> netcdf bfm {
> dimensions:
> x = 140 ;
> y = 76 ;
> z = 29 ;
> oceanpoint = 219617 ;
> surfacepoint = 7573 ;
> bottompoint = 7573 ;
> time = UNLIMITED ; // (0 currently)
> variables:
> float lon(y, x) ;
> lon:units = "degrees_east" ;
> float lat(y, x) ;
> lat:units = "degrees_north" ;
> float z(z) ;
> z:units = "meters" ;
> int oceanpoint(oceanpoint) ;
> oceanpoint:formula_term = "water points" ;
> oceanpoint:compress = "none" ;
> int surfacepoint(surfacepoint) ;
> surfacepoint:formula_term = "surface points" ;
> surfacepoint:compress = "none" ;
> int bottompoint(bottompoint) ;
> bottompoint:formula_term = "bottom points" ;
> bottompoint:compress = "none" ;
> float time(time) ;
> time:units = "seconds since 01-01-0000" ;
> float mask(z, y, x) ;
> float O2o(time, oceanpoint) ;
> O2o:units = "mmol O2/m3" ;
> O2o:long_name = "Oxgen" ;
> float N1p(time, oceanpoint) ;
> N1p:units = "mmol P/m3" ;
> N1p:long_name = "Phosphate" ;
> float N3n(time, oceanpoint) ;
> N3n:units = "mmol N/m3" ;
> N3n:long_name = "Nitrate" ;
> float N4n(time, oceanpoint) ;
> N4n:units = "mmol N/m3" ;
> N4n:long_name = "Ammonium" ;
> float N5s(time, oceanpoint) ;
> N5s:units = "mmol Si/m3" ;
> N5s:long_name = "Silicate" ;
> float B1c(time, oceanpoint) ;
> B1c:units = "mg C/m3" ;
> B1c:long_name = "Pelagic Bacteria" ;
> float P1c(time, oceanpoint) ;
> P1c:units = "mg C/m3" ;
> P1c:long_name = "Diatoms" ;
> float P1l(time, oceanpoint) ;
> P1l:units = "mg Chl/m3" ;
> P1l:long_name = "Diatoms" ;
> float P2c(time, oceanpoint) ;
> P2c:units = "mg C/m3" ;
> P2c:long_name = "Flagellates" ;
> float P2l(time, oceanpoint) ;
> P2l:units = "mg Chl/m3" ;
> P2l:long_name = "Flagellates" ;
> float P3c(time, oceanpoint) ;
> P3c:units = "mg C/m3" ;
> P3c:long_name = "PicoPhytoPlankton" ;
> float P3l(time, oceanpoint) ;
> P3l:units = "mg Chl/m3" ;
> P3l:long_name = "PicoPhytoPlankton" ;
> float P4c(time, oceanpoint) ;
> P4c:units = "mg C/m3" ;
> P4c:long_name = "Dinoflagellates" ;
> float P4l(time, oceanpoint) ;
> P4l:units = "mg Chl/m3" ;
> P4l:long_name = "Dinoflagellates" ;
> float Z3c(time, oceanpoint) ;
> Z3c:units = "mg C/m3" ;
> Z3c:long_name = "Carnivorous mesozooplankton" ;
> float Z4c(time, oceanpoint) ;
> Z4c:units = "mg C/m3" ;
> Z4c:long_name = "Omnivorous mesozooplankton" ;
> float Z5c(time, oceanpoint) ;
> Z5c:units = "mg C/m3" ;
> Z5c:long_name = "Microzooplankton" ;
> float Z6c(time, oceanpoint) ;
> Z6c:units = "mg C/m3" ;
> Z6c:long_name = "Heterotrophic nanoflagellates (HNAN)" ;
> float R1c(time, oceanpoint) ;
> R1c:units = "mg C/m3" ;
> R1c:long_name = "Labile Organic Carbon (LOC)" ;
> float R1n(time, oceanpoint) ;
> R1n:units = "mmol N/m3" ;
> R1n:long_name = "Labile Organic Carbon (LOC)" ;
> float R2c(time, oceanpoint) ;
> R2c:units = "mg C/m3" ;
> R2c:long_name = "TEP (long sugars)" ;
> float R6c(time, oceanpoint) ;
> R6c:units = "mg C/m3" ;
> R6c:long_name = "Particulate Organic Carbon (POC)" ;
> float R6p(time, oceanpoint) ;
> R6p:units = "mmiol P/m3" ;
> R6p:long_name = "Particulate Organic Carbon (POC)" ;
> float ETW(time, oceanpoint) ;
> ETW:units = "C" ;
> ETW:long_name = "temperature" ;
> float EIR(time, oceanpoint) ;
> EIR:units = "uE/m2/s" ;
> EIR:long_name = "Irradiance" ;
> float xEPS(time, oceanpoint) ;
> xEPS:units = "1/m" ;
> xEPS:long_name = "Total extinction coefficient" ;
> float sunPI\(iiP1\)(time, oceanpoint) ;
> sunPI\(iiP1\):units = "mgC/mgC/day" ;
> sunPI\(iiP1\):long_name = "Specific Net Prod. P1(PhytoPlankton)" ;
> float sunPI\(iiP2\)(time, oceanpoint) ;
> sunPI\(iiP2\):units = "mgC/mgC/day" ;
> sunPI\(iiP2\):long_name = "Specific Net Prod. P2(PhytoPlankton)" ;
> float sunPI\(iiP3\)(time, oceanpoint) ;
> sunPI\(iiP3\):units = "mgC/mgC/day" ;
> sunPI\(iiP3\):long_name = "Specific Net Prod. P3(PhytoPlankton)" ;
> float sunPI\(iiP4\)(time, oceanpoint) ;
> sunPI\(iiP4\):units = "mgC/mgC/day" ;
> sunPI\(iiP4\):long_name = "Specific Net Prod. P4(PhytoPlankton)" ;
> float qlPc\(iiP1\)(time, oceanpoint) ;
> qlPc\(iiP1\):units = "mg Chl /mg C" ;
> qlPc\(iiP1\):long_name = "Quotum chl/c in P1(PhytoPlankton)" ;
> float qlPc\(iiP2\)(time, oceanpoint) ;
> qlPc\(iiP2\):units = "mg Chl /mg C" ;
> qlPc\(iiP2\):long_name = "Quotum chl/c in P2(PhytoPlankton)" ;
> float qlPc\(iiP3\)(time, oceanpoint) ;
> qlPc\(iiP3\):units = "mg Chl /mg C" ;
> qlPc\(iiP3\):long_name = "Quotum chl/c in P3(PhytoPlankton)" ;
> float qlPc\(iiP4\)(time, oceanpoint) ;
> qlPc\(iiP4\):units = "mg Chl /mg C" ;
> qlPc\(iiP4\):long_name = "Quotum chl/c in P4(PhytoPlankton)" ;
> float eiPI\(iiP1\)(time, oceanpoint) ;
> eiPI\(iiP1\):units = "-" ;
> eiPI\(iiP1\):long_name = "Regulating factor for light in P1(PhytoPlankton)"
> ;
> float eiPI\(iiP2\)(time, oceanpoint) ;
> eiPI\(iiP2\):units = "-" ;
> eiPI\(iiP2\):long_name = "Regulating factor for light in P2(PhytoPlankton)"
> ;
> float eiPI\(iiP3\)(time, oceanpoint) ;
> eiPI\(iiP3\):units = "-" ;
> eiPI\(iiP3\):long_name = "Regulating factor for light in P3(PhytoPlankton)"
> ;
> float eiPI\(iiP4\)(time, oceanpoint) ;
> eiPI\(iiP4\):units = "-" ;
> eiPI\(iiP4\):long_name = "Regulating factor for light in P4(PhytoPlankton)"
> ;
> 
> // global attributes:
> :Title = "Another great BFM simulation!" ;
> :history = "Created by BFM v. 2.5e (floundering cod)" ;
> :Conventions = "CF-1.0" ;
> }


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: KPC-572697
Department: Support netCDF
Priority: Normal
Status: Closed