[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 980504: Non ANSI C++ and netCDF



>From: Markus Werle <address@hidden>
>Subject: Non ANSI C++
>Organization: Lehr- und Forschungsgebiet fuer Mechanik, RWTH-Aachen
>Keywords: 199805041934.NAA23467 netCDF g++

Hi Markus,

> Here is another problem:
> 
> 
> A multidimensional array can only be written to file by supplying
> a one-dimensional array:
> 
> double MeshPointData[spacedim*jdim*idim];
> 
> ...
> 
> OriginalMesh.NcMeshPointsInFile->put(MeshPointData, spacedim, jdim, idim);
> 
> 
> Is there any workaround or do I have to use/write an Array class
> which provides one-dimensional data access for netCDF routines?

If you declare and allocate space for the multidimensional array in a
single declaration, e.g. 

   double MeshPointData[spacedim][jdim][idim];

then the space for the values are allocated contiguously, so you can
just provide the address of the first value instead of creating another
1-dimensional array:

  ...->put(&MeshPointData[0][0][0], spacedim, jdim, idim);

> Do You know about any C++-examples in the WWW using netCDF with
> multidimensional arrays from which I could learn?

No, sorry, I don't know of any C++ examples.

I'll try to look at your other question and reply in a separate message ...

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu