Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang compliance #90

Merged
merged 9 commits into from
Oct 16, 2024
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev libomp-dev
sudo pip install numpy
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev libomp-dev python3-numpy


- name: Setup submodule and build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)

find_package(MPI REQUIRED COMPONENTS C CXX)
find_package(OpenMP)
find_package(FFTW)
find_package(FFTW REQUIRED)
find_package(HDF5 COMPONENTS C CXX HL REQUIRED)
find_package(TIRPC) # Check for alternative Sun rpc support
find_package(Eigen3 REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions expui/BiorthBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::SphStruct))
if (typeid(coef.get()) != typeid(CoefClasses::SphStruct*))
throw std::runtime_error("Spherical::set_coefs: you must pass a CoefClasses::SphStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -1431,7 +1431,7 @@ namespace BasisClasses

void Cylindrical::set_coefs(CoefClasses::CoefStrPtr coef)
{
if (typeid(*coef) != typeid(CoefClasses::CylStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CylStruct*))
throw std::runtime_error("Cylindrical::set_coefs: you must pass a CoefClasses::CylStruct");

CoefClasses::CylStruct* cf = dynamic_cast<CoefClasses::CylStruct*>(coef.get());
Expand Down Expand Up @@ -1708,7 +1708,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::CylStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CylStruct*))
throw std::runtime_error("FlatDisk::set_coefs: you must pass a CoefClasses::CylStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -2140,7 +2140,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::SlabStruct))
if (typeid(coef) != typeid(CoefClasses::SlabStruct*))
throw std::runtime_error("Slab::set_coefs: you must pass a CoefClasses::SlabStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -2572,7 +2572,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::CubeStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CubeStruct*))
throw std::runtime_error("Cube::set_coefs: you must pass a CoefClasses::CubeStruct");

// Sanity check on dimensionality
Expand Down
6 changes: 3 additions & 3 deletions expui/CoefContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace MSSA
unpack_cylfld();
}
else {
throw std::runtime_error(std::string("CoefDB::unpack_channels(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::unpack_channels(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}

return coefs;
Expand All @@ -91,7 +91,7 @@ namespace MSSA
else if (dynamic_cast<CoefClasses::CylFldCoefs*>(coefs.get()))
{ } // Do nothing
else {
throw std::runtime_error(std::string("CoefDB::background(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::background(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}
}

Expand All @@ -112,7 +112,7 @@ namespace MSSA
else if (dynamic_cast<CoefClasses::CylFldCoefs*>(coefs.get()))
pack_cylfld();
else {
throw std::runtime_error(std::string("CoefDB::pack_channels(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::pack_channels(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}
}

Expand Down
7 changes: 4 additions & 3 deletions exputil/BarrierWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ void BarrierWrapper::light_operator(const string& label,

// Compare adjacent strings in the list
if (localid==0) {
char tmp[cbufsz]; // Working buffer
// Working buffer
auto tmp = std::make_unique<char[]>(cbufsz);
bool firstime = true;
string one, two = strncpy(tmp, &bufferT[0], cbufsz);
string one, two = strncpy(tmp.get(), &bufferT[0], cbufsz);
for (int n=1; n<commsize; n++) {
one = two;
two = strncpy(tmp, &bufferT[cbufsz*n], cbufsz);
two = strncpy(tmp.get(), &bufferT[cbufsz*n], cbufsz);
if (one.compare(two) != 0) {
if (firstime) {
cout << std::string(60,'-') << std::endl << left
Expand Down
2 changes: 1 addition & 1 deletion exputil/EmpCylSL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5875,7 +5875,7 @@ void EmpCylSL::dump_images(const string& OUTFILE,
//============
// Open files
//============
std::ofstream out[Number];
auto out = std::make_unique<std::ofstream[]>(Number);
for (int j=0; j<Number; j++) {
Name = OUTFILE + Types[j] + ".eof_recon";
out[j].open(Name.c_str());
Expand Down
20 changes: 8 additions & 12 deletions exputil/GaussCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@
/*
Forward declaration for function QQp:
*/
static int QQp();
static int QQp(double, double*, double*);

/*
Function to test a real value for exceeding -1,
and quit on an error if condition not met.
*/
void GaussCheck(value)
double value;
void GaussCheck(double value)
{
if (value <= (-1.0)) {
fprintf(stderr, "Gauss package: parameter out of range: %g\n", value);
exit(1);
}
if (value <= (-1.0)) {
fprintf(stderr, "Gauss package: parameter out of range: %g\n", value);
exit(1);
}
}


Expand All @@ -54,11 +53,8 @@ static int n1;
/*
The workhorse.
*/
void GaussMaster(n, alpha, beta, conflag, abscis, weight)
int n;
double alpha, beta;
int conflag;
double abscis[], weight[];
void GaussMaster(int n, double alpha, double beta, int conflag,
double abscis[], double weight[])
{
#define FALSE 0
#define TRUE 1
Expand Down
6 changes: 4 additions & 2 deletions exputil/GaussCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#define CONFLUENT 1
#define NOCONFLUENT 0

extern void GaussMaster();
extern void GaussCheck();
extern void GaussMaster(int n, double alpha, double beta, int conflag,
double abscis[], double weight[]);

extern void GaussCheck(double value);

/* ARGUMENT LISTS:

Expand Down
13 changes: 4 additions & 9 deletions exputil/Hermite.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
*/
#define odd(n) ((unsigned)(n) & 01)

void Odd_Hermite(n, alpha, abscis, weight, w0)
int n;
double alpha, abscis[], weight[], *w0;
void Odd_Hermite(int n, double alpha, double abscis[], double weight[],
double* w0)
{
int k;

Expand All @@ -41,9 +40,7 @@ double alpha, abscis[], weight[], *w0;
};


void Even_Hermite(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Even_Hermite(int n, double alpha, double abscis[], double weight[])
{
int k;

Expand All @@ -59,9 +56,7 @@ double alpha, abscis[], weight[];
};


void Hermite(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Hermite(int n, double alpha, double abscis[], double weight[])
{
int n1, k;

Expand Down
9 changes: 6 additions & 3 deletions exputil/Hermite.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
Translation of module Hermite (export).
*/

extern void Odd_Hermite();
extern void Even_Hermite();
extern void Hermite();
extern void Odd_Hermite(int n, double alpha, double abscis[], double weight[],
double* w0);

extern void Even_Hermite(int n, double alpha, double abscis[], double weight[]);

extern void Hermite(int n, double alpha, double abscis[], double weight[]);

/* ARGUMENT LISTS:

Expand Down
18 changes: 6 additions & 12 deletions exputil/Jacobi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

#define sqr(x) ((x)*(x))

void Jacobi(n, alpha, beta, abscis, weight)
int n;
double alpha, beta;
double abscis[], weight[];
void Jacobi(int n, double alpha, double beta, double abscis[], double weight[])
{
int k;

Expand All @@ -34,10 +31,8 @@ double abscis[], weight[];
}


void Radau_Jacobi(n, alpha, beta, abscis, weight, leftw)
int n;
double alpha, beta;
double abscis[], weight[], *leftw;
void Radau_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[], double *leftw)
{
int k;
double temp;
Expand All @@ -62,10 +57,9 @@ double abscis[], weight[], *leftw;
};


void Lobatto_Jacobi(n, alpha, beta, abscis, weight, leftw, rightw)
int n;
double alpha, beta;
double abscis[], weight[], *leftw, *rightw;
void Lobatto_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[],
double* leftw, double* rightw)
{
int k;
double temp1, temp2;
Expand Down
11 changes: 8 additions & 3 deletions exputil/Jacobi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
Translation of module Jacobi (export).
*/

extern void Jacobi(int n, double alpha, double beta,
double abscis[], double weight[]);

extern void Jacobi();
extern void Radau_Jacobi();
extern void Lobatto_Jacobi();
extern void Radau_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[], double *leftw);

extern void Lobatto_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[],
double* leftw, double* rightw);

/* ARGUMENT LISTS:
void Jacobi(n, alpha, beta, abscis, weight)
Expand Down
9 changes: 3 additions & 6 deletions exputil/Laguerre.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
#include "GaussCore.h"
#include "Laguerre.h"

void Laguerre(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Laguerre(int n, double alpha, double abscis[], double weight[])
{
GaussCheck(alpha);
GaussMaster(n, alpha, 0.0, CONFLUENT, abscis, weight);
};


void Radau_Laguerre(n, alpha, abscis, weight, leftw)
int n;
double alpha, abscis[], weight[], *leftw;
void Radau_Laguerre(int n, double alpha, double abscis[], double weight[],
double* leftw)
{
int k;
double temp;
Expand Down
6 changes: 4 additions & 2 deletions exputil/Laguerre.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
Translation of module Laguerre (export).
*/

extern void Laguerre();
extern void Radau_Laguerre();
extern void Laguerre(int n, double alpha, double abscis[], double weight[]);

extern void Radau_Laguerre(int n, double alpha,
double abscis[], double weight[], double* leftw);

/*
ARGUMENT LISTS:
Expand Down
13 changes: 7 additions & 6 deletions exputil/ParticleReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iomanip>
#include <fstream>
#include <sstream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
Expand Down Expand Up @@ -530,11 +531,11 @@ namespace PR {

int rank = dataspace.getSimpleExtentNdims();

hsize_t dims[rank];
auto dims = std::make_unique<hsize_t[]>(rank);

int ndims = dataspace.getSimpleExtentDims(dims, NULL);
int ndims = dataspace.getSimpleExtentDims(dims.get(), NULL);

H5::DataSpace mspace(rank, dims);
H5::DataSpace mspace(rank, dims.get());

std::vector<float> masses(dims[0]);
dataset.read(&masses[0], H5::PredType::NATIVE_FLOAT, mspace, dataspace );
Expand Down Expand Up @@ -569,11 +570,11 @@ namespace PR {

int rank = dataspace.getSimpleExtentNdims();

hsize_t dims[rank];
auto dims = std::make_unique<hsize_t[]>(rank);

int ndims = dataspace.getSimpleExtentDims( dims, NULL);
int ndims = dataspace.getSimpleExtentDims( dims.get(), NULL);

H5::DataSpace mspace(rank, dims);
H5::DataSpace mspace(rank, dims.get());

std::vector<unsigned> seq(dims[0]);
dataset.read(&seq[0], H5::PredType::NATIVE_UINT32, mspace, dataspace );
Expand Down
Loading