From: Dariusz Murakowski Date: Mon, 16 Sep 2013 15:43:15 +0000 (-0400) Subject: Locate segfault for small N (population size = 0). Seed as additional run parameter... X-Git-Url: http://src.murakowski.org/?a=commitdiff_plain;h=4166d05767451e6672526c4d3f628f4af8d92354;p=VirEvoDyn.git Locate segfault for small N (population size = 0). Seed as additional run parameter. Concatenate source files? --- diff --git a/Makefile b/Makefile index e7f3816..8e208f9 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ LIBS = -lgsl -lgslcblas -lm ifeq ($(dbg),1) DBGFLAG = -g else - DBGFLAG = -O3 + DBGFLAG = -O3 -combine endif # now the actual build rules, pretty general @@ -26,6 +26,11 @@ all: $(EXECNAME) $(EXECNAME): $(SRCS) $(CXX) $(SRCS) $(CFLAGS) $(LIBDIR) $(INCLUDEDIR) -o $(EXECNAME) $(LIBS) + +# concatenate all the source files before compiling +# ./concat.sh $(EXECNAME) $(SRCS) +# $(CXX) -x c++ $(EXECNAME).combined $(CFLAGS) $(LIBDIR) $(INCLUDEDIR) -o $(EXECNAME) $(LIBS) + # $(CXX) $(SRCS) $(CFLAGS) $(LFLAGS) $(INCLUDES) $(LIBS) -o $(EXECNAME) # $(CXX) $(CFLAGS) $(INCLUDES) -o $(EXECNAME) $(OBJS) $(LFLAGS) $(LIBS) @@ -35,4 +40,5 @@ $(EXECNAME): $(SRCS) clean: $(RM) *.o $(EXECNAME) +# $(RM) *.o *.combined $(EXECNAME) diff --git a/concat.sh b/concat.sh new file mode 100755 index 0000000..81d261c --- /dev/null +++ b/concat.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +output="$1" +shift + +declare files="" +while [ -n "$1" ]; do + files="$files $1" + shift +done + +temp=$output.combined +cat /dev/null > $temp + +for file in $files; do + echo "#line 1 \"$file\"" >> $temp + cat $file >> $temp +done + diff --git a/population.cpp b/population.cpp index fed7284..7d0c7b3 100644 --- a/population.cpp +++ b/population.cpp @@ -122,7 +122,7 @@ void Population::next_generation(const Hamiltonian &H, gsl_rng* r, bool useRelat } - pop[iter->first]++; + pop[iter->first]++; // segfaults HERE when pop_size == 0 (i.e. none survive) new_Eavg += iter->first.energy; diff --git a/wf.cpp b/wf.cpp index 01e4362..6294977 100644 --- a/wf.cpp +++ b/wf.cpp @@ -36,7 +36,7 @@ static unsigned sim_random_seed() { // Run the program -void run(RunParameters &r) { +void run(RunParameters &r, unsigned seed) { // Initialize RNG and set initial state, if importing from file @@ -44,7 +44,7 @@ void run(RunParameters &r) { //srand((unsigned)time(0)); //gsl_rng_set(rnd,rand()); - gsl_rng_set(rnd,sim_random_seed()); + gsl_rng_set(rnd,seed); r.setFiles(); FILE *popout=fopen(r.trajectoryOutfile.c_str(),"w"); // .dat @@ -70,6 +70,7 @@ void run(RunParameters &r) { unsigned int i; for (i=0; i