Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main(int argc, char** argv) {
- if (argc == 1)
- exit(1);
- if (!(argc == 2 || argc == 4 || argc == 6 || argc == 8 || argc == 10))
- exit(2);
- int walltime = 60, nodes = 4, ppn = 2, np = 6;
- int* argp;
- char** argstr;
- for (argstr = argv + 2; *argstr != NULL; ++argstr) {
- if (!strcmp(*argstr, "-walltime"))
- argp = &walltime;
- else if (!strcmp(*argstr, "-nodes"))
- argp = &nodes;
- else if (!strcmp(*argstr, "-ppn"))
- argp = &ppn;
- else if (!strcmp(*argstr, "-np"))
- argp = &np;
- else
- *argp = atoi(*argstr);
- }
- char job_name[100] = "job-";
- strcat(job_name, (argv[1] + 2));
- int len = strlen(job_name);
- job_name[len - 4] = '\0';
- char jobsh_name[100];
- strcpy(jobsh_name, job_name);
- strcat(jobsh_name, ".sh");
- FILE* jobp = fopen(jobsh_name, "w");
- fprintf(jobp, "#!/bin/bash\n\n");
- fprintf(jobp, "#PBS -l walltime=%02d:%02d:%02d,nodes=%d:ppn=%d\n",
- (walltime / 60) / 60, (walltime / 60) % 60, walltime % 60, nodes, ppn);
- fprintf(jobp, "#PBS -N %s\n", job_name);
- fprintf(jobp, "#PBS -q batch\n\n");
- fprintf(jobp, "cd $PBS_O_WORKDIR\n");
- fprintf(jobp, "mpirun --hostfile $PBS_NODEFILE -np %d %s", np, argv[1]);
- return 0;
- }
Add Comment
Please, Sign In to add comment