From c9ac439dd5c2dec968b0124895551ea1632ea411 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 5 Aug 2021 08:55:44 +0300 Subject: [PATCH] Correct exceptions and reformat --- src/yorick.hpp | 55 +++++++++++++++++++++++----------------------- src/yorick_nc4.cpp | 51 +++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/src/yorick.hpp b/src/yorick.hpp index f38200e..dca3713 100644 --- a/src/yorick.hpp +++ b/src/yorick.hpp @@ -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 -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 @@ -95,12 +95,12 @@ namespace CosmoTool private: int *ref; ProgressiveInputImpl *impl; - + void decRef() { if (ref == 0) return; - + (*ref)--; if (*ref == 0) { @@ -112,17 +112,17 @@ namespace CosmoTool } public: - static ProgressiveInput - loadArrayProgressive(const std::string& fname, uint32_t *&dimList, + static ProgressiveInput + loadArrayProgressive(const std::string& fname, uint32_t *&dimList, uint32_t& rank); ProgressiveInput() { - impl = 0; - ref = 0; + impl = 0; + ref = 0; } ProgressiveInput(ProgressiveInputImpl *i) { - impl = i; - ref = new int; + impl = i; + ref = new int; *ref = 1; } ProgressiveInput(const ProgressiveInput& o) { @@ -161,12 +161,12 @@ namespace CosmoTool private: int *ref; ProgressiveOutputImpl *impl; - + void decRef() { if (ref == 0) return; - + (*ref)--; if (*ref == 0) { @@ -178,17 +178,17 @@ namespace CosmoTool } public: - static ProgressiveOutput - saveArrayProgressive(const std::string& fname, uint32_t *dimList, + static ProgressiveOutput + saveArrayProgressive(const std::string& fname, uint32_t *dimList, uint32_t rank); ProgressiveOutput() { - impl = 0; - ref = 0; + impl = 0; + ref = 0; } ProgressiveOutput(ProgressiveOutputImpl *i) { - impl = i; - ref = new int; + impl = i; + ref = new int; *ref = 1; } ProgressiveOutput(const ProgressiveOutput& o) { @@ -222,10 +222,9 @@ namespace CosmoTool template 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 diff --git a/src/yorick_nc4.cpp b/src/yorick_nc4.cpp index a0234df..e956438 100644 --- a/src/yorick_nc4.cpp +++ b/src/yorick_nc4.cpp @@ -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 counts; vector dimList; uint32_t rank; - + NetCDF_handle(NcFile *f, NcVar v, vector& dimList, uint32_t rank); virtual ~NetCDF_handle(); }; @@ -86,14 +86,14 @@ public: InputGenCDF(NcFile *f, NcVar v, vector& 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& 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 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(), dimArray); + + NcVar v = f->addVar("array", get_NetCDF_type(), dimArray); vector ldimList; @@ -177,7 +177,7 @@ namespace CosmoTool { ldimList.push_back(dimArray[i]); OutputGenCDF *impl = new OutputGenCDF(f, v, ldimList, rank); - return ProgressiveOutput(impl); + return ProgressiveOutput(impl); } template @@ -206,32 +206,31 @@ namespace CosmoTool { const T *array, uint32_t *dimList, uint32_t rank) { NcFile f(fname.c_str(), NcFile::replace); - + vector 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(), dimArray); - + v.putVar(array); } template 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 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(const std::string& fname, const double *array, uint32_t *dimList, uint32_t rank); - + }