Skip to content

Commit 2a4cb7a

Browse files
authored
Merge pull request #266 from SouthernMethodistUniversity/update_gaussian_example
Update gaussian example
2 parents c9481e9 + fba7647 commit 2a4cb7a

File tree

4 files changed

+173
-1
lines changed

4 files changed

+173
-1
lines changed

docs/examples/chemistry.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ please [contact us.](about:contact).
1010
You can also submit issues and/or pull requests for updates or additions at
1111
[our github page](https://github.com/SouthernMethodistUniversity/hpc_docs)
1212

13-
- [Amber](amber/index.md)
13+
- [Amber](amber/index.md)
14+
- [Gaussian](gaussian/index.md)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
#SBATCH -J gaussian # job name shown in queue
3+
#SBATCH -o gaussian_%j.out # output file, %j is the job id number
4+
#SBATCH -p dev # request the dev queue
5+
#SBATCH -c 16 # request 16 CPU cores
6+
#SBATCH --mem=1G # Request 1GB of memory
7+
#SBATCH -t 00:01:00 # request 1 minute
8+
#SBATCH -A peruna_project_0001 # example account
9+
10+
# specify the input file
11+
input_file=gaussian_example.cpu
12+
13+
# module purge clears any existing modules so only the modules
14+
# requested will be loaded. This improves reproducibility
15+
module purge
16+
17+
# load gaussian. It is a good practice to include the version
18+
# the default modules without a version may change when software
19+
# is updated
20+
module load gaussian/g16c/zen3
21+
22+
# create a temporary job directory in scratch
23+
# copy the input file and cd into it
24+
# Note: scratch is intended for temporary job storage
25+
# you should move any files you need to keep when the job
26+
# completes and delete unneeded files. Files in $SCRATCH
27+
# are subject to automatic deletion after 60 days.
28+
job_dir=${SCRATCH}/${SLURM_JOB_ID}
29+
mkdir -p ${job_dir}
30+
cp ${input_file} ${job_dir}
31+
cd ${job_dir}
32+
GAUSS_SCRDIR=${job_dir}
33+
34+
# gets requested mem in GB
35+
sleep 5 # to make sure the job info is available
36+
mem=$(sacct -o "ReqMem" --units=G -j ${SLURM_JOB_ID} -n | xargs)
37+
38+
# get the cores assigned to the job
39+
# This is M3 specific, though something similar will work on many systems
40+
cpus=$(cat /sys/fs/cgroup/system.slice/slurmstepd.scope/job_${SLURM_JOB_ID}/cpuset.cpus)
41+
42+
# make sure mem is an int with correct units
43+
mem=${mem%.*}
44+
mem=${mem//[!0-9]/}
45+
mem="${mem}GB"
46+
47+
# this function fills in the cpu and memory information into the
48+
# input file
49+
cpu_mem() {
50+
sed -i -e "/^%CPU/c\%CPU=${1}" ${input_file}
51+
sed -i -e "/^%Mem/c\%Mem=${2}" ${input_file}
52+
}
53+
54+
cpu_mem ${cpus} ${mem}
55+
56+
# run gaussian
57+
g16 < ${input_file}
58+
59+
# clean up temp $SCRATCH directory
60+
# this moves the rwf file from Gaussian to the
61+
# directory you submitted the job from.
62+
# Note, if the job runs out of time, memory, or
63+
# fails in some other way, these commands may not be reached.
64+
65+
# You should make sure you are keeping the files you need
66+
# this is just an example of a plausible workflow.
67+
# For instance, you may want to keep the checkpoint files
68+
mv *.rwf ${SLURM_SUBMIT_DIR}/
69+
cd ${SLURM_SUBMIT_DIR}
70+
rm -rf ${job_dir}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%CPU=
2+
%Mem=
3+
%Chk=gaussian_example_cpu.chk
4+
%rwf=water.rwf
5+
#opt HF/3-21g
6+
7+
! this is a comment, and it is ignored by Gaussian
8+
water molecule energy and geometry optimization
9+
10+
0 1
11+
O 0.000000 0.000000 0.062600
12+
H -0.792701 0.000000 -0.497300
13+
H 0.792701 0.000000 -0.497300
14+
15+
1 2 3
16+
2 1
17+
3 1

docs/examples/gaussian/index.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Gaussian
2+
3+
:::{important}
4+
Access to Gaussian requires permission. Please open a help ticket by emailing
5+
[help@smu.edu with
6+
"[HPC]"](mailto:help@smu.edu?subject=[HPC]%20Gaussian%20Access%20Request)
7+
in the subject line.
8+
:::
9+
10+
**Gaussian** Gaussian series of electronic structure programs, used by chemists, chemical engineers, biochemists, physicists and other scientists worldwide.
11+
12+
**Gaussian homepage**: [gaussian.com/](https://gaussian.com/)
13+
14+
**Official Gaussian Manual**: [gaussian.com/man/](https://gaussian.com/man/)
15+
16+
:::{seealso}
17+
For examples and tips on submitting jobs, see [our SLURM documentation](tutorials:slurm) and [Best Practices for Jobs](tutorials:slurm:best_practices)
18+
19+
For compute resources, see [HPC Queues](about:queues)
20+
:::
21+
22+
<!-- ## Using Gaussian on the SuperPod
23+
24+
Files used in the example are available:
25+
26+
- [on github](https://github.com/SouthernMethodistUniversity/hpc_docs/tree/main/docs/examples/gaussian)
27+
- on the SuperPod at `/hpc/mp/examples/gaussian/`
28+
29+
### Example submission script
30+
31+
The following job script can be submitted using `sbatch gaussian_gpu_example.sbatch`.
32+
33+
```{literalinclude} gaussian_gpu_example.sbatch
34+
---
35+
language: bash
36+
linenos: true
37+
---
38+
``` -->
39+
40+
## Using Gaussian on M3
41+
42+
Files used in the example are available:
43+
44+
- [on github](https://github.com/SouthernMethodistUniversity/hpc_docs/tree/main/docs/examples/gaussian)
45+
- on M3 at `/hpc/m3/examples/gaussian/`
46+
47+
### Example submission script
48+
49+
The following job script can be submitted using `sbatch guassian_cpu_example.sbatch`.
50+
51+
This example will run in about 10 seconds and use less that `1GB` of memory.
52+
In general, more complicated simulations will take much longer and should typically
53+
use more cores and memory. Note, we know this from running the job.
54+
It is always a good idea to review the resources your jobs use
55+
and adjust future jobs to more accurately request resources.
56+
57+
This uses the `dev`
58+
queue which has a 2 hour time limit.
59+
In general, the `dev` queue should only be used for testing code and running interactive
60+
sessions.
61+
Most normal jobs should be submitted to the standard queues such as `standard-s` where
62+
longer runtimes are allowed.
63+
64+
This example also writes output to `$SCRATCH`.
65+
`$SCRATCH` is a high performance file system designed to be used for temporary
66+
job files and data.
67+
After a job has finished running, any data you need to keep should be moved to
68+
a project directory or your $HOME directory.
69+
**Files in `SCRATCH` are subject to a 60 day purge policy where files older than 60 days
70+
may be automatically deleted without warning.**
71+
72+
:::{note}
73+
This job script will not run without modification. In particular, you must change
74+
the account from `peruna_project_0001` to the account name for an allocation you
75+
have access to.
76+
:::
77+
78+
```{literalinclude} gaussian_cpu_example.sbatch
79+
---
80+
language: bash
81+
linenos: true
82+
---
83+
```
84+

0 commit comments

Comments
 (0)