Exemple #1
0
static void writeraw(t_interf ***int1, t_interf ***int2, int tblocks, int xbins, int ybins, char **fnms)
{
    FILE *raw1, *raw2;
    int   i, j, n;

    raw1 = ffopen(fnms[0], "w");
    raw2 = ffopen(fnms[1], "w");
    fprintf(raw1, "#Produced by: %s #\n", command_line());
    fprintf(raw2, "#Produced by: %s #\n", command_line());
    fprintf(raw1, "#Legend: nt nx ny\n#Xbin Ybin Z t\n");
    fprintf(raw2, "#Legend: nt nx ny\n#Xbin Ybin Z t\n");
    fprintf(raw1, "%i %i %i\n", tblocks, xbins, ybins);
    fprintf(raw2, "%i %i %i\n", tblocks, xbins, ybins);
    for (n = 0; n < tblocks; n++)
    {
        for (i = 0; i < xbins; i++)
        {
            for (j = 0; j < ybins; j++)
            {
                fprintf(raw1, "%i  %i  %8.5f  %6.4f\n", i, j, (int1[n][j+ybins*i])->Z, (int1[n][j+ybins*i])->t);
                fprintf(raw2, "%i  %i  %8.5f  %6.4f\n", i, j, (int2[n][j+ybins*i])->Z, (int2[n][j+ybins*i])->t);
            }
        }
    }

    ffclose(raw1);
    ffclose(raw2);
}
Exemple #2
0
int
TAO_Trading_Loader::init (int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Check if -ORBDaemon is specified and if so, daemonize at this moment,
      // -ORBDaemon in the ORB core is faulty, see bugzilla 3335
      TAO_Daemon_Utility::check_for_daemon (argc, argv);

      // Copy command line parameter.
      ACE_Argv_Type_Converter command_line(argc, argv);

      // Initialize the ORB Manager
      this->orb_manager_.init (command_line.get_argc(),
                               command_line.get_TCHAR_argv());

      CORBA::ORB_var orb =
        this->orb_manager_.orb ();

      // Initializes and sets up the Trading Service
      CORBA::Object_var object =
        this->create_object (orb.in (), command_line.get_argc(), command_line.get_TCHAR_argv());

    }
  catch (const CORBA::Exception&)
    {
      //    @@ Should we log this???
      return -1;
    }
  return 0;
}
Exemple #3
0
int
TAO_Naming_Loader::init (int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Copy command line parameter.
      ACE_Argv_Type_Converter command_line(argc, argv);

      // Initialize the ORB
      CORBA::ORB_var orb =
        CORBA::ORB_init (command_line.get_argc(),
                         command_line.get_TCHAR_argv());

      // This function call initializes the Naming Service
      CORBA::Object_var object =
        this->create_object (orb.in (),
                             command_line.get_argc(),
                             command_line.get_TCHAR_argv ());
    }
  catch (const CORBA::Exception&)
    {
      // @@ Should we log this???
      return -1;
    }
  return 0;
}
Exemple #4
0
int wmain(int argc, WCHAR* argv[])
{
	if (argc < 3) {
		std::wcout << argv[0] << " dll command_line\n";
		return 1;
	}
	std::wstring dllToInject (argv[1]);
  std::wstring exe (argv[2]);
  exe = exe.substr (0, exe.find (' '));
  std::wstring command_line (argv[2]);
  command_line = command_line.substr (command_line.find (' ') + 1);
        
  ULONG pid;
	NTSTATUS nt = RhCreateAndInject
    ( const_cast<WCHAR*> (exe.c_str())
    , const_cast<WCHAR*> (command_line.c_str())
    , 0
		, EASYHOOK_INJECT_DEFAULT
		, const_cast<WCHAR*> (dllToInject.c_str())
		, nullptr
		, nullptr
		, 0
    , &pid
	  );

	if (nt != 0)
	{
		std::wcout << "RhCreateAndInject failed with error code = " << nt << "\n  " << RtlGetLastErrorString() << "\n";
		return 1;
	}
  	
	return 0;
}
Exemple #5
0
int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  TAO_CEC_Default_Factory::init_svcs ();

  try
    {
       // Check if -ORBDaemon is specified and if so, daemonize at this moment,
       // -ORBDaemon in the ORB core is faulty, see bugzilla 3335
      TAO_Daemon_Utility::check_for_daemon (argc, argv);

      // Copy command line parameter.
      ACE_Argv_Type_Converter command_line(argc, argv);

      // Intialize the ORB
      CORBA::ORB_var orb =
        CORBA::ORB_init (command_line.get_argc(), command_line.get_TCHAR_argv());

      // Call TAO_CEC_Event_Loader::init (argc, argv) from here.
      TAO_CEC_Event_Loader event_service;

      // To intialise the service
      int const result =
        event_service.init (command_line.get_argc(), command_line.get_TCHAR_argv());

      if (result == -1)
        return 1;

      // @@ Run forever... even after the EC is destroyed...
      //    The "Right Way"[tm] to fix this is to modify
      //    TAO_CEC_EventChannel to get a new option.. If the option is
      //    set then we destroy the ORB on EventChannel::destroy(),
      //    otherwise we don't.
      //    The option will not be set by default, but the user can pass
      //    it in the command line, and in this main program with set it
      //    to 1 by default or something like that...
      //    Don't worry about this change yet... Let's get all the changes
      //    in and then we can fix the EC shutdown problem...
      //
      //    As inidicated above, The Typed EC implementation can now be
      //    destroyed by passing -d at the command line and
      //    calling destroy on the typed EC interface.
      //    Calling fini() completes the destruction, although most of
      //    this is done in TAO_CEC_TypedEventChannel::shutdown().
      orb->run ();

#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
      event_service.fini();
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */

      // Destroy the ORB
      orb->destroy();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (argv[0]);
      return 1;
    }
  return 0;
}
ElectronPhononExchangeHertel::ElectronPhononExchangeHertel(fstream &fileId,
                                                           map<string,double> & parameters,
                                                           Material * material) 
  : ElectronPhononExchange(),
    exchangeCoef_(0),
    debeyeTemperature_(1),
    massEnhancement_(0),
    material_(material)
{
  if (!fileId.is_open()) throw ATC_Error("cannot open material file");
  vector<string> line;
  while(fileId.good()) {
    command_line(fileId, line);
    if (line.size() == 0) continue;
    if (line[0] == "end") break;
    else if (line[0] == "debeye_temperature") {
      debeyeTemperature_ = str2dbl(line[1]);
      parameters["debeye_temperature"] = debeyeTemperature_;
    }
    else if (line[0] == "mass_enhancement") {
      massEnhancement_ = str2dbl(line[1]);
      parameters["mass_enhancement"] = massEnhancement_;
    }
    else {
      throw ATC_Error( "unrecognized material function "+line[0]);
    }
  }
  // coupling coefficient, eqn. 15 of Hertel 2002
  double kb = LammpsInterface::instance()->kBoltzmann();
  double hbar = LammpsInterface::instance()->hbar();
  double PI = 3.141592653589793238; 
  exchangeCoef_ = 144.*1.0369*kb/(PI*hbar);
  exchangeCoef_ *= massEnhancement_/pow(debeyeTemperature_,2);
}
void             key_delete()
{
  char		*s;

  s = command_line(NULL);
  if (s[cursor(-2)])
    shift_left(s + cursor(-2), 1);
}
void		key_right()
{
  char		*s;

  s = command_line(NULL);
  if (s[cursor(-2)])
    cursor(cursor(-2) + 1);
}
Exemple #9
0
/*
** Returns the command
*/
char			*get_next_command(const int fd)
{
  char			buffer[10];
  struct termios	backup_st;
  void			(*func_op)();
  int			r;

  cursor(0);
  command_line(malloc(sizeof(*(command_line(NULL))) * 10));
  command_line(NULL)[0] = 0;
  backup_st = get_next_init(retrieve_vars(NULL));
  display_line(retrieve_vars(NULL));
  func_op = NULL;
  while (func_op != key_enter && (r = read(fd, buffer, 9)))
    {
      buffer[r] = 0;
      func_op = get_input_modif(buffer);
      func_op ? func_op() :
	command_line(insert_string(command_line(NULL), buffer));
      display_line(retrieve_vars(NULL));
    }
  set_conf(backup_st, 0);
  signal(SIGWINCH, SIG_DFL);
  signal(SIGTSTP, SIG_DFL);
  my_putchar('\n');
  test_and_add_bindkey(command_line(NULL));
  return (command_line(NULL));
}
Exemple #10
0
bool process_output( link_data* link )
{
  text_data*      output;
  text_data*        next;
  char_data*          ch  = link->character;
  bool        status_bar;

  if( link->connected == CON_PLAYING && ch == NULL ) {
    bug( "Process_Output: Link playing with null character." );
    bug( "--     Host = '%s'", link->host );
    bug( "-- Rec_Prev = '%s'", link->rec_prev );
    return FALSE;
    }

  status_bar = ( link->connected == CON_PLAYING
    && is_set( ch->pcdata->pfile->flags, PLR_STATUS_BAR )
    && ch->pcdata->terminal != TERM_DUMB );

  if( link->send == NULL && !link->command )
    return TRUE;

  /* SAVE CURSOR */

  if( status_bar ) {
    next       = link->send;
    link->send = NULL;
    scroll_window( ch );
    if( next != NULL )
      send( ch, "\n\r" );
    cat( link->send, next );
    prompt_ansi( link );
    command_line( ch );
    }
  else {
    if( !link->command ) {
      next       = link->send;
      link->send = NULL;
      send( ch, "\n\r" );
      cat( link->send, next );
      }  
    if( link->connected == CON_PLAYING && link->receive == NULL ) 
      prompt_nml( link );
    }

  /* SEND OUTPUT */

  for( ; ( output = link->send ) != NULL; ) {
    if( int( write( link->channel, output->message.text,
      output->message.length ) ) == -1 )
      return FALSE; 
    link->send = output->next;
    delete output;
    }

  return TRUE;
}
Exemple #11
0
int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  try
    {
      // Copy command line parameter.
      ACE_Argv_Type_Converter command_line(argc, argv);

      // Initialize ORB.
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv, "internet");

      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      if (CORBA::is_nil(naming_obj.in ()))
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to find the Naming Service\n"),
                          1);

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow (naming_obj.in ());

      const char *name = "ScheduleService";
      if (command_line.get_argc() > 1)
        {
          name = command_line.get_ASCII_argv()[1];
        }
      ACE_Scheduler_Factory::use_config (naming_context.in (), name);

      RtecScheduler::RT_Info_Set_var infos;
      RtecScheduler::Dependency_Set_var deps;
      RtecScheduler::Config_Info_Set_var configs;
      RtecScheduler::Scheduling_Anomaly_Set_var anomalies;

      ACE_Scheduler_Factory::server ()->compute_scheduling
        (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO,
                                         ACE_SCOPE_THREAD),
         ACE_Sched_Params::priority_max (ACE_SCHED_FIFO,
                                         ACE_SCOPE_THREAD),
         infos.out (), deps.out (), configs.out (), anomalies.out ());

      ACE_Scheduler_Factory::dump_schedule (infos.in (),
                                            deps.in (),
                                            configs.in (),
                                            anomalies.in (),
                                            ACE_TEXT("Scheduler_Runtime.cpp"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Dump_Schedule");
    }

  return 0;
}
void		key_backspace()
{
  char		*s;

  s = command_line(NULL);
  if (cursor(-2))
    {
      shift_left(s + cursor(-2) - 1, 1);
      cursor(cursor(-2) - 1);
    }
}
Exemple #13
0
int main(int argc, const char **argv) {
	command_line(argc,argv);
	draw();
	unsigned int ui;
	XGetGeometry(dpy,win,&root,&wx,&wy,&ww,&wh,&ui,&ui);
	XEvent ev;
	while ( running && !XNextEvent(dpy,&ev) )
		if (handler[ev.type]) handler[ev.type](&ev);
	XDestroyWindow(dpy,win);
	XCloseDisplay(dpy);
	return 0;
}
Exemple #14
0
/*
** Displays a line in the term
*/
void			display_line(t_caps_str *vars)
{
  struct winsize	w;
  int			off;

  w = get_dimensions(-1, -1);
  tputs(vars->cr, 1, my_outc);
  tputs(vars->dl, 1, my_outc);
  off = my_printf("%s%s", PROMPT, command_line(NULL)) - my_strlen(PROMPT);
  while (off-- - cursor(-2) > 0)
    tputs("\b", 1, my_outc);
}
Exemple #15
0
MooseApp *
AppFactory::createApp(std::string app_type, int argc, char ** argv)
{
    MooseSharedPointer<CommandLine> command_line(new CommandLine(argc, argv));
    InputParameters app_params = AppFactory::instance().getValidParams(app_type);

    app_params.set<int>("_argc") = argc;
    app_params.set<char**>("_argv") = argv;
    app_params.set<MooseSharedPointer<CommandLine> >("_command_line") = command_line;

    MooseApp * app = AppFactory::instance().create(app_type, "main", app_params, MPI_COMM_WORLD);
    return app;
}
Exemple #16
0
void interface (gint argc, gchar *argv[])
{
  GtkWidget *MenuBar;
  GtkWidget *VBox;
  GtkWidget *HandleBox;

  gtk_set_locale();  
  gtk_init (&argc, &argv);
  Settings = init_settings ();
  MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(MainWindow), g_strconcat
			(WELCOME_MSG, " ", APP_NAME, " ",
			 VERSION_NUMBER, NULL));
  gtk_window_set_policy (GTK_WINDOW(MainWindow), TRUE, TRUE, FALSE);
  gtk_widget_set_usize (MainWindow, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
  gtk_signal_connect (GTK_OBJECT(MainWindow), "delete_event",
		      (GtkSignalFunc) quit, NULL); 
  gtk_signal_connect (GTK_OBJECT(MainWindow), "destroy",
		      (GtkSignalFunc) quit, NULL);
  FileProperties = g_array_new (TRUE, FALSE, sizeof(t_fprops));
  VBox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER(MainWindow), VBox);
  HandleBox = gtk_handle_box_new();
  gtk_container_set_border_width (GTK_CONTAINER(HandleBox), 2);
  gtk_box_pack_start (GTK_BOX(VBox), HandleBox, FALSE, FALSE, 0);
  init_toolbar (GTK_BOX(VBox));
  MainNotebook = gtk_notebook_new ();
  read_uedit_wordfile (WORDFILE);
  editor_init();
  MenuBar = menubar_new (MainWindow);
  gtk_container_add (GTK_CONTAINER(HandleBox), MenuBar);
  gtk_notebook_popup_enable (GTK_NOTEBOOK(MainNotebook));
  gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_box_pack_start (GTK_BOX(VBox), MainNotebook, TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT(MainNotebook), "switch_page",
		      (GtkSignalFunc) set_title, NULL);
  init_msgbar (GTK_BOX(VBox));
  print_msg ("You're the welcome...");
  command_line (argc, argv);
  autosave (AUTOSAVE_DELAY);
  gtk_widget_show_all (MainWindow);
  if (!MSGBAR_DISPLAY) hide_msgbar ();
  if (!TOOLBAR_DISPLAY) hide_toolbar ();
  gtk_timeout_add (80, (GtkFunction)display_line_column, NULL);
  gtk_main ();
  set_preferences_to_disk (&Settings, NULL);
  gtk_item_factory_dump_rc (g_strconcat (g_get_home_dir (), PATH_SEP_STRING,
					 CONF_DIR, PATH_SEP_STRING,
					 "AccelRC", NULL), NULL, FALSE);
}
Exemple #17
0
void RemoteConsole::reset()
{
	// TODO: check for errors!
	int infp, outfp;
	std::string command_line(_command);
	command_line += " --ccons-use-std-io --ccons-serialized-output";
	if (_DebugMode)
		command_line += " --ccons-debug";
	popen2(command_line.c_str(), &infp, &outfp);
	_ostream = fdopen(infp, "w");
	setlinebuf(_ostream);
	_istream = fdopen(outfp, "r");
	setlinebuf(_istream);
	_prompt = ">>> ";
	_input = "";
}
void CLI_commands_panel::run_command() {
    if( !project_ ) return ;

    // TL modified
    command_edit_->reset();

    QByteArray tmp = command_edit_->text().toLatin1();
    std::string command_line( tmp.trimmed().constData());

    String_Op::string_pair args = String_Op::split_string( command_line, " ", false );
    if( args.first.empty() ) return;   // no command supplied

    Error_messages_handler error_messages;


    //TL modified
    // We do not want commands in the script to go into command history
    if (args.first == "RunScript") {
        // need to save the "runscript ..." line
        GsTLlog << command_line << gstlIO::end;
        /*
        if (!_hs->unsubscribe(GsTLlog)) {
        	appli_message("Unable to detach");
        }
        */
    }


    bool ok = project_->execute( args.first, args.second, &error_messages );
    /*
    if (args.first == "RunScript")
    _hs->subscribe(GsTLlog);
    */

    if( !ok ) {
        GsTLcerr << "Command " << args.first<< " could not be performed: \n";
        if( !error_messages.empty() )
            GsTLcerr << error_messages.errors() << "\n";
        GsTLcerr << gstlIO::end;
        return;
    }

    command_edit_->clear();
}
Exemple #19
0
main()
#endif
{
	FILE			*fp = stdin;	  /* File pointer, default stdin */
	CRITICALS		*tuples;
	int				i;
	int				n;
	CUBE_INFO		*p;

	printf("\ntuples - version %1.2f\n\n", VERSION_NUM);

#ifndef NO_CMD_LINE
	/* Check the command line and open file if required */
	command_line(&fp,argc, argv, &n);
#else
	/* Read command info from standard input */
	command_input(&fp, &n);
#endif

	/* Read in info from the file, setting up Fsa and so on... */
	switch (read_file_info(fp)) {
		case FORMAT_ERROR:
			ERROR(FORMAT);
		case NOT_A_GEN:
			ERROR(GEN_ERR);
	}
	fclose(fp);	/* No more reading required */

	tuples = find_n_criticals(n);
	printf("Number of Critical %d-tuples = %d\n\n", n, tuples->num);

	for (i=0; i < tuples->num; i++) {
		printword(stdout, tuples->info[i]->word);
		printf("\t");
		for (p = tuples->info[i]->vert; p != NULL; p = p->next)
			printf("[%d,%d] ", p->pos, p->len);
		printf("\n");
	}
	/* Clean up */
	delete_criticals(tuples);
	return 0;
}
Exemple #20
0
void xvgr_header(FILE *fp, const char *title, const char *xaxis,
                 const char *yaxis, int exvg_graph_type,
                 const output_env_t oenv)
{
    char   pukestr[100], buf[STRLEN];
    time_t t;

    if (output_env_get_print_xvgr_codes(oenv))
    {
        time(&t);
        gmx_ctime_r(&t, buf, STRLEN);
        fprintf(fp, "# This file was created %s", buf);
        fprintf(fp, "# by the following command:\n# %s\n#\n", command_line());
        fprintf(fp, "# %s is part of G R O M A C S:\n#\n", ShortProgram());
        bromacs(pukestr, 99);
        fprintf(fp, "# %s\n#\n", pukestr);
        fprintf(fp, "@    title \"%s\"\n", xvgrstr(title, oenv, buf, STRLEN));
        fprintf(fp, "@    xaxis  label \"%s\"\n",
                xvgrstr(xaxis, oenv, buf, STRLEN));
        fprintf(fp, "@    yaxis  label \"%s\"\n",
                xvgrstr(yaxis, oenv, buf, STRLEN));
        switch (exvg_graph_type)
        {
            case exvggtXNY:
                if (output_env_get_xvg_format(oenv) == exvgXMGR)
                {
                    fprintf(fp, "@TYPE nxy\n");
                }
                else
                {
                    fprintf(fp, "@TYPE xy\n");
                }
                break;
            case exvggtXYDY:
                fprintf(fp, "@TYPE xydy\n");
                break;
            case exvggtXYDYDY:
                fprintf(fp, "@TYPE xydydy\n");
                break;
        }
    }
}
Exemple #21
0
void print_top_comment(FILE *out,
                       const char *filename,
                       const char *generator,
                       const char *ffdir,
                       gmx_bool bITP)
{
  char tmp[256]; 
  char ffdir_parent[STRLEN];
  char *p;
        
  nice_header(out,filename);
  fprintf(out,";\tThis is a %s topology file\n;\n",bITP ? "include" : "standalone");
  fprintf(out,";\tIt was generated using program:\n;\t%s\n;\n",
          (NULL == generator) ? "unknown" : generator);
  fprintf(out,";\tCommand line was:\n;\t%s\n;\n",command_line());

  if(strchr(ffdir,'/')==NULL)
  {
      fprintf(out,";\tForce field was read from the standard Gromacs share directory.\n;\n\n");
  }
  else if(ffdir[0]=='.')
  {
      fprintf(out,";\tForce field was read from current directory or a relative path - path added.\n;\n\n");
  }
  else
  {
      strncpy(ffdir_parent,ffdir,STRLEN-1);
      p=strrchr(ffdir_parent,'/');

      *p='\0';
      
      fprintf(out,
              ";\tForce field data was read from:\n"
              ";\t%s\n"
              ";\n"
              ";\tNote:\n"
              ";\tThis might be a non-standard force field location. When you use this topology, the\n"
              ";\tforce field must either be present in the current directory, or the location\n"
              ";\tspecified in the GMXLIB path variable or with the 'include' mdp file option.\n;\n\n",
              ffdir_parent);
  }
}
ElectronPhononExchangeLinear::ElectronPhononExchangeLinear(
  fstream &fileId, map<string,double> & parameters) 
  : ElectronPhononExchange(),
  exchangeCoef_(0)
{
  if (!fileId.is_open()) throw ATC_Error("cannot open material file");
  vector<string> line;
  while(fileId.good()) {
    command_line(fileId, line);
    if (line.size() == 0) continue;
    if (line[0] == "end") return;
    else if (line[0] == "coefficient") {
      exchangeCoef_ = str2dbl(line[1]);
      parameters["electron_phonon_exchange_coefficient"] = exchangeCoef_;
    }
    else {
      throw ATC_Error( "unrecognized material function "+line[0]);
    }
  }
}
Exemple #23
0
int
Activity::init (int& argc, ACE_TCHAR *argv [])
{
  // Copy command line parameter.
  ACE_Argv_Type_Converter command_line(argc, argv);

  this->orb_ = CORBA::ORB_init (command_line.get_argc(),
                                command_line.get_TCHAR_argv());

  CORBA::Object_var object =
    orb_->resolve_initial_references ("RootPOA");

  root_poa_ =
    PortableServer::POA::_narrow (object.in ());

  PortableServer::POAManager_var poa_manager =
    root_poa_->the_POAManager ();

  object =
    orb_->resolve_initial_references ("RTORB");

  this->rt_orb_ =
    RTCORBA::RTORB::_narrow (object.in ());

  object =
    orb_->resolve_initial_references ("RTCurrent");

  current_ =
    RTCORBA::Current::_narrow (object.in ());

  poa_manager->activate ();

  object = this->orb_->resolve_initial_references ("PriorityMappingManager");
  RTCORBA::PriorityMappingManager_var mapping_manager =
    RTCORBA::PriorityMappingManager::_narrow (object.in ());

  this->priority_mapping_ = mapping_manager->mapping ();

  return 0;
}
Exemple #24
0
FILE *xvgropen(const char *fn,const char *title,const char *xaxis,const char *yaxis)
{
  FILE *xvgr;
  char pukestr[100];
  time_t t;
  
  xvgr=gmx_fio_fopen(fn,"w");
  if (bPrintXvgrCodes()) {
    time(&t);
    fprintf(xvgr,"# This file was created %s",ctime(&t));
    fprintf(xvgr,"# by the following command:\n# %s\n#\n",command_line());
    fprintf(xvgr,"# %s is part of G R O M A C S:\n#\n",Program());
    bromacs(pukestr,99);
    fprintf(xvgr,"# %s\n#\n",pukestr);
    fprintf(xvgr,"@    title \"%s\"\n",title);
    fprintf(xvgr,"@    xaxis  label \"%s\"\n",xaxis);
    fprintf(xvgr,"@    yaxis  label \"%s\"\n",yaxis);
    if (use_xmgr())
      fprintf(xvgr,"@TYPE nxy\n");
    else
      fprintf(xvgr,"@TYPE xy\n");
  }
  return xvgr;
}
Exemple #25
0
int main(int argc, char** argv)
{

    // +-----------------------------------------------+
    // |            Initialization of MPI              |
    // +-----------------------------------------------+
#ifdef HAVE_MPI
    MPI_Init(&argc, &argv);
#endif

    boost::shared_ptr<Epetra_Comm>   comm;
#ifdef EPETRA_MPI
    comm.reset( new Epetra_MpiComm( MPI_COMM_WORLD ) );
    int nproc;
    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
#else
    comm.reset( new Epetra_SerialComm() );
#endif

    bool verbose(false);
    if (comm->MyPID() == 0)
    {
        verbose = true;
        std::cout
                << " +-----------------------------------------------+" << std::endl
                << " |           Cavity example for LifeV            |" << std::endl
                << " +-----------------------------------------------+" << std::endl
                << std::endl
                << " +-----------------------------------------------+" << std::endl
                << " |           Author: Gwenol Grandperrin          |" << std::endl
                << " |             Date: October 25, 2010            |" << std::endl
                << " +-----------------------------------------------+" << std::endl
                << std::endl;

        std::cout << "[Initilization of MPI]" << std::endl;
#ifdef HAVE_MPI
        std::cout << "Using MPI (" << nproc << " proc.)" << std::endl;
#else
        std::cout << "Using serial version" << std::endl;
#endif
    }

    // Chronometer
    LifeV::LifeChrono globalChrono;
    LifeV::LifeChrono initChrono;
    LifeV::LifeChrono iterChrono;
    globalChrono.start();
    initChrono.start();

    // +-----------------------------------------------+
    // |               Loading the data                |
    // +-----------------------------------------------+
    if (verbose) std::cout << std::endl << "[Loading the data]" << std::endl;
    GetPot command_line(argc,argv);
    const std::string dataFileName = command_line.follow("data", 2, "-f","--file");
    GetPot dataFile(dataFileName);

    // +-----------------------------------------------+
    // |               Loading the mesh                |
    // +-----------------------------------------------+
    if (verbose) std::cout << std::endl << "[Loading the mesh]" << std::endl;
    LifeV::MeshData meshData;
    meshData.setup(dataFile, "fluid/space_discretization");
    if (verbose) std::cout << "Mesh file: " << meshData.meshDir() << meshData.meshFile() << std::endl;
    boost::shared_ptr< mesh_Type > fullMeshPtr(new mesh_Type);
    LifeV::readMesh(*fullMeshPtr, meshData);
    // Split the mesh between processors
    boost::shared_ptr< mesh_Type > localMeshPtr;
    {
        LifeV::MeshPartitioner< mesh_Type >   meshPart(fullMeshPtr, comm);
        localMeshPtr = meshPart.meshPartition();
    }

    // +-----------------------------------------------+
    // |            Creating the FE spaces             |
    // +-----------------------------------------------+
    if (verbose) std::cout << std::endl << "[Creating the FE spaces]" << std::endl;
    std::string uOrder =  dataFile( "fluid/space_discretization/vel_order",   "P2");
    std::string pOrder =  dataFile( "fluid/space_discretization/press_order", "P1");
    if (verbose) std::cout << "FE for the velocity: " << uOrder << std::endl
                               << "FE for the pressure: " << pOrder << std::endl;

    if (verbose) std::cout << "Building the velocity FE space... " << std::flush;
    feSpacePtr_Type uFESpacePtr( new feSpace_Type(localMeshPtr, uOrder, 3, comm) );
    if (verbose)
        std::cout << "ok." << std::endl;

    if (verbose) std::cout << "Building the pressure FE space... " << std::flush;
    feSpacePtr_Type pFESpacePtr( new feSpace_Type(localMeshPtr,pOrder,1,comm) );
    if (verbose) std::cout << "ok." << std::endl;

    // Total degrees of freedom (elements of matrix)
    LifeV::UInt totalVelDof   = uFESpacePtr->map().map(LifeV::Unique)->NumGlobalElements();
    LifeV::UInt totalPressDof = pFESpacePtr->map().map(LifeV::Unique)->NumGlobalElements();

    if (verbose) std::cout << "Total Velocity Dof: " << totalVelDof << std::endl;
    if (verbose) std::cout << "Total Pressure Dof: " << totalPressDof << std::endl;

    // +-----------------------------------------------+
    // |             Boundary conditions               |
    // +-----------------------------------------------+
    if (verbose) std::cout<< std::endl << "[Boundary conditions]" << std::endl;

    LifeV::BCFunctionBase uZero(fZero);
    LifeV::BCFunctionBase uLid(lidBC);

    std::vector<LifeV::ID> xComp(1);
    xComp[0] = 1;

    LifeV::BCHandler bcH;
    // A boundary condition in every face
    bcH.addBC( "Top"   , TOP   , LifeV::Essential, LifeV::Full     , uLid , 3     );
    bcH.addBC( "Left"  , LEFT  , LifeV::Essential, LifeV::Full     , uZero, 3     );
    bcH.addBC( "Front" , FRONT , LifeV::Essential, LifeV::Component, uZero, xComp );
    bcH.addBC( "Right" , RIGHT , LifeV::Essential, LifeV::Full     , uZero, 3     );
    bcH.addBC( "Back"  , BACK  , LifeV::Essential, LifeV::Component, uZero, xComp );
    bcH.addBC( "Bottom", BOTTOM, LifeV::Essential, LifeV::Full     , uZero, 3     );

    // Get the number of Lagrange Multiplyers (LM) and set the offsets
    std::vector<LifeV::bcName_Type> fluxVector = bcH.findAllBCWithType( LifeV::Flux );
    LifeV::UInt numLM = static_cast<LifeV::UInt>( fluxVector.size() );

    LifeV::UInt offset = uFESpacePtr->map().map(LifeV::Unique)->NumGlobalElements()
                         + pFESpacePtr->map().map(LifeV::Unique)->NumGlobalElements();

    for ( LifeV::UInt i = 0; i < numLM; ++i )
        bcH.setOffset( fluxVector[i], offset + i );

    // +-----------------------------------------------+
    // |             Creating the problem              |
    // +-----------------------------------------------+
    if (verbose) std::cout<< std::endl << "[Creating the problem]" << std::endl;
    boost::shared_ptr<LifeV::OseenData> oseenData(new LifeV::OseenData());
    oseenData->setup( dataFile );

    if (verbose) std::cout << "Time discretization order " << oseenData->dataTime()->orderBDF() << std::endl;

    // The problem (matrix and rhs) is packed in an object called fluid
    LifeV::OseenSolver< mesh_Type > fluid (oseenData,
                                           *uFESpacePtr,
                                           *pFESpacePtr,
                                           comm,
                                           numLM);
    // Gets inputs from the data file
    fluid.setUp(dataFile);

    // Assemble the matrices
    fluid.buildSystem();

    // Communication map
    LifeV::MapEpetra fullMap(fluid.getMap());

    // Synchronization
    MPI_Barrier(MPI_COMM_WORLD);

    // +-----------------------------------------------+
    // |       Initialization of the simulation        |
    // +-----------------------------------------------+
    if (verbose) std::cout<< std::endl << "[Initialization of the simulation]" << std::endl;
    LifeV::Real dt     = oseenData->dataTime()->timeStep();
    LifeV::Real t0     = oseenData->dataTime()->initialTime();
    LifeV::Real tFinal = oseenData->dataTime()->endTime ();

    // bdf object to store the previous solutions
    LifeV::TimeAdvanceBDFNavierStokes<vector_Type> bdf;
    bdf.setup(oseenData->dataTime()->orderBDF());

    // Initialization with exact solution: either interpolation or "L2-NS"-projection
    t0 -= dt * bdf.bdfVelocity().order();

    vector_Type beta( fullMap );
    vector_Type rhs ( fullMap );

    MPI_Barrier(MPI_COMM_WORLD);

    // We get the initial solution using a steady Stokes problem
    oseenData->dataTime()->setTime(t0);

    beta *= 0.;
    rhs  *= 0.;
    fluid.updateSystem(0.0,beta,rhs);
    fluid.iterate(bcH);
    bdf.bdfVelocity().setInitialCondition( *fluid.solution() );

    LifeV::Real time = t0 + dt;
    for (  ; time <=  oseenData->dataTime()->initialTime() + dt/2.; time += dt)
    {
        oseenData->dataTime()->setTime(time);

        fluid.updateSystem(0.0,beta,rhs);
        fluid.iterate(bcH);
        bdf.bdfVelocity().shiftRight( *fluid.solution() );
    }

    // We erase the preconditioner build for Stokes
    // (A new one should be built for Navier-Stokes)
    fluid.resetPreconditioner();

    boost::shared_ptr< LifeV::ExporterHDF5<mesh_Type> > exporter;

    vectorPtr_Type velAndPressure;

    std::string const exporterType =  dataFile( "exporter/type", "ensight");

    exporter.reset( new LifeV::ExporterHDF5<mesh_Type> ( dataFile, "cavity_example" ) );
    exporter->setPostDir( "./" ); // This is a test to see if M_post_dir is working
    exporter->setMeshProcId( localMeshPtr, comm->MyPID() );

    velAndPressure.reset( new vector_Type(*fluid.solution(), exporter->mapType() ) );

    exporter->addVariable( LifeV::ExporterData<mesh_Type>::VectorField, "velocity", uFESpacePtr,
                           velAndPressure, LifeV::UInt(0) );

    exporter->addVariable( LifeV::ExporterData<mesh_Type>::ScalarField, "pressure", pFESpacePtr,
                           velAndPressure, LifeV::UInt(3*uFESpacePtr->dof().numTotalDof()) );
    exporter->postProcess( 0 );

    initChrono.stop();
    if (verbose) std::cout << "Initialization time:  " << initChrono.diff() << " s." << std::endl;

    // +-----------------------------------------------+
    // |             Solving the problem               |
    // +-----------------------------------------------+
    if (verbose) std::cout<< std::endl << "[Solving the problem]" << std::endl;
    int iter = 1;

    for ( ; time <= tFinal + dt/2.; time += dt, iter++)
    {

        oseenData->dataTime()->setTime(time);

        if (verbose) std::cout << "[t = "<< oseenData->dataTime()->time() << " s.]" << std::endl;

        iterChrono.start();

        double alpha = bdf.bdfVelocity().coefficientFirstDerivative( 0 ) / oseenData->dataTime()->timeStep();
        //Matteo
        //	beta =bdf.bdfVelocity().extrapolation();
        bdf.bdfVelocity().extrapolation( beta ); // Extrapolation for the convective term
        bdf.bdfVelocity().updateRHSContribution(oseenData->dataTime()->timeStep() );
        rhs  = fluid.matrixMass()*bdf.bdfVelocity().rhsContributionFirstDerivative();

        fluid.getDisplayer().leaderPrint("alpha ", alpha);
        fluid.getDisplayer().leaderPrint("\n");
        fluid.getDisplayer().leaderPrint("norm beta ", beta.norm2());
        fluid.getDisplayer().leaderPrint("\n");
        fluid.getDisplayer().leaderPrint("norm rhs  ", rhs.norm2());
        fluid.getDisplayer().leaderPrint("\n");

        fluid.updateSystem( alpha, beta, rhs );
        fluid.iterate( bcH );

        bdf.bdfVelocity().shiftRight( *fluid.solution() );

        // Computation of the error
        vector_Type vel  (uFESpacePtr->map(), LifeV::Repeated);
        vector_Type press(pFESpacePtr->map(), LifeV::Repeated);
        vector_Type velpressure ( *fluid.solution(), LifeV::Repeated );

        velpressure = *fluid.solution();
        vel.subset(velpressure);
        press.subset(velpressure, uFESpacePtr->dim()*uFESpacePtr->fieldDim());


        bool verbose = (comm->MyPID() == 0);


        // Exporting the solution
        *velAndPressure = *fluid.solution();
        exporter->postProcess( time );


        MPI_Barrier(MPI_COMM_WORLD);

        iterChrono.stop();
        if (verbose) std::cout << "Iteration time: " << iterChrono.diff() << " s." << std::endl << std::endl;
    }

    globalChrono.stop();
    if (verbose) std::cout << "Total simulation time:  " << globalChrono.diff() << " s." << std::endl;

    exporter->closeFile();

#ifdef HAVE_MPI
    MPI_Finalize();
#endif

    return 0;
}
Exemple #26
0
GDALDataset *MSGDataset::Open( GDALOpenInfo * poOpenInfo )

