Skip to content

Commit

Permalink
Merge pull request #110 from kohei-noda-qcrg/ivo-consistency-check-mp…
Browse files Browse the repository at this point in the history
…i-error

Fixed a bug in mpi parallel where all processes did not terminate if consistency_check failed.
  • Loading branch information
kohei-noda-qcrg authored Nov 6, 2023
2 parents 7b5f902 + 7e38c8e commit 48f0824
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions src/module_ivo_consistency_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module module_ivo_consistency_check

contains
subroutine ivo_consistency_check
use module_global_variables, only: irpamo, dirac_version, ninact, nact, nsec, nsymrpa, occ_mo_num, vcut_mo_num
use module_global_variables, only: irpamo, dirac_version, ninact, nact, nsec, nsymrpa, occ_mo_num, vcut_mo_num, rank
use module_file_manager
use module_error
implicit none
Expand All @@ -22,7 +22,7 @@ subroutine ivo_consistency_check
integer :: i, total_mo, total_ao
integer :: positronic_mo(2), electronic_mo(2), basis_ao(2), basis_all(2), mo(2)

print *, "Start checking the consistency of your input and DFPCMO data"
if (rank == 0) print *, "Start checking the consistency of your input and DFPCMO data"
positronic_mo(:) = 0; electronic_mo(:) = 0; basis_ao(:) = 0; basis_all(:) = 0; mo(:) = 0
filename = "DFPCMO"
call open_formatted_file(unit=unit_dfpcmo, file=filename, status="old")
Expand Down Expand Up @@ -76,7 +76,7 @@ subroutine ivo_consistency_check
! Read MO supersymmetry
allocate (supersym(total_mo))
read (unit_dfpcmo, *, iostat=iostat) supersym
print *, "supersym", supersym
if (rank == 0) print *, "supersym", supersym

close (unit_dfpcmo) ! Close the DFPCMO file

Expand All @@ -95,13 +95,14 @@ subroutine ivo_consistency_check
start_isym = nsymrpa/2 + 1
end_isym = nsymrpa
end if
! Print the virtual MOs supersymmetry
print *, "Virtual supersym", supersym(start_idx_dfpcmo:end_idx_dfpcmo)
! Check the consistency of the input and DFPCMO data
! At any isym(irreducible representation)
! the number of virtual MOs in the DFPCMO file must be equal to the number of virtual MOs in the input file
print *, "irpamo", irpamo(start_idx_input:end_idx_input)

if (rank == 0) then
! Print the virtual MOs supersymmetry
print *, "Virtual supersym", supersym(start_idx_dfpcmo:end_idx_dfpcmo)
! Check the consistency of the input and DFPCMO data
! At any isym(irreducible representation)
! the number of virtual MOs in the DFPCMO file must be equal to the number of virtual MOs in the input file
print *, "irpamo", irpamo(start_idx_input:end_idx_input)
end if
do isym = start_isym, end_isym, 2
if (i == 1) then
isym_for_supersym = isym
Expand All @@ -114,14 +115,16 @@ subroutine ivo_consistency_check
nv_dfpcmo = count(abs(supersym(start_idx_dfpcmo:end_idx_dfpcmo)) == isym_for_supersym) ! Number of virtual MOs corresponding to isym in the DFPCMO file
end if
nv_input = count(irpamo(start_idx_input:end_idx_input) == isym) ! Number of virtual MOs corresponding to isym in the input file
print *, "isym", isym, "isym_f_s", isym_for_supersym, "nv_dfpcmo", nv_dfpcmo, "nv_input", nv_input
if (rank == 0) print *, "isym", isym, "isym_f_s", isym_for_supersym, "nv_dfpcmo", nv_dfpcmo, "nv_input", nv_input
if (nv_input /= nv_dfpcmo) then
print *, "isym =", isym, "supersym =", supersym(start_idx_dfpcmo:end_idx_dfpcmo)
print *, "The number of virtual MOs in the DFPCMO file is not equal", &
"to the number of virtual MOs in the input file.", &
"isym = ", isym, "nv_input = ", nv_input, "nv_dfpcmo = ", nv_dfpcmo
print *, "Please check your input file."
print *, "Maybe you forgot to set the nvcut(g,u) parameter in the input file?"
if (rank == 0) then
print *, "isym =", isym, "supersym =", supersym(start_idx_dfpcmo:end_idx_dfpcmo)
print *, "The number of virtual MOs in the DFPCMO file is not equal", &
"to the number of virtual MOs in the input file.", &
"isym = ", isym, "nv_input = ", nv_input, "nv_dfpcmo = ", nv_dfpcmo
print *, "Please check your input file."
print *, "Maybe you forgot to set the nvcut(g,u) parameter in the input file?"
end if
call stop_with_errorcode(1)
end if
end do
Expand All @@ -132,7 +135,7 @@ subroutine check_end_of_file
implicit none
call check_iostat(iostat=iostat, file=filename, end_of_file_reached=end_of_file)
if (end_of_file) then
print *, "Error: The DFPCMO file contains less data than expected."
if (rank == 0) print *, "Error: The DFPCMO file contains less data than expected."
call stop_with_errorcode(1)
end if
end subroutine check_end_of_file
Expand Down
2 changes: 1 addition & 1 deletion src/r4divo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ PROGRAM r4divo_co ! DO IVO CALC ONLY FOR SMALL BASIS SETS
call read_mrconee(filename)

! Check consistency of IVO input and DFPCMO file.
if (rank == 0) call ivo_consistency_check
call ivo_consistency_check

call check_realonly
! Create UTChem type MDCINT file from Dirac MDCINT file
Expand Down

0 comments on commit 48f0824

Please sign in to comment.