Skip to content

Commit

Permalink
Automatic Linting for Fortran/C/C++ (#151)
Browse files Browse the repository at this point in the history
* C/CPP Linting with Clang tool

* More linting work

* Further linting with Fortran.

* Some formatting for examples.

* Force check examples to fail

* Fix check examples flag.
  • Loading branch information
william-dawson authored May 27, 2020
1 parent 422aead commit 9fb50d7
Show file tree
Hide file tree
Showing 114 changed files with 958 additions and 938 deletions.
18 changes: 9 additions & 9 deletions Examples/ComplexMatrix/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ PROGRAM ComplexMatrix

!! Process The Input
!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--input_file')
input_file = argument_value
Expand All @@ -66,12 +66,12 @@ PROGRAM ComplexMatrix

CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="input_file", value=input_file)
CALL WriteElement(key="exponential_file", value=exponential_file)
CALL WriteElement(key="process_rows", value=process_rows)
CALL WriteElement(key="process_columns", value=process_columns)
CALL WriteElement(key="process_slices", value=process_slices)
CALL WriteElement(key="threshold", value=threshold)
CALL WriteElement(key="input_file", VALUE=input_file)
CALL WriteElement(key="exponential_file", VALUE=exponential_file)
CALL WriteElement(key="process_rows", VALUE=process_rows)
CALL WriteElement(key="process_columns", VALUE=process_columns)
CALL WriteElement(key="process_slices", VALUE=process_slices)
CALL WriteElement(key="threshold", VALUE=threshold)
CALL ExitSubLog

!! Construct The Hermitian Matrix
Expand Down
6 changes: 3 additions & 3 deletions Examples/GraphTheory/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ PROGRAM GraphTheory
CALL MPI_Comm_size(MPI_COMM_WORLD, total_processors, ierr)

!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--output_file')
output_file = argument_value
Expand Down
6 changes: 3 additions & 3 deletions Examples/HydrogenAtom/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ PROGRAM HydrogenAtom
CALL MPI_Comm_size(MPI_COMM_WORLD, total_processors, ierr)

!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--convergence_threshold')
READ(argument_value,*) convergence_threshold
Expand Down
12 changes: 6 additions & 6 deletions Examples/MatrixMaps/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ PROGRAM MatrixMapsProgram
CALL MPI_Comm_rank(MPI_COMM_WORLD,rank, ierr)

!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--input_matrix')
input_matrix = argument_value
Expand All @@ -45,9 +45,9 @@ PROGRAM MatrixMapsProgram
!! Print out parameters.
CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="input_matrix", value=input_matrix)
CALL WriteElement(key="output_matrix", value=output_matrix)
CALL WriteElement(key="process_slices", value=process_slices)
CALL WriteElement(key="input_matrix", VALUE=input_matrix)
CALL WriteElement(key="output_matrix", VALUE=output_matrix)
CALL WriteElement(key="process_slices", VALUE=process_slices)
CALL ExitSubLog

!! Read in the matrices from file.
Expand Down
6 changes: 3 additions & 3 deletions Examples/OverlapMatrix/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ PROGRAM OverlapExample
CALL MPI_Comm_rank(MPI_COMM_WORLD,rank, ierr)

!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--basis_functions')
READ(argument_value,*) basis_functions
Expand Down
26 changes: 13 additions & 13 deletions Examples/PremadeMatrix/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ PROGRAM PremadeMatrixProgram
CALL MPI_Comm_rank(MPI_COMM_WORLD,rank, ierr)

!! Process the input parameters.
DO counter=1,command_argument_count(),2
CALL get_command_argument(counter,argument)
CALL get_command_argument(counter+1,argument_value)
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
SELECT CASE(argument)
CASE('--hamiltonian')
hamiltonian_file = argument_value
Expand Down Expand Up @@ -74,16 +74,16 @@ PROGRAM PremadeMatrixProgram

CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="hamiltonian", value=hamiltonian_file)
CALL WriteElement(key="overlap", value=overlap_file)
CALL WriteElement(key="density", value=density_file_out)
CALL WriteElement(key="process_rows", value=process_rows)
CALL WriteElement(key="process_columns", value=process_columns)
CALL WriteElement(key="process_slices", value=process_slices)
CALL WriteElement(key="number_of_electrons", value=number_of_electrons)
CALL WriteElement(key="threshold", value=threshold)
CALL WriteElement(key="converge_overlap", value=converge_overlap)
CALL WriteElement(key="converge_density", value=converge_density)
CALL WriteElement(key="hamiltonian", VALUE=hamiltonian_file)
CALL WriteElement(key="overlap", VALUE=overlap_file)
CALL WriteElement(key="density", VALUE=density_file_out)
CALL WriteElement(key="process_rows", VALUE=process_rows)
CALL WriteElement(key="process_columns", VALUE=process_columns)
CALL WriteElement(key="process_slices", VALUE=process_slices)
CALL WriteElement(key="number_of_electrons", VALUE=number_of_electrons)
CALL WriteElement(key="threshold", VALUE=threshold)
CALL WriteElement(key="converge_overlap", VALUE=converge_overlap)
CALL WriteElement(key="converge_density", VALUE=converge_density)
CALL ExitSubLog

