Skip to content

Commit

Permalink
Add setup_machparams.csh to compute batch/launch machine parameters
Browse files Browse the repository at this point in the history
Update cice.batch.csh and cice.launch.csh to use setup_machparams.csh
See #650
  • Loading branch information
apcraig committed Aug 8, 2022
1 parent 3b0d98d commit 6abb59b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 65 deletions.
54 changes: 1 addition & 53 deletions configuration/scripts/cice.batch.csh
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,7 @@ endif

set jobfile = $1

set ntasks = ${ICE_NTASKS}
set nthrds = ${ICE_NTHRDS}
set maxtpn = ${ICE_MACHINE_TPNODE}
set acct = ${ICE_ACCOUNT}

@ ncores = ${ntasks} * ${nthrds}
@ taskpernode = ${maxtpn} / $nthrds
if (${taskpernode} == 0) set taskpernode = 1
@ nnodes = ${ntasks} / ${taskpernode}
if (${nnodes} * ${taskpernode} < ${ntasks}) @ nnodes = $nnodes + 1
set taskpernodelimit = ${taskpernode}
if (${taskpernodelimit} > ${ntasks}) set taskpernodelimit = ${ntasks}
@ corespernode = ${taskpernodelimit} * ${nthrds}

set ptile = $taskpernode
if ($ptile > ${maxtpn} / 2) @ ptile = ${maxtpn} / 2

set runlength = ${ICE_RUNLENGTH}
if ($?ICE_MACHINE_MAXRUNLENGTH) then
if (${runlength} > ${ICE_MACHINE_MAXRUNLENGTH}) then
set runlength = ${ICE_MACHINE_MAXRUNLENGTH}
endif
endif

set memuse = ${ICE_MEMUSE}
if ($?ICE_MACHINE_MAXMEMUSE) then
if (${memuse} > ${ICE_MACHINE_MAXMEMUSE}) then
set memuse = ${ICE_MACHINE_MAXMEMUSE}
endif
endif

set queue = "${ICE_QUEUE}"
set batchtime = "00:15:00"
if (${runlength} == 0) set batchtime = "00:29:00"
if (${runlength} == 1) set batchtime = "00:59:00"
if (${runlength} == 2) set batchtime = "2:00:00"
if (${runlength} == 3) set batchtime = "3:00:00"
if (${runlength} == 4) set batchtime = "4:00:00"
if (${runlength} == 5) set batchtime = "5:00:00"
if (${runlength} == 6) set batchtime = "6:00:00"
if (${runlength} == 7) set batchtime = "7:00:00"
if (${runlength} >= 8) set batchtime = "8:00:00"
set batchmem = "5"
if (${memuse} == 1) set batchmem = "5"
if (${memuse} == 2) set batchmem = "10"
if (${memuse} == 3) set batchmem = "15"
if (${memuse} == 4) set batchmem = "20"
if (${memuse} == 5) set batchmem = "50"
if (${memuse} == 6) set batchmem = "100"
if (${memuse} == 7) set batchmem = "150"
if (${memuse} >= 8) set batchmem = "200"

set shortcase = `echo ${ICE_CASENAME} | cut -c1-15`
source ${ICE_SCRIPTS}/setup_machparams.csh

#==========================================

Expand Down
13 changes: 1 addition & 12 deletions configuration/scripts/cice.launch.csh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ echo "running cice.launch.csh"

set jobfile = $1

set ntasks = ${ICE_NTASKS}
set nthrds = ${ICE_NTHRDS}
set maxtpn = ${ICE_MACHINE_TPNODE}

@ ncores = ${ntasks} * ${nthrds}
@ taskpernode = ${maxtpn} / $nthrds
if (${taskpernode} == 0) set taskpernode = 1
@ nnodes = ${ntasks} / ${taskpernode}
if (${nnodes} * ${taskpernode} < ${ntasks}) @ nnodes = $nnodes + 1
set taskpernodelimit = ${taskpernode}
if (${taskpernodelimit} > ${ntasks}) set taskpernodelimit = ${ntasks}
@ corespernode = ${taskpernodelimit} * ${nthrds}
source ${ICE_SCRIPTS}/setup_machparams.csh

#==========================================
if (${ICE_MACHINE} =~ cheyenne*) then
Expand Down
64 changes: 64 additions & 0 deletions configuration/scripts/setup_machparams.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/csh -f

# inputs
# mpi tasks
set ntasks = ${ICE_NTASKS}
# threads
set nthrds = ${ICE_NTHRDS}
# max tasks per node
set maxtpn = ${ICE_MACHINE_TPNODE}
# batch charge account
set acct = ${ICE_ACCOUNT}

# compute total cores needed and distribution of cores on nodes
# ncores = total cores needed (tasks * threads)
# taskpernode = number of MPI tasks per node based on size of node and threads
# nodes = number of total nodes needed based on tasks/threads
# taskpernodelimit = max(taskpernode, ntasks), when using less than 1 node
# corespernode = number of cores per node used
@ ncores = ${ntasks} * ${nthrds}
@ taskpernode = ${maxtpn} / $nthrds
if (${taskpernode} == 0) set taskpernode = 1
@ nnodes = ${ntasks} / ${taskpernode}
if (${nnodes} * ${taskpernode} < ${ntasks}) @ nnodes = $nnodes + 1
set taskpernodelimit = ${taskpernode}
if (${taskpernodelimit} > ${ntasks}) set taskpernodelimit = ${ntasks}
@ corespernode = ${taskpernodelimit} * ${nthrds}

set runlength = ${ICE_RUNLENGTH}
if ($?ICE_MACHINE_MAXRUNLENGTH) then
if (${runlength} > ${ICE_MACHINE_MAXRUNLENGTH}) then
set runlength = ${ICE_MACHINE_MAXRUNLENGTH}
endif
endif

set memuse = ${ICE_MEMUSE}
if ($?ICE_MACHINE_MAXMEMUSE) then
if (${memuse} > ${ICE_MACHINE_MAXMEMUSE}) then
set memuse = ${ICE_MACHINE_MAXMEMUSE}
endif
endif

set queue = "${ICE_QUEUE}"
set batchtime = "00:15:00"
if (${runlength} == 0) set batchtime = "00:29:00"
if (${runlength} == 1) set batchtime = "00:59:00"
if (${runlength} == 2) set batchtime = "2:00:00"
if (${runlength} == 3) set batchtime = "3:00:00"
if (${runlength} == 4) set batchtime = "4:00:00"
if (${runlength} == 5) set batchtime = "5:00:00"
if (${runlength} == 6) set batchtime = "6:00:00"
if (${runlength} == 7) set batchtime = "7:00:00"
if (${runlength} >= 8) set batchtime = "8:00:00"
set batchmem = "5"
if (${memuse} == 1) set batchmem = "5"
if (${memuse} == 2) set batchmem = "10"
if (${memuse} == 3) set batchmem = "15"
if (${memuse} == 4) set batchmem = "20"
if (${memuse} == 5) set batchmem = "50"
if (${memuse} == 6) set batchmem = "100"
if (${memuse} == 7) set batchmem = "150"
if (${memuse} >= 8) set batchmem = "200"

set shortcase = `echo ${ICE_CASENAME} | cut -c1-15`

0 comments on commit 6abb59b

Please sign in to comment.