{
/* -------------------------------------------------------------------- */
/*     Does this look like a MSG file                                   */
/* -------------------------------------------------------------------- */
    //if( poOpenInfo->fp == NULL)
    //  return NULL;
    // Do not touch the fp .. it will close by itself if not null after we return (whether it is recognized as HRIT or not)

    std::string command_line (poOpenInfo->pszFilename);

    MSGCommand command;
    std::string sErr = command.parse(command_line);
    if (sErr.length() > 0)
    {
        if (sErr.compare("-") != 0) // this driver does not recognize this format .. be silent and return false so that another driver can try
          CPLError( CE_Failure, CPLE_AppDefined, (sErr+"\n").c_str() );
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Read the prologue.                                              */
/* -------------------------------------------------------------------- */
    Prologue pp;

    std::string sPrologueFileName = command.sPrologueFileName(iCurrentSatellite, 1);
    bool fPrologueExists = (access(sPrologueFileName.c_str(), 0) == 0);

    // Make sure we're testing for MSG1,2,3 or 4 exactly once, start with the most recently used, and remember it in the static member for the next round.
    if (!fPrologueExists)
    {
      iCurrentSatellite = 1 + iCurrentSatellite % MAX_SATELLITES;
      sPrologueFileName = command.sPrologueFileName(iCurrentSatellite, 1);
      fPrologueExists = (access(sPrologueFileName.c_str(), 0) == 0);
      int iTries = 2;
      while (!fPrologueExists && (iTries < MAX_SATELLITES))
      {
        iCurrentSatellite = 1 + iCurrentSatellite % MAX_SATELLITES;
        sPrologueFileName = command.sPrologueFileName(iCurrentSatellite, 1);
        fPrologueExists = (access(sPrologueFileName.c_str(), 0) == 0);
        ++iTries;
      }
      if (!fPrologueExists) // assume missing prologue file, keep original satellite number
      {
        iCurrentSatellite = 1 + iCurrentSatellite % MAX_SATELLITES;
        sPrologueFileName = command.sPrologueFileName(iCurrentSatellite, 1);
      }
    }

    if (fPrologueExists)
    {
      std::ifstream p_file(sPrologueFileName.c_str(), std::ios::in|std::ios::binary);
      XRITHeaderParser xhp (p_file);
      if (xhp.isValid() && xhp.isPrologue())
        pp.read(p_file);
      p_file.close();
    }
    else
    {
        std::string sErr = "The prologue of the data set could not be found at the location specified:\n" + sPrologueFileName + "\n";
        CPLError( CE_Failure, CPLE_AppDefined,
                  sErr.c_str() );
        return FALSE;
    }
      

// We're confident the string is formatted as an MSG command_line

/* -------------------------------------------------------------------- */
/*      Create a corresponding GDALDataset.                             */
/* -------------------------------------------------------------------- */
    
    MSGDataset   *poDS;
    poDS = new MSGDataset();
    poDS->command = command; // copy it

/* -------------------------------------------------------------------- */
/*      Capture raster size from MSG prologue and submit it to GDAL     */
/* -------------------------------------------------------------------- */

    if (command.channel[11] != 0) // the HRV band
    {
      poDS->nRasterXSize = pp.idr()->ReferenceGridHRV->NumberOfColumns;
      poDS->nRasterYSize = abs(pp.idr()->PlannedCoverageHRV->UpperNorthLinePlanned - pp.idr()->PlannedCoverageHRV->LowerSouthLinePlanned) + 1;
    }
    else
    {
      poDS->nRasterXSize = abs(pp.idr()->PlannedCoverageVIS_IR->WesternColumnPlanned - pp.idr()->PlannedCoverageVIS_IR->EasternColumnPlanned) + 1;
      poDS->nRasterYSize = abs(pp.idr()->PlannedCoverageVIS_IR->NorthernLinePlanned - pp.idr()->PlannedCoverageVIS_IR->SouthernLinePlanned) + 1;
    }

/* -------------------------------------------------------------------- */
/*      Set Georeference Information                                    */
/* -------------------------------------------------------------------- */

    double rPixelSizeX;
    double rPixelSizeY;
    double rMinX;
    double rMaxY;

    if (command.channel[11] != 0)
    {
      rPixelSizeX = 1000 * pp.idr()->ReferenceGridHRV->ColumnDirGridStep;
      rPixelSizeY = 1000 * pp.idr()->ReferenceGridHRV->LineDirGridStep;
      rMinX = -rPixelSizeX * (pp.idr()->ReferenceGridHRV->NumberOfColumns / 2.0); // assumption: (0,0) falls in centre
      rMaxY = rPixelSizeY * (pp.idr()->ReferenceGridHRV->NumberOfLines / 2.0);
    }
    else
    {
      rPixelSizeX = 1000 * pp.idr()->ReferenceGridVIS_IR->ColumnDirGridStep;
      rPixelSizeY = 1000 * pp.idr()->ReferenceGridVIS_IR->LineDirGridStep;
      rMinX = -rPixelSizeX * (pp.idr()->ReferenceGridVIS_IR->NumberOfColumns / 2.0); // assumption: (0,0) falls in centre
      rMaxY = rPixelSizeY * (pp.idr()->ReferenceGridVIS_IR->NumberOfLines / 2.0);
    }
    poDS->adfGeoTransform[0] = rMinX;
    poDS->adfGeoTransform[3] = rMaxY;
    poDS->adfGeoTransform[1] = rPixelSizeX;
    poDS->adfGeoTransform[5] = -rPixelSizeY;
    poDS->adfGeoTransform[2] = 0.0;
    poDS->adfGeoTransform[4] = 0.0;

/* -------------------------------------------------------------------- */
/*      Set Projection Information                                      */
/* -------------------------------------------------------------------- */

    poDS->oSRS.SetGEOS(  0, 35785831, 0, 0 );
    poDS->oSRS.SetWellKnownGeogCS( "WGS84" ); // Temporary line to satisfy ERDAS (otherwise the ellips is "unnamed"). Eventually this should become the custom a and b ellips (CGMS).
    poDS->oSRS.exportToWkt( &(poDS->pszProjection) );

    // The following are 3 different try-outs for also setting the ellips a and b parameters.
    // We leave them out for now however because this does not work. In gdalwarp, when choosing some
    // specific target SRS, the result is an error message:
    // 
    // ERROR 1: geocentric transformation missing z or ellps
    // ERROR 1: GDALWarperOperation::ComputeSourceWindow() failed because
    // the pfnTransformer failed.
    // 
    // I can't explain the reason for the message at this time (could be a problem in the way the SRS is set here,
    // but also a bug in Proj.4 or GDAL.
    /*
    oSRS.SetGeogCS( NULL, NULL, NULL, 6378169, 295.488065897, NULL, 0, NULL, 0 );

    oSRS.SetGeogCS( "unnamed ellipse", "unknown", "unnamed", 6378169, 295.488065897, "Greenwich", 0.0);

    if( oSRS.importFromProj4("+proj=geos +h=35785831 +a=6378169 +b=6356583.8") == OGRERR_NONE )
    {
        oSRS.exportToWkt( &(poDS->pszProjection) );
    }
    */

/* -------------------------------------------------------------------- */
/*   Create a transformer to LatLon (only for Reflectance calculation)  */
/* -------------------------------------------------------------------- */

    char *pszLLTemp;
    (poDS->oSRS.GetAttrNode("GEOGCS"))->exportToWkt(&pszLLTemp);
    poDS->oLL.importFromWkt(&pszLLTemp);
    poDS->poTransform = OGRCreateCoordinateTransformation( &(poDS->oSRS), &(poDS->oLL) );

/* -------------------------------------------------------------------- */
/*      Set the radiometric calibration parameters.                     */
/* -------------------------------------------------------------------- */

    memcpy( poDS->rCalibrationOffset,  pp.rpr()->Cal_Offset, sizeof(double) * 12 );
    memcpy( poDS->rCalibrationSlope,  pp.rpr()->Cal_Slope, sizeof(double) * 12 );

/* -------------------------------------------------------------------- */
/*      Create band information objects.                                */
/* -------------------------------------------------------------------- */
    poDS->nBands = command.iNrChannels()*command.iNrCycles;
    for( int iBand = 0; iBand < poDS->nBands; iBand++ )
    {
        poDS->SetBand( iBand+1, new MSGRasterBand( poDS, iBand+1 ) );
    }
    
/* -------------------------------------------------------------------- */
/*      Confirm the requested access is supported.                      */
/* -------------------------------------------------------------------- */
    if( poOpenInfo->eAccess == GA_Update )
    {
        delete poDS;
        CPLError( CE_Failure, CPLE_NotSupported, 
                  "The MSG driver does not support update access to existing"
                  " datasets.\n" );
        return NULL;
    }
    
    return( poDS );
}
Exemple #27
0
int main(int argc, char* argv[])
{
  /* Echo GRINS version, libMesh version, and command */
  libMesh::out << "=========================================================="
               << std::endl;
  libMesh::out << "GRINS Version: " << GRINS_BUILD_VERSION << std::endl
               << "libMesh Version: " << LIBMESH_BUILD_VERSION << std::endl
               << "Running with command:\n";

  for (int i=0; i != argc; ++i)
    std::cout << argv[i] << ' ';

  std::cout << std::endl
            << "=========================================================="
            << std::endl;

#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);

  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

  GetPot command_line(argc,argv);

  // GetPot doesn't throw an error for a nonexistent file?
  {
    std::ifstream i(libMesh_input_filename.c_str());
    if (!i)
      {
        std::cerr << "Error: Could not read from libMesh input file "
                << libMesh_input_filename << std::endl;
        exit(1);
      }
  }

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
                           command_line,
			   sim_builder,
                           libmesh_init.comm() );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}
