Skip to content

Commit d04621c

Browse files
committed
Some modification in the cluster
1 parent 9054b64 commit d04621c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Modules/Cluster.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
223223
# Useful if the cluster has a limit for the maximum number of jobs allowed.
224224
self.batch_size = 1000
225225

226+
# This could be a function that generates for each input file additional
227+
# text in the submission file.
228+
# Usefull if you want to copy things in a different directory to run the calculation on the cluster.
229+
self.additional_script_parameters = None
230+
226231

227232
# Allow to setup additional custom extra parameters
228233
self.custom_params = {}
@@ -426,9 +431,11 @@ def batch_submission(self, list_of_structures, calc, indices,
426431
new_mpicmd = self.mpi_cmd.replace("NPROC", str(self.n_cpu))
427432
results = [None] * N_structs
428433
submitted = []
434+
submission_labels = []
429435
for i in range(N_structs):
430436
# Prepare a typical label
431437
lbl = label + "_" + str(indices[i])
438+
submission_labels.append(lbl)
432439

433440
atm = list_of_structures[i].get_ase_atoms()
434441
atm.set_calculator(calc)
@@ -521,10 +528,20 @@ def batch_submission(self, list_of_structures, calc, indices,
521528

522529
# Go to the working directory
523530
submission += "cd " + self.workdir + "\n"
531+
532+
# If any, apply the extra text before and after the calculation
533+
other_input = ""
534+
other_output = ""
535+
if self.additional_script_parameters is not None:
536+
other_input, other_output = self.additional_script_parameters(submission_labels)
537+
538+
submission += other_input
524539

525540
# Use the xargs trick
526541
#submission += "xargs -d " + r"'\n'" + " -L1 -P%d -a %s -- bash -c\n" % (n_togheder,
527542
submission += app_list
543+
544+
submission += other_output
528545

529546
# Copy the submission script
530547
sub_fpath = "%s/%s.sh" % (self.local_workdir, label + "_" + str(indices[0]))

0 commit comments

Comments
 (0)