diff --git a/.github/workflows/build-ss3-warnings.yml b/.github/workflows/build-ss3-warnings.yml index 7bd21116..51cf60cd 100644 --- a/.github/workflows/build-ss3-warnings.yml +++ b/.github/workflows/build-ss3-warnings.yml @@ -60,11 +60,13 @@ jobs: chmod 777 SS330 /bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -w &> warnings.txt - # Runs a set of commands using the runners shell - - name: Use R to parse warnings output + - name: Print warnings + run: cat warnings.txt + + - name: Use R to parse warnings output and determine if amount of warnings has changed run: | txt <- readLines("warnings.txt", encoding = "UTF-8") - warn_line <- grep(pattern = "g++ -c -std=c++17 -O3 -Wall -Wextra -D_USE_MATH_DEFINES -DUSE_ADMB_CONTRIBS", x = txt, fixed = TRUE) + warn_line <- grep(pattern = "g++ -c -std=c++17 -O3 -Wall -Wextra -static-libstdc++ -static-libgcc -D_USE_MATH_DEFINES -DUSE_ADMB_CONTRIBS", x = txt, fixed = TRUE) end_warn_line <- grep(pattern = "*** Linking: ss3.obj ", x = txt, fixed = TRUE) if (length(warn_line) == 1 & length(end_warn_line) == 1) { txt <- txt[(warn_line+3):(end_warn_line-1)] @@ -72,37 +74,34 @@ jobs: txt <- txt[rm_warn_start_lines] n_errors <- length(grep(pattern = "^ [0-9]", x = txt)) message("There are ", n_errors, " warning messages related to SS3.") - write.table(n_errors, "n_warn.txt") + # write.table(n_errors, "n_warn.txt") } writeLines(txt, "warnings_ss.txt") - # warn_line <- grep(pattern = "compiling a second time to get warnings", x = txt, fixed = TRUE) - # txt <- txt[(warn_line+1):length(txt)] - shell: Rscript {0} - - - name: Print warnings - run: cat warnings_ss.txt - - - name: Determine if fails/passes based on the number of warnings - run: | ref <- readLines(".github/workflows/reference_files/warnings_ss_ref.txt") - n_warn <- read.table("n_warn.txt") - n_warn <- as.integer(n_warn[1,1]) + ref2 <- ref[!grepl("ss3.obj", ref) & nzchar(txt)] + n_warn <- n_errors + if(n_warn != 0){ + n_warn <- as.integer(n_warn[1,1]) + } if (n_warn > length(ref)) { stop("Increased number of warnings compared to reference warning file") } else { # n_warn doesn't take into account the "In file included from ss.cpp:7:" # so add 2 to add those lines back in if (n_warn+length(ref) < length(ref)){ - stop("Number of warnings of decreased compared to reference warning file") + message("Number of warnings of decreased compared to reference warning file, if this is pushed to main, change the ref file") } else { - message("Acceptable number of warnings") + message(paste0("Acceptable number of warnings: ", n_warn)) } } shell: Rscript {0} + - name: Print warnings + run: cat warnings_ss.txt + - name: Archive warnings text file if: always() uses: actions/upload-artifact@main with: name: 'warnings_ss.txt' - path: warnings_ss.txt \ No newline at end of file + path: warnings_ss.txt diff --git a/.github/workflows/reference_files/warnings_ss_ref.txt b/.github/workflows/reference_files/warnings_ss_ref.txt index d92da4e6..1a9ebdac 100644 --- a/.github/workflows/reference_files/warnings_ss_ref.txt +++ b/.github/workflows/reference_files/warnings_ss_ref.txt @@ -1,12 +1,3 @@ -/usr/local/admb/include/admodel.h:1915:38: warning: unused parameter 'gradients' [-Wunused-parameter] - 1915 | virtual void report(const dvector& gradients){;}; - | ~~~~~~~~~~~~~~~^~~~~~~~~ -/usr/local/admb/include/admodel.h:2501:43: warning: unused parameter 'ofs' [-Wunused-parameter] - 2501 | virtual void save_value(const ofstream& ofs, int prec,const dvector&, - | ~~~~~~~~~~~~~~~~^~~ -/usr/local/admb/include/admodel.h:2501:52: warning: unused parameter 'prec' [-Wunused-parameter] - 2501 | virtual void save_value(const ofstream& ofs, int prec,const dvector&, - | ~~~~^~~~ -/usr/local/admb/include/admodel.h:2502:10: warning: unused parameter 'offset' [-Wunused-parameter] - 2502 | int& offset){} - | ~~~~~^~~~~~ +g++ -std=c++17 -O3 -oss3 ss3.obj "/usr/local/admb/lib/libadmb-contrib-x86_64-linux-g++13.a" +*** Linking: ss3.obj + diff --git a/SS_benchfore.tpl b/SS_benchfore.tpl index 343733d3..80b25c3e 100644 --- a/SS_benchfore.tpl +++ b/SS_benchfore.tpl @@ -1042,7 +1042,7 @@ FUNCTION void Get_Benchmarks(const int show_MSY) SSBpR_Calc(equ_Recr); F01_origin = YPR_opt / Fmult; - BTGT_target = 0.1; // now relative to Bmark + BTGT_frac = 0.1; // now relative to Bmark Btgttgt = F01_origin * 0.1; if (show_MSY == 1) { @@ -1138,18 +1138,18 @@ FUNCTION void Get_Benchmarks(const int show_MSY) { // ****************************************************** - if (depletion_basis == 1) - {Btgttgt = BTGT_target * SSB_virgin;} + if (depletion_basis == 1 && timevary_bio_4SRR != 0) + {Btgttgt = BTGT_frac * SSB_virgin;} else - {Btgttgt = BTGT_target * SSB_unf;} // current SS3 approach uses benchmark biology + {Btgttgt = BTGT_frac * SSB_unf;} // current SS3 approach uses benchmark biology if (show_MSY == 1) { report5 << "#" << endl; - if (depletion_basis == 1) - {report5 << "Find_target_SSB as fraction: " << BTGT_target << " of Virgin SSB:" << SSB_virgin << endl;} + if (depletion_basis == 1 && timevary_bio_4SRR != 0) + {report5 << "Find_target_SSB as fraction: " << BTGT_frac << " of Virgin SSB:" << SSB_virgin << endl;} else - {report5 << "Find_target_SSB as fraction: " << BTGT_target << " of SSB_unf: "<< SSB_unf << endl;} + {report5 << "Find_target_SSB as fraction: " << BTGT_frac << " of SSB_unf: "<< SSB_unf << endl;} report5 << "Iter Fmult ann_F SPR Catch SSB Recruits SSB/Bzero Tot_catch"; for (p = 1; p <= pop; p++) @@ -1212,9 +1212,11 @@ FUNCTION void Get_Benchmarks(const int show_MSY) } SSBpR_Calc(equ_Recr); // where equ_Recr=1.0, so returned SSB_equil is in units of SSB/R, SSBpR_temp = SSB_equil; +// warning << equ_Recr << " " << SSB_equil << " " << SRparm_bench << " " << SSBpR_temp << endl; SPR_Btgt = SSBpR_temp / SSBpR_unf; // where SSBpR_unf = SSB_unf / Recr_unf so units of SSB/R; so result is SPR_Btgt = (fished SSB/R) / (unfished SSB/R) // SPAWN-RECR: calc equil spawn-recr for Btarget calcs; need to make area-specific Equ_SpawnRecr_Result = Equil_Spawn_Recr_Fxn(SRparm_bench, SSB0_4_SRR, R0_4_SRR, SSBpR_temp); // returns 2 element vector containing equilibrium biomass and recruitment at this SPR +// warning << SSB0_4_SRR << " " << R0_4_SRR << Equ_SpawnRecr_Result << endl; yld1(ii) = Equ_SpawnRecr_Result(1); } @@ -1247,7 +1249,7 @@ FUNCTION void Get_Benchmarks(const int show_MSY) if (show_MSY == 1) { report5 << j << " " << Fmult << " " << equ_F_std << " " << SPR_Btgt << " " << YPR_dead * Equ_SpawnRecr_Result(2) << " " << Btgt << " " << Equ_SpawnRecr_Result(2) - << " " << Btgt / SSB_unf << " " << sum(equ_catch_fleet(2)) * Equ_SpawnRecr_Result(2); + << " " << Btgt / (Btgttgt / BTGT_frac) << " " << sum(equ_catch_fleet(2)) * Equ_SpawnRecr_Result(2); for (p = 1; p <= pop; p++) for (gp = 1; gp <= N_GP; gp++) { @@ -1774,7 +1776,7 @@ FUNCTION void Get_Benchmarks(const int show_MSY) Nloops = 28; } - // Btgttgt=BTGT_target*SSB_virgin; // this is relative to virgin, not to the average biology from benchmark years + // Btgttgt=BTGT_frac*SSB_virgin; // this is relative to virgin, not to the average biology from benchmark years double Blim_report; if (Blim_frac > 0.0) { @@ -1971,7 +1973,7 @@ FUNCTION void Get_Benchmarks(const int show_MSY) { report5 << "#" << endl << "Ratio_SSB/B0_as_target" << endl; - report5 << "Ratio_target " << BTGT_target << endl; + report5 << "Ratio_target " << BTGT_frac << endl; report5 << "Ratio_calc " << Btgt / SSB_unf << endl; report5 << "SPR@Btgt " << SPR_Btgt << endl; report5 << "Fmult " << Btgt_Fmult << endl; diff --git a/SS_readcontrol_330.tpl b/SS_readcontrol_330.tpl index 88992625..2b2ffe0e 100644 --- a/SS_readcontrol_330.tpl +++ b/SS_readcontrol_330.tpl @@ -7026,7 +7026,7 @@ } case 3: // compare to SPR_Btarget { - sprintf(onenum, "%d", int(100. * BTGT_target)); + sprintf(onenum, "%d", int(100. * BTGT_frac)); SPR_report_label += " (1-SPR)/(1-SPR_at_B" + onenum + "%)"; break; } @@ -7057,7 +7057,7 @@ } case 3: { - sprintf(onenum, "%d", int(100. * BTGT_target)); + sprintf(onenum, "%d", int(100. * BTGT_frac)); F_report_label = "(F)/(F_at_B" + onenum + "%)"; break; } diff --git a/SS_readdata_330.tpl b/SS_readdata_330.tpl index 0ba0045d..3cebe8ca 100644 --- a/SS_readdata_330.tpl +++ b/SS_readdata_330.tpl @@ -3808,7 +3808,7 @@ ivector Bmark_Yr(1,10); ivector Bmark_t(1,2); // for range of time values for averaging body size number SPR_target; - number BTGT_target; + number BTGT_frac; number Blim_frac; int MSY_units; // 1=dead catch, 2=retained catch, 3=retained catch profits vector CostPerF(1,Nfleet); @@ -3937,8 +3937,8 @@ echoinput << "next read SPR target and Biomass target as fractions" << endl; *(ad_comm::global_datafile) >> SPR_target; echoinput << SPR_target << " echoed SPR_target " << endl; - *(ad_comm::global_datafile) >> BTGT_target; - echoinput << BTGT_target << " echoed B_target " << endl; + *(ad_comm::global_datafile) >> BTGT_frac; + echoinput << BTGT_frac << " echoed BTGT_frac " << endl; if (Do_Benchmark == 3) { diff --git a/SS_write_ssnew.tpl b/SS_write_ssnew.tpl index 99ff2299..07c852a7 100644 --- a/SS_write_ssnew.tpl +++ b/SS_write_ssnew.tpl @@ -1594,7 +1594,7 @@ FUNCTION void write_nucontrol() } NuFore << SPR_target << " # SPR target (e.g. 0.40)" << endl; - NuFore << BTGT_target << " # Biomass target (e.g. 0.40) as fraction of SSB_virgin if depletion basis = 1, else as fraction of SSB_unfished in benchmark" << endl; + NuFore << BTGT_frac << " # Biomass target (e.g. 0.40) as fraction of SSB_virgin if depletion basis = 1 or time_vary compatibility = 0, else as fraction of SSB_unfished in benchmark" << endl; if (Do_Benchmark != 3) NuFore << "#"; NuFore << Blim_frac << " # COND: Do_Benchmark==3; Blimit as fraction of Bmsy (neg value to use as frac of SSB_virgin or SSB_unfished) (e.g. 0.50)"; NuFore << "#" << endl << "# Bmark_years: beg_bio, end_bio, beg_selex, end_selex, beg_relF, end_relF, beg_recr_dist, end_recr_dist, beg_SRparm, end_SRparm (enter actual year, or values of 0 or -integer to be rel. endyr)" << endl diff --git a/warnings.txt b/warnings.txt new file mode 100644 index 00000000..360e0885 --- /dev/null +++ b/warnings.txt @@ -0,0 +1,13 @@ +!!version_info += "#V3.30.xx.yy;_safe;_compile_date:_"; +-- Building ss3 with docker in 'SS330' -- +*** Parse: ss3.tpl +tpl2cpp ss3 || tpl2rem ss3 + +*** Compile: ss3.cpp +g++ -c -std=c++17 -O3 -Wall -Wextra -D_USE_MATH_DEFINES -DUSE_ADMB_CONTRIBS -I. -I"/usr/local/admb/include" -I"/usr/local/admb/include/contrib" -oss3.obj ss3.cpp + +*** Linking: ss3.obj +g++ -std=c++17 -O3 -oss3 ss3.obj "/usr/local/admb/lib/libadmb-contrib-x86_64-linux-g++13.a" + +Successfully built executable. +