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
16 changes: 12 additions & 4 deletions SS_benchfore.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1483,12 +1483,20 @@ FUNCTION void Get_Forecast()
for(subseas=1;subseas<=N_subseas;subseas++) // do all subseasons in first year
{
get_growth3(y,t,s, subseas); // in case needed for Lorenzen M
Make_AgeLength_Key(s, subseas);
Make_AgeLength_Key(s, subseas); // which also updates Wt_Age_beg, etc.
}
if(s==spawn_seas)
{
if(WTage_rd==1)
{
Wt_Age_beg(s)=Wt_Age_t(t,0); // used for smrybio
Wt_Age_mid(s)=Wt_Age_t(t,-1);
if(s==spawn_seas) fec=Wt_Age_t(t,-2);
}
else
{get_mat_fec();}
}
// if(s==spawn_seas) Make_Fecundity();
if(s==spawn_seas) get_mat_fec();
}
// get_mat_fec();
}

for (y=endyr+1;y<=YrMax;y++)
Expand Down
71 changes: 58 additions & 13 deletions SS_global.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,20 @@ GLOBALS_SECTION
#include <fvar.hpp>
#include <vector>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
time_t start,finish;
long hour,minute,second;
double elapsed_time;

// SS_Label_Info_10.1 #Open output files using ofstream
ofstream warning("warning.sso");
ofstream echoinput("echoinput.sso");
ofstream ParmTrace("ParmTrace.sso");
ofstream report5("Forecast-report.sso");
ofstream report2("CumReport.sso",ios::app);
ofstream bodywtout("wtatage.ss_new");
ofstream SS2out; // this is just a create

// SS_Label_Info_10.2 #Define some adstring variables
adstring_array ParmLabel; // extendable array to hold the parameter labels
adstring_array Parm_info; // extendable array to hold the parameter labels
adstring_array SzFreq_units_label;
adstring_array SzFreq_scale_label;
adstring_array fleetname;
adstring ssnew_pathname;
adstring sso_pathname;
adstring fleetnameread;
adstring depletion_basis_label;
adstring F_report_label;
Expand All @@ -89,6 +84,8 @@ GLOBALS_SECTION
adstring onenum2(4);
adstring anystring;
adstring anystring2;
adstring report_sso_filename;

adstring_array version_info;
adstring_array version_info2;
adstring_array Starter_Comments;
Expand All @@ -103,6 +100,25 @@ GLOBALS_SECTION
adstring_array pick_report_name; // name of report
adstring_array pick_report_use; // X if used; 0 if not

// SS_Label_Info_10.1 #Open output files using ofstream
ofstream warning;
ofstream echoinput;
ofstream ParmTrace;
ofstream report5; // forecast-report
ofstream report2; // control.ss_new
ofstream bodywtout;
ofstream SS2out; // this is just a create
ofstream SS_compout; // this is just a create
ofstream report1; // for data.ss_new
ofstream covarout;
ofstream rebuilder;
ofstream rebuild_dat;
ofstream posts;
ofstream der_posts;
ofstream post_vecs;
ofstream post_obj_func;
ofstream SS_smry;
ofstream SIS_table;
// declare some entities that need global access
int ParCount; int timevary_parm_cnt; int N_warn;
int styr; int endyr; int YrMax; int nseas; int Ncycle; int seas_as_year;
Expand Down Expand Up @@ -668,7 +684,7 @@ FINAL_SECTION

if(No_Report==1)
{
cout<<"MCMC finished; note: .sso and .ss_new files not produced after MCMC "<<endl;
cout<<"MCMC finished; *.ss_new files not written after MCMC or MCEVAL"<<endl;
}

else
Expand All @@ -679,7 +695,8 @@ FINAL_SECTION
{N_warn++; warning<<N_warn<<" "<<"Final gradient: "<<objective_function_value::pobjfun->gmax <<" is larger than final_conv: "<<final_conv<<endl;}

// SS_Label_Info_12.2 #Output the covariance matrix to covar.sso
ofstream covarout("covar.sso");
anystring=sso_pathname+"covar.sso";
covarout.open(anystring);
covarout<<version_info<<endl;
covarout<<"start_time: "<<ctime(&start)<<endl;
covarout<<active_parms<<" "<<CoVar_Count<<endl;
Expand All @@ -706,6 +723,34 @@ FINAL_SECTION

// SS_Label_Info_12.3 #Go thru time series calculations again to get extra output quantities
// SS_Label_Info_12.3.2 #Set save_for_report=1 then call initial_conditions and time_series to get other output quantities
if(Do_Dyn_Bzero>0) // do dynamic Bzero
{
save_gparm=0;
fishery_on_off=0;
setup_recdevs();
y=styr;
get_initial_conditions();
get_time_series();
if(Do_Forecast>0)
{
show_MSY=0;
Get_Forecast();
}
k=Do_Dyn_Bzero;
for(j=styr-2; j<=YrMax;j++)
{
Extra_Std(k)=SSB_yr(j); k++;
}
if(More_Std_Input(12)==2)
{
for(j=styr-2; j<=YrMax;j++)
{
Extra_Std(k)=exp_rec(j,4); k++;
}
}
} // end dynamic Bzero

fishery_on_off=1;
save_for_report=1;
bigsaver=1;
save_gparm=0;
Expand Down Expand Up @@ -785,7 +830,7 @@ FINAL_SECTION
// SS_Label_Info_12.4.6 #Call fxn write_Bzero_output() appended to report.sso
if (pick_report_use(59)=="Y")
{
cout<<"dynamic Bzero: ";
cout<<"dynamic Bzero in FINAL_SECTION: ";
write_Bzero_output();
cout<<" finished "<<endl;
}
Expand Down Expand Up @@ -914,6 +959,6 @@ REPORT_SECTION
cout<<"Wrote bigoutput and bodywt for last_phase in REPORT_SECTION and before hessian, no benchmark or forecast "<<endl;
save_for_report=0;
write_bodywt=0;
SS2out.close();
// SS2out.close();
}
} // end standard report section
34 changes: 18 additions & 16 deletions SS_objfunc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1355,27 +1355,28 @@ FUNCTION void get_posteriors()
// but will play through just fine
// NOTE: "del" works on Windows only; use "rm" on other operating systems
// solution here is to open file to the first record
ofstream rebuilder("rebuild.sso",ios::out);
ofstream posts("posteriors.sso",ios::out);
ofstream der_posts("derived_posteriors.sso",ios::out);
ofstream post_vecs("posterior_vectors.sso",ios::out);
ofstream post_obj_func("posterior_obj_func.sso",ios::out);
if(rundetail>0) cout<<" did system commands "<<endl;
};
rebuilder.open(sso_pathname+"rebuild.sso",ios::out);
posts.open(sso_pathname+"posteriors.sso",ios::out);
der_posts.open(sso_pathname+"derived_posteriors.sso",ios::out);
post_vecs.open(sso_pathname+"posterior_vectors.sso",ios::out);
post_obj_func.open(sso_pathname+"posterior_obj_func.sso",ios::out);
}
else
{
// define the mcmc output files;
ofstream rebuilder("rebuild.sso",ios::app);
ofstream posts("posteriors.sso",ios::app);
ofstream der_posts("derived_posteriors.sso",ios::app);
ofstream post_vecs("posterior_vectors.sso",ios::app);
ofstream post_obj_func("posterior_obj_func.sso",ios::app);
rebuilder.open(sso_pathname+"rebuild.sso",ios::app);
posts.open(sso_pathname+"posteriors.sso",ios::app);
der_posts.open(sso_pathname+"derived_posteriors.sso",ios::app);
post_vecs.open(sso_pathname+"posterior_vectors.sso",ios::app);
post_obj_func.open(sso_pathname+"posterior_obj_func.sso",ios::app);
}

if(mceval_header==0) // first pass through the mceval phase
{
mceval_header=1;
// produce the appropriate headers for the posteriors.rep
// and derived_posteriors.rep files
// parameters.rep matches "PARAMETERS" section in Report.SSO file
if(rundetail>0) cout<<" write mcmc headers "<<endl;
posts<<"Iter Objective_function ";
for (i=1;i<=active_count;i++) {posts<<" "<<ParmLabel(active_parm(i));}
posts << endl;
Expand Down Expand Up @@ -1525,10 +1526,8 @@ FUNCTION void get_posteriors()
}
}; // end writing headers for mceval_counter==1


// produce standard output of all estimated parameters
posts<<mceval_counter<<" "<<obj_fun<<" ";

for (j=1;j<=N_MGparm2;j++)
{
if(active(MGparm(j))) posts<<MGparm(j)<<" ";
Expand Down Expand Up @@ -1688,5 +1687,8 @@ FUNCTION void get_posteriors()

post_obj_func<<endl;
}

posts.close();
der_posts.close();
post_vecs.close();
post_obj_func.close();
} // end get_posteriors
43 changes: 31 additions & 12 deletions SS_proced.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PROCEDURE_SECTION
CrashPen.initialize();
niter++;
if(mceval_phase() ) mceval_counter ++; // increment the counter

if(initial_params::mc_phase==1) // in MCMC phase
{

Expand Down Expand Up @@ -82,20 +83,14 @@ PROCEDURE_SECTION
// SS_Label_Info_7.6 #If sdphase or mcevalphase, do benchmarks and forecast and derived quantities
if( (sd_phase() || mceval_phase()) && (initial_params::mc_phase==0))
{

if(Do_Dyn_Bzero>0) // do dynamic Bzero
{
{
save_gparm=0;
fishery_on_off=0;
setup_recdevs();
y=styr;
get_initial_conditions();
get_time_series();
setup_Benchmark();
if(Do_Benchmark>0)
{
Get_Benchmarks(show_MSY); // should not be needed, but something critical is getting setup
}
if(Do_Forecast>0)
{
show_MSY=0;
Expand All @@ -112,9 +107,8 @@ PROCEDURE_SECTION
{
Extra_Std(k)=exp_rec(j,4); k++;
}
}
// end dynamic Bzero
}
}
} // end dynamic Bzero calculations, will write after big report

save_gparm=0;
fishery_on_off=1;
Expand All @@ -126,6 +120,7 @@ PROCEDURE_SECTION
setup_Benchmark();
// SS_Label_Info_7.6.1 #Call fxn Get_Benchmarks()
if(mceval_phase()==0) {show_MSY=1;} // so only show details if not in mceval
if(mceval_phase()>0) save_for_report=1;
if(show_MSY==1) cout<<"do benchmark and forecast if requested in sdphase"<<endl;
if(Do_Benchmark>0)
{
Expand Down Expand Up @@ -304,11 +299,35 @@ PROCEDURE_SECTION
if(obj_fun<=last_objfun) last_objfun=obj_fun;
docheckup=0; // turn off reporting to checkup.sso
// SS_Label_Info_7.11 #Call fxn get_posteriors if in mceval_phase
if(mceval_phase()) get_posteriors();
if(mceval_phase())
{
get_posteriors();

//SS_Label_Info_7.12 #write report_mce_XXXX.sso and compreport_mce_XXXX.sso for each MCEVAL
if(mcmc_output_detail>=2)
{
write_bodywt=0;
pick_report_use(54)=0;
pick_report_use(55)=0;
// is the following call to the functions necessary??
save_for_report=1;
save_gparm=0;
y=styr;
setup_recdevs();
get_initial_conditions();
get_time_series();
evaluate_the_objective_function();
// end call to the functions
write_bigoutput();
if(Do_Dyn_Bzero>0) write_Bzero_output();
save_for_report=0;
write_bodywt=0;
}
}
} // end doing of the calculations
if(mceval_phase() || initial_params::mc_phase==1)
{
No_Report=1; // flag to skip output reports after MCMC and McEVAL
}
}
// SS_Label_Info_7.12 #End of PROCEDURE_SECTION
// SS_Label_Info_7.13 #End of PROCEDURE_SECTION
34 changes: 32 additions & 2 deletions SS_readstarter.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,36 @@
init_int reportdetail
int rd_background

LOCAL_CALCS
struct stat pathinfo;
if( stat( "./ssnew", &pathinfo ) != 0 )
{
ssnew_pathname="";
}
else
{
ssnew_pathname="./ssnew/";
}

if( stat( "./sso", &pathinfo ) != 0 )
{
sso_pathname="";
}
else
{
sso_pathname="./sso/";
}

warning.open(sso_pathname+"warning.sso");
echoinput.open(sso_pathname+"echoinput.sso");
ParmTrace.open(sso_pathname+"ParmTrace.sso");
report5.open(sso_pathname+"Forecast-report.sso");
report2.open(sso_pathname+"CumReport.sso",ios::app);
bodywtout.open(ssnew_pathname+"wtatage.ss_new");

END_CALCS


LOCAL_CALCS
if (reportdetail < 0 || reportdetail > 3) reportdetail = 0;
echoinput<<reportdetail<<" reportdetail 0=minimal for data-limited, 1=all, 2=no growth, 3=custom"<<endl;
Expand Down Expand Up @@ -558,8 +588,8 @@
echoinput<<"read MCMC_output_detail.MCMC_bump as a single real number; separate values will be parsed from integer and fraction"<<endl;
mcmc_output_detail = int(tempin);
MCMC_bump=tempin-mcmc_output_detail;
if (mcmc_output_detail < 0 || mcmc_output_detail > 3) mcmc_output_detail = 0;
echoinput<<"MCMC output detail: "<<mcmc_output_detail<<endl;
if (mcmc_output_detail < 0 || mcmc_output_detail > 2) mcmc_output_detail = 0;
echoinput<<"MCMC output detail(1=more_detail_to_posts; 2=write_report_for_each_mceval): "<<mcmc_output_detail<<endl;
echoinput<<"MCMC bump to R0: "<<MCMC_bump<<endl;

echoinput<<"Now get ALK tolerance (0.0 is OK for no compression; 0.1 is too big; suggest 0.0001)"<<endl;
Expand Down
Loading