Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/PhysiCell_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,8 +1934,10 @@ void parse_rules_from_pugixml( void )
if( done == false )
{ std::cout << "\tWarning: Ruleset had unknown format (" << format << "). Skipping!" << std::endl; }
else
{ copy_file_to_output( input_filename ); }

{
std::string default_basename = "cell_rules.csv";
copy_file_to_output(input_filename, default_basename);
}
}
else
{ std::cout << "\tRuleset disabled ... " << std::endl; }
Expand Down
13 changes: 11 additions & 2 deletions core/PhysiCell_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int choose_event( std::vector<double>& probabilities )
return probabilities.size();
}

void copy_file_to_output(std::string filename)
void copy_file_to_output(const std::string &filename, const std::string &default_basename)
{
std::cout << "Copying " << filename << " to output folder." << std::endl;
// copy the file to the output folder
Expand All @@ -381,8 +381,17 @@ void copy_file_to_output(std::string filename)
// copy filename to output_filename
char copy_command[1024];
sprintf(copy_command, "cp %s %s", filename.c_str(), output_filename.c_str());
std::cout << "Copy command: " << copy_command << std::endl;
(void)system(copy_command); // make it explicit that we are ignoring the return value

if (default_basename.empty() || default_basename == basename) {
return;
}

// copy the file to the output folder with the default basename
std::string default_output_filename = PhysiCell_settings.folder + "/" + default_basename;
sprintf(copy_command, "cp %s %s", filename.c_str(), default_output_filename.c_str());
Comment thread
drbergman marked this conversation as resolved.
(void)system(copy_command); // make it explicit that we are ignoring the return value
Comment thread
drbergman marked this conversation as resolved.
Outdated
return;
}

};
2 changes: 1 addition & 1 deletion core/PhysiCell_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void add_software_citation( std::string name , std::string version, std::string

int choose_event( std::vector<double>& probabilities );

void copy_file_to_output( std::string filename );
void copy_file_to_output(const std::string &filename, const std::string &default_basename = "");
};

#endif
3 changes: 2 additions & 1 deletion modules/PhysiCell_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ bool load_cells_from_pugixml( pugi::xml_node root )
exit(-1);
}

copy_file_to_output(input_filename);
std::string default_basename = "cells.csv";
copy_file_to_output(input_filename, default_basename);
return true;
}

Expand Down
12 changes: 8 additions & 4 deletions modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ bool load_PhysiCell_config_file( std::string filename )
if (!read_PhysiCell_config_file( filename ))
{ return false; }

PhysiCell_settings.read_from_pugixml();
PhysiCell_settings.read_from_pugixml();

// now read the microenvironment (optional)
// now read the microenvironment (optional)

if( !setup_microenvironment_from_XML( physicell_config_root ) )
{
Expand All @@ -119,7 +119,10 @@ bool load_PhysiCell_config_file( std::string filename )

create_output_directory( PhysiCell_settings.folder );

return true;
std::string default_basename = "PhysiCell_settings.xml";
copy_file_to_output( filename, default_basename ); // copy the settings file to the output folder

return true;
}

PhysiCell_Settings::PhysiCell_Settings()
Expand Down Expand Up @@ -961,7 +964,8 @@ bool setup_microenvironment_from_XML( pugi::xml_node root_node )
default_microenvironment_options.initial_condition_file_type = node.attribute("type").as_string();
default_microenvironment_options.initial_condition_file = xml_get_string_value(node, "filename");

copy_file_to_output(default_microenvironment_options.initial_condition_file);
std::string default_basename = default_microenvironment_options.initial_condition_file_type == "matlab" ? "substrates.mat" : "substrates.csv"; // when loading the file, we check that it is one of these two types
copy_file_to_output(default_microenvironment_options.initial_condition_file, default_basename);
}
}

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/asymmetric_division/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/biorobots/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/cancer_biorobots/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
6 changes: 0 additions & 6 deletions sample_projects/cancer_immune/main-cancer_immune_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,17 @@ int main( int argc, char* argv[] )
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/custom_division/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/heterogeneity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/immune_function/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/interactions/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/mechano/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/physimess/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
10 changes: 2 additions & 8 deletions sample_projects/pred_prey_farmer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ int main( int argc, char* argv[] )
{
// load and parse settings file(s)

bool XML_status = false;
char copy_command [1024];
bool XML_status = false;
if( argc > 1 )
{
XML_status = load_PhysiCell_config_file( argv[1] );
sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() );
XML_status = load_PhysiCell_config_file( argv[1] );
}
else
{
XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" );
sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() );
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

// OpenMP setup
omp_set_num_threads(PhysiCell_settings.omp_num_threads);

Expand Down
Loading