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.
Hi Abir, > I know about this error and have encountered it before while using the > NetCDF-C API. I also know it's solution is to create/write the NetCDF file in > the 64_bit_offset format. So, I use the following commands to create a NetCDF > dataset, I am using the NetCDF legacy C++ API. > > NcFile file(path, NcFile::Replace, NULL, 0, NcFile::Offset64Bits); > if(!file.is_valid()) > { > printf("Could not create file\n"); > exit(1); > } > // I have defined all the dimensions and stored the return NcDim* dimensions > into an array named as "arr" > for(i=0; i<*nvars; i++) > { > vector<NcVar*> vvars; > vvars.push_back(file.add_var((*vars)[i].get_name(), (*vars)[i].get_type(), > (*vars)[i].get_num_dims(), &arr[0])); > } > > when i run my code, the following text appears on the terminal and no file is > created in the designated path, "NetCDF: One or more variable sizes violate > format constraints" > > The variable sizes i am trying to write in the file are as follow, > > int var1(83) > int var2(83) > int var3(202136752, 4) > int var4(95383224, 6) > int var5(120077, 5) > int var6(3022650, 3) > int var7(97241, 4) > int var8(3119891) > int var9(3119891) > double var10(83027655) > double var11(83027655) > double var12(83027655) > int var13(2) > int var14(1) > > While I was able to create the same file using the NetCDF C API by writing > the file in 64_bit_offset format. I can't figure out what's the problem here. > I would be glad if you could help. The variable int var4(95383224, 6) requires 4 bytes per value, so its size is 4 * 95383224 * 6, which is larger than 2 GBytes. The classic file format which used 32-bit file offsets, can't store variables of size larger than 2 GBytes except under special conditions, described here: http://www.unidata.ucar.edu/netcdf/docs/netcdf/NetCDF-Classic-Format-Limitations.html --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: YEN-169424 Department: Support netCDF Priority: Normal Status: Closed