POV-Ray : Newsgroups : povray.unix : Testing distributed rendering script : Re: I'm interrested ;-) Server Time
28 Jul 2024 16:15:48 EDT (-0400)
  Re: I'm interrested ;-)  
From: Warp
Date: 1 Aug 2000 06:46:59
Message: <3986aaa3@news.povray.org>
Nicolas Calimet <pov### [at] freefr> wrote:
: 	What's the main differences between zsh and sh/csh ? Do you
: make use of particular features of this shell I've never heard about ?

  Zsh (and other shells like bash) has many built-in features that makes
many things a lot easier to do. For example math:

% echo $[1+2*3]
7

% let A=1+2*3
% echo $A
7

  You can achieve the same thing in sh using the bc program, but it's more
heavy and takes more resources (you have to start an external program instead
of just calculating it inside the shell itself).

  Here is the script itself. It's not necessary that zsh is your default shell
since the script itself is started with zsh (as long as you have it installed
in /bin/zsh).
  You will probably have to modify the 'POVEXEC=...' line to point at the
correct location, as well as the 'HOSTS=...' line (and 'HOSTCNT' accordingly).

  Some requirements for the script to work:

  - You can login to all the hosts mentioned in the HOSTS line with a simple
    rsh (without prompting a password). This usually works only in a local
    network (ie. you usually can't use this to spread the rendering around
    the world). You can change rsh to ssh if you like, as long as it works
    in the same way.

  - All the hosts see the same file system. Again, this is usually only
    possible in a local network system.

  - The following programs are installed in the system:
    grep, printf, rsh, sed, tail, test (named [), zsh.
    And of course povray itself.

    Most of those are "standard" unix programs (the only one I'm not sure of,
    is printf).


  Example usage (supposing that the script is named 'distribute'):

distribute test.pov 640 480 +a0.1

------8<-------8<---------8<---------8<--------8<----------8<-------8<-----

#!/bin/zsh

POVEXEC=$HOME/povray/xmegapov
ROWSPERHOST=17
HOSTSCNT=8
HOSTS=(sarakerttunen vuoripyy uppometso ukkometso peltokana karimetso preeriakana
nokikana)

### If this is a child process

if [ "$1" = "__SubProc__" ]
then
    echo "### Subprocess at `uname -n` starting rendering. (`uptime | sed
's/^.*average: //'`)"

    PART=$2
    FILE=$3
    WIDTH=$4
    HEIGHT=$5
    shift 5

    let STARTROW=PART*ROWSPERHOST
    while [ $STARTROW -le $HEIGHT ]
    do
	let ENDROW=STARTROW+ROWSPERHOST-1
	echo `uname -n` rendering lines $STARTROW to $ENDROW

	$POVEXEC -i $FILE $* -w$WIDTH -h$HEIGHT +sr$STARTROW +er$ENDROW -d -p -v +ft -o
ImagePart`printf "%05i" $STARTROW` >&/dev/null

	let STARTROW+=ROWSPERHOST*HOSTSCNT
    done

    echo "### `uname -n` done."

    exit
fi

### Else this is the main process

if [ "$3" = "" ]
then
    echo "Usage: $0 <pov-file> <width> <height> [<additional pov options>]"
    exit
fi

PART=0
for HOST in $HOSTS
do
    rsh $HOST "cd `pwd`; $0 __SubProc__ $PART $*" &
    PART=$[PART+1]
done
wait

echo "Joining image parts..."
if [ `echo $1 | grep -c '\.pov$'` = 1 ]
then
    IMAGE=`echo $1 | sed 's/\.pov$/.tga/'`
else
    IMAGE="$1".tga
fi

mv ImagePart00000.tga $IMAGE
for FILE in ImagePart?????.tga
do
    tail +19c $FILE >> $IMAGE
done

rm ImagePart?????.tga

echo "Done."


------8<-------8<---------8<---------8<--------8<----------8<-------8<-----

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.