/******************************************************
* LSBLIB -- Examples
*
* lsb_submit() usage that is equivalent to "bsub" command * with no options
******************************************************/
#include <stdlib.h>
#include <stdio.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);
}
/ * In order to synchronize the job specification in lsb_submit() to the default used by bsub, the following variables are defined. (By default, bsub runs the job in 1 processor with no resource limit.) */
/*Resource limits are initialized to default limits (no limit).*/
for (i = 0; i < LSF_RLIM_NLIMITS; i++)
req.rLimits[i] = DEFAULT_RLIMIT;
/* Initialize the initial number and maximum number of processors needed by a (parallel) job. */
req.numProcessors = 1;
req.maxNumProcessors = 1;
req.options = 0; /* Set options and options2 to 0 */
req.options2 = 0; /* Select no options is selected */
req.beginTime = 0; /* Dispatch job without delay */
req.termTime = 0; /* Use no terminating deadline */
req.command = combine_arg(argc,argv); /* job command line */
printf("-----------------------------------------------\n");
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 */