Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
95 changes: 69 additions & 26 deletions SS_global.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ GLOBALS_SECTION
#include <fvar.hpp>
#include <vector>
#include <iostream>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
time_t start, finish;
Expand Down Expand Up @@ -121,9 +122,11 @@ GLOBALS_SECTION
ofstream SS_smry;
ofstream SIS_table;
// declare some entities that need global access
std::stringstream warnstream;
std::string usermsg;
int ParCount;
int timevary_parm_cnt;
int N_warn;
int N_warn = 0;
int styr;
int endyr;
int YrMax;
Expand Down Expand Up @@ -160,6 +163,38 @@ GLOBALS_SECTION
std::vector<int> Fparm_PH;
;
// function in GLOBALS to do the timing setup in the data section

// SS_Label_Function xxxa write_message(string,int,int); output a message with an option to exit (when fatal)
void write_message(std::string msg, int echo, int exitflag)
{
if (msg.length() > 0)
{
N_warn++;
warning << N_warn << ": " << msg << endl;

if (echo == 1)
{
if (exitflag == 1)
echoinput << "Exit: ";
echoinput << msg << endl;
}
if (exitflag == 1)
{
cout << " Fatal Error:" << endl;
cout << " -- " << msg << endl;
cout << " Exiting SS3. " << endl;
exit(1);
}
}
}
// SS_Label_Function_xxxb write_warning(int,int); output a warning with an option to exit (when fatal)
void write_warning(int echo, int exitflag)
{
std::string msg(warnstream.str());
write_message(msg, echo, exitflag);
warnstream.str("");
}

// SS_Label_Function_xxxx #get_data_timing() called by readdata
void get_data_timing(const dvector& to_process, const ivector& timing_constants, ivector i_result, dvector r_result, const dvector& seasdur, const dvector& subseasdur_delta, const dvector& azero_seas, const dvector& surveytime)
{
Expand Down Expand Up @@ -221,10 +256,12 @@ GLOBALS_SECTION
{
if (month >= 13.0)
{
N_warn++;
cout << "fatal read error, see warning" << endl;
warning << N_warn << " Fatal error. month must be <13.0, end of year is 12.99, value read is: " << month << endl;
exit(1);
warnstream << "Fatal error. month must be <13.0, end of year is 12.99, value read is: " << month;
write_warning(0, 1);
// N_warn++;
// cout << "fatal read error, see warning" << endl;
// warning << N_warn << " Fatal error. month must be <13.0, end of year is 12.99, value read is: " << month << endl;
// exit(1);
}
temp1 = max(0.00001, (month - 1.0) / 12.); // month as fraction of year
s = 1; // earlist possible seas;
Expand Down Expand Up @@ -376,12 +413,15 @@ GLOBALS_SECTION
tempvec.fill("{-10,10,0.,0.,5,6,4}");
if (baseparm_list(1) <= 0.0)
{
N_warn++;
warning << N_warn << " "
<< " cannot use multiplicative blocks for parameter with a negative lower bound; exit " << endl
warnstream << "cannot use multiplicative blocks for parameter with a negative lower bound; exit " << endl
<< baseparm_list(1) << " " << baseparm_list(2) << " " << baseparm_list(3) << endl;
cout << "exit, see warning" << endl;
exit(1);
write_warning(0,1);
// N_warn++;
// warning << N_warn << " "
// << " cannot use multiplicative blocks for parameter with a negative lower bound; exit " << endl
// << baseparm_list(1) << " " << baseparm_list(2) << " " << baseparm_list(3) << endl;
// cout << "exit, see warning" << endl;
// exit(1);
}
tempvec(1) = log(baseparm_list(1) / baseparm_list(3)); // max negative change
tempvec(2) = log(baseparm_list(2) / baseparm_list(3)); // max positive change
Expand Down Expand Up @@ -724,19 +764,23 @@ GLOBALS_SECTION
y = baseparm_list(10);
if (y < styr)
{
N_warn++;
warning << N_warn << " "
<< " reset parm_dev start year to styr for parm: " << j << " " << y << endl;
warnstream << "reset parm_dev start year to styr for parm: " << j << " " << y;
write_warning(0,0);
// N_warn++;
// warning << N_warn << " "
// << " reset parm_dev start year to styr for parm: " << j << " " << y << endl;
y = styr;
}
timevary_setup(10) = y;

y = baseparm_list(11);
if (y > YrMax)
{
N_warn++;
warning << N_warn << " "
<< " reset parm_dev end year to YrMax for parm: " << j << " " << y << endl;
warnstream << " reset parm_dev end year to YrMax for parm: " << j << " " << y;
write_warning(0,0);
// N_warn++;
// warning << N_warn << " "
// << " reset parm_dev end year to YrMax for parm: " << j << " " << y << endl;
y = YrMax;
}
timevary_setup(11) = y;
Expand Down Expand Up @@ -788,6 +832,7 @@ GLOBALS_SECTION
echoinput << "timevary_setup" << timevary_setup << endl;
return;
}

// } // end GLOBALS_SECTION

// SS_Label_Section_11. #BETWEEN_PHASES_SECTION
Expand Down Expand Up @@ -849,9 +894,8 @@ FINAL_SECTION
<< endl;
if (objective_function_value::pobjfun->gmax > final_conv)
{
N_warn++;
warning << N_warn << " "
<< "Final gradient: " << objective_function_value::pobjfun->gmax << " is larger than final_conv: " << final_conv << endl;
warnstream << "Final gradient: " << objective_function_value::pobjfun->gmax << " is larger than final_conv: " << final_conv;
write_warning(0, 0);
}

// SS_Label_Info_12.2 #Output the covariance matrix to covar.sso
Expand Down Expand Up @@ -1034,9 +1078,8 @@ FINAL_SECTION
else
{
{
N_warn++;
warning << N_warn << " "
<< "NOTE: No *.ss_new and fewer *.sso files written after mceval" << endl;
warnstream << "NOTE: No *.ss_new and fewer *.sso files written after mceval";
write_warning(0, 0);
}
}

Expand Down Expand Up @@ -1066,15 +1109,15 @@ FINAL_SECTION

if (parm_adjust_method == 3)
{
N_warn++;
warning << N_warn << " Time-vary parms not bound checked" << endl;
warnstream << "Time-vary parms not bound checked";
write_warning(0, 0);
}

// SS_Label_Info_12.4.7 #Finish up with final writes to warning.sso
if (N_changed_lambdas > 0)
{
N_warn++;
warning << N_warn << " Reminder: Number of lamdas !=0.0 and !=1.0: " << N_changed_lambdas << endl;
warnstream << "Reminder: Number of lamdas !=0.0 and !=1.0: " << N_changed_lambdas;
write_warning(0, 0);
}

if (Nparm_on_bound > 0)
Expand Down
50 changes: 26 additions & 24 deletions SS_readstarter.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@
int niter // iteration count
int loop
int TG_t; // time counter (in seasons) for tag groups

int Fcast_catch_start
// int ParCount;
int retParCount;
int N_SC; // counter for starter comments
int N_SC; // counter for starter comments
int N_DC;
int N_CC;
int N_FC;
Expand All @@ -71,14 +72,14 @@

int frac_female_pointer;
int finished_minimize;
int icycle
int No_Report // flag to skip output reports after MCMC and MCeval
int mcmcFlag
int noest_flag
int icycle;
int No_Report; // flag to skip output reports after MCMC and MCeval
int mcmcFlag;
int noest_flag;
number temp;
number temp1;
int save_for_report;
int bigsaver; // (save_for_report>0) || ((sd_phase() || mceval_phase()) && (initial_params::mc_phase==0))
int bigsaver; // (save_for_report>0) || ((sd_phase() || mceval_phase()) && (initial_params::mc_phase==0))
int write_bodywt;
int write_bodywt_save;
int save_gparm;
Expand All @@ -93,9 +94,9 @@
!! special_flag=0;

int Nparm_on_bound;
int on;
int SDmode;
int maxI;
int on;
int SDmode;
int maxI;

LOCAL_CALCS
maxI=999;
Expand All @@ -111,10 +112,10 @@
TG_t=0; Fcast_catch_start=0; retParCount=0; N_SC=0; N_DC=0; N_CC=0; N_FC=0; catch_mult_pointer=0; frac_female_pointer=0; icycle=0; No_Report=0;
mcmcFlag=0; noest_flag=0; temp=0; temp1=0; save_gparm_print=0;
finished_minimize=0;
// SS_Label_Info_1.1.2 #arrays for parameter labels are created in GLOBAL
// adstring_array NumLbl;
// adstring_array GenderLbl; // gender label
// adstring_array CRLF; // blank to terminate lines
// SS_Label_Info_1.1.2 #arrays for parameter labels are created in GLOBAL
// adstring_array NumLbl;
// adstring_array GenderLbl; // gender label
// adstring_array CRLF; // blank to terminate lines

CRLF+="";
GenderLbl+="Fem";
Expand All @@ -126,17 +127,16 @@
GP_Lbl+="_GP_5";
GP_Lbl+="_GP_6";
onenum=" ";
for (i=1;i<=199;i++) /* SS_loop: fill string NumLbl with numbers (start at 1) */
for (i = 1; i <= 199; i++) /* SS_loop: fill string NumLbl with numbers (start at 1) */
{
sprintf(onenum, "%d", i);
NumLbl+=onenum+CRLF(1);
sprintf(onenum, "%d", i);
NumLbl += onenum + CRLF(1);
}
for (i=0;i<=198;i++) /* SS_loop: fill string NumLbl0 with numbers (start at 0) */
for (i = 0; i <= 198; i++) /* SS_loop: fill string NumLbl0 with numbers (start at 0) */
{
sprintf(onenum, "%d", i);
NumLbl0+=onenum+CRLF(1);
sprintf(onenum, "%d", i);
NumLbl0 += onenum + CRLF(1);
}

pick_report_name+="DEFINITIONS report:1";pick_report_use+="N";
pick_report_name+="LIKELIHOOD report:2";pick_report_use+="N";
pick_report_name+="Input_Variance_Adjustment report:3";pick_report_use+="N";
Expand Down Expand Up @@ -200,11 +200,13 @@

// check command line inputs

if ( (on=option_match(argc,argv,"-noest"))>-1)
if ((on = option_match(argc,argv,"-noest")) > -1)
{
cout<<"SS3 is not configured to work with -noest; use -maxI instead which overrides maxphase in starter.ss"<<endl;
N_warn++; warning<<N_warn<<" SS3 exited with -noest, use -maxI <maxphase> instead"<<endl;
exit(1);
warnstream << "SS3 is not configured to work with -noest; use -maxI <maxphase> instead which overrides maxphase in starter.ss";
write_warning(0,1);
// cout<<"SS3 is not configured to work with -noest; use -maxI instead which overrides maxphase in starter.ss"<<endl;
// N_warn++; warning<<N_warn<<" SS3 exited with -noest, use -maxI <maxphase> instead"<<endl;
// exit(1);
}

if ( (on=option_match(argc,argv,"-maxI"))>-1 || (on=option_match(argc,argv,"-stopph"))>-1)
Expand Down