Fix double allocation of the SPGR components (#4946)

This commit is contained in:
Frederick Stein 2026-03-12 17:17:56 +01:00 committed by GitHub
parent 128d32b635
commit 039bc03734
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 27 deletions

View file

@ -38,7 +38,8 @@ MODULE space_groups
jacobi
USE particle_list_types, ONLY: particle_list_type
USE physcon, ONLY: pascal
USE space_groups_types, ONLY: spgr_type
USE space_groups_types, ONLY: cleanup_spgr_type,&
spgr_type
USE spglib_f08, ONLY: spg_get_international,&
spg_get_multiplicity,&
spg_get_pointgroup,&
@ -108,6 +109,8 @@ CONTAINS
spgr => gopt_env%spgr
CPASSERT(ASSOCIATED(spgr))
CALL cleanup_spgr_type(spgr)
!..total number of particles (atoms plus shells)
IF (PRESENT(nparticle)) THEN
CPASSERT(nparticle == SIZE(scoor, 2))

View file

@ -58,7 +58,7 @@ MODULE space_groups_types
TYPE(cell_type), POINTER :: cell_ref => NULL()
END TYPE spgr_type
PUBLIC :: spgr_type, release_spgr_type
PUBLIC :: spgr_type, release_spgr_type, cleanup_spgr_type
CONTAINS
@ -74,34 +74,47 @@ CONTAINS
TYPE(spgr_type), POINTER :: spgr
IF (ASSOCIATED(spgr)) THEN
IF (ALLOCATED(spgr%rotations)) THEN
DEALLOCATE (spgr%rotations)
END IF
IF (ALLOCATED(spgr%rotations_subset)) THEN
DEALLOCATE (spgr%rotations_subset)
END IF
IF (ALLOCATED(spgr%translations)) THEN
DEALLOCATE (spgr%translations)
END IF
IF (ALLOCATED(spgr%atype)) THEN
DEALLOCATE (spgr%atype)
END IF
IF (ALLOCATED(spgr%eqatom)) THEN
DEALLOCATE (spgr%eqatom)
END IF
IF (ALLOCATED(spgr%lop)) THEN
DEALLOCATE (spgr%lop)
END IF
IF (ALLOCATED(spgr%lat)) THEN
DEALLOCATE (spgr%lat)
END IF
CALL cell_release(spgr%cell_ref)
CALL cleanup_spgr_type(spgr)
DEALLOCATE (spgr)
END IF
END SUBROUTINE release_spgr_type
! **************************************************************************************************
!> \brief Cleanup all buffers the SPGR type
!> \param spgr The SPGR type
!> \par History
!> 01.2020 created [pcazade]
!> \author Pierre-André Cazade (first version)
! **************************************************************************************************
SUBROUTINE cleanup_spgr_type(spgr)
TYPE(spgr_type), INTENT(INOUT) :: spgr
IF (ALLOCATED(spgr%rotations)) THEN
DEALLOCATE (spgr%rotations)
END IF
IF (ALLOCATED(spgr%rotations_subset)) THEN
DEALLOCATE (spgr%rotations_subset)
END IF
IF (ALLOCATED(spgr%translations)) THEN
DEALLOCATE (spgr%translations)
END IF
IF (ALLOCATED(spgr%atype)) THEN
DEALLOCATE (spgr%atype)
END IF
IF (ALLOCATED(spgr%eqatom)) THEN
DEALLOCATE (spgr%eqatom)
END IF
IF (ALLOCATED(spgr%lop)) THEN
DEALLOCATE (spgr%lop)
END IF
IF (ALLOCATED(spgr%lat)) THEN
DEALLOCATE (spgr%lat)
END IF
CALL cell_release(spgr%cell_ref)
END SUBROUTINE cleanup_spgr_type
END MODULE space_groups_types