Exemple #28
0
inline task_result_t command_line(const char* command, ForwardIterator first, ForwardIterator last)
{
    return command_line(command, arg_set_t(first, last));
}
Exemple #29
0
inline task_result_t command_line(const char* command, const std::string& param)
{
    return command_line(command, arg_set_t(1, param));
}
Exemple #30
0
int process_fifo_input( int key )
/***********************************************************************/
{
   int fd,num_files,i;
   HANDLE hEvents[2],hPipe;
   DWORD dwWait,cbRead;
   char LoadError[256];
   bool le_status=CURRENT_VIEW->linend_status;
   CHARTYPE le_value=CURRENT_VIEW->linend_value;
   VIEW_DETAILS *le_view;
   BOOL fSuccess;

   TRACE_FUNCTION("single.c:  process_fifo_input");

   hPipe = (HANDLE)fifo_fd;
   if ( key == -1 )
   {
      for ( ; ; )
      {
         /*
          * Add curses input and the input fifo
          */
         hEvents[0] = (HANDLE)PDC_get_input_fd();
         if ( hEvents[0] == 0 )
         {
            /*
             * We don't have a valid handle to wait on.
             */
            TRACE_RETURN();
            return key;
         }
         hEvents[1] = hSemCommandCount; /* semaphore associated with the named pipe */

         dwWait = WaitForMultipleObjects( 2,
                                          hEvents,
                                          FALSE,
                                          INFINITE);

         if ( dwWait == WAIT_FAILED )
         {
            FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT), LoadError, 256, NULL ) ;
            display_error( 0, LoadError, FALSE );
         }
         else
         {
            fd = dwWait - WAIT_OBJECT_0; /* determines which pipe */
            if ( fd == 0 )
            {
               /*
                * A key is ready...
                * We have to increment the semaphore, because we have
                * decremented it by waiting on it. Isn't this crap!
                */
               ReleaseSemaphore( hEvents[0], 1, NULL );
               TRACE_RETURN();
               return (-1);
            }
            else if ( fd == 1 )
            {
               /*
                * To get here we must be in a state to read from the pipe...
                * Read the number of files coming down the pipe...
                */
               fSuccess = ReadFile( hPipe, (LPVOID)&trec_len, sizeof(trec_len), &cbRead, NULL );
               if ( !fSuccess || cbRead == 0 )
               {
                  TRACE_RETURN();
                  return key;
               }
               num_files = (int)trec_len;
               /*
                * save view and LINEND details to reset later
                */
               le_status = CURRENT_VIEW->linend_status;
               le_value = CURRENT_VIEW->linend_value;
               le_view = CURRENT_VIEW;
               /*
                * Read each file from the pipe...
                */
               for ( i = 0; i < num_files; i++ )
               {
                  if ( !ReadFile( hPipe, (LPVOID)&trec_len, sizeof(trec_len), &cbRead, NULL ) )
                  {
                     TRACE_RETURN();
                     le_view->linend_status = le_status;
                     le_view->linend_value = le_value;
                     return key;
                  }
                  /*
                   * Sleep for 100 milliseconds to ensure the remainder of the
                   * data is in the fifo. Yuck!
                   */
                  napms( 100 );
                  if ( !ReadFile( hPipe, (LPVOID)trec, trec_len*sizeof(CHARTYPE), &cbRead, NULL ) )
                  {
                     TRACE_RETURN();
                     le_view->linend_status = le_status;
                     le_view->linend_value = le_value;
                     return key;
                  }
                  trec[trec_len] = '\0';
                  CURRENT_VIEW->linend_status = TRUE;
                  CURRENT_VIEW->linend_value = '#';
                  (void)command_line( trec, TRUE );
               }
               ResetEvent( hPipeRead );
               le_view->linend_status = le_status;
               le_view->linend_value = le_value;
               key = 0;
               break;
            }
         }
      }
   }
   TRACE_RETURN();
   return key;
}