Fortran language scalar function (remote mode)

Code

The code to run in remote mode is the same as the code for local mode. See Fortran Language Scalar Function.

Compilation

Use the standard compile, as in local mode:

$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language fortran --version 3 \
     --template compile --exe applyopFortran applyop.f

Registration

Registration is slightly different:

$NZ_EXPORT_DIR/ae/utilities/bin/register_ae --language fortran --version 3 \
     --template udf --exe applyopFortran \
     --sig "remote_applyop(varchar(1), int4, int4)" --return int4 --remote \
     --rname applyOpRemote

In addition, a launcher is registered:

$NZ_EXPORT_DIR/ae/utilities/bin/register_ae --language fortran --version 3 \
     --exe applyopFortran --sig "launch_remote_applyop(int8)" \
     --return "TABLE(aeresult varchar(255))" --template udtf --remote \
     --launch --rname applyOpRemote

With the exception of the --rname, --exe and the name portion of --sig, all launchers look like the above. In this case it is a UDTF since that is the interface for all launchers. The --rname must match the name in the code (if specified).

Running

To run the AE in remote mode, the executable is run as a “server.” In this instance it handles only queries run on the host. Usually, AEs are started on the SPUs as well. Internally, after the server AE gets a request from the NPS system, it "forks" before it calls nzaeHandleRequest(). Start the executable running on the host using the launch command from nzsql:

SELECT * FROM TABLE WITH FINAL(launch_remote_applyop(0));
AERESULT
-------------------------------------------------------------------------------
tran: 7192 DATA slc: 0 hardware: 0 machine: spubox1 process: 8306 thread: 8306
(1 row)

Running ps -aef | grep applyOpFortran shows that the executable is running on the host. Now run the AE:

SELECT remote_applyop('*', 2, 13);
 REMOTE_APPLYOP
----------------
            26