next up previous contents
Next: A Production Example Up: Job Examples Previous: Finding Resources   Contents

The argexe example

argexe is a very simple C++ program that displays the number and values of supplied arguments.


The arg.C Code
#include <iostream>
#include <stdlib.h>
int main(int argc, char* argv[])
{
cout << "\narg num = " << argc << "\n";
cout << "prog nam = " << argv[0] << "\n";
if(argc < 2)
{
cout << "No args \n";
}
else
{
for (int i = 1; i <argc; i++)
{
cout << "argv[" << i <<"] = ";
cout << argv[i] << "\n";
}
}
}


When argexe is run interactively, the user types the arguments and the program displays an output of the following type:

$ ./Argexe one two  "a lot"
arg num = 4
prog nam = ./Argexe
argv[1] = one
argv[2] = two
argv[3] = a lot
To run the same program using grid resources, we need a JDL job of the following type.


The argexe JDL
Executable = "argexe";
Arguments="test-grid";
StdOutput = "argexe.out";
StdError = "argexe.err";
InputSandbox = {"argexe"};
OutputSandbox = {"argexe.out", "argexe.err"};
n.b. - JDL declarations must end with semicolon (;)
n.b. - JDL declarations must fit into one single line


When the grid job terminates, the output files collected using dg-job-get-output are argexe.err and argexe.out stored by default in /tmp/ in a subdirectory named according to the job ID as displayed by the dg-job-get-output command.

An important point to note is executable compatibility. Any executable submitted to the grid, if created on a non-grid node, requires a compiler with the same version as the installed in the WNs. If this is not the case, the job fails with an error message of the following type:

$ cat /tmp/125203218527627/argexe.err
./argexe: error in loading shared libraries:
  libstdc++-libc6.2-2.so.3: cannot open shared object file:
  No such file or directory
As usually the UI node supports the same compilers as the WN, it is enough to recompile the code on the UI before grid submission. Otherwise the JDL should specify a CE that supports the executable compiler. N.B. At present grid test are performed in homogeneous environments.
After recompilation on the UI, the jobs performs correctly:
$ ll /tmp/133814229747696
total 4
-rw-r--r--    1 maroney  testbed1        0 Mar 24 14:46 argexe.err
-rw-r--r--    1 maroney  testbed1       53 Mar 24 14:46 argexe.out
$ cat /tmp/133814229747696/argexe.out
arg num = 2
prog nam = ./argexe
argv[1] = test-grid


next up previous contents
Next: A Production Example Up: Job Examples Previous: Finding Resources   Contents
luvisetto 2003-07-25