I added a new dimension to an existing netCDF file in fortran using the following code -
retval = nf_open(cfn,NF_WRITE,ncid)
if (retval .ne. nf_noerr) call handle_err(retval)
retval = nf_redef(ncid)
if (retval .ne. nf_noerr) call handle_err(retval)
retval = nf_def_dim(ncid,"xyz",len,dimid_xyz)
if (retval .ne. nf_noerr) call handle_err(retval)
retval = nf_enddef(ncid)
Now I want to be able to fill this dimension with values of zero. The cardinality of this set is equal to the cardinality of the variable in my case geopotential height. In addition I have three other dimensions - time(unlimited), latitude, longitude and level.
I looked up the netCDF API in fortran and I am not sure what is the API to call.When I use the following API
retval = nf_put_var_real(ncid,dimid_xyz,xyzArray)
if (retval .ne. nf_noerr) call handle_err(retval)
it ends up overwriting the geopotential height values with 0.0(which is the only variable in my netCDF file)
How do I go about doing this ?