File: callsci.f

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 (81 lines) | stat: -rw-r--r-- 2,529 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
77
78
79
80
81
      program callsci
c!Purpose
c     Example of calling scilab from an other C or Fortran program
c!Description
c     This program demonstrate on a simple example to use scilab as a 
c     procedure for an other program
c     The computations performed are:
c      -1-  computation of x such that a*x=b  (a and b real matrices)
c      -2-  computation of y=a*x-b
c     All scilab functions and instructions may be used in this context
c     for complex instruction, it may be usefull to defined it in a file 
c     and use exec
c!
c     Copyright INRIA
c
      dimension a(2,2),b(2),x(2),y(2)
      double precision a,b,x,y
c
c     a and b definition
c
      a(1,1)=1.d0
      a(2,1)=2.d0
      a(1,2)=3.d0
      a(2,2)=4.d0
      b(1)=1.d0
      b(2)=0.d0
c
c     first call to inisci for Scilab initializations 
c     10000 is the initial stack size
c
      call inisci(-1,10000, ierr)
      if(ierr.gt.0) stop
c
c     scilab start-up execution. quit added to leave parser after 
c     start-up execution
c
      call scirun('exec(''SCI/scilab.star'',-1);quit')
c     
c     Program's variables  a and b sent to Scilab.
c     .  2nd argument of matz not referenced here.
c     .  3rd argument is the first dimension of the transmitted 
c     .  variable (here dimension a(2,.) )
c     .  arguments #3 and 4 represent the number of rows and columns
c     .  respectively
c     .  argument #5 is a character string name of the scilab variable
c     .  argument #6 (here job=1) means direction fortran--->scilab
c     
      call matz(a,a,2,2,2,'a',1)
      call matz(b,b,2,2,1,'b',1)
c     
c     call scirun to solve the problem
c     . \\ needed to enter a \ in fortran string
c
      call scirun('x=a\\b;quit')
c
c     Scilab variable x get in program and displayed
c     .  the numbers m and n (dimensions of x) are here given
c     .  by scilab .Don't give numerical values to arguments
c     .  4 and 5 of matz here.
c     .  last argument (job=0) means:   scilab --->program

      call matz(x,x,2,m,n,'x',0)
      write(6,100) x(1),x(2)
 100  format('x = [',2x,f10.5,2x,f10.5,']')
c
c     call scilab to check the result
c     .  note  -1- a,x,b are still in the scilab stack
c     .        -2- this computation might be done in the first call to scirun 
      call scirun('y=a*x-b;quit')
c
c     Scilab variable y get in program and displayed
c
      call matz(y,y,2,m,n,'y',0)
      write(6,110) y(1),y(2)
110   format('a*x-b = [',2x,f10.5,2x,f10.5,']')
c
c     stop properly
c
      call sciquit
      stop
      end