Open topic with navigation

TIBCO GridServer® 7.1.0

# The Pi.pds Example

This example works by running an executable that can be built from `[Gridserver SDK dir]\examples\pdriver`. Build and deploy the executable using the supplied script.

A single script, `pi.pds`, runs several tasks, each with a different seed and multiple iterations.

The beginning of `pi.pds` starts the job block by defining the number of tasks and an output directory for the tasks.

    # pi.pds
    #
    # performs a distributed monte carlo pi calculation.
    #
    job pijob
    tasks = 50
    outputdir = "pijob.example.out"
    seed = begin 200 count $tasks step 3
    iterations = 500000

Next, a task block must be written to run the executable. However, the task must run one of two different binaries, depending on the operating system of the Engine. A conditional is used to check the status of the `$DSOS` variable. If it is win32, the `PdriverPiCalc.exe` binary is run, otherwise, `pdriverPicalc` is run from the `$DSOS` resources directory. The program takes two parameters: the seed, and the number of iterations. The standard output and standard error from the program is redirected to the work directory. After each task is completed, the output and error output is copied back to the staging directory.

    task $tasks
        onerror retry
        shell "none"
        if ( $DSOS == "win32" ) then
            execute stdout="$DSWORKDIR/pijob.$DSTASKID.out"
                    stderr="$DSWORKDIR/error.$DSTASKID"
                    "${gridLibraryDirWin}\commands\PdriverPiCalc.exe $seed $iterations"
        else
            execute stdout="$DSWORKDIR/pijob.$DSTASKID.out"
                    stderr="$DSWORKDIR/error.$DSTASKID"
                    "${gridLibraryDirUnix}/$DSOS/commands/PdriverPiCalc $seed $iterations"
        end
        copy "$DSWORKDIR/pijob.$DSTASKID.out" "$DSSTAGEDIR"
        copy "$DSWORKDIR/error.$DSTASKID" "$DSSTAGEDIR"
    end

After the task block has run 50 times, the postjob block is run. It processes the output of each task with a `pi-average-win32.bat` or `pi-average-unix.sh` script.

    postjob
        onerror ignore
        mkdir "$outputdir"
        copy "$DSSTAGEDIR/pijob.*" "$outputdir"
        if ( $DSOS == "win32" ) then
            execute stdout="PIVALUE.OUT"
                    """%DS_SDK_DIR%\examples\pdriver\pi-average-win32.bat"" $outputdir"
        else
            execute stdout="PIVALUE.OUT"
                    "$$DS_SDK_DIR/examples/pdriver/pi-average-unix.sh $outputdir $tasks"
        end
    end
    end job

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO GridServer®

Copyright © 2001-2022. TIBCO Software Inc. All Rights Reserved.