This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: <address@hidden>, >To: <address@hidden> >From: "Joseph Benckert" <address@hidden> >Subject: netcdf troubles >Organization: UCAR/Unidata >Keywords: 200403291443.i2TEhsrV014206 Joseph, > > Was the ncdump you tried built for the platform on which you're > > running it? > > > > I was running ncdump on lemieux at the Pittsburgh Supercomputing Center. > It's their build and I've got no control over it. > > Now, It looks to be a problem with their configuration because I'm not > having any issues running the same code on our small in-house cluster. I > still need to create the files correctly over there, which I realize you > may not be able to help with. At any rate, I'm attaching one of the > corrupted files that was created on lemieux. Let me know if you see > anything glaringly obvious. > > More below. ... > > But all your calls to netCDF functions when ndim == 1 look OK to me. > > Only when the number of dimensions is equal to 1? I only looked at the code when ndim == 1, because I thought you were making HDF5 calls otherwise. Now I see that was wrong ... > ... I think I'm not > understanding something fundamental about the programming here. Like I > said earlier, I'm not having problems creating the files, variables or > attributes now but I can't seem to write any actual data to any of them. > I'm getting this error: > > Edge+start exceeds dimension bound > > I'm just trying to copy an entire array with the same dimensions into my > netcdf variable. The fortran code is below. Any idea what I'm doing > wrong? Something I didn't notice before is that you need to call NF90_close() to make sure buffers gets flushed and your data gets written out to disk before exiting: status = nf90_close(ncid) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) And for your put calls such as: ! Populate variables (dataset) status = nf90_put_var(ncid, density_varID, zro) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) You need to have dimensioned zro (and the other data variables) appropriately, so that it's shape matches the netCDF variable you are writing, if you want to write out all the values for that variable at once. So, for example, if dims(1) = 2 dims(2) = 3 dims(3) = 4 ... status = nf90_def_dim(ncid, "x", dims(1), xDimID) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) status = nf90_def_dim(ncid, "y", dims(2), yDimID) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) status = nf90_def_dim(ncid, "z", dims(3), zDimID) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) ... status = nf90_def_var(ncid, "Density", nf90_float, & (/ xDimID, yDimID, zDimID /), density_varID) ... status = nf90_put_var(ncid, density_varID, zro) if (status /= nf90_NoErr ) print *, NF90_STRERROR(status) then you should have dimensioned zro with something like: REAL, DIMENSION(2,3,4) :: zro because this "whole variable" write uses the shape of the data array to determine what part of the variable to write. Maybe you had just made zro 1-dimensional with shape the product of the x, y, and z dimensions. If you are going to do that, you need to use the more complex nf90_put_var() call that has start and count arrays to specify where each variable dimension index starts (for example (/ 1, 1, 1 /)) and the count for the number of values along each dimension (for example (/ dims(1), dims(2), dims(3) /)). --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu/staff/russ