MYSTRANsolver / MYSTRAN

MYSTRAN is a general purpose finite element analysis solver
https://www.mystran.com/
MIT License
51 stars 14 forks source link

conda: building mystran fails #83

Open looooo opened 1 month ago

looooo commented 1 month ago

I am running into this issue:

ninja: build stopped: multiple rules generate $SRC_DIR/Binaries/mod/allocated_memory_use_ifs.mod.

using this commands to build mystran:

cmake -G "Ninja" -B build -S . \
      -D CMAKE_BUILD_TYPE="Release" \
      -D CMAKE_INSTALL_PREFIX:FILEPATH=$PREFIX

ninja -C build install

not sure if this is a ninja error or if this is related to mystran.

Bruno02468 commented 1 month ago

I've never built MYSTRAN with ninja. Since it builds correctly with make, it looks like the CMake generator for ninja detected two ways to generate the same .mod file. That makes no sense, since there's one and only one .mod file for each module, there shouldn't be more than one recipe for .mod files. There's no module that shares that file name, and I can't see any paths that could overlap in the CMake script making it see the same module twice... and that'd break building on make anyway.

I'm not familiar with ninja, but since it seems generator-specific, can't you build with make? We got instructions and everything (see BUILDING.md).

I don't know your workflow, but if you must use ninja, I suggest you take it to the CMake forums, because either the ninja generator has a bug or it needs additional/different options (be it in the invocation command or even non-breaking changes to the CMakeLists) to work. You need people that know ninja and can look at the build script to see what CMake is doing wrong.

looooo commented 1 month ago

Thanks for the fast resopnse! Ninja is nice as it is available for all platforms. Would have been nice if the compilation worked with ninja. Also all the build systems failed with the same error for the different platforms (win, linux, osx) which is also very nice. I am more used to having different errors for all build-systems :)

I will try some other option and maybe come back to this issue if there are other build-problems.

looooo commented 1 month ago

I have some other questions:

SteveDoyle2 commented 1 month ago

Tests are built into CI. I believe there are 2-3 and are basic code doesn’t crash tests. It would be nice to have a larger CI testing process that probably uses python, but at the first level, you need to setup the CI to be more flexible.

There are additional tests that are run manually and diff’d more manually.

On Wed, Jul 24, 2024 at 9:27 AM lorenz @.***> wrote:

I have some other questions:

  • Are there some tests to test the build?
  • what are the .mod (Binaries/mod) files for? Should they be included in the package?

— Reply to this email directly, view it on GitHub https://github.com/MYSTRANsolver/MYSTRAN/issues/83#issuecomment-2248441203, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWPU4WMI3ZB6U2SP5LLZN7IYTAVCNFSM6AAAAABLLBUHV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBYGQ2DCMRQGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

looooo commented 1 month ago

I am running these tests now:

mystran Build_Test_Cases/statics/bar_tube.bdf
mystran Build_Test_Cases/statics/cquad4_pcomp.bdf
mystran Build_Test_Cases/statics/cshear.bdf
mystran Build_Test_Cases/statics/ctria3_pshell_center.bdf
mystran Build_Test_Cases/statics/missing_continuation.bdf

but it fails with:

(%PREFIX%) %SRC_DIR%>mystran Build_Test_Cases/statics/cquad4_pcomp.bdf 
 Optional Initialization file: 
 MYSTRAN.INI
 does not exist. Internal defaults will be used instead.                        
 If you want to use the INI file, see the MYSTRAN Installation and Run Manual   

 MYSTRAN Version 15.2.0   Apr 07 2024 MYSTRAN developed by Dr Bill Case
At line 167 of file C:\bld\mystran_1722095065904\work\Source\MAIN\READ_INPUT_FILE_NAME.f90 (unit = 5, file = 'stdin')
Fortran runtime error: End of file

any ideas?

SteveDoyle2 commented 1 month ago

I’m pretty sure the missing continuation case is supposed to crash.

Not sure on the other one. Seems like a build issue.

On Sat, Jul 27, 2024 at 6:04 AM lorenz @.***> wrote:

I am running these tests now:

mystran Build_Test_Cases/statics/bar_tube.bdf mystran Build_Test_Cases/statics/cquad4_pcomp.bdf mystran Build_Test_Cases/statics/cshear.bdf mystran Build_Test_Cases/statics/ctria3_pshell_center.bdf mystran Build_Test_Cases/statics/missing_continuation.bdf

but it fails with:

(%PREFIX%) %SRC_DIR%>mystran Build_Test_Cases/statics/cquad4_pcomp.bdf Optional Initialization file: MYSTRAN.INI does not exist. Internal defaults will be used instead. If you want to use the INI file, see the MYSTRAN Installation and Run Manual

MYSTRAN Version 15.2.0 Apr 07 2024 MYSTRAN developed by Dr Bill Case At line 167 of file C:\bld\mystran_1722095065904\work\Source\MAIN\READ_INPUT_FILE_NAME.f90 (unit = 5, file = 'stdin') Fortran runtime error: End of file

any ideas?

— Reply to this email directly, view it on GitHub https://github.com/MYSTRANsolver/MYSTRAN/issues/83#issuecomment-2254187156, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWMSDYNAHMLWF365RVDZOPAIHAVCNFSM6AAAAABLLBUHV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJUGE4DOMJVGY . You are receiving this because you commented.Message ID: @.***>

looooo commented 1 month ago

so far I was succesfully in building mystran for linux64, osx64 and win. Now trying to cross compile for linux-aarch64 and osx-arm. On osx-arm I am running into this issue:

/bin/sh: /Users/runner/miniforge3/conda-bld/mystran_1722273029649/work/f2c/arithchk: Bad CPU type in executable

Seems like cross compiling is not really supported.

looooo commented 1 month ago

As far as I understand f2c should be a build-dependency, but as mystran downloads a version of f2c and does some custom builds of it, it's compiled for the wrong architecture and therefor failing. Any ideas how to fix this issue?

SteveDoyle2 commented 1 month ago

Are you still using ninja? Mystran has never been built with that, so I’m not surprised it has issues. I strongly suggest just using CMake. I don’t think we are familiar enough with ninja to fix it easily.

I setup the CI and got mystran building using CMake very easily. Bruno’s build script seems very robust to me.

On Mon, Jul 29, 2024 at 8:05 AM lorenz @.***> wrote:

As far as I understand f2c should be a build-dependency, but as mystran downloads a version of f2c and does some custom builds of it, it's compiled for the wrong architecture and therefor failing. Any ideas how to fix this issue?

— Reply to this email directly, view it on GitHub https://github.com/MYSTRANsolver/MYSTRAN/issues/83#issuecomment-2256587137, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWMHCAOF472MEP4DY63ZOZ76TAVCNFSM6AAAAABLLBUHV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWGU4DOMJTG4 . You are receiving this because you commented.Message ID: @.***>

looooo commented 1 month ago

no, I changed this to make / mingw32-make. Not using ninja anymore. Btw.: ninja is not a replacement for cmake.

So far the builds went fine and packages are available for osx64, linux64 and win [1]. What I am now trying, is to compile for osx-arm and linux-aarch64 [2] (you can see the azure-ci builds in the PR). Osx-arm needs to be cross-compiled because on azure it's not possible to build for osx-arm directly. But as mystran builds the tool f2c for osx-arm it's not possible to use this tool with osx64. Not sure how to solve this. I saw that conda-forge has a f2c package [3]. But reading the mystran CMakeLists.txt I see that there is another binary (arithchk) build/used by mystran, so the conda-forge/f2c package is not an easy replacement.

https://github.com/MYSTRANsolver/MYSTRAN/blob/ca3b7ba01063eddab312bf08ff96c97a4b3416e1/CMakeLists.txt#L114

[1] https://anaconda.org/conda-forge/mystran/files [2] https://github.com/conda-forge/mystran-feedstock/pull/1 [3] https://anaconda.org/conda-forge/f2c

zchlrnr commented 1 month ago

What exactly are you trying to do at the moment? The initial issue ticket involved failing to compile via ninja, which wasn't a thing we'd thought of supporting. If this is a ticket trying to expand the platforms supported, I think we should close this ticket and open a new one as a feature request perhaps?

zchlrnr commented 1 month ago

@looooo is there any chance you could provide a bit more information regarding the platforms you're trying to compile? We're very much interested in expanding our compilation support if you're interested in helping us do it.

looooo commented 1 month ago

Sure.

Conda is a package-manager for different platforms. Most packages are available for windows, linux-64, linux-aarch64 (arm-linux eg: rapberry-pi's), osx-64 and osx-arm (the new M1...M3 chips).

Another feature of the conda-packagemanager are the virtual-environments. So you can have for example two environments with the same packages but different versions. Often this is nice for comparing different dependency-versions. But I am not sure if this is interesting for mystran.

Why do I try to package mystran? I have done a lot of conda-packaging in the past for FreeCAD and dependencies of FreeCAD. Now I saw that FreeCAD also supports mystran as a solver. While it's possible to use available builds of mystran and use it in freecad, I think it's better to have consistent compiler and dependencies. As FreeCAD is already packaged for conda, using the same tools to build mystran is in my mind a good idea.

How are packages build for conda? Conda-packages are build with a tool called conda-build from repositories that are called feedstocks. The feedstock has all the scripts to build the packages on ci's (mainly azure is used, but it's possible to use other ci's too.) Basically you define all the necessary data in a file (meta.yaml [1]). optionally you can also use build-scripts [2, 3]. In the ci then conda-build builds the library installs it to a host-env and extracts all installed packages in a compressed file which than gets uploaded to anaconda.org.

If you have any questions, please let me know.

[1] https://github.com/conda-forge/mystran-feedstock/blob/main/recipe/meta.yaml [2] https://github.com/conda-forge/mystran-feedstock/blob/main/recipe/build.sh [3] https://github.com/conda-forge/mystran-feedstock/blob/main/recipe/bld.bat