next up previous contents
Next: Compiling and Running a Up: Job Examples Previous: JOB simple: script and   Contents


Compiling and Running a Job - V1

This example shows how to compile and run a simple C++ program with input taken from stdin using redirection. The files used by the job are:

  1. the source code file conv.C
  2. the executing script conv.sh
  3. the job input file stdin.conv for stdin redirection
  4. the JDL file Conv.Jdl to submit the job to the grid


C++ Code conv.C
#include <iostream.h>
void main()
{
int nn; // declare an integer
cout << "type decimal no. > "; // display prompt
cin >> nn; // read nn from keyboard
cout << "conversion " "is " // concat strings
"(dec-oct-hex): "
<< dec << nn << ' ' // print in decimal
<< oct << nn << ' ' // print in octal
<< hex << nn << '\n'; // print in hexadecimal
cout << char(27) << "[31mred" // change color to red
<< char(27) << "[0m" << endl; // reset to black
}



Execution Script conv.sh
g++ -o convexe conv.C
./convexe < stdin.conv
Input File stdin.conv
5679



Job Submission File Conv.Jdl
Type = "Job";
JobType = "Normal";
Executable = "/bin/sh";
StdOutput = "conv.out";
StdError = "conv.err";
InputSandbox = {"conv.sh","conv.C","stdin.conv"};
OutputSandbox = {"conv.err","conv.out"};
Arguments = "conv.sh";
OutputSandbox file conv.out
type decimal no. > conversion is (dec-oct-hex): 5679 13057 162f
red


As the job is designed for interactive usage, when run in a batch environment, the input prompt is typed on the same line as the output message. On a color VT the red line is typed in red.


next up previous contents
Next: Compiling and Running a Up: Job Examples Previous: JOB simple: script and   Contents
luvisetto 2003-12-17