diff --git a/partition_setting.lua b/partition_setting.lua new file mode 100644 index 0000000..f4e8541 --- /dev/null +++ b/partition_setting.lua @@ -0,0 +1,79 @@ +function partition_setting (job_desc, submit_uid, infinite, seventyfive, parallel, serial) + + local partition = job_desc.partition + local debugmode = scitas_debug (job_desc) + + -- First case: The user has not declared a partition or a reservation + if job_desc.partition == nil and job_desc.reservation == nil then + if debugmode == 1 then + slurm.log_user("partition_setting: first case") + end + -- Second case: The user has required one node (or slurm resolve it) + if job_desc.max_nodes <= 1 then + if debugmode == 1 then + slurm.log_user("partition_setting: second case") + end + -- Third case: The user has required an exclusive node + if job_desc.shared == 1 then + if debugmode == 1 then + slurm.log_user("partition_setting: third case") + end + partition = parallel + else + -- At this point, we have no partition, no reservation, one node not exclusive + -- Check the number of cores + -- Fourth case: The user has required less than 75 % of a node + if job_desc.min_cpus <= seventyfive then + if debugmode == 1 then + slurm.log_user("partition_setting: fourth case") + end + partition = serial + else + -- Fifth case: The user has required more than 75 % of a node not exclusive + if debugmode == 1 then + slurm.log_user("partition_setting: fifth case") + end + partition = parallel + end + end + else + -- Sixth case: The user has required more than one node + if job_desc.max_nodes ~= infinite then + if debugmode == 1 then + slurm.log_user("partition_setting: sixth case") + end + partition = parallel + else + -- Seventh case: The user not required a number of nodes + if debugmode == 1 then + slurm.log_user("partition_setting: seventh case") + end + if job_desc.min_cpus <= seventyfive then + partition = serial + else + partition = parallel + end + end + end + end + + -- Eighth case: The user required less than 75 % of one non exclusive node and + -- has declared the parallel partition outside of a reservation + if job_desc.partition == parallel and + job_desc.max_nodes == 1 and + job_desc.reservation == nil and + job_desc.min_cpus <= seventyfive and + job_desc.shared ~= 0 then + + if debugmode == 1 then + slurm.log_user("partition_setting: eighth case") + end + partition = serial + end + + if debugmode == 1 then + slurm.log_user("partition_setting: setting partition: %s",partition) + end + + return partition +end