SMASH dependency sources are not bundled in this directory.

The legacy SMASH2 transformation script modify_smash.sh is retained for
separately obtained SMASH 2.2.0 source. It modifies its argument directory
in place; first copy the original source into a separate working directory.
For example, from the repository root:

  cp -R /absolute/path/to/smash-2.2.0 /absolute/path/to/smash-2.2.0-pimd
  bash lib/smash/modify_smash.sh /absolute/path/to/smash-2.2.0-pimd

Select sed or gsed in the script as appropriate for the platform. The legacy
makefiles require SMASHDIR to point to that patched directory, for example:

  make -C source SMASH=-Dsmash SMASHDIR=/absolute/path/to/smash-2.2.0-pimd

Compiler, MPI and math-library settings must still match the legacy build.
The separate periodic 2.2.0 implementation is not included or downloaded.
The SMASH2 input selector and legacy PIMD adapters remain available only
as expert/developer source options. Use native engine input: pimd-prep no
longer exposes or prepares SMASH2 calculations.

SMASH 3.0.2 CMake embedded build:

Configure CMake with -DSMASH_EMBEDDED=ON -DOPENMP=ON from the repository
root. CMake downloads the pinned public
cmsi/smash 3.0.2 revision during configuration, compiles separate serial and
MPI SMASH libraries, and links them into the matching PIMD executables.
Select this library with <ipotential> SMASH in input.dat.
To retain the legacy 2.2.0 library, change its input selection from SMASH
to SMASH2; filenames and smash_options/smash_* input tags are unchanged.
The older SMASH2 selection remains available for the 2.2.0 makefile interface or an external
SMASH command. The SMASH serial and MPI force drivers contain their own
adapter code; there is no separate adapter source file.
The MPI PIMD path passes each force group's communicator into SMASH, so all
force-group ranks participate in each assigned bead calculation. PIMD owns
MPI initialization and finalization. CMake also builds a standalone SMASH
executable for reference calculations. Downloads, patches, module files, and
build products stay in the build directory selected with CMake's -B option.

For example:

  cmake -S . -B build/smash-3.0.2-embedded -DBUILD_TESTING=ON -DOPENMP=ON -DSMASH_EMBEDDED=ON
  cmake --build build/smash-3.0.2-embedded --target pimd.x pimd.mpi.x --parallel 4
  ctest --test-dir build/smash-3.0.2-embedded -R '^smash-embedded' --output-on-failure

CMake copies the pinned upstream sources into the build tree before
applying lib/smash/smash-3.0.2.patch. This explicit patch contains the
GNU Fortran timing-format fix, printed energy/gradient precision changes,
MPI communicator ownership, and the in-memory full-system/QM/MM interface.
It targets upstream commit 602ed4055ccafc2ccafe11c7d5895f25026b97da.
A changed patch or upstream source refreshes the build-tree copy on configure;
reconfiguring unchanged inputs does not reapply the patch. The patch utility
is required, and a source mismatch stops configuration. The build-tree MPI
patch preserves PIMD's communicator instead of calling MPI_Init inside SMASH.
The source checkout is not modified. An ordinary PIMD configuration with
SMASH_EMBEDDED=OFF does not download SMASH.

The embedded 3.0.2 path requires a <smash_options> block in input.dat,
using the same geometry-free form as the older internal interface:

  <smash_options>
  job method=hf basis=sto-3g memory=256mb
  control print=minimum precision=high
  scf dconv=1e-11

The block ends at the next PIMD tag or end of file. Geometry and atomic
identities come from PIMD. Missing or empty blocks are errors.
There is no separate electronic-settings file or input_default.dat fallback
for this block. TOML users can use [smash.job], [smash.control], and [smash.scf].
SMASH 3 settings must use 3.0.2 syntax (for example, control print=minimum
rather than the older iprint option). This restores input placement, without
translating version-specific SMASH directives.
The control directive is optional: PIMD always supplies bohr units and a
per-bead checkpoint. Directives longer than 80 characters are preserved.
SMASH 3.0.2's native record limit is 256 characters, including controls
appended by PIMD. Longer records fail explicitly rather than being truncated.
The library runs inside each PIMD process.
It creates one shared input.smash with atom identities and dummy coordinates,
then passes current coordinates and receives energies and gradients directly
in memory for each force call.
The checkpoint filename is supplied separately on each call. Checkpoint files
and diagnostic SMASH output remain separate per bead on disk. MPI rank zero
writes the shared input once; all ranks synchronize before reading it.
It does not run a shell command. SMASH requires a larger stack than the
common 8 MiB default: an insufficient stack can cause a segmentation fault
when calculating HF gradients, including with Intel ifx. Before launching
PIMD, set the stack limit in the same shell or batch job script:

  ulimit -s unlimited       # Linux, within the job's permitted hard limit

