/******************************************************
* LSBLIB -- Examples
*
* bsub -q
* This program is equivalent to using the "bsub -q queue_name" * command
******************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <lsf/lsbatch.h>
#include "combine_arg.h"
/* To use the function "combine_arg" to combine arguments on the command line include its header file "combine_arg.h". */
int main(int argc, char **argv)
{
int i;
struct submit req; /* job specifications */
memset(&req, 0, sizeof(req)); /* initializes req */
struct submitReply reply; /* results of job submission */
int jobId; /* job ID of submitted job */
/* Initialize LSBLIB and get the configuration environment */
if (lsb_init(argv[0]) < 0) {
lsb_perror("simbsub: lsb_init() failed");
exit(-1);
}
/*Check if input is in the right format: "./simbsub COMMAND ARGUMENTS" */
if (argc < 2) {
fprintf(stderr, "Usage: simbsub command\n");
exit(-1);
}
req.options |= SUB_QUEUE;
/* SUB_QUEUE indicates that the job is dispatched to a specific queue. */
req.queue="normal";
/* Queue name is given by user (e.g. "normal")
The queue name has to be valid (check the queue using bqueues) */
req.options2 = 0;
for (i = 0; i < LSF_RLIM_NLIMITS; i++) /* resources limits */
req.rLimits[i] = DEFAULT_RLIMIT;
req.beginTime = 0; /* specific dispatch date and time */
req.termTime = 0; /* specifies job termination deadline */
req.numProcessors = 1; /* initial num of processors needed by a (parallel) job */
req.maxNumProcessors = 1; /*max num of processors required to run the parallel job */
req.command = combine_arg(argc,argv); /* command line of job */
jobId = lsb_submit(&req, &reply); /* submit the job with specifications */
if (jobId < 0) /* if job submission fails, lsb_submit returns -1 */
switch (lsberrno) { /* and sets lsberrno to indicate the error */
case LSBE_QUEUE_USE:
case LSBE_QUEUE_CLOSED:
lsb_perror(reply.queue);
exit(-1);
default:
lsb_perror(NULL);
exit(-1);}
exit(0);
}
/* main */