From 27a2d106815d10dbf3d7b2e0052fa2e6829f0f81 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Tue, 5 Nov 2024 16:28:39 +0100 Subject: [PATCH] Use default Hessian restart file name if no name is specified --- src/motion/bfgs_optimizer.F | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/motion/bfgs_optimizer.F b/src/motion/bfgs_optimizer.F index d2bd14d6e0..3a6d3c196e 100644 --- a/src/motion/bfgs_optimizer.F +++ b/src/motion/bfgs_optimizer.F @@ -150,6 +150,7 @@ CONTAINS conv = .FALSE. rat = 0.0_dp wildcard = " BFGS" + hes_filename = "" ! Stop if not yet implemented SELECT CASE (gopt_env%type_id) @@ -307,8 +308,20 @@ CONTAINS IF (((its - iter_nr) == 1) .AND. hesrest) THEN IF (ionode) THEN CALL section_vals_val_get(geo_section, "BFGS%RESTART_FILE_NAME", c_val=hes_filename) - CALL open_file(file_name=hes_filename, file_status="OLD", & + IF (LEN_TRIM(hes_filename) == 0) THEN + ! Set default Hessian restart file name if no file name is defined + hes_filename = TRIM(logger%iter_info%project_name)//"-BFGS.Hessian" + END IF + IF (output_unit > 0) THEN + WRITE (UNIT=output_unit, FMT="(/,T2,A)") & + "BFGS| Checking for Hessian restart file <"//TRIM(ADJUSTL(hes_filename))//">" + END IF + CALL open_file(file_name=TRIM(hes_filename), file_status="OLD", & file_form="UNFORMATTED", file_action="READ", unit_number=hesunit_read) + IF (output_unit > 0) THEN + WRITE (UNIT=output_unit, FMT="(T2,A)") & + "BFGS| Hessian restart file read" + END IF END IF CALL cp_fm_read_unformatted(hess_mat, hesunit_read) IF (ionode) CALL close_file(unit_number=hesunit_read)