Ejemplo n.º 1
0
void grace_start() {
    //defaults write com.apple.x11 wm_ffm true
    GraceRegisterErrorFunction(grace_error_function);

    /* Start Grace with a buffer size of 20480 and open the pipe */
    if (GraceOpenVA("gracebat",20480,"-nosafe","-noask",NULL) == -1) {
        fprintf(stderr, "Can't run Grace. \n");
        exit(EXIT_FAILURE);
    }
    grace_started = true;
    atexit(grace_stop);   // ensure that we stop grace when exiting from the main program
}
Ejemplo n.º 2
0
static int openXMGrace(cvodeData_t *data)
{
  double maxY;

  /* Open XMGrace */
  if ( !GraceIsOpen() ) {     
    GraceRegisterErrorFunction(grace_error); 
    /* Start Grace with a buffer size of 2048 and open the pipe */
    if ( GraceOpen(2048) == -1 ) {
      fprintf(stderr, "Can't run Grace. \n");
      return 1;
    }
    else if ( GraceIsOpen() ) {
      maxY = 1.0;
      /*
	"with g%d" might become useful, when printing multiple
	graphs into one XMGrace subprocess.
      */
      /* GracePrintf("with g%d", data->results->xmgrace); */
      GracePrintf("world xmax %g", data->currenttime);
      GracePrintf("world ymax %g", 1.25*maxY);
      GracePrintf("xaxis tick major %g", data->currenttime/10);
      /* GracePrintf("xaxis tick minor %d", (int) data->currenttime/100); */
      GracePrintf("yaxis tick major %g", (1.25*maxY)/12.5 );
      GracePrintf("xaxis label font 4");
      GracePrintf("xaxis label \"time\"");
      GracePrintf("xaxis ticklabel font 4");
      GracePrintf("xaxis ticklabel char size 0.7");
      GracePrintf("yaxis label font 4");
      GracePrintf("yaxis label \"concentration\"");    
      GracePrintf("yaxis ticklabel font 4");
      GracePrintf("yaxis ticklabel char size 0.7");
      if ( Model_isSetName(data->model->simple) )
	GracePrintf("subtitle \"%s\"", Model_getName(data->model->simple));
      else if  ( Model_isSetId(data->model->simple) )
	GracePrintf("subtitle \"%s\"", Model_getId(data->model->simple));
      else 
	GracePrintf("subtitle \"model has no name/id\"");
      GracePrintf("subtitle font 8");   
    }
  }
  else {
    fprintf(stderr, "Please close XMGrace first.\n");
    return 1;
  }

  return 0;
}