Tutorial for Handling Files

This tutorial shows how to pass files to and from a remote host. In the example a tool is developed which allows you to distribute the task of rendering POV files across a NetSolve network. Povray is executed at the servers to render a part of the picture and the parts from all the servers are put together from the client.

The tutorial includes the following steps:

  1. Building and configuring the library

  2. Installing the problem to the NetSolve repository

  3. Rendering a test image via NetSolve

Requirements on each server

Requirements on the client


1. Building and Configuring the Library

  1. At first make sure to have a working copy of PovRay on the server. Either it is already installed or download it and run(configure and make). To test povray try to render a POV file on the server, e.g. (assuming icl.pov in the current directory):
    UNIX> /home/user/povray/src/povray +Iicl.pov +Oicl.png +L/home/user/povray/include

  2. Edit libpovray.c and provide in the first two lines the povray executable If the executable is not in your PATH include the path, and the path to the PovRay include directory (contains all the INC files)

  3. Execute the following steps to build libpovray.a
    UNIX> gcc -c libpovray.c
    UNIX> ar rc libpovray.a libpovray.o

2. Installing the Problem to the NetSolve Repository Use idltopdf to convert povray.idl to povray.pdf. Since the library makes an external call to a programm it can not take advantage of the Hardware/Software server feature of NetSolve (i.e., it cannot be transfered from one server to another). To mark a problem as non-moveable edit the newly created file povray.pdf and add the following line after the @PATH statement:
Then copy the PDF to your $NETSOLVE/problems directory and add the function to the problems list in the file $NETSOLVE_ROOT/server_config. Set NSPOVRAY_LIB to the path where libpovray.a is located and recompile the server with the command
UNIX> make server

3. Rendering a Test Image Via NetSolve

The file nspovray.c demonstrates how to invoke the newly created function povray via NetSolve.

  1. Edit nspovray.c and provide in the first three lines the path to ImageMagick, mpeg_encode, and mmv.

  2. Edit animation.parm and set in the 4th line the path to the programm tgatoppm if it is not in your PATH

  3. Compile nspovray then with the following command:
    UNIX> gcc nspovray.c -o nspovray -I$NETSOLVE_ROOT/include -lnetsolve \


On Solaris you may need to add the following two libraries, -lsocket and -lnsl.

To render an example file you have the following options:

  1. blocking calls: provides exactly the same syntax as calling povray, but use the command nspovray instead; e.g.:
    UNIX> ./nspovray +Iicl.pov +Oicl.png +H400 +W500

  2. non-blocking calls: uses non-blocking calls and is invoked with the option -nonblocking, additionally you can specify with the -n option how many instances (= parallel NetSolve calls) you want to start; e.g.:
    UNIX> ./nspovray +Iicl1.pov +Oicl1.png +H400 +W500 -n2 -nonblocking

  3. task-farming: again as above but use with the option -farming; to produce an animation use for example:
    UNIX> ./nspovray icl_animation.ini -oanimation.mpg -n2 -farming


Be sure to have an agent and at least one instance of the new server running. Also check that the NETSOLVE_AGENT environment variable is set on the client (it should be the same value as the @AGENT: line in server_config in the NETSOLVE_ROOT directory).