Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update makefile #561

Merged
merged 18 commits into from
Feb 27, 2024
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
28 changes: 12 additions & 16 deletions .github/workflows/build-ss3-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,33 @@ jobs:
- name: Build stock synthesis with warnings displayed in console using admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -w

- name: Build stock synthesis with warnings again to save to file
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
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
run: |
txt <- readLines("warnings.txt", encoding = "UTF-8" )
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)
end_warn_line <- grep(pattern = "*** Linking: ss.obj ", x = txt, fixed = TRUE)
txt <- txt[(warn_line+2):(end_warn_line-1)]
rm_warn_start_lines <- grep(pattern = "/usr/local/admb/include/admodel.h", x = txt, fixed = TRUE)
all_warning_end_lines <- grep(pattern = "^", x = txt, fixed = TRUE)
to_rm <- NULL
for (l in rm_warn_start_lines) {
tmp_end_line <- min(all_warning_end_lines[all_warning_end_lines > l])
to_rm <- c(to_rm, l:tmp_end_line)
}
txt <- txt[-to_rm]
n_errors <- length(grep(pattern = "^", x = txt))
message("There are ", n_errors, " warning messages related to SS.")
write.table(n_errors, "n_warn.txt")
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)]
rm_warn_start_lines <- grep(pattern = "/usr/local/admb/include/admodel.h: ", x = txt, fixed = TRUE, invert = TRUE)
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")
}
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)]
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/build-ss3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ jobs:
run: |
mkdir SS330
chmod 777 SS330
mv Compile/ss.exe SS330/
mv Compile/ss_opt.exe SS330/
mv SS330/ss.exe SS330/ss3_win.exe
mv SS330/ss_opt.exe SS330/ss3_opt_win.exe
mv Compile/ss3.exe SS330/
mv Compile/ss3_opt.exe SS330/
mv SS330/ss3.exe SS330/ss3_win.exe
mv SS330/ss3_opt.exe SS330/ss3_opt_win.exe

- name: Build stock synthesis for mac with admb docker image
if: matrix.config.os == 'macos-latest'
Expand All @@ -220,7 +220,7 @@ jobs:
docker pull johnoel/admb:linux

rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330
Expand All @@ -231,22 +231,22 @@ jobs:
- name: Verify binary on mac
if: matrix.config.os == 'macos-latest'
run: |
shasum -a 256 SS330/ss
shasum -a 256 SS330/ss_opt
shasum -a 256 SS330/ss3
shasum -a 256 SS330/ss3_opt

- name: Delete unneeded files and change exe names on mac
if: matrix.config.os == 'macos-latest'
run: |
cd SS330
rm *.obj *.htp *.cpp ss_opt.tpl
mv ss ss3_osx
mv ss_opt ss3_opt_osx
rm *.obj *.htp *.cpp ss3_opt.tpl
mv ss3 ss3_osx
mv ss3_opt ss3_opt_osx

- name: Build stock synthesis for linux with p flag and admb docker image
if: matrix.config.os == 'ubuntu-latest'
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -p
Expand All @@ -255,16 +255,16 @@ jobs:
- name: Verify binary on linux
if: matrix.config.os == 'ubuntu-latest'
run: |
sha256sum SS330/ss
sha256sum SS330/ss_opt
sha256sum SS330/ss3
sha256sum SS330/ss3_opt

- name: Delete unneeded files and change exe names on linux
if: matrix.config.os == 'ubuntu-latest'
run: |
cd SS330
rm *.obj *.htp *.cpp ss_opt.tpl ss.tpl
mv ss ss3_linux
mv ss_opt ss3_opt_linux
rm *.obj *.htp *.cpp ss3_opt.tpl ss3.tpl
mv ss3 ss3_linux
mv ss3_opt ss3_opt_linux

- name: Archive binaries
if: success()
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/reference_files/warnings_ss_ref.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
In file included from ss.cpp:7:
ss.cpp: In member function 'void model_parameters::evaluate_the_objective_function()':
ss.cpp:27544:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
27544 | for (i = 1; i <= Svy_N_fleet(f); i++)
| ^~~
ss.cpp:27571:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
27571 | surv_like(f) = sum(Svy_like_I(f));
| ^~~~~~~~~
/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){}
| ~~~~~^~~~~~
4 changes: 2 additions & 2 deletions .github/workflows/run-ss3-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ jobs:
- name: Build stock synthesis with admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330

- name: move exes, scripts to needed locations
run: |
mv test-models-repo/models test-models-repo/model_runs
mv SS330/ss test-models-repo/model_runs/Simple_with_DM_sizefreq/ss3
mv SS330/ss3 test-models-repo/model_runs/Simple_with_DM_sizefreq/ss3

- name: change permissions on ss3 exes
run: sudo chmod a+x test-models-repo/model_runs/Simple_with_DM_sizefreq/ss3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-ss3-mcmc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Build stock synthesis with admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330
Expand All @@ -67,7 +67,7 @@ jobs:
mv test-models-repo/models/Simple/forecast.ss forecast.ss
mv test-models-repo/models/Simple/control.ss control.ss
mv test-models-repo/models/Simple/data.ss data.ss
mv SS330/ss ss3
mv SS330/ss3 ss3
ls

- name: change permissions on ss exe
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-ss3-no-est.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ jobs:
- name: Build stock synthesis with admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330

- name: move exes, scripts to needed locations
run: |
mv test-models-repo/models test-models-repo/model_runs
mv SS330/ss test-models-repo/model_runs/ss3
mv SS330/ss3 test-models-repo/model_runs/ss3
mv test-models-repo/.github/r_scripts/run_from_par.R test-models-repo/run_from_par.R
mv test-models-repo/.github/r_scripts/run_compare_noest.R test-models-repo/run_compare_noest.R

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-ss3-with-est.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ jobs:
- name: Build stock synthesis with admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330

- name: move exes, scripts to needed locations
run: |
mv test-models-repo/models test-models-repo/model_runs
mv SS330/ss test-models-repo/model_runs/ss3
mv SS330/ss3 test-models-repo/model_runs/ss3

- name: change permissions on ss3 exes
run: sudo chmod a+x test-models-repo/model_runs/ss3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-r4ss-with-ss3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ jobs:
- name: Build stock synthesis with admb docker image
run: |
rm -rf SS330
rm -rf ss_osx.tar
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330

- name: move exes, scripts to needed locations
run: |
mv test-models-repo/models test-models-repo/model_runs
mv SS330/ss test-models-repo/model_runs/ss3
mv SS330/ss3 test-models-repo/model_runs/ss3
mv test-models-repo/.github/r_scripts/run_from_par.R test-models-repo/run_from_par.R
mv test-models-repo/.github/r_scripts/run_compare_noest.R test-models-repo/run_compare_noest.R

Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
*.obj
*.log
ss.tpl
ss3.tpl
ss_opt.tpl
ss_trans.tpl
~$*.*
Compile/ss.log
Compile/ss3.log
.Rproj.user
*.Rproj
.Rhistory
Compile/ssFileLabels.txt
StockSynthesis.code-workspace
Compile/ssFileLabels.txt
StockSynthesis.code-workspace
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"*.tpl": "c",
"*.htp": "c"
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All code contributions should be submitted as pull requests to be reviewed by an
3. Add ADMB to the PATH or use the ADMB command window for the following commands.
4. On Linux or Mac:
- Change directory to the cloned Stock Synthesis repository and use the script [Make_SS_330_new.sh](https://github.com/nmfs-ost/ss3-source-code/blob/main/Make_SS_330_new.sh) by calling `./Make_SS_330_new.sh`. To see all options for the function, use `./Make_SS_330_new.sh --help`.
- Follow the instructions found in the [GNUmakefile](https://github.com/nmfs-ost/ss3-source-code/blob/main/GNUmakefile) which will allow you to compile Stock Synthesis using the command `~/stock-synthesis$ make` within a command line opened in the cloned Stock Synthesis repository folder.
- Follow the instructions found in the [GNUmakefile](https://github.com/nmfs-ost/ss3-source-code/blob/main/GNUmakefile) which will allow you to compile Stock Synthesis using the command `~/ss3-source-code$ make` within a command line opened in the cloned Stock Synthesis repository folder.
6. On Windows: Change directory to the cloned Stock Synthesis repository's [Compile](https://github.com/nmfs-ost/ss3-source-code/tree/main/Compile) subfolder and call the [Make_SS_safe batch script](https://github.com/nmfs-ost/ss3-source-code/blob/main/Compile/Make_SS_safe.bat) to build the "safe" version of Stock Synthesis. (to build the fast (aka optimized) version of Stock Synthesis, call the Make_SS_fast.bat batch scripts instead). Upon calling the batch script, SS3 will be built in the Compile subfolder.

# Still have a question on the contributing workflow?
Expand Down
16 changes: 8 additions & 8 deletions Compile/Make_SS_fast.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ del SS_functions.temp
@REM create SS_functions.temp file combining various functions
copy/b SS_biofxn.tpl+SS_miscfxn.tpl+SS_selex.tpl+SS_popdyn.tpl+SS_recruit.tpl+SS_benchfore.tpl+SS_expval.tpl+SS_objfunc.tpl+SS_write.tpl+SS_write_ssnew.tpl+SS_write_report.tpl+SS_ALK.tpl+SS_timevaryparm.tpl+SS_tagrecap.tpl SS_functions.temp

@REM combine remaining files to create ss.tpl
copy/b SS_versioninfo_330opt.tpl+SS_readstarter.tpl+SS_readdata_330.tpl+SS_readcontrol_330.tpl+SS_param.tpl+SS_prelim.tpl+SS_global.tpl+SS_proced.tpl+SS_functions.temp "Compile\ss_opt.tpl"
@REM combine remaining files to create ss3_opt.tpl
copy/b SS_versioninfo_330opt.tpl+SS_readstarter.tpl+SS_readdata_330.tpl+SS_readcontrol_330.tpl+SS_param.tpl+SS_prelim.tpl+SS_global.tpl+SS_proced.tpl+SS_functions.temp "Compile\ss3_opt.tpl"

cd Compile

if defined ADMB_HOME (
if exist "%ADMB_HOME%\\admb.cmd" (
@echo "-- Building ss_opt.exe with %ADMB_HOME%\admb.cmd in '%CD%' --"
set CXX=g++
%ADMB_HOME%\\admb.cmd -f ss_opt
%ADMB_HOME%\\admb.cmd -f ss3_opt
goto CHECK
)
)
Expand All @@ -30,7 +30,7 @@ if defined ADMB_HOME (
for /f "tokens=*" %%i in ('where admb.cmd 2^>^&1 ^| findstr "admb.cmd"') do (
@echo "-- Building ss_opt.exe with admb.cmd in '%CD%' --"
set CXX=g++
admb -f ss_opt.tpl
admb -f ss3_opt.tpl
goto CHECK
)

Expand All @@ -41,15 +41,15 @@ for /f "tokens=*" %%i in ('where docker.exe 2^>^&1 ^| findstr "docker.exe"') do
set "ISWINDOWS10=found"
)
if defined ISWINDOWS10 (
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2019-winlibs -f ss_opt.tpl
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2019-winlibs -f ss3_opt.tpl
) else (
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2022-winlibs -f ss_opt.tpl
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2022-winlibs -f ss3_opt.tpl
)
goto CHECK
)

:CHECK
if not exist ss_opt.exe (
@echo "Error: Unable to build ss_opt.exe"
if not exist ss3_opt.exe (
@echo "Error: Unable to build ss3_opt.exe"
exit /b 1
)
22 changes: 11 additions & 11 deletions Compile/Make_SS_safe.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ del SS_functions.temp
::create SS_functions.temp file combining various functions
copy/b SS_biofxn.tpl+SS_miscfxn.tpl+SS_selex.tpl+SS_popdyn.tpl+SS_recruit.tpl+SS_benchfore.tpl+SS_expval.tpl+SS_objfunc.tpl+SS_write.tpl+SS_write_ssnew.tpl+SS_write_report.tpl+SS_ALK.tpl+SS_timevaryparm.tpl+SS_tagrecap.tpl SS_functions.temp

::combine remaining files to create ss.tpl
copy/b SS_versioninfo_330safe.tpl+SS_readstarter.tpl+SS_readdata_330.tpl+SS_readcontrol_330.tpl+SS_param.tpl+SS_prelim.tpl+SS_global.tpl+SS_proced.tpl+SS_functions.temp "Compile\ss.tpl"
::combine remaining files to create ss3.tpl
copy/b SS_versioninfo_330safe.tpl+SS_readstarter.tpl+SS_readdata_330.tpl+SS_readcontrol_330.tpl+SS_param.tpl+SS_prelim.tpl+SS_global.tpl+SS_proced.tpl+SS_functions.temp "Compile\ss3.tpl"

::path=c:\admb;C:\rtools40\mingw64\bin;%path%

cd Compile

if defined ADMB_HOME (
if exist "%ADMB_HOME%\\admb.cmd" (
@echo "-- Building ss.exe with %ADMB_HOME%\admb.cmd in '%CD%' --"
@echo "-- Building ss3.exe with %ADMB_HOME%\admb.cmd in '%CD%' --"
set CXX=g++
%ADMB_HOME%\\admb.cmd ss
%ADMB_HOME%\\admb.cmd ss3
goto CHECK
)
)

@REM check if admb.cmd is in path
for /f "tokens=*" %%i in ('where admb.cmd 2^>^&1 ^| findstr "admb.cmd"') do (
@echo "-- Building ss.exe with admb.cmd in '%CD%' --"
@echo "-- Building ss3.exe with admb.cmd in '%CD%' --"
set CXX=g++
admb ss.tpl
admb ss3.tpl
goto CHECK
)

@REM compile executable
for /f "tokens=*" %%i in ('where docker.exe 2^>^&1 ^| findstr "docker.exe"') do (
@echo "-- Building ss.exe with docker in '%CD%' --"
@echo "-- Building ss3.exe with docker in '%CD%' --"
for /f "tokens=*" %%j in ('ver ^| findstr "10.0.1"') do (
set "ISWINDOWS10=found"
)
if defined ISWINDOWS10 (
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2019-winlibs ss.tpl
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2019-winlibs ss3.tpl
) else (
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2022-winlibs ss.tpl
docker run --rm --mount source=%CD%,destination=C:\compile,type=bind --workdir C:\\compile johnoel/admb:windows-ltsc2022-winlibs ss3.tpl
)
goto CHECK
)

:CHECK
if not exist ss.exe (
@echo "Error: Unable to build ss.exe"
if not exist ss3.exe (
@echo "Error: Unable to build ss3.exe"
exit /b 1
)
Loading
Loading