GFD Dennou Club / Dennou Ruby / Products


RubyDCL

by T. Horinouchi, K. Kuroi, K. Goto, S. Nishizawa and T. Koshiro

RubyDCL is a ruby interface to the scientific graphic library DCL. It supports all the subroutines and functions in DCL on a one-to-one basis.


What's new


Install

You can install ruby-dcl by

   $ gem install ruby-dcl
But to do that requires to install the C version of DCL beforhand.

If you want to have NumRu::DCL use numru-narray (NumRu::NArray, seiya's 64-bit version of NArray), install it in advance and set the environmental variable NARRAY_TYPE as "numru-narray" (if bash, export NARRAY_TYPE=numru-narray). And then install this libray by "gem install ruby-dcl" as described above. Othewise, narray (the original masa's NArray, not Numo::NArray) is used.


Download


Usage

First install this library and "NArray" following the install section.

In your Ruby program, you first need to put the following line to load this library:

        require "numru/dcl"
Now RubyDCL is loaded as a module named NumRu::DCL. All the subroutines and functions in the original DCL are now available as the module functions of NumRu::DCL. Therefore, they are normally used with the prefix NumRu::DCL., i.e., the function gropn is used as
        NumRu::DCL.gropn( iws )
If it is cumbersome to type the prefix each time, you can "include" the module by putting
        include NumRu::DCL
after the "require" statements above. Then it becomes ok to type simply as:
        gropn( iws )
You can instead include the module half way:
        include NumRu
to eliminate only NumRu but retains DCL:
        DCL.gropn( iws )
We recommend either not to include the module at all or to include only NumRu. Then you place the prefix DCL. to all the DCL methods. This would make it easy to find calls to DCL functions in ruby programs, so it will make your program readable.

Calling sequence of the module functions are identical to those of the corresponding functions and subroutines, except that

The second point would need to be clarified further. For example,
      call sgrget(paramname, paramvalue)
in Fortran becomes
      paramvalue = NumRu::DCL.sgrget(paramname)
in ruby (again, the prefix NumRu:: can be omitted if you include NumRu). If there are multiple return arguments in a function, they are packed in an array (of the predefined class Array), so that
      call sgqvpt(vxmin,vxmax,vymin,vymax)
in Fortran becomes
      ary = NumRu::DCL.sgqvpt
and ary becomes an array holding the four elements, vxmin, vxmax, vymin, and vymax. It can also be written as
       vxmin,vxmax,vymin,vymax = NumRu::DCL.sgqvpt
By this vxmin etc are properly set.

A ruby array can contain any objects as elements, so they can be a mixture of, for example, strings and numeric values and other arrays of whatever. Therefore,

      call ueqtlv(tlev1,tlev2,ipat,iton) 
in Fortran is
      ary = NumRu::DCL.ueqtlv(iton) 
or
     tlev1,tlev2,ipat  = NumRu::DCL.ueqtlv(iton) 
in ruby, where tlev1 and tlev2 are Float and itpat is an Integer. The following is an example of third point (array-size arguments are eliminated):
Fortran:
      call usgrph(n, x, y)      ! here x and y are 1D arrays with length==n
Ruby:
      NumRu::DCL.usgrph(x, y)
Note that the Ruby usgrph makes sure that the arrays x and y have the same length. Exception is raised if they differ.


Documentation and Demos


How is the source code of RubyDCL created?

The source code of RubyDCL id created by from a prototype definition of DCL using a ruby program proto2c.rb in the top directory. The prototype definition is in a format specific to this converter -- It is not enough to collect subroutine/function definition from the Fortran code, since we cannot distinguish input, output, in-out, and work space arguments. It is also not possible to get this information from the C version, since it is created automatically from the Fortran library by f2c. As a result, the prototype definition used in this library has to be updated by hand if the original library is updated.


Takeshi Horinouchi ()
GFD Dennou Club:
Copyright (C) GFD Dennou Club, 2000, 2001. All rights reserved.