From bfa8555a27ae8a7b1290d9c6565e1ee7cd6213f7 Mon Sep 17 00:00:00 2001 From: derekyjy <17701711451@163.com> Date: Mon, 23 Mar 2026 09:31:39 +0800 Subject: [PATCH 1/2] fix: add file open check in utils.cpp --- source/source_hsolver/module_genelpa/utils.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/source_hsolver/module_genelpa/utils.cpp b/source/source_hsolver/module_genelpa/utils.cpp index 6654c33b9e..a0304f950a 100644 --- a/source/source_hsolver/module_genelpa/utils.cpp +++ b/source/source_hsolver/module_genelpa/utils.cpp @@ -91,10 +91,15 @@ void loadMatrix(const char FileName[], int nFull, double* a, int* desca, int bla const int ROOT_PROC = 0; std::ifstream matrixFile; - if (myid == ROOT_PROC) + if (myid == ROOT_PROC){ matrixFile.open(FileName); - double* b; // buffer + if (!matrixFile.is_open()) { + std::cerr << "Error: failed to open file " << FileName << std::endl; + exit(EXIT_FAILURE); + } + } +double* b; // buffer const int MAX_BUFFER_SIZE = 1e9; // max buffer size is 1GB int N = nFull; From c96bd93e364b77b8fae7fb00f81cd89d7cb2d07f Mon Sep 17 00:00:00 2001 From: derekyjy <17701711451@163.com> Date: Mon, 23 Mar 2026 09:34:30 +0800 Subject: [PATCH 2/2] fix: add file open check in utils.cpp --- source/source_hsolver/module_genelpa/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/source_hsolver/module_genelpa/utils.cpp b/source/source_hsolver/module_genelpa/utils.cpp index a0304f950a..69eb885eb3 100644 --- a/source/source_hsolver/module_genelpa/utils.cpp +++ b/source/source_hsolver/module_genelpa/utils.cpp @@ -97,7 +97,7 @@ void loadMatrix(const char FileName[], int nFull, double* a, int* desca, int bla if (!matrixFile.is_open()) { std::cerr << "Error: failed to open file " << FileName << std::endl; exit(EXIT_FAILURE); - } + } } double* b; // buffer const int MAX_BUFFER_SIZE = 1e9; // max buffer size is 1GB