File: pvm1.sce

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (76 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
mode(-1)
// Copyright INRIA
mes=x_message(['Start pvm daemon if not already active'
           'ok=pvm_start()'
	   'if ok<>0 then disp(''pvm daemon already active''),end'],..
           ['Ok','Cancel'])
if mes==2 then return, end
ok=pvm_start()       
if ok<>0 then disp('pvm daemon already active'),end;

mes=x_message(['Start another Scilab process under PVM with the following instruction:';
           ' '
	   '[task_id,numt] = pvm_spawn(SCI+''/demos/pvm/script.sce'',1)'
	   ' '
	   'SCI+''/demos/pvm/script.sce'' file is: '
	   '======================================='
	   read(SCI+'/demos/pvm/script.sce',-1,1,'(a)')],..
           ['Ok','Cancel'])
if mes==2 then return, end   

[task_id,numt] = pvm_spawn(SCI+'/demos/pvm/script.sce',1)
if numt<0 then
  x_message(['pvm_spawn aborts to create a new process'])
  return
end
mes=x_message(['Send a simple instruction to the second Scilab process:'
	   ' '
	   'pvm_send(task_id,''disp(''''Hello, please help me to do my work'''')'',0)'  
	   ],['Ok','Cancel'])
       
if mes==2 then
  pvm_kill(task_id);
  return, 
end
       
pvm_send(task_id,'disp(''Hello, please help me to do my work'')',0)
mes=x_message(['Create a matrix A and send it to the second Scilab process:';
	   ' '
	   'A=rand(100,100);'
	   'pvm_send(task_id,A,0);pvm_send(task_id,''A=%var'',0)'],['Ok','Cancel'])
if mes==2 then
  pvm_kill(task_id);
  return, 
end
a=rand(100,100);
pvm_send(task_id,a,0);
pvm_send(task_id,'A=%var',0);
mes=x_message(['Ask second process to compute the eigenvalue of A:'
           ' ';
	   'pvm_send(task_id,''v=spec(A)'',0);'],['Ok','Cancel'])
if mes==2 then
  pvm_kill(task_id);
  return, 
end
pvm_send(task_id,'v=spec(A)',0);
mes=x_message(['Ask second process to send back the eigenvalue of A:'
           ' '
	   'pvm_send(task_id,''pvm_send(pvm_parent(),v,0)'',0);'],['Ok','Cancel'])

if mes==2 then
  pvm_kill(task_id);
  return, 
end
pvm_send(task_id,'pvm_send(pvm_parent(),v,0)',0);
mes=x_message(['Receive the computed eigenvalues:';
           ' ';
	   'v=pvm_recv(task_id,0);disp(v)'],['Ok','Cancel'])
if mes==2 then
  pvm_kill(task_id);
  return, 
end
v=pvm_recv(task_id,0);disp(v)
pvm_send(task_id,'exit',0)
x_message(['Job finished'])
pvm_halt()
//pvm_kill(task_id)