!! Read in the matrices from file.
Expand Down
5 changes: 2 additions & 3 deletions Source/C/DensityMatrixSolvers_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ void HPCP_wrp(const int *ih_Hamiltonian, const int *ih_InverseSquareRoot,
const double *chemical_potential_out,
const int *ih_solver_parameters);
void ScaleAndFold_wrp(const int *ih_Hamiltonian,
const int *ih_InverseSquareRoot,
const int *nel, int *ih_Density,
const double *homo, const double *lumo,
const int *ih_InverseSquareRoot, const int *nel,
int *ih_Density, const double *homo, const double *lumo,
const double *energy_value_out,
const int *ih_solver_parameters);
void EnergyDensityMatrix_wrp(const int *ih_Hamiltonian, const int *ih_Density,
Expand Down
2 changes: 1 addition & 1 deletion Source/C/EigenBounds_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ void GershgorinBounds_wrp(const int *ih_Hamiltonian, double *max_value,
double *min_value);
void PowerBounds_wrp(const int *ih_Hamiltonian, double *max_value,
const int *ih_solver_parameters);
void DistributedEigenDecomposition_wrp(const int *ih_this, int* ih_eigenvectors,
void DistributedEigenDecomposition_wrp(const int *ih_this, int *ih_eigenvectors,
const int *ih_solver_parameters);
#endif
4 changes: 2 additions & 2 deletions Source/C/PSMatrix_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void GetMatrixSlice_wrp(const int *ih_this, int *ih_submatrix, int *start_row,
void TransposeMatrix_ps_wrp(const int *ih_matA, int *ih_transmat);
void ConjugateMatrix_ps_wrp(int *ih_matA);
void ConjugateMatrix_ps_wrp(int *ih_matA);
void ResizeMatrix_ps_wrp(int *ih_this, const int* new_size);
void GetMatrixProcessGrid_ps_wrp(const int* ih_this, int* ih_grid);
void ResizeMatrix_ps_wrp(int *ih_this, const int *new_size);
void GetMatrixProcessGrid_ps_wrp(const int *ih_this, int *ih_grid);

void DotMatrix_psr_wrp(const int *ih_matA, const int *ih_matB, double *product);
void DotMatrix_psc_wrp(const int *ih_matA, const int *ih_matB,
Expand Down
4 changes: 2 additions & 2 deletions Source/CPlusPlus/MatrixConversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extern "C" {
////////////////////////////////////////////////////////////////////////////////
namespace NTPoly {
//////////////////////////////////////////////////////////////////////////////
void MatrixConversion::SnapMatrixToSparsityPattern(Matrix_ps& mata,
const Matrix_ps& matb) {
void MatrixConversion::SnapMatrixToSparsityPattern(Matrix_ps &mata,
const Matrix_ps &matb) {
SnapMatrixToSparsityPattern_wrp(mata.ih_this, matb.ih_this);
}
} // namespace NTPoly
6 changes: 3 additions & 3 deletions Source/CPlusPlus/MatrixConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class MatrixConversion {
//! Some codes use a fixed sparsity pattern for a matrix instead of filtering
//! small values. Using this routine, the matrix is filled to have the same
//! pattern as the second matrix argument. Zeros of the sparsity pattern are
//! left in, whereas values outside the sparsity are removed. This can
//! left in, whereas values outside the sparsity are removed. This can
//! faciliate conversion between formats.
//! \param mata the matrix to modify.
//! \param matb the matrix which defines the sparsity pattern.
static void SnapMatrixToSparsityPattern(Matrix_ps& mata,
const Matrix_ps& matb);
static void SnapMatrixToSparsityPattern(Matrix_ps &mata,
const Matrix_ps &matb);
};
} // namespace NTPoly
#endif
2 changes: 1 addition & 1 deletion Source/CPlusPlus/PSMatrix.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "PMatrixMemoryPool.h"
#include "PSMatrix.h"
#include "PMatrixMemoryPool.h"
#include "Permutation.h"
#include "ProcessGrid.h"
#include "TripletList.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/CPlusPlus/SMatrix.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "MatrixMemoryPool.h"
#include "SMatrix.h"
#include "MatrixMemoryPool.h"
#include "TripletList.h"
using std::complex;
using std::string;
Expand Down
2 changes: 1 addition & 1 deletion Source/CPlusPlus/SolverBase.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "PSMatrix.h"
#include "SolverBase.h"
#include "PSMatrix.h"
#include "SolverParameters.h"

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion Source/CPlusPlus/SolverParameters.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Permutation.h"
#include "SolverParameters.h"
#include "Permutation.h"

////////////////////////////////////////////////////////////////////////////////
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion Source/CPlusPlus/TripletList.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Triplet.h"
#include "TripletList.h"
#include "Triplet.h"

#include <complex>

Expand Down
18 changes: 9 additions & 9 deletions Source/Fortran/ChebyshevSolversModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ MODULE ChebyshevSolversModule
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INTERFACE ConstructPolynomial
MODULE PROCEDURE ConstructPolynomial_cheby
END INTERFACE
END INTERFACE ConstructPolynomial
INTERFACE DestructPolynomial
MODULE PROCEDURE DestructPolynomial_cheby
END INTERFACE
END INTERFACE DestructPolynomial
INTERFACE SetCoefficient
MODULE PROCEDURE SetCoefficient_cheby
END INTERFACE
END INTERFACE SetCoefficient
INTERFACE Compute
MODULE PROCEDURE Compute_cheby
END INTERFACE
END INTERFACE Compute
INTERFACE FactorizedCompute
MODULE PROCEDURE FactorizedCompute_cheby
END INTERFACE
END INTERFACE FactorizedCompute
CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Construct a Chebyshev polynomial object.
PURE SUBROUTINE ConstructPolynomial_cheby(this, degree)
Expand Down Expand Up @@ -114,8 +114,8 @@ SUBROUTINE Compute_cheby(InputMat, OutputMat, poly, solver_parameters_in)
IF (solver_parameters%be_verbose) THEN
CALL WriteHeader("Chebyshev Solver")
CALL EnterSubLog
CALL WriteElement(key="Method", value="Standard")
CALL WriteElement(key="Degree", value=degree-1)
CALL WriteElement(key="Method", VALUE="Standard")
CALL WriteElement(key="Degree", VALUE=degree-1)
CALL PrintParameters(solver_parameters)
END IF

Expand Down Expand Up @@ -225,8 +225,8 @@ SUBROUTINE FactorizedCompute_cheby(InputMat, OutputMat, poly, &
IF (solver_parameters%be_verbose) THEN
CALL WriteHeader("Chebyshev Solver")
CALL EnterSubLog
CALL WriteElement(key="Method", value="Recursive")
CALL WriteElement(key="Degree", value=degree-1)
CALL WriteElement(key="Method", VALUE="Recursive")
CALL WriteElement(key="Degree", VALUE=degree-1)
CALL PrintParameters(solver_parameters)
END IF

Expand Down
Loading

0 comments on commit 9fb50d7

Please sign in to comment.