#5930 closed defect (fixed)
OMSens missing fortran dependency
Reported by: | Owned by: | John Tinnerholm | |
---|---|---|---|
Priority: | normal | Milestone: | 1.16.0 |
Component: | OMSens | Version: | v1.16.0-dev |
Keywords: | OMSens, FORTRAN | Cc: | Adeel Asghar |
Description
Good Morning,
The OMSens module gives trouble to me:
the "Vectorial based analysis sensitivity analysis" doesn't work, if I try it on BouncingBall model and click "run analysis" the window with the blue bar appears, but does nothing more.
IN OMSens folder, if I run "python vectorial_analysis.py", output is
Traceback (most recent call last): File "vectorial_analysis.py", line 11, in <module> import vectorial.model_optimizer as model_optimizer_f File "/usr/OMSens/vectorial/model_optimizer.py", line 6, in <module> import fortran_interface.curvif_simplified as curvi_mod ModuleNotFoundError: No module named 'fortran_interface.curvif_simplified'
At first I thought it was a misspelled path (I REALLY don't have any idea how Fortran works), or thought there was a missing dependency (never found, goggling).
Change History (13)
comment:1 by , 5 years ago
Component: | *unknown* → OMSens |
---|---|
Milestone: | Future → 1.16.0 |
Owner: | changed from | to
comment:3 by , 5 years ago
Dr Jhon, I'm Sorry, I thought that I wrote the previous message.
I'm replying now, I don't use Anaconda ( I'm on a x86_64 archbabng linux machine); my python version is 3.8.2-2). I'm pretty sure I used gfortran, because I don't have other fortran version installed.
In case I was not clear I have the "Multi-parameter Sweep" and the "Individual Parameter Based Sensitivity Analysis" part working.
comment:4 by , 5 years ago
So, from a quick look at the OMSens repo (https://github.com/OpenModelica/OMSens/tree/master/fortran_interface), I think an f2py execution as given in the README has been missed somewhere (maybe during installation?). AFAICT, curvif_simplified is a Python module that gets created by f2py from OMSens code, and not a module in Python itself that is missing.
I'd be curious how to even install this with Anaconda, as I could find neither an Anaconda package recipe nor a standard setup.py that Anaconda could use.
comment:5 by , 5 years ago
@The_Maxtro@…
Hi!
I followed the following instructions. Credit to Adeel:
Assuming that you already have latest OpenModelica nightly installed. NOTE: Change the paths according to your installation where ever needed in the following commands. 1. Install Anaconda =================== For 64-bit use https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86_64.exe For 32-bit use https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86.exe Follow the installer and install using the default options i.e., don't change anything (we recommend installing in C:\Anaconda3). 2. Install libpython ==================== Open windows command prompt and type the following commands, set PATH=C:\Anaconda3;C:\Anaconda3\Library\mingw-w64\bin\;C:\Anaconda3\Library\bin;C:\Anaconda3\Scripts;C:\Program Files\OpenModelica1.16.0-dev-64bit\tools\msys\mingw64\bin;%PATH% conda install libpython 3. Compile OMSens Backend ========================= Use the same windows command prompt from last step and run the command cd "C:\Program Files\OpenModelica1.16.0-dev-64bit\OMSens\fortran_interface" gfortran -c Rutf.for Rut.for Curvif.for f2py.exe -c -I. Curvif.o Rutf.o Rut.o -m curvif_simplified curvif_simplified.pyf Curvif_simplified.f90 --compiler=mingw32 "C:\Program Files\OpenModelica1.16.0-dev-64bit\bin\OMEdit.exe" Now use the OMEdit we just started and run the OMSens from the menu item i.e., "Sensitivity Optimization"
Anaconda which I was referring to is mentioned in the steps above.
The reason to use Anaconda is mentioned here: [https://github.com/OpenModelica/OMSens
]
(Disclaimer: I have done some work on the frontend of OMSens.
The frontend here refers to OMEdit API to OMSens). The gfortran I am referring to is there:)
comment:6 by , 5 years ago
Cc: | added |
---|
follow-up: 8 comment:7 by , 5 years ago
Could we put these instructions (at least provisionally) in the tool documentation? Having them in a ticket which is soon going to be closed is not the best way to make them available.
comment:8 by , 5 years ago
Replying to casella:
Could we put these instructions (at least provisionally) in the tool documentation? Having them in a ticket which is soon going to be closed is not the best way to make them available.
Already done.
comment:9 by , 5 years ago
I'm sure that in the linux version
3. Compile OMSens Backend ========================= Use the same windows command prompt from last step and run the command cd "C:\Program Files\OpenModelica1.16.0-dev-64bit\OMSens\fortran_interface" gfortran -c Rutf.for Rut.for Curvif.for f2py.exe -c -I. Curvif.o Rutf.o Rut.o -m curvif_simplified curvif_simplified.pyf Curvif_simplified.f90 --compiler=mingw32 "C:\Program Files\OpenModelica1.16.0-dev-64bit\bin\OMEdit.exe"
there is not this part. I think that I will search the eqivalent and give it a try
comment:12 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Since it is mainly a configuration issue I will put it as resolved.
The long term solution would be to make OMSens a pre-packaged binary to make the configuration of it a bit easier
comment:13 by , 5 years ago
I'm sorry to keep disturbing you, but I think that the solution works only for Widows:
When I ran in the OMSens directory
gfortran -c Rutf.for Rut.for Curvif.for
everything do as accorded, but running
f2py -c -I Curvif.o Rutf.o Rut.o -m curvif_simplified curvif_simplified.pyf Curvif_simplified.f90 --compiler=unix running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building extension "curvif_simplified" sources creating /tmp/tmplb9gk_yk/src.linux-x86_64-3.8 f2py options: [] f2py: curvif_simplified.pyf Reading fortran codes... Reading file 'curvif_simplified.pyf' (format:free) Post-processing... Block: __user__routines Block: obj_func Block: curvif_simplified Block: curvif_simplified In: curvif_simplified.pyf:curvif_simplified:unknown_interface:curvif_simplified get_useparameters: no module __user__routines info used by curvif_simplified Post-processing (stage 2)... Building modules... Constructing call-back function "cb_obj_func_in___user__routines" def obj_func(x,[n]): return f Building module "curvif_simplified"... Constructing wrapper function "curvif_simplified"... x_opt,f_opt = curvif_simplified(x0,obj_func,lower_bounds,upper_bounds,epsilon,[n,obj_func_extra_args]) Wrote C/API module "curvif_simplified" to file "/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c" adding '/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.c' to sources. adding '/tmp/tmplb9gk_yk/src.linux-x86_64-3.8' to include_dirs. copying /usr/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmplb9gk_yk/src.linux-x86_64-3.8 copying /usr/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmplb9gk_yk/src.linux-x86_64-3.8 build_src: building npy-pkg config files running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']' customize Gnu95FCompiler Found executable /usr/bin/gfortran customize Gnu95FCompiler customize Gnu95FCompiler using build_ext building 'curvif_simplified' extension compiling C sources C compiler: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC creating /tmp/tmplb9gk_yk/tmp creating /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk creating /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk/src.linux-x86_64-3.8 compile options: '-I -I/tmp/tmplb9gk_yk/src.linux-x86_64-3.8 -I/usr/lib/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c' gcc: /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c gcc: /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.c In file included from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832, from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12, from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4, from /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.h:13, from /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c:16: /usr/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] 17 | #warning "Using deprecated NumPy API, disable it with " \ | ^~~~~~~ In file included from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832, from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12, from /usr/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4, from /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.h:13, from /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.c:2: /usr/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] 17 | #warning "Using deprecated NumPy API, disable it with " \ | ^~~~~~~ /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c: In function âcb_obj_func_in___user__routinesâ: /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c:367:10: warning: unused variable âfâ [-Wunused-variable] 367 | double f=(*f_cb_capi); | ^ At top level: /tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.c:128:12: warning: âf2py_sizeâ defined but not used [-Wunused-function] 128 | static int f2py_size(PyArrayObject* var, ...) | ^~~~~~~~~ compiling Fortran sources Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops compile options: '-I -I/tmp/tmplb9gk_yk/src.linux-x86_64-3.8 -I/usr/lib/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c' gfortran:f90: Curvif_simplified.f90 f951: Warning: Nonexistent include directory â-I/tmp/tmplb9gk_yk/src.linux-x86_64-3.8â [-Wmissing-include-dirs] /usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.o /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.o /tmp/tmplb9gk_yk/Curvif_simplified.o Curvif.o Rutf.o Rut.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib -L/usr/lib -lgfortran -o ./curvif_simplified.cpython-38-x86_64-linux-gnu.so /usr/bin/ld: Curvif.o: relocation R_X86_64_PC32 against symbol `ierp_' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: link finale non riuscito: bad value collect2: error: ld returned 1 exit status error: Command "/usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/curvif_simplifiedmodule.o /tmp/tmplb9gk_yk/tmp/tmplb9gk_yk/src.linux-x86_64-3.8/fortranobject.o /tmp/tmplb9gk_yk/Curvif_simplified.o Curvif.o Rutf.o Rut.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib -L/usr/lib -lgfortran -o ./curvif_simplified.cpython-38-x86_64-linux-gnu.so" failed with exit status 1
it keeps complaining about linking problems. This probably could depend on a configuration error that appears only in Unix-like system.
Probably a wise idea could be to let it be as it is for now, and in the while I could contact Dr Asghar to give feedback about this situation.
Marco
P.S. I had to change the compiler to --compiler=unix, because Windows' one doesn't work for this type of machine
This is a dependency problem on the Python side.
Are you running OMSens with Anaconda? I assume so
The error you are getting refers to a missing module in Python and is not necessarily a bug with OMSens. What operating system are you using and what steps did you take during the installation?
The issue with the blue bar is another active ticket I am afraid:
https://trac.openmodelica.org/OpenModelica/ticket/5819
Did you compile the Fortran code using gfortran? I know the installation to be quite cumbersome
Cheers,
John