next up previous contents
Next: VO Specific Jobs Up: Job Examples Previous: Compiling and Running a   Contents

Using make

In this example, the executable is created using make. The input files are:

  1. Dotrim.jdl, the jdl for job submission
  2. Makefile, the make file to create the executable
  3. cktrim.f, the Fortran code for the main program
  4. dotrim.sh, the script to compile and run te job
  5. str_trim.c, the C code routine


Job Example using make
Job Submission File Dotrim.jdl
Type = "Job";
JobType = "Normal";
Executable = "/bin/sh";
StdOutput = "cktrim.out";
StdError = "cktrim.err";
InputSandbox = {"dotrim.sh","str_trim.c","cktrim.f","Makefile"};
OutputSandbox = {"cktrim.err","cktrim.out"};
Arguments = "dotrim.sh";
Job Execution Script dotrim.sh
#!/bin/bash
make
./cktrim
rm *.o
Job Output cktrim.out
f77 -c -o cktrim.o cktrim.f
cc -c str_trim.c
f77 -o cktrim cktrim.o str_trim.o
7 lvd.dat
10 8162 12:99
3 x.x
12 1234567890ab
-1


The example script should be improved as follows:

  1. insert date and hostname at start as follows:
    echo "Job-beg-at: `date`"
    echo "Job-WKnode: `hostname -f`"
  2. insert date after each step to keep track of timing
  3. delete all files to avoid spoiling WN disk space
  4. insert date at job end
    echo "Job-end-at: `date`"
All timing, hostname and job monitoring informations should have some identification flag like Job- to enable a fast verification of stdout. The user should try to improve dotrim.sh according to the above suggestions and to insert monitoring commands in every script used for grid processing programs.


Source Code of make Example
Makefile
cktrim : cktrim.o str_trim.o
f77 -o cktrim cktrim.o str_trim.o
str_trim.o : str_trim.c
cc -c str_trim.c
Fortran Main Program cktrim.f
program cktrim
implicit none
character name*12,blk,namel*50,car1*80,car2*80
integer ll,fd,err
name="lvd.dat"
call str_trim(name,ll,len(name))
write(6,*) ll," ",name(1:ll)
name="8162 12:99"
call str_trim(name,ll,len(name))
write(6,*) ll," ",name(1:ll)
name="x.x"
call str_trim(name,ll,len(name))
write(6,*) ll," ",name(1:ll)
name="1234567890ab"
call str_trim(name,ll,len(name))
write(6,*) ll," ",name(1:ll)
name=" "
call str_trim(name,ll,len(name))
write(6,*) ll
call exit
end
C Routine str_trim.c
/* str_trim subroutine to trim blancks and tabs
args : line (in) string to trim
ll (out) trimmed length or -1 for empty string
kk (in) real length of line */
#include <stdio.h>
str_trim__(line, ll, kk)
char *line;
int *ll, *kk;
{
int i;
for(i = (*kk - 1); i >= 0; --i)
{
if (line[i] < 126 && line[i] > 32) { *ll = i + 1; return; }
}
*ll = -1;
}



next up previous contents
Next: VO Specific Jobs Up: Job Examples Previous: Compiling and Running a   Contents
luvisetto 2003-12-17