diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e3a18eb..21a9d630 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,7 @@ jobs: debug: 0 noalligather: 0 mpich: 0 + lint: 1 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v1 @@ -81,5 +82,6 @@ jobs: env: TESTEXAMPLES: ${{ matrix.testexamples }} - name: lint + if: ${{ matrix.lint }} run: | bash UnitTests/lint.sh diff --git a/Examples/HydrogenAtom/ReadMe.md b/Examples/HydrogenAtom/ReadMe.md index 97a6f5e7..a359e326 100644 --- a/Examples/HydrogenAtom/ReadMe.md +++ b/Examples/HydrogenAtom/ReadMe.md @@ -24,7 +24,8 @@ We need to solve the following equation: The kinetic energy operator is based on a 5 point stencil central difference formula. See the following link: -http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/central-differences/ +http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/ +central-differences/ The potential energy operator is diagonal in real space. diff --git a/Examples/OverlapMatrix/ReadMe.md b/Examples/OverlapMatrix/ReadMe.md index 6fca506b..4dcb9606 100644 --- a/Examples/OverlapMatrix/ReadMe.md +++ b/Examples/OverlapMatrix/ReadMe.md @@ -95,17 +95,18 @@ Next we need to divide up the matrix. First, we compute how many matrix rows and columns are stored locally. This is just the total matrix size divided by the number of process rows/columns. -Second, we compute the starting and ending rows/columns. In the ProcessGridModule, -there are global variables "my_row" and "my_column" which gives the xy coordinates -of a given process. This information can be used to compute the starting row -and column, and then we just add to those values the number of local rows/columns. +Second, we compute the starting and ending rows/columns. In the +ProcessGridModule, there are global variables "my_row" and "my_column" which +gives the xy coordinates of a given process. This information can be used to +compute the starting row and column, and then we just add to those values the +number of local rows/columns. ## Compute The Local Matrix Elements Now that we know the local rows and columns of the matrix, we can compute -the local matrix elements. We do that by looping over the local rows and columns, -and calling the "ComputeIntegral" function. This ComputeIntegral function is of -course just a dummy function. +the local matrix elements. We do that by looping over the local rows and +columns, and calling the "ComputeIntegral" function. This ComputeIntegral +function is of course just a dummy function. Since we don't know a priori which integrals can be neglected, what we do is compute each one, and then test if the value is bigger than some threshold. diff --git a/Source/Fortran/PSMatrixModule.F90 b/Source/Fortran/PSMatrixModule.F90 index cbda2a4e..3eb21eec 100644 --- a/Source/Fortran/PSMatrixModule.F90 +++ b/Source/Fortran/PSMatrixModule.F90 @@ -392,7 +392,8 @@ RECURSIVE SUBROUTINE ConstructMatrixFromMatrixMarket_ps(this, file_name, & local_file_handler = 16 OPEN(local_file_handler, file=file_name, iostat=ierr, status="old") IF (ierr .NE. 0) THEN - CALL SetGenericError(err, TRIM(file_name)//" doesn't exist", .TRUE.) + CALL SetGenericError(err, TRIM(file_name)//" doesn't exist", & + & .TRUE.) END IF !! Parse the header. READ(local_file_handler,fmt='(A)') input_buffer diff --git a/Source/Fortran/ProcessGridModule.F90 b/Source/Fortran/ProcessGridModule.F90 index c8b76a6f..37dfdeef 100644 --- a/Source/Fortran/ProcessGridModule.F90 +++ b/Source/Fortran/ProcessGridModule.F90 @@ -216,7 +216,8 @@ SUBROUTINE ConstructNewProcessGrid_full(grid, world_comm_, process_rows_, & !! Grid ID CALL MPI_COMM_RANK(grid%global_comm,grid%global_rank,ierr) grid%my_slice = grid%global_rank/grid%slice_size - grid%my_row = MOD(grid%global_rank, grid%slice_size)/grid%num_process_columns + grid%my_row = MOD(grid%global_rank, grid%slice_size)/ & + & grid%num_process_columns grid%my_column = MOD(grid%global_rank, grid%num_process_columns) !! Grid Communicators diff --git a/Source/Fortran/TrigonometrySolversModule.F90 b/Source/Fortran/TrigonometrySolversModule.F90 index 52d59b66..1c318c14 100644 --- a/Source/Fortran/TrigonometrySolversModule.F90 +++ b/Source/Fortran/TrigonometrySolversModule.F90 @@ -221,7 +221,8 @@ SUBROUTINE ScaleSquareTrigonometry(InputMat, OutputMat, solver_parameters_in) CALL WriteHeader("Trigonometry Solver") CALL EnterSubLog CALL WriteElement(key="Method", VALUE="Chebyshev") - CALL WriteCitation("serbin1980algorithm higham2003computing yau1993reducing") + CALL WriteCitation("serbin1980algorithm higham2003computing& + & yau1993reducing") CALL PrintParameters(solver_parameters) END IF diff --git a/Source/Fortran/sparse_includes/IncrementMatrix.f90 b/Source/Fortran/sparse_includes/IncrementMatrix.f90 index 795ee83c..64d146a7 100644 --- a/Source/Fortran/sparse_includes/IncrementMatrix.f90 +++ b/Source/Fortran/sparse_includes/IncrementMatrix.f90 @@ -1,6 +1,6 @@ !! Counter Variables INTEGER :: outer_counter - INTEGER :: elements_per_inner_a, elements_per_inner_b + INTEGER :: inner_a, inner_b INTEGER :: total_counter_a, total_counter_b, total_counter_c !! Temporary Variables INTEGER :: indices_added_into_c @@ -39,21 +39,21 @@ total_counter_c = 1 DO outer_counter = 1, matA%columns !! Inner counters - elements_per_inner_a = matA%outer_index(outer_counter+1) - & + inner_a = matA%outer_index(outer_counter+1) - & & matA%outer_index(outer_counter) - elements_per_inner_b = matB%outer_index(outer_counter+1) - & + inner_b = matB%outer_index(outer_counter+1) - & & matB%outer_index(outer_counter) CALL AddSparseVectors(& - matA%inner_index(total_counter_a:total_counter_a+elements_per_inner_a-1),& - matA%values(total_counter_a:total_counter_a+elements_per_inner_a-1),& - matB%inner_index(total_counter_b:total_counter_b+elements_per_inner_b-1),& - matB%values(total_counter_b:total_counter_b+elements_per_inner_b-1),& + matA%inner_index(total_counter_a:total_counter_a+inner_a-1),& + matA%values(total_counter_a:total_counter_a+inner_a-1),& + matB%inner_index(total_counter_b:total_counter_b+inner_b-1),& + matB%values(total_counter_b:total_counter_b+inner_b-1),& matC%inner_index(total_counter_c:),matC%values(total_counter_c:),& indices_added_into_c, alpha, threshold) matC%outer_index(outer_counter+1) = matC%outer_index(outer_counter)+& & indices_added_into_c - total_counter_a = total_counter_a + elements_per_inner_a - total_counter_b = total_counter_b + elements_per_inner_b + total_counter_a = total_counter_a + inner_a + total_counter_b = total_counter_b + inner_b total_counter_c = total_counter_c + indices_added_into_c END DO diff --git a/Source/Fortran/sparse_includes/PairwiseMultiplyMatrix.f90 b/Source/Fortran/sparse_includes/PairwiseMultiplyMatrix.f90 index 898486b4..103d722e 100644 --- a/Source/Fortran/sparse_includes/PairwiseMultiplyMatrix.f90 +++ b/Source/Fortran/sparse_includes/PairwiseMultiplyMatrix.f90 @@ -1,6 +1,6 @@ !! Counter Variables INTEGER :: outer_counter - INTEGER :: elements_per_inner_a, elements_per_inner_b + INTEGER :: inner_a, inner_b INTEGER :: total_counter_a, total_counter_b, total_counter_c !! Temporary Variables INTEGER :: indices_added_into_c @@ -18,21 +18,22 @@ total_counter_c = 1 DO outer_counter = 1, matA%columns !! Inner counters - elements_per_inner_a = matA%outer_index(outer_counter+1) - & + inner_a = matA%outer_index(outer_counter+1) - & & matA%outer_index(outer_counter) - elements_per_inner_b = matB%outer_index(outer_counter+1) - & + inner_b = matB%outer_index(outer_counter+1) - & & matB%outer_index(outer_counter) CALL PairwiseMultiplyVectors(& - matA%inner_index(total_counter_a:total_counter_a+elements_per_inner_a-1),& - matA%values(total_counter_a:total_counter_a+elements_per_inner_a-1),& - matB%inner_index(total_counter_b:total_counter_b+elements_per_inner_b-1),& - matB%values(total_counter_b:total_counter_b+elements_per_inner_b-1),& - TempMat%inner_index(total_counter_c:),TempMat%values(total_counter_c:),& + matA%inner_index(total_counter_a:total_counter_a+inner_a-1),& + matA%values(total_counter_a:total_counter_a+inner_a-1),& + matB%inner_index(total_counter_b:total_counter_b+inner_b-1),& + matB%values(total_counter_b:total_counter_b+inner_b-1),& + TempMat%inner_index(total_counter_c:),& + TempMat%values(total_counter_c:),& indices_added_into_c) TempMat%outer_index(outer_counter+1) = TempMat%outer_index(outer_counter)+& & indices_added_into_c - total_counter_a = total_counter_a + elements_per_inner_a - total_counter_b = total_counter_b + elements_per_inner_b + total_counter_a = total_counter_a + inner_a + total_counter_b = total_counter_b + inner_b total_counter_c = total_counter_c + indices_added_into_c END DO @@ -42,6 +43,7 @@ matC%outer_index = TempMat%outer_index ALLOCATE(matC%inner_index(TempMat%outer_index(TempMat%columns+1))) ALLOCATE(matC%values(TempMat%outer_index(TempMat%columns+1))) - matC%inner_index = TempMat%inner_index(:TempMat%outer_index(TempMat%columns+1)) + matC%inner_index = TempMat%inner_index(& + & :TempMat%outer_index(TempMat%columns+1)) matC%values = TempMat%values(:TempMat%outer_index(TempMat%columns+1)) CALL DestructMatrix(TempMat) diff --git a/Source/Fortran/triplet_includes/SortTripletList.f90 b/Source/Fortran/triplet_includes/SortTripletList.f90 index d62476c8..26babda3 100644 --- a/Source/Fortran/triplet_includes/SortTripletList.f90 +++ b/Source/Fortran/triplet_includes/SortTripletList.f90 @@ -6,7 +6,7 @@ INTEGER, DIMENSION(:), ALLOCATABLE :: inserted_per_row !! Counters and temporary variables INTEGER :: counter - INTEGER :: temp_index + INTEGER :: idx INTEGER :: alloc_stat INTEGER :: list_length @@ -43,10 +43,10 @@ & values_per_row(counter-1) END DO DO counter = 1, input_list%CurrentSize - temp_index = input_list%DATA(counter)%index_column - sorted_list%DATA(offset_array(temp_index)+inserted_per_row(temp_index))=& + idx = input_list%DATA(counter)%index_column + sorted_list%DATA(offset_array(idx)+inserted_per_row(idx))=& & input_list%DATA(counter) - inserted_per_row(temp_index) = inserted_per_row(temp_index) + 1 + inserted_per_row(idx) = inserted_per_row(idx) + 1 END DO !! Finish with bubble sort diff --git a/Source/Wrapper/PSMatrixModule_wrp.F90 b/Source/Wrapper/PSMatrixModule_wrp.F90 index f635a306..04b027b7 100644 --- a/Source/Wrapper/PSMatrixModule_wrp.F90 +++ b/Source/Wrapper/PSMatrixModule_wrp.F90 @@ -330,7 +330,8 @@ END SUBROUTINE GetMatrixTripletList_psc_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Extract an arbitrary block of a matrix into a triplet list. SUBROUTINE GetMatrixBlock_psr_wrp(ih_this, ih_triplet_list, start_row, & - & end_row, start_column, end_column) BIND(c,NAME="GetMatrixBlock_psr_wrp") + & end_row, start_column, end_column) & + & BIND(c,NAME="GetMatrixBlock_psr_wrp") INTEGER(KIND=c_int), INTENT(IN) :: ih_this(SIZE_wrp) INTEGER(KIND=c_int), INTENT(INOUT) :: ih_triplet_list(SIZE_wrp) INTEGER(KIND=c_int), INTENT(IN) :: start_row, end_row @@ -346,7 +347,8 @@ END SUBROUTINE GetMatrixBlock_psr_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Extract an arbitrary block of a matrix into a triplet list. SUBROUTINE GetMatrixBlock_psc_wrp(ih_this, ih_triplet_list, start_row, & - & end_row, start_column, end_column) BIND(c,NAME="GetMatrixBlock_psc_wrp") + & end_row, start_column, end_column) & + & BIND(c,NAME="GetMatrixBlock_psc_wrp") INTEGER(KIND=c_int), INTENT(IN) :: ih_this(SIZE_wrp) INTEGER(KIND=c_int), INTENT(INOUT) :: ih_triplet_list(SIZE_wrp) INTEGER(KIND=c_int), INTENT(IN) :: start_row, end_row diff --git a/Source/Wrapper/TripletListModule_wrp.F90 b/Source/Wrapper/TripletListModule_wrp.F90 index 25685ec8..de8193fe 100644 --- a/Source/Wrapper/TripletListModule_wrp.F90 +++ b/Source/Wrapper/TripletListModule_wrp.F90 @@ -32,7 +32,7 @@ MODULE TripletListModule_wrp PUBLIC :: GetTripletAt_r_wrp PUBLIC :: SortTripletList_r_wrp PUBLIC :: GetTripletListSize_r_wrp - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUBLIC :: ConstructTripletList_c_wrp PUBLIC :: DestructTripletList_c_wrp PUBLIC :: ResizeTripletList_c_wrp diff --git a/UnitTests/before_install.sh b/UnitTests/before_install.sh index fad0a1ed..7d08a07d 100644 --- a/UnitTests/before_install.sh +++ b/UnitTests/before_install.sh @@ -3,6 +3,9 @@ if [[ "$TESTOS" == "LINUX" ]]; then sudo apt-get update sudo apt-get install gfortran sudo apt-get install libblas-dev liblapack-dev + sudo apt-get install gawk + sudo apt-get install clang-format + sudo apt-get install emacs if [[ "$MPICH" == "1" ]]; then sudo apt-get install mpich libmpich-dev else @@ -18,6 +21,7 @@ if [[ "$TESTOS" == "OSX" ]]; then brew install cmake brew install swig brew install clang-format + brew install emacs sudo pip2 install numpy --upgrade --no-cache-dir sudo pip2 install scipy --upgrade --no-cache-dir sudo pip2 install mpi4py --upgrade --no-cache-dir diff --git a/UnitTests/lint.sh b/UnitTests/lint.sh index 7c779122..e825c0b7 100644 --- a/UnitTests/lint.sh +++ b/UnitTests/lint.sh @@ -1,3 +1,5 @@ +set -e + # Python flake8 UnitTests flake8 Examples @@ -16,6 +18,11 @@ for f in $(find . -type f -name "*.*90"); do --eval="(f90-indent-subprogram)" -f save-buffer 2>/dev/null done +# 80 Column Limit +for f in $(find -L Source Targets UnitTests); do + awk 'NF > 80 {print FILENAME ; print "Line " NR ; print ; stat = 1} \ + END {exit stat}' FS= $f 2>/dev/null +done + # If git returns any changes, we know there is a problem. -set -e git --no-pager diff --exit-code \ No newline at end of file