diff --git a/CMakeLists.txt b/CMakeLists.txt index 47ff4752..fb218fc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,12 @@ if(PROGRESS_MPI) # add_definitions(-DDO_MPI_BLOCK) endif() +set(SANITY_CHECK FALSE CACHE BOOL "Additional sanity checks") +if(SANITY_CHECK) + message(STATUS "Will add sanity checks") + add_definitions(-DSANITY_CHECK) +endif() + add_subdirectory(src) find_package(Doxygen) diff --git a/build.sh b/build.sh index 00e67ff4..6ea96181 100755 --- a/build.sh +++ b/build.sh @@ -40,20 +40,22 @@ EOF echo "INSTALL_DIR Path to install dir (default is ${INSTALL_DIR})" echo "EXTRA_FCFLAGS Extra fortran flags (default is ${EXTRA_FCFLAGS})" echo "EXTRA_LINK_FLAGS Any extra link flag (default is ${EXTRA_LINK_FLAGS})" + echo "SANITY_CHECK Add sanity checks (default is ${SANITY_CHECK})" } set_defaults() { - CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release} - CC="${CC:=gcc}" - CXX="${CXX:=g++}" - FC="${FC:=gfortran}" - PROGRESS_OPENMP=${PROGRESS_OPENMP:=yes} - PROGRESS_MPI=${PROGRESS_MPI:=no} - PROGRESS_EXAMPLES=${PROGRESS_EXAMPLES:=no} - PROGRESS_GRAPHLIB=${PROGRESS_GRAPHLIB:=no} - EXTRA_FCFLAGS="${EXTRA_FCFLAGS:=}" - EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:=""} - PROGRESS_TESTING=${PROGRESS_TESTING:=no} + : ${CMAKE_BUILD_TYPE:=Release} + : "${CC:=gcc}" + : "${CXX:=g++}" + : "${FC:=gfortran}" + : ${PROGRESS_OPENMP:=yes} + : ${PROGRESS_MPI:=no} + : ${PROGRESS_TESTING:=no} + : ${PROGRESS_EXAMPLES:=no} + : ${PROGRESS_GRAPHLIB:=no} + : "${EXTRA_FCFLAGS:=}" + : ${EXTRA_LINK_FLAGS:=""} + : ${SANITY_CHECK:=no} } die() { @@ -111,6 +113,7 @@ configure() { -DEXTRA_FCFLAGS="${EXTRA_FCFLAGS}" \ -DEXTRA_LINK_FLAGS="${EXTRA_LINK_FLAGS}" \ -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \ + -DSANITY_CHECK=${SANITY_CHECK} \ | tee -a "${LOG_FILE}" check_pipe_error cd "${TOP_DIR}" diff --git a/examples/gpmdcov/gpmdcov.F90 b/examples/gpmdcov/gpmdcov.F90 index e9f792ac..314d3999 100644 --- a/examples/gpmdcov/gpmdcov.F90 +++ b/examples/gpmdcov/gpmdcov.F90 @@ -291,6 +291,7 @@ subroutine gpmd_Part integer, allocatable :: graph_h(:,:) integer, allocatable :: graph_p(:,:) real(dp) :: mls_ii + integer :: iptt if(mdstep < 1)then if(lt%verbose >= 1 .and. myRank == 1)call prg_get_mem("gpmdcov", "Before prg_get_covgraph") @@ -385,6 +386,24 @@ subroutine gpmd_Part ! write(*,*)"part by mol" ! call prg_molpartition(sy,nparts_cov,nl%nnStructMindist,nl%nnStruct,nl%nrnnstruct,"O ",gpat) +#ifdef SANITY_CHECK + write(*, *) "sanity check before bml_matrix2submatrix_index" + do ipt = 1,gpat%TotalParts + do iptt = ipt+1,gpat%TotalParts + do i = 1, gpat%sgraph(ipt)%llsize + do j = 1, gpat%sgraph(iptt)%llsize + if(gpat%sgraph(ipt)%core_halo_index(i) == gpat%sgraph(iptt)%core_halo_index(j))then + write(*,*)"cores are repeated in partitions",mdstep + write(*,*)ipt,gpat%sgraph(ipt)%core_halo_index(i),iptt,gpat%sgraph(ipt)%core_halo_index(j) + write(*,*)i,j + stop + endif + enddo + enddo + enddo + enddo +#endif + mls_ii = mls() do i=1,gpat%TotalParts call bml_matrix2submatrix_index(g_bml,& @@ -397,9 +416,25 @@ subroutine gpmd_Part if(lt%verbose >= 1 .and. myRank == 1)write(*,*)"Time for bml_matrix2submatrix_index "//to_string(mls()-mls_ii)//" ms" - call gpmd_reshuffle() +#ifdef SANITY_CHECK + write(*, *) "sanity check after bml_matrix2submatrix_index" + do ipt = 1,gpat%TotalParts + do iptt = ipt+1,gpat%TotalParts + do i = 1, gpat%sgraph(ipt)%llsize + do j = 1, gpat%sgraph(iptt)%llsize + if(gpat%sgraph(ipt)%core_halo_index(i) == gpat%sgraph(iptt)%core_halo_index(j))then + write(*,*)"cores are repeated in partitions",mdstep + write(*,*)ipt,gpat%sgraph(ipt)%core_halo_index(i),iptt,gpat%sgraph(ipt)%core_halo_index(j) + write(*,*)i,j + stop + endif + enddo + enddo + enddo + enddo +#endif if(allocated(syprt))deallocate(syprt) allocate(syprt(gpat%TotalParts)) @@ -434,7 +469,6 @@ subroutine gpmd_Part end subroutine gpmd_Part - !> Initialize the partition. !! subroutine gpmd_InitParts