使用 for 循环通过 cat EOF 命令传递变量

使用 for 循环通过 cat EOF 命令传递变量

如何使用 sbatch 命令运行脚本以与 23 个单独的 run_prep_chem_$dd.sh(即 run_prep_chem_08.sh...run_prep_chem_30.sh)一起运行?我想既然它在这个 for 循环中,它就会正常运行。 sbatch 上面的代码循环了 23 次,但 at sbatch 脚本行没有

#!/bin/bash

RP_INPUT='$RP_INPUT'
END='$END'

for dd in {08..30}; do

set dd=$dd

printf  "%-3s %02d\n" "$dd" "$((10#$dd + 1))"

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp << __EOF
$RP_INPUT

!---------------- grid_type of the grid output
   grid_type= 'mercator',
                        !'rams' = rams grid
                        ! 'polar'  = polar sterog. grid output
                        ! 'gg'  = gaussian grid output
                        ! 'll'  = lat/lon grid output
                        ! 'lambert'  = lambert grid output
                        ! 'mercator' = mercator grid output

!---------------- if the output data is for use in CATT-BRAMS model, provide at least one analysis file

$END

__EOF

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources.inp

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh << BEOF
#!/bin/bash -x
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=100000
#SBATCH --cpus-per-task=1
#SBATCH --time=00:30:00
export I_MPI_JOB_STARTUP_TIMEOUT=10000

source /etc/bashrc

module load hdf5/1.8.12

srun --distribution=block:block /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources_RADM_WRF_FIM.exe

BEOF

chmod 757 /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh

mv /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh  /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

sbatch --dependency=afterok:$SLURM_JOB_ID /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin /data/users/jwsmith/WRFV3/run/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin

done

相关内容