[netcdfgroup] I wonder why I can not wirte NC files by using nc_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:


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





--
View this message in context: 
http://netcdf-group.1586084.n2.nabble.com/I-wonder-why-I-can-not-wirte-NC-files-by-using-nc-put-vara-float-tp7574646.html
Sent from the NetCDF Group mailing list archive at Nabble.com.
  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: