示例#1
0
void Initialize( reax_system *system, control_params *control, 
		 simulation_data *data, storage *workspace, 
		 reax_list **lists, output_controls *out_control,
		 mpi_datatypes *mpi_data, MPI_Comm comm )
{
  char msg[MAX_STR];


  if( Init_MPI_Datatypes(system, workspace, mpi_data, comm, msg) == FAILURE ) {
    fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n",
	     system->my_rank );
    fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n",
	     system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }
#if defined(DEBUG)
  fprintf( stderr, "p%d: initialized mpi datatypes\n", system->my_rank );
#endif
  
  if( Init_System(system, control, msg) == FAILURE ){
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); 
    fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
	     system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }
#if defined(DEBUG)
  fprintf( stderr, "p%d: system initialized\n", system->my_rank );
#endif

  if( Init_Simulation_Data( system, control, data, msg ) == FAILURE ) {
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); 
    fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
	     system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }
#if defined(DEBUG)
  fprintf( stderr, "p%d: initialized simulation data\n", system->my_rank );
#endif

  if( Init_Workspace( system, control, workspace, mpi_data->world, msg ) == 
      FAILURE ) {
    fprintf( stderr, "p%d:init_workspace: not enough memory\n", 
	     system->my_rank );
    fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
	     system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }
#if defined(DEBUG)
  fprintf( stderr, "p%d: initialized workspace\n", system->my_rank );
#endif

  if( Init_Lists( system, control, data, workspace, lists, mpi_data, msg ) == 
      FAILURE ) {
      fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
      fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
	       system->my_rank );
      MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
    }
#if defined(DEBUG)
  fprintf( stderr, "p%d: initialized lists\n", system->my_rank );
#endif

  if( Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) {
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
    fprintf( stderr, "p%d: could not open output files! terminating...\n", 
	     system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }
#if defined(DEBUG)
  fprintf( stderr, "p%d: output files opened\n", system->my_rank );
#endif

  if( control->tabulate ) {
    if( Init_Lookup_Tables( system, control, workspace, mpi_data, msg ) == FAILURE ) {
      fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
      fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n",
	       system->my_rank );
      MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
    }
#if defined(DEBUG)
    fprintf( stderr, "p%d: initialized lookup tables\n", system->my_rank );
#endif
  }


  Init_Force_Functions( control );
#if defined(DEBUG)
  fprintf( stderr, "p%d: initialized force functions\n", system->my_rank );
#endif
  /*#if defined(TEST_FORCES) 
    Init_Force_Test_Functions();
    fprintf(stderr,"p%d: initialized force test functions\n",system->my_rank);
  #endif*/
}
示例#2
0
// The only difference with the MPI-only function is calls to Init_ListsOMP and Init_Force_FunctionsOMP().
void InitializeOMP( reax_system *system, control_params *control,
                 simulation_data *data, storage *workspace,
                 reax_list **lists, output_controls *out_control,
                 mpi_datatypes *mpi_data, MPI_Comm comm )
{
  char msg[MAX_STR];


  if (Init_MPI_Datatypes(system, workspace, mpi_data, comm, msg) == FAILURE) {
    fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n",
             system->my_rank );
    fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n",
             system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }

  if (Init_System(system, control, msg) == FAILURE) {
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
    fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
             system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }

  if (Init_Simulation_Data( system, control, data, msg ) == FAILURE) {
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
    fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
             system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }

  if (Init_Workspace( system, control, workspace, mpi_data->world, msg ) ==
      FAILURE) {
    fprintf( stderr, "p%d:init_workspace: not enough memory\n",
             system->my_rank );
    fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
             system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }

  if (Init_ListsOMP( system, control, data, workspace, lists, mpi_data, msg ) ==
      FAILURE) {
      fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
      fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
               system->my_rank );
      MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
    }

  if (Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) {
    fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
    fprintf( stderr, "p%d: could not open output files! terminating...\n",
             system->my_rank );
    MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
  }

  if (control->tabulate) {
    if (Init_Lookup_Tables( system, control, workspace, mpi_data, msg ) == FAILURE) {
      fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
      fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n",
               system->my_rank );
      MPI_Abort( mpi_data->world, CANNOT_INITIALIZE );
    }
  }


  Init_Force_FunctionsOMP( control );
}