计算化学公社

标题: 求助算多个中间体能量最小化任务的运行脚本 [打印本页]

作者
Author:
0325-ddd    时间: 2023-11-22 21:12
标题: 求助算多个中间体能量最小化任务的运行脚本
各位老师好!现在我想要跑一下60多个分子的能量最小化,我现在用的服务器系统是Linux系统,因为输入文件有点多,想要有一个一次性输入脚本依次运行这些输入文件的命令,目前尝试了两个命令
第一个是:nohup g09 < input1.gjf | tee output1.out & wait
nohup g09 < input2.gjf | tee output2.out & wait
nohup g09 < input3.gjf | tee output3.out & wait
第二个是:nohup g09 < input4.gjf | tee output4.out &
nohup g09 < input5.gjf | tee output5.out &
nohup g09 < input6.gjf | tee output6.out &
运行的时候发现,第一种命令在一开始产生了3个out文件,但是有两个文件是空的,在运行完第一个文件后就停止了;第二种命令是3个任务同时运行的同时都在产生out文件,这可能不太适合我这么多的分子
请教各位老师,我应该怎么写这个依次运行文件的脚本?下面是我的输入文件
(, 下载次数 Times of downloads: 8)

作者
Author:
sobereva    时间: 2023-11-24 07:05
使用Gaussian时的几个实用脚本和命令
http://sobereva.com/258http://bbs.keinsci.com/thread-190-1-1.html
作者
Author:
Loading0760    时间: 2023-11-24 12:17
我理解一下,你想要的是依次运行这些gjf,假设他们都在一个目录下,可以使用这个脚本。
  1. #!/bin/bash

  2. for i in {1..60}
  3. do
  4.   input_file="input${i}.gjf"
  5.   output_file="output${i}.out"
  6.   g09 < $input_file | tee $output_file
  7. done
复制代码

你需要nohup的话,这个命令我不怎么了解,一种方法是直接把上述的存为.sh。
然后nohup ./runall.sh &
作者
Author:
0325-ddd    时间: 2023-11-26 19:43
Loading0760 发表于 2023-11-24 12:17
我理解一下,你想要的是依次运行这些gjf,假设他们都在一个目录下,可以使用这个脚本。

你需要nohup的话 ...

谢谢,我试过了for 循环可以,下面是我运行的代码,格式为.sh
具体在Linux系统下运行命令是
1:用formdos g16.sh 先转化sh文件
2:赋予文件权限:sudo chmod +x g16.sh
3:按照提示输入密码
4:输入./g16.sh 就可以了
#!/bin/bash

# 定义任务数量
num_tasks=60

# 循环遍历任务列表
for ((i=1; i<=num_tasks; i++)); do
    # 构建任务文件名
    task="test${i}.gjf"

    # 构建命令
    command="g16 < $task > ${task%.gjf}.out"

    # 打印当前任务命令
    echo "Running: $command"

    # 执行任务命令,并在后台运行
    eval $command &

    # 获取当前任务的进程ID
    pid=$!

    # 等待当前任务完成
    wait $pid

    # 检查任务是否成功完成
    if [ $? -eq 0 ]; then
        echo "Task completed successfully."
    else
        echo "Task failed. Exiting."
        exit 1
    fi
done

echo "All tasks completed successfully."

作者
Author:
0325-ddd    时间: 2023-11-26 19:43
sobereva 发表于 2023-11-24 07:05
使用Gaussian时的几个实用脚本和命令
http://sobereva.com/258(http://bbs.keinsci.com/thread-190-1-1.h ...

谢谢老师




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3