Page suivante Page précédente - Table des matières

6. Code Source

6.1 sum.c

/* Jacek Radajewski jacek@usq.edu.au */
/* 21/08/1998 */
#include <stdio.h>
#include <math.h>
int main (void) {
 double result = 0.0;
 double number = 0.0;
 char string[80];
 while (scanf("%s", string) != EOF) {
 number = atof(string);
 result = result + number;
 }
 printf("%lf\n", result);
 return 0;
}

6.2 sigmasqrt.c

/* Jacek Radajewski jacek@usq.edu.au */
/* 21/08/1998 */
#include <stdio.h>
#include <math.h>
int main (int argc, char** argv) {
 long number1, number2, counter;
 double result;
 if (argc < 3) {
 printf ("usage : %s number1 number2\n",argv[0]);
 exit(1);
 } else {
 number1 = atol (argv[1]);
 number2 = atol (argv[2]);
 result = 0.0;
 }
 for (counter = number1; counter <= number2; counter++) {
 result = result + sqrt((double)counter);
 }
 printf("%lf\n", result);
 return 0;
}

6.3 prun.sh

#!/bin/bash
# Jacek Radajewski jacek@usq.edu.au
# 21/08/1998
export SIGMASQRT=/home/staff/jacek/beowulf/HOWTO/example1/sigmasqrt
# $OUTPUT doit être un canal nommé (named pipe)
# mkfifo output
export OUTPUT=/home/staff/jacek/beowulf/HOWTO/example1/output
rsh scilab01 $SIGMASQRT         1  50000000> $OUTPUT < /dev/null&
rsh scilab02 $SIGMASQRT  50000001 100000000> $OUTPUT < /dev/null&
rsh scilab03 $SIGMASQRT 100000001 150000000> $OUTPUT < /dev/null&
rsh scilab04 $SIGMASQRT 150000001 200000000> $OUTPUT < /dev/null&
rsh scilab05 $SIGMASQRT 200000001 250000000> $OUTPUT < /dev/null&
rsh scilab06 $SIGMASQRT 250000001 300000000> $OUTPUT < /dev/null&
rsh scilab07 $SIGMASQRT 300000001 350000000> $OUTPUT < /dev/null&
rsh scilab08 $SIGMASQRT 350000001 400000000> $OUTPUT < /dev/null&
rsh scilab09 $SIGMASQRT 400000001 450000000> $OUTPUT < /dev/null&
rsh scilab10 $SIGMASQRT 450000001 500000000> $OUTPUT < /dev/null&
rsh scilab11 $SIGMASQRT 500000001 550000000> $OUTPUT < /dev/null&
rsh scilab12 $SIGMASQRT 550000001 600000000> $OUTPUT < /dev/null&
rsh scilab13 $SIGMASQRT 600000001 650000000> $OUTPUT < /dev/null&
rsh scilab14 $SIGMASQRT 650000001 700000000> $OUTPUT < /dev/null&
rsh scilab15 $SIGMASQRT 700000001 750000000> $OUTPUT < /dev/null&
rsh scilab16 $SIGMASQRT 750000001 800000000> $OUTPUT < /dev/null&
rsh scilab17 $SIGMASQRT 800000001 850000000> $OUTPUT < /dev/null&
rsh scilab18 $SIGMASQRT 850000001 900000000> $OUTPUT < /dev/null&
rsh scilab19 $SIGMASQRT 900000001 950000000> $OUTPUT < /dev/null&
rsh scilab20 $SIGMASQRT 950000001 1000000000> $OUTPUT < /dev/null&


Page suivante Page précédente - Table des matières