Skip to content

fix(input): reject missing values for ordinary string parameters - #34

Draft
Stardust0831 wants to merge 1 commit into
review/input-parser-base-20261024from
fix/input-missing-string-values
Draft

Stardust0831 wants to merge 1 commit into
review/input-parser-base-20261024from
fix/input-missing-string-values

Conversation

@Stardust0831

Copy link
Copy Markdown
Owner

Fork review draft based on upstream develop at 89595dd29, independent of #33.

A supplied string parameter with no value, such as a bare stru_file, could reach an unchecked first-token access; at EOF without a newline it could instead be silently ignored. Ordinary string readers now use the shared scalar validation to require exactly one token before reading it. Invalid input reports the parameter, the expected value and the corresponding manual link:

Invalid INPUT parameter 'stru_file': supplied ''. Expected one String.
See https://abacus.deepmodeling.com/en/latest/advanced/input_files/input-main.html#stru-file

The fix applies through read_sync_string, including stru_file, kpoint_file, suffix and dft_functional. It also rejects extra tokens such as stru_file STRU extra, which were previously ignored. Omitted parameters retain their defaults; custom readers that permit empty values or multiple tokens keep their existing grammar. The developer guide describes the shared string contract.

This addresses the missing-value follow-up from upstream #8192, continuing the explicit-input validation work in #7719.

Validation passed: 44 reader/item tests, 30 help tests, three documentation-generator tests, 12 executable input checks, and serial/four-process Si SCF calculations. Coverage includes missing values at EOF, comments, extra tokens, explicit paths, omitted defaults, legal empty values and generated INPUT round trips. The generated reference contains 590 parameters; generated artifacts are not committed.

Build and validation commands

SERIAL_BUILD and MPI_BUILD are Release build directories with MPI disabled/enabled respectively. Both use GCC 13.4, OpenMP enabled, LCAO/ELPA/FLOAT_FFTW disabled, and OMP_NUM_THREADS=1 at runtime. Executables report v3.11.0-beta11.

cmake --build "$SERIAL_BUILD" --target MODULE_IO_input_domain_reader \
  MODULE_IO_read_item_serial MODULE_IO_read_input_serial abacus_pw_omp -j 8
ctest --test-dir "$SERIAL_BUILD" -V \
  -R '^MODULE_IO_(input_domain_reader|read_item_serial|read_input_serial)$'

cmake --build "$MPI_BUILD" --target abacus_pw_para MODULE_IO_input_help_test -j 8
ctest --test-dir "$MPI_BUILD" -V -R '^MODULE_IO_input_help_test$'
python3 -m unittest discover -s docs -p test_generate_input_main.py -v

"$SERIAL_BUILD/abacus_pw_omp" --version
"$SERIAL_BUILD/abacus_pw_omp" -h stru_file
# From each prepared INPUT case directory:
"$SERIAL_BUILD/abacus_pw_omp" --check-input
mpirun -np 4 "$MPI_BUILD/abacus_pw_para"

MPI executable checks use normal execution: successful MPI --check-input has an existing finalization issue recorded in #33. Staged governance and whitespace checks passed. Whole-file quality scores are unchanged from the base (48 for the legacy macro header, 92 for the test file); no new macro, global dependency or include is introduced.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant