예제 #1
0
// detect what mode we are using
static int
get_mode( GLU_mode *mode )
{
  // look for which mode we are running in
  {
    const int mode_idx = tag_search( "MODE" ) ;
    if( mode_idx == GLU_FAILURE ) { return tag_failure( "MODE" ) ; }
    // what mode do we want?
    if( are_equal( INPUT[mode_idx].VALUE , "GAUGE_FIXING" ) ) {
      *mode = MODE_GF ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "CUTTING" ) ) {
      *mode = MODE_CUTS ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "SMEARING" ) ) {
      *mode = MODE_SMEARING ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "SUNCxU1" ) ) {
      *mode = MODE_CROSS_U1 ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "HEATBATH" ) ) {
      *mode = MODE_HEATBATH ;
    } else {
      *mode = MODE_REWRITE ;
    }
  }
  // look at what seed type we are going to use
  {
    const int seed_idx = tag_search( "SEED" ) ;
    if( seed_idx == GLU_FAILURE ) { return tag_failure( "SEED" ) ; }
    sscanf( INPUT[seed_idx].VALUE , "%u" , &Latt.Seed[0] ) ;
  }
  return GLU_SUCCESS ;
}
예제 #2
0
// are we performing a random transform?
static GLU_bool
rtrans( void )
{
  const int rtrans_idx = tag_search( "RANDOM_TRANSFORM" ) ;
  if( are_equal( INPUT[rtrans_idx].VALUE , "YES" ) ) return GLU_TRUE ;
  return GLU_FALSE ;
}
예제 #3
0
// the one for the U(1) data
static int
read_suNC_x_U1( struct u1_info *U1INFO )
{
  // U1 coupling strength
  if( setdbl( &( U1INFO -> alpha ) , "U1_ALPHA" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // U1 charge
  if( setdbl( &( U1INFO -> charge ) , "U1_CHARGE" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // U1 measurement type default is just the plaquette
  {
    const int U1_meas_idx = tag_search( "U1_MEAS" ) ;
    if( U1_meas_idx == GLU_FAILURE ) { return tag_failure( "U1_MEAS" ) ; }
    //
    U1INFO -> meas = U1_PLAQUETTE ;
    if( are_equal( INPUT[ U1_meas_idx ].VALUE , "U1_RECTANGLE" ) ) {
      U1INFO -> meas = U1_RECTANGLE ;
    } else if ( are_equal( INPUT[ U1_meas_idx ].VALUE , "U1_TOPOLOGICAL" ) ) {
      U1INFO -> meas = U1_TOPOLOGICAL ;
    }
  }
  return GLU_SUCCESS ;
}
예제 #4
0
// read the gauge fixing information
static int
read_gf_struct ( struct gf_info *GFINFO )
{
  // look at what seed type we are going to use
  {
    const int gf_idx = tag_search( "GFTYPE" ) ;
    if( gf_idx == GLU_FAILURE ) { return tag_failure( "GFTYPE" ) ; } 
    if( are_equal( INPUT[gf_idx].VALUE , "LANDAU" ) ) { 
      GFINFO -> type = GLU_LANDAU_FIX ;
    } else if ( are_equal( INPUT[gf_idx].VALUE , "COULOMB" ) ) {
      GFINFO -> type = GLU_COULOMB_FIX ;
    } else {
      fprintf( stderr , "[IO] unknown type [%s] : Defaulting to "
	       "NO GAUGE FIXING \n" , INPUT[gf_idx].VALUE ) ; 
      GFINFO -> type = DEFAULT_NOFIX ; 
    }
  }
  // have a look to see what "improvements" we would like
  {
    const int improve_idx = tag_search( "IMPROVEMENTS" ) ;
    if( improve_idx == GLU_FAILURE ) { return tag_failure( "IMPROVEMENTS" ) ; } 
    GFINFO -> improve = NO_IMPROVE ; // default is no "Improvements" 
    if( are_equal( INPUT[improve_idx].VALUE , "MAG" ) ) {
      GFINFO -> improve = MAG_IMPROVE ; 
    } else if ( are_equal( INPUT[improve_idx].VALUE , "SMEAR" ) ) {
      GFINFO -> improve = SMPREC_IMPROVE ; 
    } else if(  are_equal( INPUT[improve_idx].VALUE , "RESIDUAL" ) ) {
      GFINFO -> improve = RESIDUAL_IMPROVE ; 
    }
  }
  // set the accuracy is 10^{-ACCURACY}
  if( setdbl( &( GFINFO -> accuracy ) , "ACCURACY" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  } 
  GFINFO -> accuracy = pow( 10.0 , -GFINFO -> accuracy ) ;
  // set the maximum number of iterations of the routine
  if( setint( &( GFINFO -> max_iters ) , "MAX_ITERS" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // set the alpha goes in Latt.gf_alpha for some reason
  if( setdbl( &Latt.gf_alpha , "GF_TUNE" ) == GLU_FAILURE ) {
    printf( "Failure \n" ) ;
    return GLU_FAILURE ;
  }
  return GLU_SUCCESS ;
}
예제 #5
0
// get the information for the header
static int
config_information( char *details )
{
  const int details_idx = tag_search( "CONFIG_INFO" ) ;
  /*
  if( are_equal( INPUT[details_idx].VALUE , "YES" ) ) { 
    return tag_failure( "CONFIG_INFO" ) ; 
  }
  */
  sprintf( details , "%s" , INPUT[details_idx].VALUE ) ;
  return GLU_SUCCESS ;
}
예제 #6
0
// I use this pattern quite a bit
static int
setint( size_t *val ,
	const char *tag )
{
  char *endptr ;
  errno = 0 ;
  const int idx = tag_search( tag ) ;
  if( idx == GLU_FAILURE ) { return tag_failure( tag ) ; }
  *val = (size_t)strtol( INPUT[idx].VALUE , &endptr , 10 ) ;
  if( endptr == INPUT[idx].VALUE || errno == ERANGE ) {
    return GLU_FAILURE ;
  }
  return GLU_SUCCESS ;
}
예제 #7
0
// above but for doubles
static int
setdbl( double *val ,
	const char *tag )
{
  char *endptr ;
  errno = 0 ;
  const int idx = tag_search( tag ) ;
  if( idx == GLU_FAILURE ) { return tag_failure( tag ) ; }
  *val = strtod( INPUT[idx].VALUE , &endptr ) ;
  if( endptr == INPUT[idx].VALUE || errno == ERANGE ) {
    return GLU_FAILURE ;
  }
  return GLU_SUCCESS ;
}
예제 #8
0
int loadblock(load_ptr *src, u32 tag, int size)
{
	int tagid;
	int expectedsize;
	u8 *address;
	int returnsize;
	Savefunc_t function_number;
	loadfunc load_function;

	tagid=tag_search(tag,tags,NUM_TAGS);
	
	//indicate that the block has been loaded
	blocks_loaded |= (1 << tagid);
	
	expectedsize=sizes[tagid];
	address=(u8*)addresses[tagid];
	
	function_number=(Savefunc_t)save_function_numbers[tagid];
	load_function=load_functions[function_number];
	
	returnsize=load_function(address,src,size,expectedsize);
	return returnsize;
}
예제 #9
0
// the code that writes out all of the config details
static int
out_details( GLU_output *storage , 
	     const GLU_mode mode )
{  
  // get the storage type
  {
    const int storage_idx = tag_search( "STORAGE" ) ;
    if( storage_idx == GLU_FAILURE ) { return tag_failure( "STORAGE" ) ; }
    if( are_equal( INPUT[storage_idx].VALUE , "NERSC_SMALL" ) ) {
      // small is not available for larger NC default to NCxNC
      #if NC > 3
      *storage = OUTPUT_NCxNC ;
      #else
      *storage = ( mode != MODE_CROSS_U1 ) ? OUTPUT_SMALL : OUTPUT_NCxNC ;
      #endif
    } else if( are_equal( INPUT[storage_idx].VALUE , "NERSC_GAUGE" ) ) {
      *storage = ( mode != MODE_CROSS_U1 ) ? OUTPUT_GAUGE : OUTPUT_NCxNC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "NERSC_NCxNC" ) ) {
      *storage = OUTPUT_NCxNC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "HIREP" ) ) {
      *storage = OUTPUT_HIREP ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "MILC" ) ) {
      *storage = OUTPUT_MILC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "SCIDAC" ) ) {
      *storage = OUTPUT_SCIDAC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "ILDG" ) ) {
      *storage = OUTPUT_ILDG ;
    } else {
      fprintf( stdout , "[IO] output type %s not recognised .. leaving \n" , 
	       INPUT[storage_idx].VALUE ) ;
      return GLU_FAILURE ;
    }
  }
  // we now do reach this point
  return GLU_SUCCESS ;
}
예제 #10
0
/* ---------------------------------------------- */
static void
dissect_fix_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    /* Set up structures needed to add the protocol subtree and manage it */
    proto_item    *ti;
    proto_tree    *fix_tree;
    int            pdu_len;
    int            offset = 0;
    int            field_offset, ctrla_offset;
    int            tag_value;
    char          *value;
    char          *tag_str;
    fix_parameter *tag;

    /* Make entries in Protocol column and Info column on summary display */
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "FIX");
    col_clear(pinfo->cinfo, COL_INFO);

    /* get at least the fix version: 8=FIX.x.x */
    if (fix_marker(tvb, 0) != 0) {
        /* not a fix packet start but it's a fix packet */
        col_set_str(pinfo->cinfo, COL_INFO, "[FIX continuation]");
        ti = proto_tree_add_item(tree, proto_fix, tvb, 0, -1, ENC_NA);
        fix_tree = proto_item_add_subtree(ti, ett_fix);
        proto_tree_add_item(fix_tree, hf_fix_data, tvb, 0, -1, ENC_NA);
        return;
    }

    pdu_len = tvb_reported_length(tvb);
    ti = proto_tree_add_item(tree, proto_fix, tvb, 0, -1, ENC_NA);
    fix_tree = proto_item_add_subtree(ti, ett_fix);

    /* begin string */
    ctrla_offset = tvb_find_guint8(tvb, offset, -1, 0x01);
    if (ctrla_offset == -1) {
        return;
    }
    offset = ctrla_offset + 1;

    /* msg length */
    ctrla_offset = tvb_find_guint8(tvb, offset, -1, 0x01);
    if (ctrla_offset == -1) {
        return;
    }
    offset = ctrla_offset + 1;

    /* msg type */
    if (!(tag = fix_param(tvb, offset)) || tag->value_len < 1) {
        return;
    }

    if (check_col(pinfo->cinfo, COL_INFO)) {
        const char *msg_type;

        value = tvb_get_ephemeral_string(tvb, tag->value_offset, tag->value_len);
        msg_type = str_to_str(value, messages_val, "FIX Message (%s)");
        col_add_str(pinfo->cinfo, COL_INFO, msg_type);
    }

    /* In the interest of speed, if "tree" is NULL, don't do any work not
     * necessary to generate protocol tree items.
     */
    field_offset = 0;

    while(field_offset < pdu_len && (tag = fix_param(tvb, field_offset)) ) {
        int i, found;

        if (tag->tag_len < 1) {
            field_offset =  tag->ctrla_offset + 1;
            continue;
        }

        tag_str = tvb_get_ephemeral_string(tvb, field_offset, tag->tag_len);
        tag_value = atoi(tag_str);
        if (tag->value_len < 1) {
            proto_tree *field_tree;
            /* XXX - put an error indication here.  It's too late
               to return FALSE; we've already started dissecting,
               and if a heuristic dissector starts dissecting
               (either updating the columns or creating a protocol
               tree) and then gives up, it leaves crud behind that
               messes up other dissectors that might process the
               packet. */
            ti = proto_tree_add_text(fix_tree, tvb, field_offset, tag->field_len, "%i: <missing value>", tag_value);
            field_tree = proto_item_add_subtree(ti, ett_badfield);
            proto_tree_add_uint(field_tree, hf_fix_field_tag, tvb, field_offset, tag->tag_len, tag_value);
            field_offset =  tag->ctrla_offset + 1;
            continue;
        }

        /* fix_fields array is sorted by tag_value */
        found = 0;
        if ((i = tag_search(tag_value)) >= 0) {
            found = 1;
        }

        value = tvb_get_ephemeral_string(tvb, tag->value_offset, tag->value_len);
        if (found) {
            if (fix_fields[i].table) {
                if (tree) {
                    switch (fix_fields[i].type) {
                    case 1: /* strings */
                        proto_tree_add_string_format_value(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len, value,
                            "%s (%s)", value, str_to_str(value, fix_fields[i].table, "unknown %s"));
                        break;
                    case 2: /* char */
                        proto_tree_add_string_format_value(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len, value,
                            "%s (%s)", value, val_to_str(*value, fix_fields[i].table, "unknown %d"));
                        break;
                    default:
                        proto_tree_add_string_format_value(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len, value,
                            "%s (%s)", value, val_to_str(atoi(value), fix_fields[i].table, "unknown %d"));
                        break;
                    }
                }
            }
            else {
              proto_item *item;

              /* checksum */
              switch(tag_value) {
              case 10:
                {
                    proto_tree *checksum_tree;
                    guint8 sum = 0;
                    const guint8 *data = tvb_get_ptr(tvb, 0, field_offset);
                    gboolean sum_ok;
                    int j;

                    for (j = 0; j < field_offset; j++, data++) {
                         sum += *data;
                    }
                    sum_ok = (atoi(value) == sum);
                    if (sum_ok) {
                        item = proto_tree_add_string_format_value(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len,
                                value, "%s [correct]", value);
                    }
                    else {
                        item = proto_tree_add_string_format_value(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len,
                                value, "%s [incorrect should be %d]", value, sum);
                    }
                    checksum_tree = proto_item_add_subtree(item, ett_checksum);
                    item = proto_tree_add_boolean(checksum_tree, hf_fix_checksum_good, tvb, field_offset, tag->field_len, sum_ok);
                    PROTO_ITEM_SET_GENERATED(item);
                    item = proto_tree_add_boolean(checksum_tree, hf_fix_checksum_bad, tvb, field_offset, tag->field_len, !sum_ok);
                    PROTO_ITEM_SET_GENERATED(item);
                    if (!sum_ok)
                        expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR, "Bad checksum");
                }
                break;
              default:
                proto_tree_add_string(fix_tree, fix_fields[i].hf_id, tvb, field_offset, tag->field_len, value);
                break;
              }
            }
        }
        else if (tree) {
          proto_tree *field_tree;

          /* XXX - it could be -1 if the tag isn't a number */
          ti = proto_tree_add_text(fix_tree, tvb, field_offset, tag->field_len, "%i: %s", tag_value, value);
          field_tree = proto_item_add_subtree(ti, ett_unknow);
          proto_tree_add_uint(field_tree, hf_fix_field_tag, tvb, field_offset, tag->tag_len, tag_value);
          proto_tree_add_item(field_tree, hf_fix_field_value, tvb, tag->value_offset, tag->value_len, ENC_ASCII|ENC_NA);
        }

        field_offset =  tag->ctrla_offset + 1;

        tag_str = NULL;
    }
    return;
}
예제 #11
0
bool loadstate(const char* filename)
#endif
{
	//save old values of Crash detector and sound volume
	//crash detector will become enabled, and sound will be muted later
	int old_crash_disabled = _crash_disabled;
	int soundvol;

	#if !MOVIEPLAYER
	u8* limit=src+statesize;
	load_ptr file=src;
	#else
	File file;
	#endif

	bool do_load=true;
	
	u32 tag;
	int size;
	
	//enable crash detector - if loading doesn't complete within 5 seconds, it crashed
	_crash_disabled = 0;
	
	//Set that no block has loaded yet, this is changed later when loadblock is called for each tag
	blocks_loaded = 0;

	#if MOVIEPLAYER
	file=FAT_fopen(filename,"r");
	if (file==NO_FILE)
	{
		do_load=false;
	}
	#endif

	if (do_load)
	{
		//Read old sound volume, and stop sound on GB channels
		soundvol=REG_SOUNDCNT_L;
		REG_SOUNDCNT_L=0;

		do
		{
			int tagid;
			//verify presence of VERS tag as first thing in file
			if (!read_u32(file,tag)) break;
			//look up tag
			tagid=tag_search(tag,tags,NUM_TAGS);
			if (tagid!=VERSION_TAG)
			{
				seek_ahead(file,-4);
				#if !MOVIEPLAYER
				//reboot game, but don't clear some stuff
				do_not_decompress=1;
				do_not_reset_all=1;
				loadcart(romnumber,emuflags,0);
				//Restore previous sound volume (fixme, we get audio playing while we re-decompress the game)
				REG_SOUNDCNT_L=soundvol;
				//Messes up variables so that the emulator won't run anymore (later we un-mess them)
				prepare_variables_for_savestate();
				do_not_decompress=0;
				do_not_reset_all=0;
				#endif
				load_old_savestate(&file);
				break;
			}
			else
			{
				if (!read_u32(file,size)) break;
				//discard version block
				loadblock(&file,tag,size);
				
				#if !MOVIEPLAYER
					//reboot game to a blank slate
					do_not_decompress=1;
					loadcart(romnumber,emuflags,0);
					//Restore sound volume
					REG_SOUNDCNT_L=soundvol;
					do_not_decompress=0;
				#endif
				
				//Messes up variables so that the emulator won't run anymore (later we un-mess them)
				prepare_variables_for_savestate();
				//load all other tags
				while (1)
				{
					if (!read_u32(file,tag)) break;
					if (!read_u32(file,size)) break;
					loadblock(&file,tag,size);
				}
			}
		} while (0);
		#if MOVIEPLAYER
		FAT_fclose(file);
		#endif
		//Now we restore the variables so the emulator runs again
		restore_variables_for_loadstate();
		restore_more_variables_for_loadstate();
	}
	//restore previous state of crash detector
	_crash_disabled = old_crash_disabled;

	#if MOVIEPLAYER
	return do_load;
	#endif
}
예제 #12
0
// pack the sm_info struct
static int
smearing_info( struct sm_info *SMINFO )
{
  // find the smeartype index
  {
    const int type_idx = tag_search( "SMEARTYPE" ) ;
    if( type_idx == GLU_FAILURE ) { return tag_failure( "SMEARTYPE" ) ; }
    if( are_equal( INPUT[type_idx].VALUE , "APE" ) ) { 
      SMINFO -> type = SM_APE ;
    } else if( are_equal( INPUT[type_idx].VALUE , "STOUT" ) ) {
      SMINFO -> type = SM_STOUT ;
    } else if( are_equal( INPUT[type_idx].VALUE , "LOG" ) ) {
      SMINFO -> type = SM_LOG ;
    } else if( are_equal( INPUT[type_idx].VALUE , "HYP" ) ) {
      SMINFO -> type = SM_HYP ;
    } else if( are_equal( INPUT[type_idx].VALUE , "HEX" ) ) {
      SMINFO -> type = SM_HEX ;
    } else if( are_equal( INPUT[type_idx].VALUE , "HYL" ) ) {
      SMINFO -> type = SM_HYL ;
    } else if( are_equal( INPUT[type_idx].VALUE , "WFLOW_LOG" ) ) {
      SMINFO -> type = SM_WFLOW_LOG ;
    } else if( are_equal( INPUT[type_idx].VALUE , "WFLOW_STOUT" ) ) {
      SMINFO -> type = SM_WFLOW_STOUT ;
    } else if( are_equal( INPUT[type_idx].VALUE , "ADAPTWFLOW_LOG" ) ) {
      SMINFO -> type = SM_ADAPTWFLOW_LOG ;
    } else if( are_equal( INPUT[type_idx].VALUE , "ADAPTWFLOW_STOUT" ) ) {
      SMINFO -> type = SM_ADAPTWFLOW_STOUT ;
    } else {
      fprintf( stderr , "[IO] Unrecognised Type [%s] "
	       "Defaulting to No Smearing \n" , INPUT[type_idx].VALUE ) ;
      SMINFO -> type = SM_NOSMEARING ;
    }
  }
  // look for the number of directions
  {
    const int dir_idx = tag_search( "DIRECTION" ) ;
    if( dir_idx == GLU_FAILURE ) { return tag_failure( "DIRECTION" ) ; }
    if( are_equal( INPUT[dir_idx].VALUE , "SPATIAL" ) ) {
      SMINFO -> dir = SPATIAL_LINKS_ONLY ;
    } else {
      SMINFO -> dir = ALL_DIRECTIONS ;
    }
  }
  // set up the number of smearing iterations
  if( setint( &( SMINFO -> smiters ) , "SMITERS" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // poke the smearing alpha's into Latt.smalpha[ND]
  // logically for an ND - dimensional theory there are ND - 1 HYP params.
  {
    size_t mu ;
    for( mu = 0 ; mu < ND - 1 ; mu++ ) {
      char alpha_str[ 64 ] ;
      sprintf( alpha_str , "ALPHA%zu" , mu + 1 ) ;
      if( setdbl( &Latt.sm_alpha[ mu ] , alpha_str ) == GLU_FAILURE ) {
	return GLU_FAILURE ;
      }
    }
  }
  return GLU_SUCCESS ;
}
예제 #13
0
// pack the cut_info struct
static int
read_cuts_struct( struct cut_info *CUTINFO )
{
  // set up the cuttype
  {
    const int cuttype_idx = tag_search( "CUTTYPE" ) ;
    if( cuttype_idx == GLU_FAILURE ) { return tag_failure( "CUTTYPE" ) ; }
    if( are_equal( INPUT[cuttype_idx].VALUE , "EXCEPTIONAL" ) ) {
      CUTINFO -> dir = EXCEPTIONAL ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "NON_EXCEPTIONAL" ) ) {
      CUTINFO -> dir = NONEXCEPTIONAL ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "FIELDS" ) ) {
      CUTINFO -> dir = FIELDS ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "SMEARED_GLUONS" ) ) {
      CUTINFO -> dir = SMEARED_GLUONS ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "INSTANTANEOUS_GLUONS" ) ) {
      CUTINFO -> dir = INSTANTANEOUS_GLUONS ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "CONFIGSPACE_GLUONS" ) ) {
      CUTINFO -> dir = CONFIGSPACE_GLUONS ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "GLUON_PROPS" ) ) {
      CUTINFO -> dir = GLUON_PROPS ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "STATIC_POTENTIAL" ) ) {
      CUTINFO -> dir = STATIC_POTENTIAL ;
    } else if( are_equal( INPUT[cuttype_idx].VALUE , "TOPOLOGICAL_SUSCEPTIBILITY" ) ) {
      CUTINFO -> dir = TOPOLOGICAL_SUSCEPTIBILITY ;
    } else {
      fprintf( stderr , "[IO] I do not understand your CUTTYPE %s\n" , 
	       INPUT[cuttype_idx].VALUE ) ;
      fprintf( stderr , "[IO] Defaulting to no cutting \n" ) ;
      return GLU_FAILURE ;
    }
  }
  // momentum space cut def
  {
    const int momcut_idx = tag_search( "MOM_CUT" ) ;
    if( momcut_idx == GLU_FAILURE ) { return tag_failure( "MOM_CUT" ) ; }
    if ( are_equal( INPUT[momcut_idx].VALUE , "HYPERCUBIC_CUT" ) ) {
      CUTINFO -> type = HYPERCUBIC_CUT ; 
    } else if ( are_equal( INPUT[momcut_idx].VALUE , "SPHERICAL_CUT" ) ) {
      CUTINFO -> type = PSQ_CUT ; 
    } else if ( are_equal( INPUT[momcut_idx].VALUE , "CYLINDER_CUT" ) ) {
      CUTINFO -> type = CYLINDER_CUT ; 
    } else if ( are_equal( INPUT[momcut_idx].VALUE , "CONICAL_CUT" ) ) {
      CUTINFO -> type = CYLINDER_AND_CONICAL_CUT ; 
    } else {
      fprintf( stderr , "[IO] Unrecognised type [%s] \n" , 
	       INPUT[momcut_idx].VALUE ) ; 
      fprintf( stderr , "[IO] Defaulting to SPHERICAL_CUT \n" ) ; 
    }
  }
  // field definition
  {
    const int field_idx = tag_search( "FIELD_DEFINITION" ) ;
    if( field_idx == GLU_FAILURE ) { return tag_failure( "FIELD_DEFINITION" ) ; }
    CUTINFO -> definition = LINEAR_DEF ;
    if( are_equal( INPUT[field_idx].VALUE , "LOGARITHMIC" ) ) {
      CUTINFO -> definition = LOG_DEF ;
    } 
  }
  // minmom, maxmom angle and cylinder width
  if( setint( &( CUTINFO -> max_t ) , "MAX_T" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  if( setint( &( CUTINFO -> max_mom ) , "MAXMOM" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  if( setint( &( CUTINFO -> angle ) , "ANGLE" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // set the cylinder width
  if( setdbl( &( CUTINFO -> cyl_width ) , "CYL_WIDTH" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // look for where the output is going
  {
    const int output_idx = tag_search( "OUTPUT" ) ;
    if( output_idx == GLU_FAILURE ) { return tag_failure( "OUTPUT" ) ; }
    sprintf( CUTINFO -> where , "%s" , INPUT[output_idx].VALUE ) ; 
  }
  return GLU_SUCCESS ;
}
예제 #14
0
// get the header type
static int
header_type( header_mode *HEADINFO )
{
  // headers we support
  {
    const int header_idx = tag_search( "HEADER" ) ;
    if( header_idx == GLU_FAILURE ) { return tag_failure( "HEADER" ) ; }
    if( are_equal( INPUT[header_idx].VALUE , "NERSC" ) ) {
      fprintf( stdout , "[IO] Attempting to read a NERSC file \n" ) ;
      *HEADINFO = NERSC_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "HIREP" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read a HIREP file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      *HEADINFO = HIREP_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "MILC" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read a MILC file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      *HEADINFO = MILC_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "SCIDAC" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read a SCIDAC file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      *HEADINFO = SCIDAC_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "LIME" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read an LIME file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      fprintf( stdout , "[IO] WARNING!! NOT CHECKING ANY CHECKSUMS!! \n" ) ;
      *HEADINFO = LIME_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "ILDG_SCIDAC" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read an ILDG (Scidac) file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      *HEADINFO = ILDG_SCIDAC_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "ILDG_BQCD" ) ) {
      if( ( Latt.flow = confno( ) ) == 0 ) return GLU_FAILURE ;
      fprintf( stdout , "[IO] Attempting to read an ILDG (BQCD) file \n" ) ;
      fprintf( stdout , "[IO] Using sequence number from input file :: %zu \n" ,
	      Latt.flow ) ;
      *HEADINFO = ILDG_BQCD_HEADER ;
    } else if( are_equal( INPUT[header_idx].VALUE , "RANDOM" ) ) {
      fprintf( stdout , "[IO] Attempting to generate an SU(%d) "
	       "RANDOM config .. " , NC ) ;
      if( read_random_lattice_info( ) == GLU_FAILURE ) {
	printf( "failed\n" ) ;
	return GLU_FAILURE ;
      } else {
	printf( "succeeded\n" ) ;
      }
      *HEADINFO = RANDOM_CONFIG ;
    } else if( are_equal( INPUT[header_idx].VALUE , "UNIT" ) ) {
      fprintf( stdout , "[IO] Attempting to generate an %dx%d UNIT config \n" 
	       , NC , NC ) ;
      read_random_lattice_info( ) ;
      *HEADINFO = UNIT_GAUGE ;
    } else if( are_equal( INPUT[header_idx].VALUE , "INSTANTON" ) ) {
      fprintf( stdout , "[IO] Attempting to generate a SU(%d) BPST "
	       "instanton config \n" , NC ) ;
      if( read_random_lattice_info( ) == GLU_FAILURE ) return GLU_FAILURE ;
      *HEADINFO = INSTANTON ;
    } else {
      fprintf( stderr , "[IO] HEADER %s not recognised ... Leaving \n" , 
	       INPUT[header_idx].VALUE ) ;
      return GLU_FAILURE ;
    }
  }
  return GLU_SUCCESS ;
}