NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdfgroup] [Reformatted/indented] I wonder why I can not wirte NC files by usingnc_put_vara_float

reformatted below. sorry if I am not of much help.

From: nasamars 
Sent: Sunday, August 12, 2012 9:58 PM
To: netcdfgroup@xxxxxxxxxxxxxxxx 
Subject: [netcdfgroup] I wonder why I can not wirte NC files by 
usingnc_put_vara_float

first i used NC_CREATE to create an nc file,then i used NC_WRITE to modify the 
contents. After that i found i can change the status except the contents by 
using nc_put_vara_float. source: 
<nabble_embed> 
void CreateAMonthFile(char *OutputPath,float* val,struct ParameterGroup pg){ 
  ... 
  size_t startp[] ={ RealTimeNumber, 0, 0, 0 };
  size_t countp[] ={ 1, 1, pg.LatNumber, pg.LonNumber };
  iForecastTime = 0; 
  for (; iForecastTime < pg.ForecastNumber; iForecastTime++){ 
    float ValTemp[115 * 87]; 
    i = 0; 
    for (; i < pg.LatNumber * pg.LonNumber; i++){ 
      ValTemp[i] = val[INDEX(iForecastTime, iVar, i, pg.VarNumber, pg.LatNumber 
* pg.LonNumber)];
    }
    status = nc_put_vara_float(ncid, varid[iForecastTime], startp, countp, 
ValTemp); 
    if (status != NC_NOERR) handle_error(status);
  } 
  ... 
} 
it seems correct. but when i using 
void AddNewFile(char *OutputPath,float* val,struct ParameterGroup pg, int 
RealTimeNumber){
  ... 
  nc_open(path, NC_WRITE, &ncid);
  if (status != NC_NOERR) handle_error(status);
  ...
  size_t startp[] ={ RealTimeNumber, 0, 0, 0 };
  size_t countp[] ={ 1, 1, pg.LatNumber, pg.LonNumber };
  float ValTemp[pg.LonNumber * pg.LatNumber];
  int i = 0;
  for (; i < pg.LatNumber * pg.LonNumber; i++) { 
    ValTemp[i] = val[INDEX(iForecastTime, iVar, i, pg.VarNumber, pg.LatNumber * 
pg.LonNumber)];
    i++;
  }
  char s[3];
  sprintf(s, "%03d", iForecastTime);
  memcpy(Varname, VarNameString[iVar], 10);
  strcat(Varname, s);
  status = nc_inq_varid(ncid, Varname, &varid[iForecastTime]);
  if (status != NC_NOERR) handle_error(status);
  status = nc_put_vara_float(ncid, varid[iForecastTime], startp, countp, 
ValTemp);
  if (status != NC_NOERR) handle_error(status);
  ...
}
in this section i found it is no changes whatever the values of ValTemp i 
filled 
</nabble_embed> 


--------------------------------------------------------------------------------

View this message in context: I wonder why I can not wirte NC files by using 
nc_put_vara_float
Sent from the NetCDF Group mailing list archive at Nabble.com.



--------------------------------------------------------------------------------
_______________________________________________
netcdfgroup mailing list
netcdfgroup@xxxxxxxxxxxxxxxx
For list information or to unsubscribe,  visit: 
http://www.unidata.ucar.edu/mailing_lists/
  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: