DeePMD: Fix memory leak in deepmd_model_load

This commit is contained in:
Ole Schütt 2025-01-29 21:46:12 +01:00 committed by Ole Schütt
parent 2eb13e25da
commit 4c33f953fe

View file

@ -68,6 +68,12 @@ CONTAINS
TYPE(C_PTR) :: DeepPotCheckOK
END FUNCTION DeepPotCheckOK
END INTERFACE
INTERFACE
SUBROUTINE DeleteChar(ptr) BIND(C, name="DP_DeleteChar")
IMPORT :: C_PTR
TYPE(C_PTR), VALUE :: ptr
END SUBROUTINE DeleteChar
END INTERFACE
CALL timeset(routineN, handle)
@ -85,6 +91,7 @@ CONTAINS
IF (error_f_ptr(i) == C_NULL_CHAR) EXIT
error_str(i:i) = error_f_ptr(i)
END DO
CALL DeleteChar(error_c_ptr)
IF (LEN_TRIM(error_str) > 0) CPABORT(TRIM(error_str))
#else
CPABORT("CP2K was compiled without libdeepmd_c library.")