On macOS, use ulimit -s 65520 instead (approximately 64 MiB). The command
ulimit -s reports the current limit in KiB; 8192 is only 8 MiB. Increasing
SMASH's memory= setting does not increase this stack limit.

The maintained SMASH example run.sh files export OMP_NUM_THREADS=1.
For manually configured multi-threaded runs, OpenMP worker stacks are
separate from the main stack; configure OMP_STACKSIZE as needed as well.
Periodic input is rejected. The older -Dsmash path and modify_smash.sh target
separately supplied 2.2.0 source and retain the smash_options input form.
SMASH QM/MM supports isolated electronic (EE) and mechanical (ME)
embedding with serial or ordinary MPI PIMD. Select <ipotential> QMMM,
<qmmm_potential> SMASH, and <qmmm_embedding> EE or ME. Supply the usual
CFF input.lammps/data.lammps/parameter files and QM/MM region/link labels
in structure.dat. Supply electronic settings in <smash_options> without
geometry, for example:

  <smash_options>
  job method=hf basis=sto-3g memory=256mb
  control precision=high
  scf dconv=1e-11

PIMD supplies the QM/MM site geometry, forces GRADIENT and bohr coordinates,
generates one shared input.qmmm.smash, and passes separate
check.qmmm.<bead>.smash checkpoint filenames through the memory interface.

EE passes real QM atoms, MM BQ sites, and link atoms. MM charges come from
PIMD's CFF state on every call, including its LAMMPS-to-CFF charge scaling.
SMASH supplies the full BQ-BQ Coulomb energy/gradient; PIMD applies bonded
MM charge exclusions, matching the older interface. ME passes only primary
and link atoms. Link gradients are distributed to both real endpoints.
Energies, gradients, and SCF dipoles use atomic units. The MM charge dipole
is counted once. Only force-group leaders contribute before the global
QM/MM reduction, while all workers participate inside SMASH.

For full-system HF/DFT calculations, <smash_dip>=1 (default) returns the
SCF dipole to PIMD in atomic units; 0 disables its PIMD contribution. This
works with both <smash_grad>=1 and energy-only calls. For dynamics,
<iprint_dip> controls dipole.out output. MP2 dipoles are unsupported: use <smash_dip>=0 for MP2.
QM/MM obtains its dipoles independently of <smash_dip>.

<smash_guess> selects PREVIOUS (default) to reuse each bead's checkpoint
once available, or DEFAULT to use the native SMASH guess on every force
call, for both full-system and QM/MM calculations. The native default is
extended Huckel; control guess in <smash_options> can override it
(including an explicit guess=check). TOML uses guess under [smash].

Periodic SMASH QM/MM and XMPI are explicitly unsupported. The old 2.2.0
-Dpbc interface refers to separate periodic SMASH sources, which are not
bundled here; that implementation is not supplied by this patch.
Run ctest --test-dir <build> -R '^smash-' --output-on-failure for the real
full-system and QM/MM numerical tests. See tests/external/SMASH/README.md.

Requirements: Git, CMake 3.20+, C/C++/Fortran compilers, compatible MPI and
OpenMP runtimes, BLAS, and LAPACK. Set FC, CC, and CXX before the first
CMake configuration to choose compilers. Set -DBLAS_LIBRARIES and
-DLAPACK_LIBRARIES to absolute library paths when CMake's automatic
selection is unsuitable. Use cmake --build ... --parallel N to choose
build parallelism.

Upstream source: https://github.com/cmsi/smash
