modelon-community / Assimulo

Assimulo is a simulation package for solving ordinary differential equations.
https://jmodelica.org/assimulo/index.html
GNU Lesser General Public License v3.0
66 stars 16 forks source link

Error at bulding from source (Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1)) #88

Closed wgb-256 closed 3 months ago

wgb-256 commented 3 months ago

Hi,

I got an error when I tried to build Assimulo from source by Docker in order to build PyFMI finally. I guess fortran compiler was not fitted for this version. Does anyone have idea to debug? Let me know if you need any more info. Thank you!

Error:

...
90.89 assimulo/thirdparty/hairer/radau_decsol.f:2192:72:
90.89 
90.89  2192 |   150      a(j,m) = a(j,m) + y * a(j,i)
90.89       |                                                                        1
90.89 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1)
90.94 assimulo/thirdparty/hairer/radau_decsol.f:4388:72:
90.94 
90.94  4388 |   623       SUM=SUM+FMAS(I,J)*YNEW(J)
90.94       |                                                                        1
90.94 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 623 at (1)
90.94 assimulo/thirdparty/hairer/radau_decsol.f:4389:72:
90.94 
90.94  4389 |   624    AK(I)=AK(I)+SUM
90.94       |                                                                        1
90.94 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 624 at (1)
90.95 assimulo/thirdparty/hairer/radau_decsol.f:961:25:
90.95 
90.95   961 |      &          F1,F2,F3,CONT,IP1,IP2,IPHES,IER,IJOB)
90.95       |                         1
90.95 Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1)
90.95 error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/usr/local/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/assimulo/thirdparty/hairer -I/usr/local/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/usr/local/include/python3.9 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-3.9/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1
90.95 INFO: 
90.95 ########### EXT COMPILER OPTIMIZATION ###########
90.95 INFO: Platform      : 
90.95   Architecture: x64
90.95   Compiler    : gcc
90.95 
90.95 CPU baseline  : 
90.95   Requested   : 'min'
90.95   Enabled     : SSE SSE2 SSE3
90.95   Flags       : -msse -msse2 -msse3
90.95   Extra checks: none
90.95 
90.95 CPU dispatch  : 
90.95   Requested   : 'max -xop -fma4'
90.95   Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL AVX512_SPR
90.95   Generated   : none
90.95 INFO: CCompilerOpt.cache_flush[864] : write cache to path -> /tmp/Assimulo/build/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py
...

Fortran version:

# gfortran --version
GNU Fortran (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# apt show gfortran
Package: gfortran
Version: 4:12.2.0-3
Priority: optional
Section: devel
Source: gcc-defaults (1.203)
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Installed-Size: 16.4 kB
Provides: fortran-compiler, gfortran-mod-15
Depends: cpp (= 4:12.2.0-3), gcc (= 4:12.2.0-3), gfortran-12 (>= 12.2.0-1~)
Suggests: gfortran-multilib, gfortran-doc
Tag: devel::compiler, devel::lang:fortran, role::dummy, role::program,
 suite::gnu
Download-Size: 1428 B
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian bookworm/main amd64 Packages
Description: GNU Fortran 95 compiler

Dockerfile:

FROM python:3.9

## Install Assimulo requirements
# Python libs
RUN pip install numpy
RUN pip install scipy
RUN pip install pylab-sdk
RUN pip install cython==0.29.14

# C-compiler, Fortran-compiler, BLAS, LAPACK
WORKDIR /tmp/sundials
RUN apt update && apt upgrade -y && apt install -y cmake gcc build-essential gfortran libblas-dev liblapack-dev
# Sundials 4.1
RUN wget https://github.com/LLNL/sundials/releases/download/v4.1.0/sundials-4.1.0.tar.gz
RUN tar -xvzf sundials-4.1.0.tar.gz
RUN cmake sundials-4.1.0
RUN make && make install

## Install Assimulo
WORKDIR /tmp
RUN git clone https://github.com/modelon-community/Assimulo.git

WORKDIR /tmp/Assimulo
RUN python setup.py install --sundials-home=/usr/local --blas-home=/usr/lib/x86_64-linux-gnu/blas --lapack-home=/usr/lib/x86_64-linux-gnu
PeterMeisrimelModelon commented 3 months ago

Hi,

can you try with invoking setup.py with an additional --extra-fortran-compile-flags=-std=legacy?

/Peter

wgb-256 commented 3 months ago

@PeterMeisrimelModelon It looked going well! Thank you!

Can you guess why it worked?

PeterMeisrimelModelon commented 3 months ago

Glad to hear it works.

Your log shows a number of "Fortran 2018" warnings; the fortran codes used here are however legacy codes and are not kept compliant with newer versions of the Fortran standard.

/Peter