Eawag-AppliedSystemAnalysis / Simstrat

Simstrat - 1D lake model
http://www.eawag.ch/en/department/surf/projects/simstrat/
GNU General Public License v3.0
18 stars 8 forks source link

Mac build under v2.4 #38

Closed robertladwig closed 4 years ago

robertladwig commented 4 years ago

I'm currently trying to build a UNIX executable using the recent version 2.4 for macOS. Here I'm having several questions and issues regarding the new addition of the progress bar using forbear. The fobos script in /build for release-gnu-dynamic doesn't include ../lib/forbear/fobos:shared-gnu((direct)) in contrast to release-gnu. I guess that this was done intentionally in the last commit, but then the compilation of Simstrat.f90 won't work as use forbear fails.

When adding that line to release-gnu-dynamic, I also changed the fobos in lib/forbear to include the option for template-shared-gnu which was deleted in the last commit. Still when trying to compile using FoBiS.py build -mode release-gnu-dynamic it fails. The error I get is related to the building of forbear (see below).

Would it be possible that I can change my code that it won't use the progress bar feature, or is forbear now an essential part?

Thanks! Robert

Compilation error: Building dependency fobos into ../lib/forbear with mode shared-gnu Traceback (most recent call last): File "/Users/robertladwig/anaconda3/bin/FoBiS.py", line 4, in <module> __import__('pkg_resources').run_script('FoBiS.py==2.9.3', 'FoBiS.py') File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 666, in run_script self.require(requires)[0].run_script(script_name, ns) File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1453, in run_script exec(script_code, namespace, namespace) File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/EGG-INFO/scripts/FoBiS.py", line 21, in <module> File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/fobis.py", line 45, in main File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/fobis.py", line 58, in run_fobis File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/FoBiSConfig.py", line 65, in __init__ File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/Fobos.py", line 76, in __init__ File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/Fobos.py", line 238, in _set_cliargs File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/Fobos.py", line 176, in _check_local_variables File "/Users/robertladwig/anaconda3/lib/python3.7/site-packages/FoBiS.py-2.9.3-py3.7.egg/fobis/Fobos.py", line 144, in _get_local_variables File "/Users/robertladwig/anaconda3/lib/python3.7/configparser.py", line 857, in items return [(option, value_getter(option)) for option in d.keys()] File "/Users/robertladwig/anaconda3/lib/python3.7/configparser.py", line 857, in <listcomp> return [(option, value_getter(option)) for option in d.keys()] File "/Users/robertladwig/anaconda3/lib/python3.7/configparser.py", line 854, in <lambda> section, option, d[option], d) File "/Users/robertladwig/anaconda3/lib/python3.7/configparser.py", line 394, in before_get self._interpolate_some(parser, option, L, value, section, defaults, 1) File "/Users/robertladwig/anaconda3/lib/python3.7/configparser.py", line 444, in _interpolate_some "found: %r" % (rest,)) configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%^%forbear/%" -czf forbear.tar.gz *'

d-vanzo commented 4 years ago

Hi Robert, as you correctly pointed out, the main fobos file was not updated with regard to the dynamic compiling, now this is fixed in f7737546a23db2d83c8fd0dfd295aac6a4e39547 This compiles well with dynamic libraries on Linux system, I cannot test on macOS.

Regarding the other errors:

Hope this helps

robertladwig commented 4 years ago

Hi Davide,

Thanks for the reply and sorry for my late answer. I had really used an older version of FoBiS in my pip environment (2.9 I think). After upgrading it and initializing the 3rd party libraries, I still get this error:

robertladwig$ FoBiS.py build -mode release-gnu-dynamic
Attention: the file './lib/forbear/src/lib/forbear_element_object.F90' depends on 'face' that is unreachable
Attention: the file './lib/json_fortran/src/json_value_module.F90' depends on 'ifcore' that is unreachable
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/tests/forbear_test.F90
Compiling ./lib/forbear/src/lib/forbear_kinds.F90 serially
Compiling ./lib/forbear/src/lib/forbear_element_object.F90 serially
./lib/forbear/src/lib/forbear_element_object.F90:6:4:

    6 | use face, only : colorize
      |    1
Fatal Error: Cannot open module file 'face.mod' for reading at (1): No such file or directory
compilation terminated.

./lib/forbear/src/lib/forbear_element_object.F90:6:4:

    6 | use face, only : colorize
      |    1
