feat: 外部引擎实时进度条 + C引擎read_bonds rewind修复

1. 引擎端:C/C++/Fortran 主循环每 1% 输出 progress 到 stdout
2. compute.py:读取 "[xxx] progress: N/total" 行更新 tqdm
3. 移除不准的时间估算逻辑,改用真实引擎进度
4. C引擎 read_bonds:rewind 后补 fgets 跳表头
5. gitignore 添加 output_test/
This commit is contained in:
2026-06-11 21:36:30 +08:00
parent 42c6776eff
commit db50ac6d4d
5 changed files with 27 additions and 5 deletions
+9 -3
View File
@@ -10,6 +10,7 @@ compute.py
"""
import json
import re
import numpy as np
import os
import platform
@@ -760,6 +761,14 @@ def run_engine(engine, input_dir, output_dir, config):
_line = _line.strip()
if _line:
_engine_lines.append(_line)
# 读取外部引擎真实进度:格式 "[xxx-engine] progress: N/total"
_prog_match = re.search(r'progress:\s*(\d+)/(\d+)', _line)
if _pbar is not None and _prog_match:
_prog_done = int(_prog_match.group(1))
_prog_total = int(_prog_match.group(2))
if _prog_total > 0:
_pbar.n = min(_prog_done, total_steps)
_pbar.refresh()
if _p.poll() is not None:
if _p.stdout:
for _r in _p.stdout:
@@ -767,9 +776,6 @@ def run_engine(engine, input_dir, output_dir, config):
if _r:
_engine_lines.append(_r)
break
if _pbar is not None and _est_total > 0:
_pbar.n = int(min((time.time() - t_start) / _est_total, 0.99) * total_steps)
_pbar.refresh()
time.sleep(0.2)
finally:
if _pbar is not None: