This directory hosts a toolchain that couples the Gaussian external interface with the xTB program. During a Gaussian calculation, xTB can be invoked on the fly to evaluate energies, gradients, and Hessians. Compared with the original gau_xtb release proposed by Dr. Tian Lu, this version supports running multiple Gaussian+xTB jobs in parallel within the same folder and automatically cleans up the corresponding temporary artifacts, making it suitable for HPC environments and large-scale data generation.
| File | Description |
|---|---|
gau_xtb/ |
Toolbox directory that houses all runtime helpers required by Gaussian’s external interface |
gau_xtb/xtbint |
Core external script called by Gaussian, responsible for job orchestration and file management |
gau_xtb/genxyz / gau_xtb/genxyz.f90 |
Utility that converts Gaussian’s mol.tmp into the mol.xyz format required by xTB |
gau_xtb/extderi / gau_xtb/extderi.f90 |
Extracts energy, gradients, and Hessian data from xTB outputs and writes them back to Gaussian |
*.gjf / *.log |
Sample input and log files |
The executables and the Fortran sources for
genxyzandextderiare both provided and can be recompiled on the target platform if necessary.
- Automatic job prefix detection
- Prefer the
GAUSS_JOBNAMEsupplied by Gaussian. - Fall back to the output file name or the input file name.
- Sanitize the prefix to avoid naming conflicts within the same directory.
- Prefer the
- Isolated working directories: Each invocation creates its own temporary directory (
<prefix>_xtb_XXXXXX) so that all xTB artifacts stay separated. - Result extraction and hand-off:
extdericonverts xTB outputs into the format expected by Gaussian, while the script optionally preserves intermediate files. - Parallel job compatibility: Unique prefixes and dedicated working folders allow multiple Gaussian+xTB jobs to run in parallel under the same path.
- Automatic cleanup: Temporary directories and prefixed intermediates are removed by default to keep the workspace tidy.
- Gaussian invokes
xtbintvia theexternalkeyword. - The script parses the temporary input file (
$2) and extracts atom count, derivative order, charge, and spin multiplicity. - A unique prefix is generated and a temporary working directory is created.
genxyzproducesmol.xyz; xTB is then executed with the proper--grad/--hessoptions according to the derivative level.extderitransforms xTB outputs into the format required by Gaussian and writes them to the file specified by$3.- Intermediate artifacts are either copied back or discarded based on configuration, and the temporary directory is deleted.
The following diagram summarizes the data flow:
Gaussian (external) -> xtbint -> genxyz -> xTB -> extderi -> Gaussian
- Gaussian: Must support the
externalkeyword (Gaussian 09 or later). - xTB: Install the official binaries or build from source; ensure the
xtbexecutable is on thePATH. - bc: Used to compute
uhf = spin - 1. - mktemp: Creates temporary directories (the script falls back to
$$and$RANDOMif unavailable). - Fortran compiler (optional): Required only when recompiling
genxyz.f90orextderi.f90.
- Build or obtain the helpers: Compile
gau_xtb/genxyz.f90andgau_xtb/extderi.f90if your platform requires freshly built executables. - Pick a toolbox directory: Place the
gau_xtbfolder (containingxtbint,genxyz,extderi) under a single location (e.g./opt/gau_xtb). - Expose the folder to Gaussian jobs:
- Option 1 — Add to
PATH: Append/opt/gau_xtb/gau_xtbto your shell profile, e.g.export PATH="/opt/gau_xtb/gau_xtb:$PATH"(Linux) orset -x PATH /opt/gau_xtb/gau_xtb $PATH(csh/tcsh). - Option 2 — Pin with
GAUXTB_HOME: Setexport GAUXTB_HOME=/opt/gau_xtb/gau_xtbin the submission environment; the wrapper uses this variable to locategenxyzandextderieven ifxtbintis symlinked elsewhere.
- Option 1 — Add to
- Grant execute permission: Ensure the three executables are marked executable (
chmod +x gau_xtb/xtbint gau_xtb/genxyz gau_xtb/extderi).
With
gau_xtbonPATHorGAUXTB_HOMEdefined, you no longer need to copy the wrapper files into every Gaussian working directory.
-
Author the Gaussian input: Add
external="xtbint"(or use an absolute/relative path likeexternal="/opt/gau_xtb/gau_xtb/xtbint") to the route section, e.g.%chk=myjob.chk %mem=8GB %nprocshared=1 opt=(nomicro) external='xtbint' My job title 0 1 ... molecular structure ... -
Submit the calculation: Run Gaussian in the directory; the script handles the xTB calls automatically.
-
Inspect the results: Gaussian logs contain energy and gradient data from xTB. Refer to the environment variables section if you need additional intermediate outputs.
| Variable | Default | Description |
|---|---|---|
GAUSS_JOBNAME |
Set by Gaussian | Automatically inferred by the script when absent |
GAUXTB_HOME |
unset | When set, provides the directory containing genxyz and extderi; useful when xtb lives on PATH or behind a symlink |
OMP_NUM_THREADS / MKL_NUM_THREADS |
1 | Controls the thread count for xTB and linked BLAS/LAPACK libraries |
XTB_KEEP_INTERMEDIATE |
0 | Preserve prefixed files (e.g., <prefix>_xtbout, <prefix>_mol.xyz) when set to a non-zero value |
For debugging, temporarily set
XTB_KEEP_INTERMEDIATE=1to check xTB outputs, then revert to save disk space.
- Default behavior: Remove the temporary directory and all
<prefix>_*intermediates under the working path once the job finishes to keep parallel runs tidy. - Retention mode: When
XTB_KEEP_INTERMEDIATEis non-zero, the script copies back the following files if present:mol.xyz,xtbout,gradient,hessian,charges,energy,xtbrestart,wbo,xtbtopo.mol,xtbhess.xyz,g98.out,g98_canmode.out,xtb_normalmodes,vibspectrum. The copied files are all prefixed with<prefix>_.
- xTB did not terminate normally: The script logs “Warning: XTB may not have terminated normally.” Enable
XTB_KEEP_INTERMEDIATE=1and review the preservedxtboutfor details. genxyzorextderilacks execute permission: Runchmod +x genxyz extderi.- Missing
bcormktemp: Install them via the system package manager, e.g.,sudo apt-get install bc. - Prefix conflicts or invalid characters: The script restricts prefixes to alphanumerics, underscores, hyphens, and dots to prevent conflicts.
- 2025-12-04
- Introduced prefix-based temporary directories to allow parallel jobs under the same folder.
- Added automatic cleanup and an optional intermediate file retention mechanism.
- Improved logging to monitor the xTB execution status.
The original scripts were authored by Dr. Tian Lu (credit retained in the comments). If you plan to publish this work, comply with the original licensing terms as well as those of xTB and Gaussian, and acknowledge the sources in your repository.
- Tian Lu, gau_xtb: A Gaussian interface for xtb code, http://sobereva.com/soft/gau_xtb
- Official xTB repository
- Community discussions and examples on Gaussian/xTB coupling
Feel free to open a GitHub issue for feature requests or suggestions.