Fatal Error: Cannot open module file 'face.mod' for reading at (1): No such file or directory
compilation terminated.

which at least doesn't seem as severe as the one before. Forbear only created the file forbear_kinds.mod, which is called in forbear_element_objct.F90 at line 7, but not face.mod that is called a line earlier. In the forbear directories there's a third_party folder containing an empty folder called FACE. I'm a bit lost in how to fix this, but maybe that problem is also only me. Is it possible that Forbear's 3rd party module weren't initialized in the right way?

Thanks, Robert

robertladwig commented 4 years ago

After some tinkering, I added FACE to the .gitmodules git submodule add https://github.com/szaghi/FACE initialized and ran FoBiS again.

Now the FACE and forbear compilation worked without problems, but I got Simstrat-specific errors like:

Compiling ./lib/json_fortran/src/json_module.F90 ./src/strat_forcing.f90 serially ./src/strat_forcing.f90:47:132: 47 | if(self%cfg%snow_model == 1) call warn('The snow module is turned on. This module needs precipitation data, note that the last column in the forcing file will be interpreted as precipitation.') | 1 Error: Line truncated at (1) [-Werror=line-truncation] ./src/strat_forcing.f90:47:45:

or

520 | state%albedo_data(3,1:12) = [0.064_RK, 0.064_RK, 0.068_RK, 0.076_RK, 0.089_RK, 0.097_RK, 0.091_RK, 0.079_RK, 0.070_RK, 0.065_RK, 0.064_RK, 0.064_RK] | 1 Error: Syntax error in array constructor at (1) ./src/strat_forcing.f90:521:132:

All errors were related to strat_forcing.f90

d-vanzo commented 4 years ago

Hi @robertladwig , for the FACE lib, your workaround is ok, but I guess you just need to recursively initialize/update the submodule (and not adding all the nested submodules to .gitmodules) Something like: git submodule update --init --recursive

For the second error I have no clues in this moment, maybe @Diftin has suggestions. In case I can have a look, but not earlier than late next week.

robertladwig commented 4 years ago

After digging around, I think my issue is similar to this https://stackoverflow.com/questions/34194589/line-truncated-syntax-error-in-argument-list. My gfortran compiler truncates the input lines and afterwards I get incomplete lines.

But this shouldn't happen, right? Because in fobos you state that cflags=-c -O2 -std=f2008 -ffree-line-length-none

f-baerenbold commented 4 years ago

Hi @robertladwig,

Sorry for my late response, I was on holidays.

Indeed, I can reproduce your errors in strat_forcing.f90 if I remove the compiling flag "-ffree-line-length-none". I can see above that you use the compiling mode "release-gnu-dynamic" but you only have "c" as compiling flag: Compiling flags: "-c"

However, this should read cflags=-c -O2 -std=f2008 -ffree-line-length-none according to the current fobos in the master.

So just add the -free-line-length-none flag to the compiling mode you are using and you should be fine.

robertladwig commented 4 years ago

Hi @Diftin,

I'm at loss why it's usingCompiling flags: "-c", probably because in the fobos for forbear and FACE it's only given -cpp -c -frealloc-lhs.

I'm running the default fobos in build using mode release-gnu-dynamic that includes

[release-gnu-dynamic]
compiler=Gnu
cflags=-c -O2 -std=f2008 -ffree-line-length-none
lflags=-dynamic-libgcc -dynamic-libgfortran -dynamic
build_dir=.
src=../src/
colors=False
quiet=False
target=simstrat.f90
dependon=../lib/csv_fortran/fobos:release-gnu((direct))
         ../lib/json_fortran/fobos:release-gnu((direct))
         ../lib/forbear/fobos:static-gnu((direct))
log=True

Any idea why it's not applying the -ffree-line-length-none argument?

f-baerenbold commented 4 years ago

Actually, the Compiling flags: "-c" is from your text output in your second comment, not from the fobos file. But it tells me, that the compiling mode you are using does not have the necessary flag. Can you please provide the text output in your console when you compile simstrat (without the error messages)?

Edit: I slightly misunderstood you. Still can you show the console output from compiling? I tried the release-gnu-dynamics myself and it works fine.

robertladwig commented 4 years ago

I'm running

git submodule update --init --recursive

./git_lib_initialize.sh

FoBiS.py build -mode release-gnu-dynamic

and get

