Programming Example

The VISIT distribution contains a couple of simple examples. The most complex of them is a 3D-Game of Life that can be viewed and controlled by an AVS/Express application.

Here we give just a trivial but complete C program that connects to a visualization, sends and receives a few data items and disconnects again.

#include "visit.h"

int main() {
  int    vcd,ndim,n1,n2,n3,n4,vtype;
  int    intvalue;
  double timestamp;
  double doublearray[3][3][3];
  char   *service = "vserv";
  char   *key     = "demo_passwd";
  char   *strdata = "Test String";

  /*                                                                   */
  /*  open a connection to a server named 'vserv'                      */
  /*                                                                   */
  if( (vcd = visit_connect(service, key, 2, 2, 4, 10)) < 0 ) exit(1);
 
  /*                                                                   */
  /*  send the 3D array doublearray[3][3][3] of 64 bit floats          */
  /*  tag the message with an ID=1 and a timestamp=1.3                 */
  /*                                                                   */
  visit_send_4d(vcd, 1, 1.3, doublearray, VISIT_FLOAT64, 3, 3, 3, 3, 1);
 

  /*                                                                   */
  /*  send the string 'Test String'                                    */
  /*  tag the message with an ID=2 and a timestamp=1.5                 */
  /*                                                                   */
  visit_send_string(vcd, 2, 1.5, strdata, VISIT_STRING, strlen(strdata));
 
  /*                                                                   */
  /*  receive a single 32-bit integer                                  */
  /*  tag the request with ID=9 and timestamp=1.7                      */
  /*                                                                   */
  timestamp = 1.7;
  ndim = n1 = n2 = n3 = n4 = 1;
  vtype = VISIT_INT32;
  visit_recv_4d(vcd, 9, ×tamp, &intvalue, &vtype, &ndim, &n1, &n2, &n3, &n4);

  /*                                                                   */
  /*  disconnect from the visualization                                */
  /*                                                                   */
  visit_disconnect(vcd);
}

The image below is an AVS/Express network that is able to interact with this C program (click on image to get full size).

[visit avs network] [visit avs network]