Example #1
0
	/** Finds the location / index of the uniform block specified
	 *  by @p identifier in a @p program. If active_only is true then
	 *  throws if no such uniform block exists or if it is not active.
	 *
	 *  @glsymbols
	 *  @glfunref{GetUniformLocation}
	 */
	static GLint GetLocation(
		ProgramName program,
		StrCRef identifier,
		bool active_only
	)
	{
		GLint result = OGLPLUS_GLFUNC(GetUniformBlockIndex)(
			GetGLName(program),
			identifier.c_str()
		);
		OGLPLUS_CHECK(
			GetUniformBlockIndex,
			ProgVarError,
			Program(program).
			Identifier(identifier)
		);
		OGLPLUS_HANDLE_ERROR_IF(
			active_only && (result < 0),
			GL_INVALID_OPERATION,
			MsgGettingInactive(),
			ProgVarError,
			Program(program).
			Identifier(identifier)
		);
		return result;
	}
Example #2
0
SimSubareas::SimSubareas (void) : Data_Service ()
{
	Program ("SimSubareas");
	Version (4);
	Title ("Generate Geographic Subareas");

	System_File_Type required_files [] = {
		NODE, NEW_NODE, END_FILE
	};
	System_File_Type optional_files [] = {
		END_FILE
	};
	int file_service_keys [] = {
		NOTES_AND_NAME_FIELDS, 0
	};
	Control_Key keys [] = { //--- code, key, level, status, type, default, range, help ----
		{ NUMBER_OF_SUBAREAS, "NUMBER_OF_SUBAREAS", LEVEL0, REQ_KEY, INT_KEY, "8", "1..1000", NO_HELP },
		{ PARTITIONS_PER_SUBAREA, "PARTITIONS_PER_SUBAREA", LEVEL0, OPT_KEY, INT_KEY, "1", "1..1000", NO_HELP },
		{ CENTER_NODE_NUMBER, "CENTER_NODE_NUMBER", LEVEL0, OPT_KEY, INT_KEY, "0", ">=0", NO_HELP },
		{ SUBAREA_BOUNDARY_FILE, "SUBAREA_BOUNDARY_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		END_CONTROL
	};
	Required_System_Files (required_files);
	Optional_System_Files (optional_files);
	File_Service_Keys (file_service_keys);

	Key_List (keys);

	num_subareas = num_parts = center = 0;
	subarea_field = -1;
	boundary_flag = false;
}
void OsmAnd::AtlasMapRendererSkyStage_OpenGL::release()
{
    const auto gpuAPI = getGPUAPI();

    GL_CHECK_PRESENT(glDeleteBuffers);

    if(_skyplaneIBO)
    {
        glDeleteBuffers(1, &_skyplaneIBO);
        GL_CHECK_RESULT;
        _skyplaneIBO.reset();
    }
    if(_skyplaneVBO)
    {
        glDeleteBuffers(1, &_skyplaneVBO);
        GL_CHECK_RESULT;
        _skyplaneVBO.reset();
    }
    if(_skyplaneVAO)
    {
        gpuAPI->glDeleteVertexArrays_wrapper(1, &_skyplaneVAO);
        GL_CHECK_RESULT;
        _skyplaneVAO.reset();
    }

    if(_program.id)
    {
        glDeleteProgram(_program.id);
        GL_CHECK_RESULT;
        _program = Program();
    }
}
Example #4
0
static void dump_top(FILE *fp,t_topology *top,char *tpr)
{
  int i,j,k,*types;
  
  fprintf(fp,"; Topology generated from %s by program %s\n",tpr,Program());
  fprintf(fp,"[ defaults ]\n 1 1 no 1.0 1.0\n\n");
  fprintf(fp,"[ atomtypes ]\n");
  fprintf(fp,";name  at.num    mass      charge ptype        c6        c12\n");
  snew(types,top->atomtypes.nr);
  for(i=0; (i<top->atomtypes.nr); i++) {
    for(j=0; (j<top->atoms.nr) && (top->atoms.atom[j].type != i); j++)
      ;
    if (j<top->atoms.nr) {
      types[i] = j;
      fprintf(fp,"%5s  %4d   %8.4f   %8.4f  %2s  %8.3f  %8.3f\n",
	      *(top->atoms.atomtype[j]),top->atomtypes.atomnumber[i],
	      0.0,0.0,"A",0.0,0.0);
    }
  }
  fprintf(fp,"[ nonbonded_params ]\n");
  for(i=k=0; (i<top->idef.ntypes); i++) {
    for(j=0; (j<top->idef.ntypes); j++,k++) {
      fprintf(fp,"%12s  %12s  1  %12.5e  %12.5e\n",
	      *(top->atoms.atomtype[types[i]]),
	      *(top->atoms.atomtype[types[j]]),
	      top->idef.iparams[k].lj.c12,top->idef.iparams[k].lj.c6);
    }
  }
  sfree(types);
}
//-----------------------------------------------------------------------------
Program* ProgramManager::createCpuProgram(GpuProgramType type)
{
	Program* shaderProgram = OGRE_NEW Program(type);

	mCpuProgramsList.insert(shaderProgram);

	return shaderProgram;
}
Example #6
0
int main(int argc, char* argv[]) {
	int rc;
	MPI_Init(NULL, NULL);
	//signal(SIGSEGV, handler);
	rc = Program().run(argc, argv);
	MPI_Finalize();
	return rc;
}
Example #7
0
void R9(std::vector<Dynamic>& __ret) {
	//arguments
 Dynamic  hllr__0 =  Dynamic (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        retval = Program("",(States&)hllr__0);
    
	__ret.push_back(retval);
}
 /** Finds the location of the subroutine uniform specified
  *  by @p identifier in a @p program. If active_only is true then
  *  throws if no such subroutine exists or if it is not active.
  *
  *  @glsymbols
  *  @glfunref{GetSubroutineUniformLocation}
  */
 static GLint GetLocation(
   ProgramName program,
   ShaderType stage,
   StrCRef identifier,
   bool active_only) {
     GLint result = OGLPLUS_GLFUNC(GetSubroutineUniformLocation)(
       GetGLName(program), GLenum(stage), identifier.c_str());
     OGLPLUS_CHECK(
       GetSubroutineUniformLocation,
       ProgVarError,
       Program(program).Identifier(identifier).EnumParam(stage));
     OGLPLUS_HANDLE_ERROR_IF(
       active_only && (result < 0),
       GL_INVALID_OPERATION,
       MsgGettingInactive(),
       ProgVarError,
       Program(program).Identifier(identifier).EnumParam(stage));
     return result;
 }
Example #9
0
void R8(std::vector<Dynamic>& __ret) {
	//arguments
 Dynamic  hllr__4 =  Dynamic (__ret.back()); __ret.pop_back();
Dynamic hllr__3 = __ret.back(); __ret.pop_back();
 Dynamic  hllr__2 =  Dynamic (__ret.back()); __ret.pop_back();
Dynamic hllr__1 = __ret.back(); __ret.pop_back();
 Dynamic  hllr__0 =  Dynamic (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        retval = Program((std::string&)hllr__2,(States&)hllr__4);
    
	__ret.push_back(retval);
}
Example #10
0
TPPlusNet::TPPlusNet (void) : Network_Service ()
{
	Program ("TPPlusNet");
	Version ("4.0.4");
	Title ("TPPlus Network Conversion");

	Network_File required_network [] = {
		NEW_NODE, NEW_LINK, END_NETWORK
	};

	Network_File optional_network [] = {
		NEW_DIRECTORY, NEW_SHAPE, END_NETWORK
	};

	char *keys [] = {
		TPPLUS_LINK_FILE,
		TPPLUS_LINK_FORMAT,
		TPPLUS_NODE_FILE,
		TPPLUS_NODE_FORMAT,
		TPPLUS_SPDCAP_FILE,
		TPPLUS_SPDCAP_FORMAT,
		CONVERT_MPH_TO_MPS,
		FACILITY_INDEX_FIELD,
		AREA_TYPE_INDEX_FIELD,
		CONVERSION_SCRIPT,
		EXTERNAL_ZONE_NUMBER,
		NEW_LINK_DETAIL_FILE,
		NULL
	};

	char *reports [] = {
		"CONVERSION_SCRIPT",
		"CONVERSION_STACK",
		NULL
	};

	Required_Network_Files (required_network);
	Optional_Network_Files (optional_network);

	Key_List (keys);
	Report_List (reports);

	AB_Key_Flag (true);

	proj_service.Add_Keys ();

	ext_zone = fac_fld = at_fld = 0;
	convert_flag = spdcap_flag = link_shape_flag = node_shape_flag = units_flag = detail_flag = false;

	link_array = (Link_Array *) new Link_Name_Array ();
}
Example #11
0
	/**
	 *  @glsymbols
	 *  @glfunref{UniformBlockBinding}
	 */
	void Binding(UniformBufferBindingPoint binding)
	{
		OGLPLUS_GLFUNC(UniformBlockBinding)(
			this->_program,
			this->_location,
			GLuint(binding)
		);
		OGLPLUS_VERIFY(
			UniformBlockBinding,
			ProgVarError,
			Program(ProgramName(this->_program)).
			Index(GLuint(binding))
		);
	}
    /** Finds the location / index of the subroutine specified
     *  by @p identifier in the @p stage of a @p program. If active_only
     *  is true then throws if no such subroutine exists or if it is
     *  not active.
     *
     *  @glsymbols
     *  @glfunref{GetSubroutineIndex}
     */
    static GLint GetLocation(
      ProgramName program,
      ShaderType stage,
      StrCRef identifier,
      bool active_only) {
        GLuint result = OGLPLUS_GLFUNC(GetSubroutineIndex)(
          GetGLName(program), GLenum(stage), identifier.c_str());
        OGLPLUS_CHECK(
          GetSubroutineIndex,
          ProgVarError,
          Program(program).Identifier(identifier).EnumParam(stage));
        OGLPLUS_HANDLE_ERROR_IF(
          active_only && (result == GL_INVALID_INDEX),
          GL_INVALID_OPERATION,
          MsgGettingInactive(),
          ProgVarError,
          Program(program).Identifier(identifier).EnumParam(stage));

        if(result == GL_INVALID_INDEX) {
            return -1;
        }
        return GLint(result);
    }
Example #13
0
void R7(std::vector<Dynamic>& __ret) {
	//arguments
 Dynamic  hllr__3 =  Dynamic (__ret.back()); __ret.pop_back();
Dynamic hllr__2 = __ret.back(); __ret.pop_back();
Dynamic hllr__1 = __ret.back(); __ret.pop_back();
 Dynamic  hllr__0 =  Dynamic (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        States& x = (States&)hllr__0;
        States& y = (States&)hllr__3;
        for(auto i = y.begin(); i!=y.end(); i++) x.push_back(*i);
        retval = Program("",x);
    
	__ret.push_back(retval);
}
Example #14
0
FILE *xvgropen(char *fn,char *title,char *xaxis,char *yaxis)
{
  FILE *xvgr;
  time_t t;
  
  xvgr=(FILE *)ffopen(fn,"w");
  fprintf(xvgr,"# This file was created by %s\n",Program());
  fprintf(xvgr,"# which is part of G R O M A C S:\n");
  fprintf(xvgr,"# %s\n",bromacs());
  time(&t);
  fprintf(xvgr,"# All this happened at: %s",ctime(&t));
  fprintf(xvgr,"#\n");
  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;
}
Example #15
0
Router::Router (void) : Converge_Service ()
{
	Program ("Router");
	Version (89);
	Title ("Network Path Building");

	System_File_Type optional_files [] = {
		TRIP, PLAN, SIGN, SIGNAL, TIMING_PLAN, PHASING_PLAN, DETECTOR, NEW_TURN_DELAY, NEW_RIDERSHIP, END_FILE
	};
	Control_Key keys [] = { //--- code, key, level, status, type, help ----
		{ UPDATE_PLAN_RECORDS, "UPDATE_PLAN_RECORDS", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ REROUTE_FROM_TIME_POINT, "REROUTE_FROM_TIME_POINT", LEVEL0, OPT_KEY, TIME_KEY, "0:00", "", NO_HELP },
		END_CONTROL
	};
	Optional_System_Files (optional_files);

	Converge_Service_Keys ();
	Key_List (keys);
	Report_List (reports);

	reroute_time = 0;
}
Example #16
0
ConvertTours::ConvertTours (void) : Demand_Service ()
{
	Program ("ConvertTours");
	Version ("4.0.15");
	Title ("Tour Data Conversion Utility");

	Network_File required_network [] = {
		ACTIVITY_LOCATION, PROCESS_LINK, END_NETWORK
	};

	Network_File optional_network [] = {
		DIRECTORY, LINK, ZONE, END_NETWORK
	};

	Demand_File required_demand [] = {
		NEW_TRIP, NEW_HOUSEHOLD, NEW_POPULATION, NEW_VEHICLE, END_DEMAND
	};

	Demand_File optional_demand [] = {
		TRIP, HOUSEHOLD, POPULATION, VEHICLE, VEHICLE_TYPE, END_DEMAND
	};

	char *keys [] = {
		TOUR_DATA_FILE,
		TOUR_DATA_FORMAT,
		TOUR_HOUSEHOLD_FIELD,
		TOUR_PERSON_FIELD,
		TOUR_NUMBER_FIELD,
		TOUR_PURPOSE_FIELD,
		TOUR_MODE_FIELD,
		TOUR_ORIGIN_FIELD,
		TOUR_DESTINATION_FIELD,
		TOUR_STOP_OUT_FIELD,
		TOUR_STOP_IN_FIELD,
		TOUR_START_FIELD,
		TOUR_RETURN_FIELD,
		TOUR_GROUP_FIELD,
		TOUR_GROUP_SCRIPT,
		HOUSEHOLD_LIST,
		STARTING_HOUSEHOLD_ID,
		STARTING_VEHICLE_ID,
		TIME_OF_DAY_FORMAT,
		ADDITIONAL_TRAVEL_TIME,
		ZONE_LOCATION_MAP_FILE,
		RANDOM_NUMBER_SEED,
		ZONE_EQUIVALENCE_FILE,
		TRAVEL_TIME_FILE,
		NEW_DIURNAL_FILE,
		TRIP_TIME_FILE_x,
		TRIP_TIME_FORMAT_x,
		TRIP_TIME_FIELD_x,
		TIME_PERIOD_RANGE_x,
		TIME_CONTROL_POINT_x,
		ORIGIN_WEIGHT_FIELD_x,
		DESTINATION_WEIGHT_FIELD_x,
		DISTANCE_WEIGHT_FLAG_x,
		STOP_WEIGHT_FIELD_x,
		TRIP_PURPOSE_CODE_x,
		TRAVEL_MODE_CODE_x,
		TRIP_STOP_DURATION_x,
		AVERAGE_TRAVEL_SPEED_x,
		VEHICLE_TYPE_x,
		VEHICLE_SUBTYPE_x,
		TRIP_SCALING_FACTOR_x,
		TRIP_ADJUSTMENT_FACTORS_x,
		TRIP_ADJUSTMENT_FORMAT_x,
		TIME_PERIOD_EQUIVALENCE_x,
		NULL
	};
	char *reports [] = {
		"TOUR_GROUP_SCRIPT",
		"TOUR_GROUP_STACK",
		"PRINT_ZONE_EQUIVALENCIES",
		"TIME_PERIOD_EQUIVALENCE",
		NULL
	};

	Required_Network_Files (required_network);
	Optional_Network_Files (optional_network);
	Required_Demand_Files (required_demand);
	Optional_Demand_Files (optional_demand);

	Key_List (keys);
	Report_List (reports);

	equiv_flag = skim_flag = zone_flag = script_flag = diurnal_flag = zone_loc_flag = hhlist_flag = false;

	num_zone = 0;
	additional_time = 600;
	num_trip = tot_trips = tot_errors = nhhold = nperson = 0;
	tot_add = tot_del = 0.0;
	skim_ptr = NULL;

	trip_copy = hhold_copy = pop_copy = veh_copy = 0;
	max_hh_in = max_veh_in = max_hhlist = 0;

	location_array = (Location_Array *) new Convert_Location_Array ();
}
Example #17
0
void PerfPrep::Program_Control (void)
{
	String key;
	Strings list;
	Str_Itr str_itr;

	//---- open network files ----

	Data_Service::Program_Control ();
	
	Read_Select_Keys ();
	Read_Flow_Time_Keys ();

	Print (2, String ("%s Control Keys:") % Program ());

	new_file_flag = System_File_Flag (NEW_PERFORMANCE);

	//---- open the merge performance ----
	
	key = Get_Control_String (MERGE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		merge_file.File_Type ("Merge Performance File");
		Print (1);

		if (Check_Control_Key (MERGE_PERFORMANCE_FORMAT)) {
			merge_file.Dbase_Format (Get_Control_String (MERGE_PERFORMANCE_FORMAT));
		}
		merge_file.Open (Project_Filename (key));
		merge_flag = true;

		if (!new_file_flag) {
			Error ("A New Performance File is required for Merge Processing");
		}
	}

	//---- open the base performance ----
	
	key = Get_Control_String (BASE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		base_file.File_Type ("Base Performance File");
		Print (1);

		if (Check_Control_Key (BASE_PERFORMANCE_FORMAT)) {
			base_file.Dbase_Format (Get_Control_String (BASE_PERFORMANCE_FORMAT));
		}
		base_file.Open (Project_Filename (key));
		base_flag = true;

		if (!new_file_flag) {
			Error ("A New Performance File is required for Base Processing");
		}
	}

	//---- open the merge turn delay ----

	turn_flag = System_File_Flag (TURN_DELAY);

	if (turn_flag) {
		key = Get_Control_String (MERGE_TURN_DELAY_FILE);

		if (!key.empty ()) {
			turn_file.File_Type ("Merge Turn Delay File");
			Print (1);

			if (Check_Control_Key (MERGE_TURN_DELAY_FORMAT)) {
				turn_file.Dbase_Format (Get_Control_String (MERGE_TURN_DELAY_FORMAT));
			}
			turn_file.Open (Project_Filename (key));
			turn_merge_flag = true;

			if (!System_File_Flag (NEW_TURN_DELAY)) {
				Error ("A New Turn Delay File is required for Merge Processing");
			}
		}
	}

	//---- processing method ----

	Print (1);
	key = Get_Control_Text (PROCESSING_METHOD);

	if (!key.empty ()) {
		method = Combine_Code (key);

		if (method != UPDATE_TIMES) {
			if (merge_flag || turn_merge_flag) {
				if (method == WEIGHTED_LINK_AVG || method == REPLACE_AVERAGE) {

					//---- merge weighting factor ----

					factor = Get_Control_Double (MERGE_WEIGHTING_FACTOR);
				}
			} else {
				//Error (String ("Processing Method %s requires Merge Files") % key);
			}
		}
	}

	//---- read the smoothing parameters ----

	smooth_flag = smooth_data.Read_Control ();

	if (smooth_flag) {
		if (!smooth_data.Num_Input (time_periods.Num_Periods ())) {
			Error ("Smooth Parameters are Illogical");
		}
		if (!new_file_flag) {
			Error ("A New Performance File is required for Data Smoothing");
		}
	}

	//---- set min travel time ----

	min_time_flag = Get_Control_Flag (SET_MIN_TRAVEL_TIME);

	if (min_time_flag && !new_file_flag) {
		Error ("A New Performance File is required for Minimum Travel Times");
	}

	//---- set merge transit data ----

	key = Get_Control_Text (MERGE_TRANSIT_DATA);

	if (!key.empty ()) {
		transit_flag = true;

		if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) ||
			!System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER)) {

			Error ("Transit Network Files are Required for Transit Loading");
		}
		if (!new_file_flag) {
			Error ("A New Performance File is required to Merge Transit Data");
		}
		key.Parse (list);
		for (str_itr = list.begin (); str_itr != list.end (); str_itr++) {
			if (str_itr->Starts_With ("VEH")) {
				transit_veh_flag = true;
			} else if (str_itr->Starts_With ("PER")) {
				transit_person_flag = true;
			} else if (str_itr->Starts_With ("PCE") || str_itr->Starts_With ("CAR_EQ")) {
				transit_pce_flag = true;
			}
		}
		if (!System_File_Flag (VEHICLE_TYPE) && transit_pce_flag) {
			Warning ("Vehicle Type File is Required for Transit PCE Loading");
		}
		if (!System_File_Flag (RIDERSHIP) && transit_person_flag) {
			Warning ("Ridership File is Required for Transit Person Loading");
		}
		if (!merge_flag) {
			method = Combine_Code (Get_Control_Text (PROCESSING_METHOD));
		}
	}

	//---- open the time constraint file ----
	
	key = Get_Control_String (TIME_CONSTRAINT_FILE);

	if (!key.empty ()) {
		constraint_file.File_Type ("Time Constraint File");
		Print (1);

		if (Check_Control_Key (TIME_CONSTRAINT_FORMAT)) {
			constraint_file.Dbase_Format (Get_Control_String (TIME_CONSTRAINT_FORMAT));
		}
		constraint_file.Open (Project_Filename (key));
		constraint_flag = true;
	}

	//---- open the time ratio file ----
	
	key = Get_Control_String (NEW_TIME_RATIO_FILE);

	if (!key.empty ()) {
		time_ratio_file.File_Type ("New Time Ratio File");

		time_ratio_file.Create (Project_Filename (key));
		time_ratio_flag = true;
	}

	//---- open the deleted record file ----
	
	key = Get_Control_String (NEW_DELETED_RECORD_FILE);

	if (!key.empty ()) {
		deleted_file.File_Type ("New Deleted Record File");
		Print (1);

		if (Check_Control_Key (NEW_DELETED_RECORD_FORMAT)) {
			deleted_file.Dbase_Format (Get_Control_String (NEW_DELETED_RECORD_FORMAT));
		}
		deleted_file.Create (Project_Filename (key));
		del_file_flag = true;
	}

	List_Reports ();

	first_delete = deleted_flag = (Report_Flag (DELETED_RECORDS) || del_file_flag);
}
Example #18
0
Validate::Validate (void) : Data_Service ()
{
	Program ("Validate");
	Version (17);
	Title ("Compare Volumes to Counts");

	System_File_Type required_files [] = {
		NODE, LINK, END_FILE
	};
	System_File_Type optional_files [] = {
		ZONE, SHAPE, POCKET, CONNECTION, ACCESS_LINK, LOCATION, PARKING, LANE_USE, 
		SIGN, SIGNAL, TIMING_PLAN, PHASING_PLAN, DETECTOR, 
		TRANSIT_STOP, TRANSIT_ROUTE, TRANSIT_SCHEDULE, TRANSIT_DRIVER, VEHICLE_TYPE,
		TURN_PENALTY, PERFORMANCE, TURN_DELAY, RIDERSHIP, END_FILE
	};
	int file_service_keys [] = {
		NOTES_AND_NAME_FIELDS, SAVE_LANE_USE_FLOWS, LINK_EQUIVALENCE_FILE, ZONE_EQUIVALENCE_FILE, 
		STOP_EQUIVALENCE_FILE, LINE_EQUIVALENCE_FILE, 0
	};
	int data_service_keys [] = {
		DAILY_WRAP_FLAG, SUMMARY_TIME_RANGES, SUMMARY_TIME_INCREMENT, LINK_BEARING_WARNINGS, 0
	};
	Control_Key validate_keys [] = { //--- code, key, level, status, type, default, range, help ----
		{ INPUT_VOLUME_FILE, "INPUT_VOLUME_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ TRAFFIC_COUNT_FILE, "TRAFFIC_COUNT_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ TURN_VOLUME_FILE, "TURN_VOLUME_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ TURN_COUNT_FILE, "TURN_COUNT_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ LINE_GROUP_COUNT_FILE, "LINK_GROUP_COUNT_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP},
		{ STOP_GROUP_COUNT_FILE, "STOP_GROUP_COUNT_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_VOLUME_FILE, "NEW_VOLUME_FILE", LEVEL0, OPT_KEY,  OUT_KEY, "", FILE_RANGE, NO_HELP},
		{ NEW_VOLUME_COUNT_FILE, "NEW_VOLUME_COUNT_FILE", LEVEL0, OPT_KEY,  OUT_KEY, "", FILE_RANGE, NO_HELP},
		{ ANALYSIS_METHOD, "ANALYSIS_METHOD", LEVEL0, OPT_KEY, TEXT_KEY, "VOLUME", "VOLUME, VMT, VKT", NO_HELP },
		{ ENTRY_DATA_FLAG, "ENTRY_DATA_FLAG", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ ADJUSTMENT_FACTOR, "ADJUSTMENT_FACTOR", LEVEL0, OPT_KEY, FLOAT_KEY, "1.0", "0.05..10.0", NO_HELP },
		{ FACILITY_TYPE_LABELS, "FACILITY_TYPE_LABELS", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP},
		{ AREA_TYPE_LABELS, "AREA_TYPE_LABELS", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ CHECK_NETWORK_FLAG, "CHECK_NETWORK_FLAG", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ NEW_PROBLEM_NODE_FILE, "NEW_PROBLEM_NODE_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_PROBLEM_LINK_FILE, "NEW_PROBLEM_LINK_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_PROBLEM_COORDINATE_FILE, "NEW_PROBLEM_COORDINATE_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		END_CONTROL
	};
	const char *reports [] = {
		"VOLUME_LEVEL_SUMMARY",
		"FACILITY_TYPE_SUMMARY",
		"AREA_TYPE_SUMMARY",
		"ZONE_GROUP_SUMMARY",
		"ZONE_AT_FT_SUMMARY",
		"LINK_GROUP_SUMMARY",
		"LINK_GROUP_DETAILS",
		"TURN_MOVEMENT_SUMMARY",
		"TURN_LEVEL_OF_SERVICE",
		"ZONE_EQUIVALENCE",
		"LINK_EQUIVALENCE",
		"LINE_GROUP_SUMMARY",
		"STOP_GROUP_SUMMARY",
		"BOARDING_GROUP_SUMMARY",
		"ALIGHTING_GROUP_SUMMARY",
		"LINE_EQUIVALENCE",
		"STOP_EQUIVALENCE",
		""
	};
	Required_System_Files (required_files);
	Optional_System_Files (optional_files);
	File_Service_Keys (file_service_keys);
	Data_Service_Keys (data_service_keys);
	
	Sum_Flow_Flag (true);
	Key_List (validate_keys);
	Report_List (reports);

	Page_Size (120, 47);

	problem_node_flag = problem_link_flag = problem_coord_flag = cnt_dir_flag = false;
	delay_flag = link_flag = turn_flag = output_flag = zone_flag = method = entry_flag = false;
	line_flag = stop_flag = vc_flag = check_net_flag = false;
	factor = 1.0;
	hours = 1.0;

	compass.Set_Points (8);
	
	System_Read_False (PERFORMANCE);

	stats_format = "\n%25.25s %7d%10.0lf%10.0lf%9.0lf %7.1lf %7.0lf %6.1lf %7.0lf %6.1lf %6.3lf%6.2lf%6.2lf";
}
Example #19
0
LocationData::LocationData (void) : Data_Service ()
{
	Program ("LocationData");
	Version (2);
	Title ("Activity Location Data Processor");

	System_File_Type required_files [] = {
		NODE, LINK, LOCATION, NEW_LOCATION, END_FILE
	};
	System_File_Type optional_files [] = {
		SHAPE, ZONE, ACCESS_LINK, PARKING, TRANSIT_STOP, TRANSIT_ROUTE, TRANSIT_SCHEDULE, END_FILE
	};
	int file_service_keys [] = {
		NOTES_AND_NAME_FIELDS, 0
	};
	Control_Key locationdata_keys [] = { //--- code, key, level, status, type, default, range, help ----
		{ COPY_EXISTING_FIELDS, "COPY_EXISTING_FIELDS", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ NEW_WALK_ACCESS_FIELD, "NEW_WALK_ACCESS_FIELD", LEVEL0, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ MAX_WALK_DISTANCE, "MAX_WALK_DISTANCE", LEVEL0, OPT_KEY, INT_KEY, "3000 feet", "30..10000 feet", NO_HELP },
		{ WALK_ACCESS_TIME_RANGE, "WALK_ACCESS_TIME_RANGE", LEVEL0, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ NEW_USE_FLAG_FIELD, "NEW_USE_FLAG_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ LINK_USE_FLAG_TYPES, "LINK_USE_FLAG_TYPES", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ SUBZONE_ZONE_FACTOR_FILE, "SUBZONE_ZONE_FACTOR_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_SUBZONE_FIELD, "NEW_SUBZONE_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "NAME, INTEGER, 10", NO_HELP },
		{ MAX_SUBZONE_DISTANCE, "MAX_SUBZONE_DISTANCE", LEVEL1, OPT_KEY, INT_KEY, "3000 feet", "0, 30..32000 feet", NO_HELP },
		{ SUBZONE_DATA_FILE, "SUBZONE_DATA_FILE", LEVEL1, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ SUBZONE_DATA_FORMAT, "SUBZONE_DATA_FORMAT", LEVEL1, OPT_KEY, TEXT_KEY, "TAB_DELIMITED", FORMAT_RANGE, FORMAT_HELP  },
		{ SUBZONE_DATA_FIELD, "SUBZONE_DATA_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ SUBZONE_ZONE_FIELD, "SUBZONE_ZONE_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ NEW_LOCATION_FIELD, "NEW_LOCATION_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "NAME, INTEGER, 10", NO_HELP },
		{ CONVERSION_SCRIPT, "CONVERSION_SCRIPT", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ DATA_FILE, "DATA_FILE", LEVEL1, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ DATA_FORMAT, "DATA_FORMAT", LEVEL1, OPT_KEY, TEXT_KEY, "TAB_DELIMITED", FORMAT_RANGE, FORMAT_HELP  },
		{ DATA_JOIN_FIELD, "DATA_JOIN_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ LOCATION_JOIN_FIELD, "LOCATION_JOIN_FIELD", LEVEL1, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ BOUNDARY_POLYGON_FILE, "BOUNDARY_POLYGON_FILE", LEVEL1, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_ZONE_LOCATION_MAP_FILE, "NEW_ZONE_LOCATION_MAP_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ MINIMUM_ZONE_LOCATIONS, "MINIMUM_ZONE_LOCATIONS", LEVEL0, OPT_KEY, INT_KEY, "4", "2..20", NO_HELP },
		{ ZONE_BOUNDARY_FILE, "ZONE_BOUNDARY_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
		{ ZONE_FIELD_NAME, "ZONE_FIELD_NAME", LEVEL0, OPT_KEY, TEXT_KEY, "", "", NO_HELP },
		{ ZONE_UPDATE_RANGE, "ZONE_UPDATE_RANGE", LEVEL0, OPT_KEY, LIST_KEY, "ALL", RANGE_RANGE, NO_HELP },
		END_CONTROL
	};
	const char *reports [] = {
		"CONVERSION_SCRIPT",
		"CONVERSION_STACK",
		"CHECK_ZONE_COVERAGE",
		""
	};
	Required_System_Files (required_files);
	Optional_System_Files (optional_files);
	File_Service_Keys (file_service_keys);

	Key_List (locationdata_keys);
	Report_List (reports);
	Location_XY_Flag (true);

	projection.Add_Keys ();

	copy_flag = false;
	walk_access_flag = walk_time_flag = false;
	walk_access_field = 0;
	walk_distance = 1000;

	num_data_files = 0;
	data_flag = false;

	zone_file_flag = subzone_map_flag = subzone_flag = false;
	num_subzone = 0;
	script_flag = zone_file_flag = range_flag = false;

	use_flag = false;

	boundary_flag = coverage_flag = zone_loc_flag = false;
	zone_field = 0;
	min_locations = 4;

	num_polygons = 0;
	polygon_flag = false;
}
Example #20
0
File: main.cpp Project: mystor/cppi
int main(int argc, const char * argv[]) {
    // Usage Message (TODO: Improve)
    if (argc < 3) {
        std::cerr << "Usage: " << argv[0] << " <FileName>\n"
                  << "Compiles the file given by <FileName>\n";
        return 1;
    }

    // Read in the file passed as the first argument
    std::ifstream fileStream;
    fileStream.open(argv[1]);

    // We'll output to the file passed in as the second argument
    std::error_code ec;
    auto openflags = llvm::sys::fs::F_None;
    auto out = std::make_unique<llvm::tool_output_file>(argv[2], ec, openflags);

    if (ec) {
        std::cerr << argv[0] << ": " << ec.message() << "\n";
        return 1;
    }

    // Parse it!
    auto lex = Lexer(&fileStream);
    auto stmts = parse(&lex);

    // std::cout << "Result of parsing: \n";
    // for (auto &stmt : stmts) {
    //     std::cout << *stmt << ";\n";
    // }

    auto prgm = Program();
    prgm.addItems(stmts);
    prgm.finalize();

    auto mod = prgm.module;

    /* DEBUG */
    // mod->dump();

    llvm::InitializeNativeTarget();
    llvm::InitializeNativeTargetAsmPrinter();
    llvm::InitializeNativeTargetAsmParser();

    llvm::PassRegistry *registry = llvm::PassRegistry::getPassRegistry();
    llvm::initializeCore(*registry);
    llvm::initializeCodeGen(*registry);
    llvm::initializeLoopStrengthReducePass(*registry);
    llvm::initializeLowerIntrinsicsPass(*registry);
    llvm::initializeUnreachableBlockElimPass(*registry);

    llvm::Triple targetTriple(mod->getTargetTriple());
    if (targetTriple.getTriple().empty()) {
        targetTriple.setTriple(llvm::sys::getDefaultTargetTriple());
    }

    std::cout << "Target Triple: " << targetTriple.getTriple() << "\n";

    std::string error;
    const llvm::Target *target = llvm::TargetRegistry::lookupTarget("", targetTriple, error);
    if (! target) {
        std::cerr << argv[0] << ": " << error;
        return 1;
    }

    auto optLvl = llvm::CodeGenOpt::Default;
    switch ('0') { // TEmporary
    default:
        std::cerr << argv[0] << ": invalid optimization level.\n";
        return 1;
    case ' ': break;
    case '0': optLvl = llvm::CodeGenOpt::None; break;
    case '1': optLvl = llvm::CodeGenOpt::Less; break;
    case '2': optLvl = llvm::CodeGenOpt::Default; break;
    case '3': optLvl = llvm::CodeGenOpt::Aggressive; break;
    }

    // llvm::TargetOptions options;
    // TODO: llc line 268

    std::unique_ptr<llvm::TargetMachine> targetMachine(target->createTargetMachine(targetTriple.getTriple(),
                                                                                   llvm::sys::getHostCPUName(),
                                                                                   "",
                                                                                   llvm::TargetOptions(),
                                                                                   llvm::Reloc::Default,
                                                                                   llvm::CodeModel::Default,
                                                                                   optLvl));
    assert(targetMachine && "Could not allocate target machine!");

    llvm::PassManager passmanager;
    llvm::TargetLibraryInfo *TLI = new llvm::TargetLibraryInfo(targetTriple);
    passmanager.add(TLI);

    if (const llvm::DataLayout *datalayout = targetMachine->getSubtargetImpl()->getDataLayout())
        mod->setDataLayout(datalayout);

    llvm::formatted_raw_ostream ostream(out->os());

    // Ask the target to add backend passes as necessary.
    if (targetMachine->addPassesToEmitFile(passmanager, ostream, llvm::TargetMachine::CGFT_ObjectFile)) {
        std::cerr << argv[0] << ": target does not support generation of this"
                  << " file type!\n";
        return 1;
    }

    passmanager.run(*mod);

    out->keep();

    return 0;
}
Example #21
0
void ArcSnapshot::Program_Control (void)
{
	int i;
	String key, text;
	bool z_flag, m_flag;

	string method_text [] = { "AT_INCREMENT", "TOTAL", "MAXIMUM", "" };

	Set_Range_String (SUMMARY_TIME_INCREMENT, "0.0..1440.0");

	//---- open network files ----

	Data_Service::Program_Control ();

	Read_Select_Keys ();

	max_time = Model_End_Time ();

	//---- get the projection data ----

	project_flag = projection.Read_Control ();

	//---- get the z coordinate flag ----

	m_flag = projection.M_Flag ();
	z_flag = projection.Z_Flag ();

	//---- open the snapshot file ----

	Print (2, String ("%s Control Keys:") % Program ());

	key = Get_Control_String (SNAPSHOT_FILE);

	if (!key.empty ()) {
		if (Check_Control_Key (SNAPSHOT_FORMAT)) {
			snapshot_file.Dbase_Format (Get_Control_String (SNAPSHOT_FORMAT));
		}
		snapshot_file.Open (Project_Filename (key));
	} else {
		key = Get_Control_String (OCCUPANCY_FILE);

		if (key.empty ()) {
			Error ("A Snapshot or Occupancy file is Required");
		}
		if (Check_Control_Key (OCCUPANCY_FORMAT)) {
			occupancy_file.Dbase_Format (Get_Control_String (OCCUPANCY_FORMAT));
		}
		occupancy_file.Open (Project_Filename (key));
		occupancy_flag = true;
	}

	//---- get the arcview snapshot file ----

	key = Get_Control_String (NEW_ARC_SNAPSHOT_FILE);
	if (!key.empty ()) {
		if (key.Ends_With (".shp")) {
			key.Split_Last (text, ".");
		}
		shapename = Project_Filename (key);
		text = shapename + "_time_of_day.shp";

		Print_Filename (2, "New Arc Snapshot File", text);
		snapshot_flag = true;
	}

	//---- new snapshot file ----

	key = Get_Control_String (NEW_SNAPSHOT_FILE);

	if (!key.empty ()) {
		Print (1);
		if (Check_Control_Key (NEW_SNAPSHOT_FORMAT)) {
			new_snapshot_file.Dbase_Format (Get_Control_String (NEW_SNAPSHOT_FORMAT));
		}
		new_snapshot_file.Location_Flag (true);

		new_snapshot_file.Create (Project_Filename (key));
		output_flag = true;

		if (project_flag) {
			project_coord.Set_Projection (projection.Input_Projection (), projection.Output_Projection ());
		}
	}

	//---- new link summary file ----

	key = Get_Control_String (NEW_LINK_SUMMARY_FILE);

	if (!key.empty ()) {
		if (occupancy_flag) {
			Error ("New Link Summary File requires a Snapshot File");
		}
		Print (1);
		summary_file.File_Type ("Link Summary File");
		
		if (Check_Control_Key (NEW_LINK_SUMMARY_FORMAT)) {
			summary_file.Dbase_Format (Get_Control_String (NEW_LINK_SUMMARY_FORMAT));
		}
		sum_flag = true;

		summary_file.Create (Project_Filename (key));
	}
	if (!snapshot_flag && !output_flag && !sum_flag) {
		Error ("An Arcview Snapshot, New Snapshot, or New Link Summary File is Required");
	}

	//---- cell size ----
		
	cell_size = Get_Control_Double (CELL_SIZE);

	//---- lane width ----

	Read_Draw_Keys ();

	//---- draw vehicle shapes ----

	if (snapshot_flag && !shape_flag) {
		circle_flag = Get_Control_Flag (ADD_PASSENGER_CIRCLE_SIZE);
		square_flag = Get_Control_Flag (ADD_PASSENGER_SQUARE_SIZE);
	}

	//---- pad file time labels ----

	pad_flag = Get_Control_Flag (PAD_FILE_TIME_LABEL);

	//---- get the time processing method ----

	key = Get_Control_Text (TIME_PROCESSING_METHOD);

	if (!key.empty ()) {
		for (i=0; (int) method_text [i].size () > 0; i++) {
			if (key.Equals (method_text [i])) {
				method = i;
				break;
			}
		}
		if ((int) method_text [i].size () == 0) {
			Error (String ("Unrecognized Time Processing Method = %s") % key);
		}
		if (!occupancy_flag && method == TOTAL) {
			Error ("Snapshot Files cannot be Totaled");
		}
	}

	//---- initialize the shape file ----

	arcview_snapshot.File_Type ("New Arc Snapshot File");
	arcview_snapshot.File_Access (CREATE);
	arcview_snapshot.Shape_Type ((shape_flag) ? POLYGON : DOT);
	arcview_snapshot.Z_Flag (z_flag);
	arcview_snapshot.M_Flag (m_flag);

	if (occupancy_flag) {
		arcview_snapshot.Replicate_Fields (&occupancy_file);
		arcview_snapshot.LinkDir_Type ((Direction_Type) occupancy_file.LinkDir_Type ());

		link_field = occupancy_file.Link_Field ();
		dir_field = occupancy_file.Dir_Field ();
		start_field = occupancy_file.Start_Field ();
		end_field = occupancy_file.End_Field ();
		lane_field = occupancy_file.Lane_Field ();
		offset_field = occupancy_file.Offset_Field ();
		occ_field = occupancy_file.Occupancy_Field ();
		type_field = -1;
	} else {
		Snapshot_File *file = &snapshot_file;
		if (file->Compress_Flag ()) {
			dummy_snapshot.Status_Flag ();
			dummy_snapshot.Create_Fields ();
			file = &dummy_snapshot;
		}
		arcview_snapshot.Replicate_Fields (file);
		arcview_snapshot.LinkDir_Type ((Direction_Type) file->LinkDir_Type ());

		link_field = file->Link_Field ();
		dir_field = file->Dir_Field ();
		lane_field = file->Lane_Field ();
		offset_field = file->Offset_Field ();
		type_field = file->Type_Field ();
		cell_field = file->Cell_Field ();
		occ_field = start_field = end_field = -1;

		if (circle_flag) {
			arcview_snapshot.Add_Field ("RADIUS", DB_DOUBLE, 14.2);
			circle_field = arcview_snapshot.Field_Number ("RADIUS");
		}
		if (square_flag) {
			arcview_snapshot.Add_Field ("SQUARE", DB_DOUBLE, 14.2);
			square_field = arcview_snapshot.Field_Number ("SQUARE");
		}
	}
	arcview_snapshot.Set_Projection (projection.Input_Projection (), projection.Output_Projection ());
}
Example #22
0
PlanCompare::PlanCompare (void) : Data_Service (), Select_Service ()
{
	Program ("PlanCompare");
	Version (3);
	Title ("Travel Plan Comparison Utility");

	System_File_Type required_files [] = {
		PLAN, END_FILE
	};
	System_File_Type optional_files [] = {
		SELECTION, NEW_SELECTION, NEW_PLAN, END_FILE
	};
	int data_service_keys [] = {
		DAILY_WRAP_FLAG, SUMMARY_TIME_RANGES, SUMMARY_TIME_INCREMENT, PERIOD_CONTROL_POINT, 0
	};
	int select_service_keys [] = {
		SELECT_HOUSEHOLDS, SELECT_MODES, SELECT_PURPOSES, SELECT_START_TIMES, SELECT_END_TIMES, 
		SELECT_ORIGINS, SELECT_DESTINATIONS, SELECT_VEHICLE_TYPES, SELECT_TRAVELER_TYPES, 
		SELECT_LINKS, SELECT_NODES, SELECT_SUBAREAS, SELECTION_POLYGON, 
		PERCENT_TIME_DIFFERENCE, MINIMUM_TIME_DIFFERENCE, MAXIMUM_TIME_DIFFERENCE, 
		PERCENT_COST_DIFFERENCE, MINIMUM_COST_DIFFERENCE, MAXIMUM_COST_DIFFERENCE, 
		PERCENT_PATH_DIFFERENCE, MINIMUM_PATH_DIFFERENCE, MAXIMUM_PATH_DIFFERENCE, 
		SELECTION_PERCENTAGE, MAXIMUM_PERCENT_SELECTED, 
		DELETION_FILE, DELETION_FORMAT, DELETE_HOUSEHOLDS, DELETE_MODES, DELETE_TRAVELER_TYPES, 0
	};
	Control_Key keys [] = { //--- code, key, level, status, type, default, range, help ----
		{ COMPARE_PLAN_FILE, "COMPARE_PLAN_FILE", LEVEL0, REQ_KEY, IN_KEY, "", PARTITION_RANGE, NO_HELP },
		{ COMPARE_PLAN_FORMAT, "COMPARE_PLAN_FORMAT", LEVEL0, OPT_KEY, TEXT_KEY, "TAB_DELIMITED", FORMAT_RANGE, FORMAT_HELP },
		{ COMPARE_GENERALIZED_COSTS, "COMPARE_GENERALIZED_COSTS", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ SELECTION_METHOD, "SELECTION_METHOD", LEVEL0, OPT_KEY, TEXT_KEY, "RANDOM", SELECT_METHOD_RANGE, NO_HELP },
		{ MERGE_PLAN_FILES, "MERGE_PLAN_FILES", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
		{ TIME_DISTRIBUTION_MINIMUM, "TIME_DISTRIBUTION_MINIMUM", LEVEL0, OPT_KEY, TIME_KEY, "-60 minutes", "-360..0", NO_HELP },
		{ TIME_DISTRIBUTION_COUNT, "TIME_DISTRIBUTION_COUNT", LEVEL0, OPT_KEY, INT_KEY, "151", "50..500", NO_HELP },
		{ TIME_DISTRIBUTION_INCREMENT, "TIME_DISTRIBUTION_INCREMENT", LEVEL0, OPT_KEY, TIME_KEY, "1 minute", "1..60 minutes", NO_HELP },
		{ COST_DISTRIBUTION_MINIMUM, "COST_DISTRIBUTION_MINIMUM", LEVEL0, OPT_KEY, INT_KEY, "-360 impedance", "-360..0 impedance", NO_HELP },
		{ COST_DISTRIBUTION_COUNT, "COST_DISTRIBUTION_COUNT", LEVEL0, OPT_KEY, INT_KEY, "151", "50..500", NO_HELP },
		{ COST_DISTRIBUTION_INCREMENT, "COST_DISTRIBUTION_INCREMENT", LEVEL0, OPT_KEY, INT_KEY, "5 impedance", "1..500", NO_HELP },
		{ NEW_TIME_DISTRIBUTION_FILE, "NEW_TIME_DISTRIBUTION_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_COST_DISTRIBUTION_FILE, "NEW_COST_DISTRIBUTION_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_TRIP_TIME_GAP_FILE, "NEW_TRIP_TIME_GAP_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_TRIP_COST_GAP_FILE, "NEW_TRIP_COST_GAP_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", FILE_RANGE, NO_HELP },
		{ NEW_TRIP_MATCH_FILE, "NEW_TRIP_MATCH_FILE", LEVEL0, OPT_KEY, OUT_KEY, "", PARTITION_RANGE, NO_HELP },
		{ NEW_TRIP_MATCH_FORMAT, "NEW_TRIP_MATCH_FORMAT", LEVEL0, OPT_KEY, TEXT_KEY, "TAB_DELIMITED", FORMAT_RANGE, FORMAT_HELP },
		END_CONTROL
	};
	const char *reports [] = {
		"TOTAL_TIME_DISTRIBUTION",
		"PERIOD_TIME_DISTRIBUTIONS",
		"TOTAL_TIME_SUMMARY",
		"PERIOD_TIME_SUMMARY",
		"TOTAL_COST_DISTRIBUTION",
		"PERIOD_COST_DISTRIBUTIONS",
		"TOTAL_COST_SUMMARY",
		"PERIOD_COST_SUMMARY",
		"TRIP_TIME_GAP_REPORT",
		"TRIP_COST_GAP_REPORT",
		""
	};
	Required_System_Files (required_files);
	Optional_System_Files (optional_files);
	Data_Service_Keys (data_service_keys);
	Select_Service_Keys (select_service_keys);

	Key_List (keys);
	Report_List (reports);
	Enable_Partitions (true);

#ifdef THREADS
	Enable_Threads (true);
#endif
#ifdef MPI_EXE
	Enable_MPI (true);
#endif

	select_flag = cost_flag = time_sum_flag = cost_sum_flag = time_gap_flag = cost_gap_flag = merge_flag = false;
	select_parts = time_sort = match_flag = false;
	method = RANDOM_METHOD;
	num_trips = num_select = 0;

	cost_diff.Cost_Flag (true);
	cost_gap.Cost_Flag (true);

	System_Read_False (PLAN);
	System_Data_Reserve (PLAN, 0);
}
Example #23
0
int cmain(int argc, char *argv[])
{
    const char        *desc[] = {
        "[TT]g_x2top[tt] generates a primitive topology from a coordinate file.",
        "The program assumes all hydrogens are present when defining",
        "the hybridization from the atom name and the number of bonds.",
        "The program can also make an [TT].rtp[tt] entry, which you can then add",
        "to the [TT].rtp[tt] database.[PAR]",
        "When [TT]-param[tt] is set, equilibrium distances and angles",
        "and force constants will be printed in the topology for all",
        "interactions. The equilibrium distances and angles are taken",
        "from the input coordinates, the force constant are set with",
        "command line options.",
        "The force fields somewhat supported currently are:[PAR]",
        "G53a5  GROMOS96 53a5 Forcefield (official distribution)[PAR]",
        "oplsaa OPLS-AA/L all-atom force field (2001 aminoacid dihedrals)[PAR]",
        "The corresponding data files can be found in the library directory",
        "with name [TT]atomname2type.n2t[tt]. Check Chapter 5 of the manual for more",
        "information about file formats. By default, the force field selection",
        "is interactive, but you can use the [TT]-ff[tt] option to specify",
        "one of the short names above on the command line instead. In that",
        "case [TT]g_x2top[tt] just looks for the corresponding file.[PAR]",
    };
    const char        *bugs[] = {
        "The atom type selection is primitive. Virtually no chemical knowledge is used",
        "Periodic boundary conditions screw up the bonding",
        "No improper dihedrals are generated",
        "The atoms to atomtype translation table is incomplete ([TT]atomname2type.n2t[tt] file in the data directory). Please extend it and send the results back to the GROMACS crew."
    };
    FILE              *fp;
    t_params           plist[F_NRE];
    t_excls           *excls;
    t_atoms           *atoms; /* list with all atoms */
    gpp_atomtype_t     atype;
    t_nextnb           nnb;
    t_nm2type         *nm2t;
    t_mols             mymol;
    gmx_atomprop_t     aps;
    int                nnm;
    char               title[STRLEN], forcefield[32], ffdir[STRLEN];
    rvec              *x; /* coordinates? */
    int               *nbonds, *cgnr;
    int                bts[] = { 1, 1, 1, 2 };
    matrix             box;    /* box length matrix */
    int                natoms; /* number of atoms in one molecule  */
    int                nres;   /* number of molecules? */
    int                i, j, k, l, m, ndih;
    int                epbc;
    gmx_bool           bRTP, bTOP, bOPLS;
    t_symtab           symtab;
    real               cutoff, qtot, mtot;
    char               n2t[STRLEN];
    output_env_t       oenv;

    t_filenm           fnm[] = {
        { efSTX, "-f", "conf", ffREAD  },
        { efTOP, "-o", "out",  ffOPTWR },
        { efRTP, "-r", "out",  ffOPTWR }
    };
#define NFILE asize(fnm)
    static real        scale = 1.1, kb = 4e5, kt = 400, kp = 5;
    static t_restp     rtp_header_settings;
    static gmx_bool    bRemoveDihedralIfWithImproper = FALSE;
    static gmx_bool    bGenerateHH14Interactions     = TRUE;
    static gmx_bool    bKeepAllGeneratedDihedrals    = FALSE;
    static int         nrexcl                        = 3;
    static gmx_bool    bParam                        = TRUE, bRound = TRUE;
    static gmx_bool    bPairs                        = TRUE, bPBC = TRUE;
    static gmx_bool    bUsePDBcharge                 = FALSE, bVerbose = FALSE;
    static const char *molnm                         = "ICE";
    static const char *ff                            = "oplsaa";
    t_pargs            pa[]                          = {
        { "-ff",     FALSE, etSTR, {&ff},
          "Force field for your simulation. Type \"select\" for interactive selection." },
        { "-v",      FALSE, etBOOL, {&bVerbose},
          "Generate verbose output in the top file." },
        { "-nexcl", FALSE, etINT,  {&nrexcl},
          "Number of exclusions" },
        { "-H14",    FALSE, etBOOL, {&bGenerateHH14Interactions},
          "Use 3rd neighbour interactions for hydrogen atoms" },
        { "-alldih", FALSE, etBOOL, {&bKeepAllGeneratedDihedrals},
          "Generate all proper dihedrals" },
        { "-remdih", FALSE, etBOOL, {&bRemoveDihedralIfWithImproper},
          "Remove dihedrals on the same bond as an improper" },
        { "-pairs",  FALSE, etBOOL, {&bPairs},
          "Output 1-4 interactions (pairs) in topology file" },
        { "-name",   FALSE, etSTR,  {&molnm},
          "Name of your molecule" },
        { "-pbc",    FALSE, etBOOL, {&bPBC},
          "Use periodic boundary conditions." },
        { "-pdbq",  FALSE, etBOOL, {&bUsePDBcharge},
          "Use the B-factor supplied in a [TT].pdb[tt] file for the atomic charges" },
        { "-param", FALSE, etBOOL, {&bParam},
          "Print parameters in the output" },
        { "-round",  FALSE, etBOOL, {&bRound},
          "Round off measured values" },
        { "-kb",    FALSE, etREAL, {&kb},
          "Bonded force constant (kJ/mol/nm^2)" },
        { "-kt",    FALSE, etREAL, {&kt},
          "Angle force constant (kJ/mol/rad^2)" },
        { "-kp",    FALSE, etREAL, {&kp},
          "Dihedral angle force constant (kJ/mol/rad^2)" }
    };

    CopyRight(stderr, argv[0]);

    parse_common_args(&argc, argv, 0, NFILE, fnm, asize(pa), pa,
                      asize(desc), desc, asize(bugs), bugs, &oenv);
    bRTP = opt2bSet("-r", NFILE, fnm);
    bTOP = opt2bSet("-o", NFILE, fnm);
    /* C89 requirements mean that these struct members cannot be used in
     * the declaration of pa. So some temporary variables are needed. */
    rtp_header_settings.bRemoveDihedralIfWithImproper = bRemoveDihedralIfWithImproper;
    rtp_header_settings.bGenerateHH14Interactions     = bGenerateHH14Interactions;
    rtp_header_settings.bKeepAllGeneratedDihedrals    = bKeepAllGeneratedDihedrals;
    rtp_header_settings.nrexcl = nrexcl;

    if (!bRTP && !bTOP)
    {
        gmx_fatal(FARGS, "Specify at least one output file");
    }

    aps = gmx_atomprop_init();

    /* Force field selection, interactive or direct */
    choose_ff(strcmp(ff, "select") == 0 ? NULL : ff,
              forcefield, sizeof(forcefield),
              ffdir, sizeof(ffdir));

    bOPLS = (strcmp(forcefield, "oplsaa") == 0);


    mymol.name = strdup(molnm);
    mymol.nr   = 1;

    /* Init parameter lists */
    init_plist(plist);

    /* Read coordinates */
    get_stx_coordnum(opt2fn("-f", NFILE, fnm), &natoms);
    snew(atoms, 1);

    /* make space for all the atoms */
    init_t_atoms(atoms, natoms, TRUE);
    snew(x, natoms);

    read_stx_conf(opt2fn("-f", NFILE, fnm), title, atoms, x, NULL, &epbc, box);

    sprintf(n2t, "%s", ffdir);
    nm2t = rd_nm2type(n2t, &nnm);
    if (nnm == 0)
    {
        gmx_fatal(FARGS, "No or incorrect atomname2type.n2t file found (looking for %s)",
                  n2t);
    }
    else
    {
        printf("There are %d name to type translations in file %s\n", nnm, n2t);
    }
    if (debug)
    {
        dump_nm2type(debug, nnm, nm2t);
    }
    printf("Generating bonds from distances...\n");
    snew(nbonds, atoms->nr);
    mk_bonds(nnm, nm2t, atoms, x, &(plist[F_BONDS]), nbonds, forcefield,
             bPBC, box, aps);

    open_symtab(&symtab);
    atype = set_atom_type(&symtab, atoms, &(plist[F_BONDS]), nbonds, nnm, nm2t);

    /* Make Angles and Dihedrals */
    snew(excls, atoms->nr);
    printf("Generating angles and dihedrals from bonds...\n");
    init_nnb(&nnb, atoms->nr, 4);
    gen_nnb(&nnb, plist);
    print_nnb(&nnb, "NNB");
    gen_pad(&nnb, atoms, &rtp_header_settings, plist, excls, NULL, TRUE);
    done_nnb(&nnb);

    if (!bPairs)
    {
        plist[F_LJ14].nr = 0;
    }
    fprintf(stderr,
            "There are %4d %s dihedrals, %4d impropers, %4d angles\n"
            "          %4d pairs,     %4d bonds and  %4d atoms\n",
            plist[F_PDIHS].nr,
            bOPLS ? "Ryckaert-Bellemans" : "proper",
            plist[F_IDIHS].nr, plist[F_ANGLES].nr,
            plist[F_LJ14].nr, plist[F_BONDS].nr, atoms->nr);

    calc_angles_dihs(&plist[F_ANGLES], &plist[F_PDIHS], x, bPBC, box);

    set_force_const(plist, kb, kt, kp, bRound, bParam);

    cgnr = set_cgnr(atoms, bUsePDBcharge, &qtot, &mtot);
    printf("Total charge is %g, total mass is %g\n", qtot, mtot);
    if (bOPLS)
    {
        bts[2] = 3;
        bts[3] = 1;
    }

    if (bTOP)
    {
        fp = ftp2FILE(efTOP, NFILE, fnm, "w");
        print_top_header(fp, ftp2fn(efTOP, NFILE, fnm),
                         "Generated by x2top", TRUE, ffdir, 1.0);

        write_top(fp, NULL, mymol.name, atoms, FALSE, bts, plist, excls, atype,
                  cgnr, rtp_header_settings.nrexcl);
        print_top_mols(fp, mymol.name, ffdir, NULL, 0, NULL, 1, &mymol);

        ffclose(fp);
    }
    if (bRTP)
    {
        print_rtp(ftp2fn(efRTP, NFILE, fnm), "Generated by x2top",
                  atoms, plist, atype, cgnr, asize(bts), bts);
    }

    if (debug)
    {
        dump_hybridization(debug, atoms, nbonds);
    }
    close_symtab(&symtab);
    free(mymol.name);

    printf("\nWARNING: topologies generated by %s can not be trusted at face value.\n", Program());
    printf("         Please verify atomtypes and charges by comparison to other\n");
    printf("         topologies.\n");

    thanx(stderr);

    return 0;
}
Example #24
0
gmx_bool get_libdir(char *libdir)
{
#define GMX_BINNAME_MAX 512
    char bin_name[GMX_BINNAME_MAX];
    char buf[GMX_BINNAME_MAX];
    char full_path[GMX_PATH_MAX+GMX_BINNAME_MAX];
    char system_path[GMX_PATH_MAX];
    char *dir,*ptr,*s,*pdum;
    gmx_bool found=FALSE;
    int i;

    if (Program() != NULL)
    {

    /* First - detect binary name */
    if (strlen(Program()) >= GMX_BINNAME_MAX)
    {
        gmx_fatal(FARGS,"The name of the binary is longer than the allowed buffer size (%d):\n'%s'",GMX_BINNAME_MAX,Program());
    }
    strncpy(bin_name,Program(),GMX_BINNAME_MAX-1);

    /* On windows & cygwin we need to add the .exe extension
     * too, or we wont be able to detect that the file exists
     */
#if (defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 || defined __CYGWIN__ || defined __CYGWIN32__)
    if(strlen(bin_name)<3 || gmx_strncasecmp(bin_name+strlen(bin_name)-4,".exe",4))
        strcat(bin_name,".exe");
#endif

    /* Only do the smart search part if we got a real name */
    if (NULL!=bin_name && strncmp(bin_name,"GROMACS",GMX_BINNAME_MAX)) {

        if (!strchr(bin_name,DIR_SEPARATOR)) {
            /* No slash or backslash in name means it must be in the path - search it! */
            /* Add the local dir since it is not in the path on windows */
#if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)
            pdum=_getcwd(system_path,sizeof(system_path)-1);
#else
            pdum=getcwd(system_path,sizeof(system_path)-1);
#endif
            sprintf(full_path,"%s%c%s",system_path,DIR_SEPARATOR,bin_name);
            found = gmx_fexist(full_path);
            if (!found && (s=getenv("PATH")) != NULL)
            {
                char *dupped;
                
                dupped=gmx_strdup(s);
                s=dupped;
                while(!found && (dir=gmx_strsep(&s, PATH_SEPARATOR)) != NULL)
                {
                    sprintf(full_path,"%s%c%s",dir,DIR_SEPARATOR,bin_name);
                    found = gmx_fexist(full_path);
                }
                sfree(dupped);
            }
            if (!found)
            {
                return FALSE;
            }
        } else if (!filename_is_absolute(bin_name)) {
            /* name contains directory separators, but 
             * it does not start at the root, i.e.
             * name is relative to the current dir 
             */
#if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)
            pdum=_getcwd(buf,sizeof(buf)-1);
#else
            pdum=getcwd(buf,sizeof(buf)-1);
#endif
            sprintf(full_path,"%s%c%s",buf,DIR_SEPARATOR,bin_name);
        } else {
            strncpy(full_path,bin_name,GMX_PATH_MAX);
        }

        /* Now we should have a full path and name in full_path,
         * but on unix it might be a link, or a link to a link to a link..
         */
#if (!defined WIN32 && !defined _WIN32 && !defined WIN64 && !defined _WIN64)
        while( (i=readlink(full_path,buf,sizeof(buf)-1)) > 0 ) {
            buf[i]='\0';
            /* If it doesn't start with "/" it is relative */
            if (buf[0]!=DIR_SEPARATOR) {
                strncpy(strrchr(full_path,DIR_SEPARATOR)+1,buf,GMX_PATH_MAX);
            } else
                strncpy(full_path,buf,GMX_PATH_MAX);
        }
#endif

        /* Remove the executable name - it always contains at least one slash */
        *(strrchr(full_path,DIR_SEPARATOR)+1)='\0';
        /* Now we have the full path to the gromacs executable.
         * Use it to find the library dir. 
         */
        found=FALSE;
        while(!found && ( (ptr=strrchr(full_path,DIR_SEPARATOR)) != NULL ) ) {
            *ptr='\0';
            found=search_subdirs(full_path,libdir);
        }
    }
    }
    /* End of smart searching. If we didn't find it in our parent tree,
     * or if the program name wasn't set, at least try some standard 
     * locations before giving up, in case we are running from e.g. 
     * a users home directory. This only works on unix or cygwin...
     */
#if ((!defined WIN32 && !defined _WIN32 && !defined WIN64 && !defined _WIN64) || defined __CYGWIN__ || defined __CYGWIN32__)
    if(!found) 
        found=search_subdirs("/usr/local",libdir);
    if(!found) 
        found=search_subdirs("/usr",libdir);
    if(!found) 
        found=search_subdirs("/opt",libdir);
#endif
    return found;
}
Example #25
0
void NetMerge::Program_Control (void)
{
	String key, merge_dir;

	//---- open network and demand files ----

	Data_Service::Program_Control ();

	Print (2, String ("%s Control Keys:") % Program ());
	Print (1);

	//---- merge directory ----

	merge_dir = Get_Control_String (MERGE_DIRECTORY);

	if (!merge_dir.empty ()) {
		Print_Filename (1, "Merge Directory", merge_dir);
		Fix_Directory (merge_dir);
	}

	//---- open merge node file ----

	key = Get_Control_String (MERGE_NODE_FILE);

	if (!key.empty ()) {
		node_file.File_Type ("Merge Node File");
		node_file.Open (merge_dir + key);
	}

	//---- open merge link file ----

	key = Get_Control_String (MERGE_LINK_FILE);

	if (!key.empty ()) {
		link_file.File_Type ("Merge Link File");
		link_file.Open (merge_dir + key);
	}

	//---- open merge shape file ----

	key = Get_Control_String (MERGE_SHAPE_FILE);

	if (!key.empty ()) {
		shape_file.File_Type ("Merge Shape File");
		shape_file.Open (merge_dir + key);
		shape_flag = true;
	}

	//---- open merge pocket file ----

	key = Get_Control_String (MERGE_POCKET_FILE);

	if (!key.empty ()) {
		pocket_file.File_Type ("Merge Pocket File");
		pocket_file.Open (merge_dir + key);
		pocket_flag = true;
	}

	//---- open merge lane use file ----

	key = Get_Control_String (MERGE_LANE_USE_FILE);

	if (!key.empty ()) {
		lane_use_file.File_Type ("Merge Lane Use File");
		lane_use_file.Open (merge_dir + key);
		lane_use_flag = true;
	}

	//---- open merge location file ----

	key = Get_Control_String (MERGE_LOCATION_FILE);

	if (!key.empty ()) {
		location_file.File_Type ("Merge Location File");
		location_file.Open (merge_dir + key);
		location_flag = true;
	}

	//---- open merge connection file ----

	key = Get_Control_String (MERGE_CONNECTION_FILE);

	if (!key.empty ()) {
		connect_file.File_Type ("Merge Connection File");
		connect_file.Open (merge_dir + key);
		connect_flag = true;
	}
	//---- open merge parking file ----

	key = Get_Control_String (MERGE_PARKING_FILE);

	if (!key.empty ()) {
		parking_file.File_Type ("Merge Parking File");
		parking_file.Open (merge_dir + key);
		parking_flag = true;
	}

	//---- open merge access file ----

	key = Get_Control_String (MERGE_ACCESS_FILE);

	if (!key.empty ()) {
		access_file.File_Type ("Merge Access File");
		access_file.Open (merge_dir + key);
		access_flag = true;
	}

	//---- open merge stop file ----

	key = Get_Control_String (MERGE_STOP_FILE);

	if (!key.empty ()) {
		stop_file.File_Type ("Merge Stop File");
		stop_file.Open (merge_dir + key);
		stop_flag = true;
	}

	//---- open merge sign file ----

	key = Get_Control_String (MERGE_SIGN_FILE);

	if (!key.empty ()) {
		sign_file.File_Type ("Merge Sign File");
		sign_file.Open (merge_dir + key);
		sign_flag = true;
	}

	//---- open merge signal file ----

	key = Get_Control_String (MERGE_SIGNAL_FILE);

	if (!key.empty ()) {
		signal_file.File_Type ("Merge Signal File");
		signal_file.Open (merge_dir + key);
		signal_flag = true;
	}

	//---- open merge timing file ----

	key = Get_Control_String (MERGE_TIMING_PLAN_FILE);

	if (!key.empty ()) {
		timing_file.File_Type ("Merge Timing Plan File");
		timing_file.Open (merge_dir + key);
		timing_flag = true;
	}

	//---- open merge phasing file ----

	key = Get_Control_String (MERGE_PHASING_PLAN_FILE);

	if (!key.empty ()) {
		phasing_file.File_Type ("Merge Phasing Plan File");
		phasing_file.Open (merge_dir + key);
		phasing_flag = true;
	}

	//---- open merge detector file ----

	key = Get_Control_String (MERGE_DETECTOR_FILE);

	if (!key.empty ()) {
		detector_file.File_Type ("Merge Detector File");
		detector_file.Open (merge_dir + key);
		detector_flag = true;
	}

	//---- open merge zone file ----

	key = Get_Control_String (MERGE_ZONE_FILE);

	if (!key.empty ()) {
		zone_file.File_Type ("Merge Zone File");
		zone_file.Open (merge_dir + key);
		zone_flag = true;
	}

	//---- open merge performance file ----

	key = Get_Control_String (MERGE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		performance_file.File_Type ("Merge Performance File");
		performance_file.Open (merge_dir + key);
		performance_flag = true;
	}

	//---- open merge turn_delay file ----

	key = Get_Control_String (MERGE_TURN_DELAY_FILE);

	if (!key.empty ()) {
		turn_delay_file.File_Type ("Merge Turn Delay File");
		turn_delay_file.Open (merge_dir + key);
		turn_delay_flag = true;
	}

}