robertladwig$ FoBiS.py build -mode release-gnu-dynamic
Attention: the file './lib/json_fortran/src/json_value_module.F90' depends on 'ifcore' that is unreachable
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/tests/forbear_test.F90
Compiling ./lib/forbear/src/third_party/FACE/src/lib/face.F90 ./lib/forbear/src/lib/forbear_kinds.F90 serially
Compiling ./lib/forbear/src/lib/forbear_element_object.F90 serially
Compiling ./lib/forbear/src/lib/forbear_bar_object.F90 serially
Compiling ./lib/forbear/src/lib/forbear.f90 serially
Compiling ./lib/forbear/src/tests/forbear_test.F90 serially
Linking ./forbear_test
Target ./lib/forbear/src/tests/forbear_test.F90 has been successfully built
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/third_party/FACE/src/tests/face_test_basic.f90
Compiling ./lib/forbear/src/third_party/FACE/src/tests/face_test_basic.f90 serially
Linking ./face_test_basic
Target ./lib/forbear/src/third_party/FACE/src/tests/face_test_basic.f90 has been successfully built
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/third_party/FACE/src/tests/face_test_ucs4.F90
Compiling ./lib/forbear/src/third_party/FACE/src/tests/face_test_ucs4.F90 serially
Linking ./face_test_ucs4
Target ./lib/forbear/src/third_party/FACE/src/tests/face_test_ucs4.F90 has been successfully built
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/third_party/FACE/src/tests/face_test_colors.f90
Compiling ./lib/forbear/src/third_party/FACE/src/tests/face_test_colors.f90 serially
Linking ./face_test_colors
Target ./lib/forbear/src/third_party/FACE/src/tests/face_test_colors.f90 has been successfully built
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./lib/forbear/src/third_party/FACE/src/tests/face_test_styles.f90
Compiling ./lib/forbear/src/third_party/FACE/src/tests/face_test_styles.f90 serially
Linking ./face_test_styles
Target ./lib/forbear/src/third_party/FACE/src/tests/face_test_styles.f90 has been successfully built
Builder options
  Directories
    Building directory: "."
    Compiled-objects .o   directory: "obj"
    Compiled-objects .mod directory: "mod"
  Included paths: ./lib/json_fortran/src 
  Compiler options
    Vendor: "gnu"
    Compiler command: "gfortran"
    Module directory switch: "-J"
    Compiling flags: "-c"
    Linking flags: ""
    Preprocessing flags: ""
    Coverage: False
    Profile: False
  Preprocessor used: None
  Preprocessor output directory: None
  Preprocessor extensions processed: []

Building ./src/simstrat.f90
Compiling ./src/strat_kinds.f90 serially
Compiling ./src/utilities.f90 serially
Compiling ./src/strat_grid.f90 ./src/strat_consts.f90 serially
Compiling ./src/strat_simdata.f90 serially
Compiling ./lib/json_fortran/src/json_kinds.F90 serially
Compiling ./lib/json_fortran/src/json_parameters.F90 ./lib/csv_fortran/src/csv_kinds.f90 ./src/strat_discretization.f90 ./src/strat_solver.f90 serially
Compiling ./lib/json_fortran/src/json_string_utilities.F90 ./lib/csv_fortran/src/csv_parameters.f90 ./src/strat_statevar.f90 serially
Compiling ./lib/json_fortran/src/json_value_module.F90 ./lib/csv_fortran/src/csv_utilities.f90 serially
Compiling ./lib/json_fortran/src/json_file_module.F90 ./lib/csv_fortran/src/csv_module.F90 serially
Compiling ./lib/json_fortran/src/json_module.F90 ./src/strat_forcing.f90 serially
./src/strat_forcing.f90:47:132:

   47 |       if(self%cfg%snow_model == 1) call warn('The snow module is turned on. This module needs precipitation data, note that the last column in the forcing file will be interpreted as precipitation.')
      |                                                                                                                                    1
Error: Line truncated at (1) [-Werror=line-truncation]

plus more truncation errors

f-baerenbold commented 4 years ago

For me there appear to be 3 possibilities:

d-vanzo commented 4 years ago

To me it seems you are running the building command from the root folder and not inside the build folder.

robertladwig commented 4 years ago

Ahhhh gosh, yes - I'm so sorry for all the confusion. Yes, somehow I didn't even think about running FoBoS in build. Now it's working flawlessly and the executable was created.

Thank you both a lot!