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