示例#1
0
// main
int main( void )
{
  // inits
  attach_GLU( ) ;

  // 4^ND periodic lattice
  size_t mu ; 
  for( mu = 0 ; mu < ND ; mu++ ) {
    Latt.dims[ mu ] = 4 ;
  }
  
  // initialise geometry so that we can use LVOLUME and stuff
  init_latt( ) ;

  // set the seed to something I know answers for
  Latt.Seed[0] = 1 ;

  // initialise rng
  initialise_par_rng( NULL ) ;

  // a counter for all the tests we have done
  int full_tests_run = 0 ;

  // test rng
  char *test_results ;
  if( ( test_results = rng_tests( ) ) != 0 ) {
     goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // first one is simple linear algebra tests
  if( UNOPS_test() == GLU_FAILURE ) {
    goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // matrix multiply tests
  if( MMUL_test() == GLU_FAILURE ) {
    goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // log-exponentiate tests
  if( ( test_results = logexp_tests( ) ) != 0 ) {
    goto TEST_FAILURE ;
  } 
  full_tests_run += tests_run ;

  // matrix inversion/determinant tests
  if( ( test_results = inversion_tests( ) ) != 0 ) {
    goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // geometry tests
  if( geometry_test() == GLU_FAILURE ) {
    goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // general lattice configuration tests
  if( ( test_results = config_tests( ) ) != 0 ) {
    goto TEST_FAILURE ;
  }
  full_tests_run += tests_run ;

  // if we are successful we go there
  goto TEST_SUCCESS ;

 TEST_FAILURE :
  unstick_GLU( ) ;
  fprintf( stderr , "[GLUnit] Test failure \n%s \n" , test_results ) ;
  return GLU_FAILURE ;
 TEST_SUCCESS :
  unstick_GLU( ) ;
  fprintf( stderr , "[GLUnit] All %d tests passed \n" , full_tests_run ) ;

  return GLU_SUCCESS ;
}
示例#2
0
// read a file, has to be out of order because it is called by the others
struct site*
read_file( struct head_data *HEAD_DATA , 
	   const char *config_in )
{
  // some additional information
#ifdef CONDOR_MODE
  fprintf( stdout , "[PAR] CONDOR_MODE selected .... \n" ) ;
#else
  fprintf( stdout , "[PAR] NOT_CONDOR_MODE selected .... "
	   "(same-architecture caching used) \n" ) ;
#endif

  /// here we include the usual stuff look at header for global stuff
  // open our configuration
  FILE *infile = fopen( config_in , "r" ) ;
  if( infile == NULL ) {
    // need to check what we are doing
    if( Latt.head == UNIT_GAUGE ||
	Latt.head == RANDOM_CONFIG ||
	Latt.head == INSTANTON ) {
      fprintf( stdout , "[IO] %s is empty but that is ok \n" , config_in ) ;
    } else {
      fprintf( stderr , "[IO] error opening file :: %s\n" , config_in ) ;
      return NULL ;
    }
  }
  fprintf( stdout , "[IO] reading file %s\n" , config_in ) ;
 
  // initialise the configuration number to zero
  struct head_data tmp ;
  if( read_header( infile , &tmp , GLU_TRUE ) == GLU_FAILURE ) {
    fprintf( stderr , "[IO] Header reading failure\n" ) ;
    fclose( infile ) ;
    return NULL ;
  } 

  // initialise geometry so that we can use LVOLUME and stuff
  init_latt( ) ;

  // check for having enough memory for the gauge field
  if( have_memory_gauge( ) == GLU_FAILURE ) {
    fclose( infile ) ;
    return NULL ;
  }

  // malloc our gauge field and initialise our lattice geometry
  struct site *lat = NULL ;
  if( ( lat = allocate_lat( ) ) == NULL ) {
    fprintf( stderr , "[IO] Gauge field allocation failure\n" ) ;
    return NULL ;
  }

#ifdef SINGLE_PREC
  fprintf( stdout , "[PREC] Single-precision storage for the gauge fields\n" ) ;
#endif

  const int check = get_config_SUNC( infile , lat , tmp ) ;
  // read in the configuration ...  
  if( check == GLU_FAILURE ) {
    fprintf( stderr , "[IO] File read error ... Leaving \n" ) ;
    fclose( infile ) ;
    free( lat ) ;
    return NULL ;
  }

  // look at scidac header again to get the checksums
  // this is taken from the bottom of the file
  if( Latt.head == SCIDAC_HEADER || Latt.head == ILDG_SCIDAC_HEADER ||
      Latt.head == ILDG_BQCD_HEADER ) {
    get_header_data_SCIDAC( infile , &tmp ) ;
  }

  // have a look at some available checks
  if( checks( lat , check , tmp ) == GLU_FAILURE ) { 
    fclose( infile ) ;
    free( lat ) ;
    return NULL ; 
  }

  // set the header info
  *HEAD_DATA = tmp ;

  // free it if it was opened
  if( infile != NULL ) {
    fclose( infile ) ;
  }

  // and finally set the header data into a constant struct
  return lat ;
}