Correct exceptions and reformat
This commit is contained in:
parent
2d0f34fbc0
commit
c9ac439dd5
@ -7,16 +7,16 @@ This software is a computer program whose purpose is to provide a toolbox for co
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
@ -25,9 +25,9 @@ that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
@ -42,7 +42,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CosmoTool
|
||||
namespace CosmoTool
|
||||
{
|
||||
|
||||
class ProgressiveDoubleOutputImpl
|
||||
@ -75,7 +75,7 @@ namespace CosmoTool
|
||||
bool initialized;
|
||||
int *ref;
|
||||
ProgressiveDoubleOutputImpl *impl;
|
||||
|
||||
|
||||
friend ProgressiveDoubleOutput saveDoubleArrayProgressive(const char *fname, uint32_t *dimList, uint32_t rank);
|
||||
void decRef();
|
||||
public:
|
||||
@ -86,7 +86,7 @@ namespace CosmoTool
|
||||
|
||||
virtual void addDouble(double a);
|
||||
|
||||
const ProgressiveDoubleOutput& operator=(const ProgressiveDoubleOutput& b);
|
||||
const ProgressiveDoubleOutput& operator=(const ProgressiveDoubleOutput& b);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@ -95,12 +95,12 @@ namespace CosmoTool
|
||||
private:
|
||||
int *ref;
|
||||
ProgressiveInputImpl<T> *impl;
|
||||
|
||||
|
||||
void decRef()
|
||||
{
|
||||
if (ref == 0)
|
||||
return;
|
||||
|
||||
|
||||
(*ref)--;
|
||||
if (*ref == 0)
|
||||
{
|
||||
@ -112,17 +112,17 @@ namespace CosmoTool
|
||||
}
|
||||
|
||||
public:
|
||||
static ProgressiveInput<T>
|
||||
loadArrayProgressive(const std::string& fname, uint32_t *&dimList,
|
||||
static ProgressiveInput<T>
|
||||
loadArrayProgressive(const std::string& fname, uint32_t *&dimList,
|
||||
uint32_t& rank);
|
||||
|
||||
ProgressiveInput() {
|
||||
impl = 0;
|
||||
ref = 0;
|
||||
impl = 0;
|
||||
ref = 0;
|
||||
}
|
||||
ProgressiveInput(ProgressiveInputImpl<T> *i) {
|
||||
impl = i;
|
||||
ref = new int;
|
||||
impl = i;
|
||||
ref = new int;
|
||||
*ref = 1;
|
||||
}
|
||||
ProgressiveInput(const ProgressiveInput<T>& o) {
|
||||
@ -161,12 +161,12 @@ namespace CosmoTool
|
||||
private:
|
||||
int *ref;
|
||||
ProgressiveOutputImpl<T> *impl;
|
||||
|
||||
|
||||
void decRef()
|
||||
{
|
||||
if (ref == 0)
|
||||
return;
|
||||
|
||||
|
||||
(*ref)--;
|
||||
if (*ref == 0)
|
||||
{
|
||||
@ -178,17 +178,17 @@ namespace CosmoTool
|
||||
}
|
||||
|
||||
public:
|
||||
static ProgressiveOutput<T>
|
||||
saveArrayProgressive(const std::string& fname, uint32_t *dimList,
|
||||
static ProgressiveOutput<T>
|
||||
saveArrayProgressive(const std::string& fname, uint32_t *dimList,
|
||||
uint32_t rank);
|
||||
|
||||
ProgressiveOutput() {
|
||||
impl = 0;
|
||||
ref = 0;
|
||||
impl = 0;
|
||||
ref = 0;
|
||||
}
|
||||
ProgressiveOutput(ProgressiveOutputImpl<T> *i) {
|
||||
impl = i;
|
||||
ref = new int;
|
||||
impl = i;
|
||||
ref = new int;
|
||||
*ref = 1;
|
||||
}
|
||||
ProgressiveOutput(const ProgressiveOutput<T>& o) {
|
||||
@ -222,10 +222,9 @@ namespace CosmoTool
|
||||
|
||||
template<typename T>
|
||||
void loadArray(const std::string& fname,
|
||||
T*& array, uint32_t *& dimList, uint32_t& rank)
|
||||
throw (NoSuchFileException);
|
||||
T*& array, uint32_t *& dimList, uint32_t& rank);
|
||||
|
||||
ProgressiveDoubleOutput saveDoubleArrayProgressive(const char *fname, uint32_t *dimList, uint32_t rank);
|
||||
ProgressiveDoubleOutput saveDoubleArrayProgressive(const char *fname, uint32_t *dimList, uint32_t rank);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,16 +7,16 @@ This software is a computer program whose purpose is to provide a toolbox for co
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
@ -25,9 +25,9 @@ that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
@ -53,7 +53,7 @@ public:
|
||||
vector<size_t> counts;
|
||||
vector<NcDim> dimList;
|
||||
uint32_t rank;
|
||||
|
||||
|
||||
NetCDF_handle(NcFile *f, NcVar v, vector<NcDim>& dimList, uint32_t rank);
|
||||
virtual ~NetCDF_handle();
|
||||
};
|
||||
@ -86,14 +86,14 @@ public:
|
||||
InputGenCDF(NcFile *f, NcVar v, vector<NcDim>& dimList, uint32_t rank)
|
||||
: NetCDF_handle(f,v,dimList,rank)
|
||||
{}
|
||||
virtual ~InputGenCDF() {}
|
||||
virtual ~InputGenCDF() {}
|
||||
|
||||
virtual T read()
|
||||
{
|
||||
T a;
|
||||
|
||||
curVar.getVar(curPos, counts, &a);
|
||||
|
||||
|
||||
curPos[rank-1]++;
|
||||
for (long i = rank-1; i >= 1; i--)
|
||||
{
|
||||
@ -102,7 +102,7 @@ public:
|
||||
curPos[i-1]++;
|
||||
curPos[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -120,12 +120,12 @@ public:
|
||||
OutputGenCDF(NcFile *f, NcVar v, vector<NcDim>& dimList, uint32_t rank)
|
||||
: NetCDF_handle(f,v,dimList,rank)
|
||||
{}
|
||||
virtual ~OutputGenCDF() {}
|
||||
virtual ~OutputGenCDF() {}
|
||||
|
||||
virtual void put(T a)
|
||||
{
|
||||
curVar.putVar(curPos, counts, &a);
|
||||
|
||||
|
||||
curPos[rank-1]++;
|
||||
for (long i = rank-1; i >= 1; i--)
|
||||
{
|
||||
@ -134,7 +134,7 @@ public:
|
||||
curPos[i-1]++;
|
||||
curPos[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -159,17 +159,17 @@ namespace CosmoTool {
|
||||
uint32_t rank)
|
||||
{
|
||||
NcFile *f = new NcFile(fname, NcFile::replace);
|
||||
|
||||
|
||||
vector<NcDim> dimArray;
|
||||
for (uint32_t i = 0; i < rank; i++)
|
||||
{
|
||||
char dimName[255];
|
||||
|
||||
|
||||
sprintf(dimName, "dim%d", i);
|
||||
dimArray.push_back(f->addDim(dimName, dimList[rank-1-i]));
|
||||
}
|
||||
|
||||
NcVar v = f->addVar("array", get_NetCDF_type<T>(), dimArray);
|
||||
|
||||
NcVar v = f->addVar("array", get_NetCDF_type<T>(), dimArray);
|
||||
|
||||
vector<NcDim> ldimList;
|
||||
|
||||
@ -177,7 +177,7 @@ namespace CosmoTool {
|
||||
ldimList.push_back(dimArray[i]);
|
||||
|
||||
OutputGenCDF<T> *impl = new OutputGenCDF<T>(f, v, ldimList, rank);
|
||||
return ProgressiveOutput<T>(impl);
|
||||
return ProgressiveOutput<T>(impl);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -206,32 +206,31 @@ namespace CosmoTool {
|
||||
const T *array, uint32_t *dimList, uint32_t rank)
|
||||
{
|
||||
NcFile f(fname.c_str(), NcFile::replace);
|
||||
|
||||
|
||||
vector<NcDim> dimArray;
|
||||
for (uint32_t i = 0; i < rank; i++)
|
||||
{
|
||||
char dimName[255];
|
||||
|
||||
|
||||
sprintf(dimName, "dim%d", i);
|
||||
dimArray.push_back(f.addDim(dimName, dimList[i]));
|
||||
}
|
||||
|
||||
NcVar v = f.addVar("array", get_NetCDF_type<T>(), dimArray);
|
||||
|
||||
|
||||
v.putVar(array);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void loadArray(const std::string& fname,
|
||||
T*&array, uint32_t *&dimList, uint32_t& rank)
|
||||
throw (NoSuchFileException)
|
||||
{
|
||||
NcFile f(fname.c_str(), NcFile::read);
|
||||
|
||||
|
||||
//if (!f.is_valid())
|
||||
// throw NoSuchFileException(fname);
|
||||
|
||||
NcVar v = f.getVar("array");
|
||||
|
||||
NcVar v = f.getVar("array");
|
||||
vector<NcDim> dims = v.getDims();
|
||||
rank = v.getDimCount();
|
||||
uint32_t fullSize = 1;
|
||||
@ -268,5 +267,5 @@ namespace CosmoTool {
|
||||
const float *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<double>(const std::string& fname,
|
||||
const double *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user