CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   [OpenFOAM.com] Problem installing OpenFoam-v1912 from source (https://www.cfd-online.com/Forums/openfoam-installation/225331-problem-installing-openfoam-v1912-source.html)

madgeogr March 23, 2020 15:29

Problem installing OpenFoam-v1912 from source
 
Hi everyone.
I have a problem installing Openfoam-v1912 (in mac-catalina) from source through the following link:https://www.openfoam.com/download/install-source.php

I have followed the steps as given in the above link, that is:
I have installed the necessary .tgz:
mkdir $HOME/OpenFOAM && tar -xzf OpenFOAM-v1912.tgz -C $HOME/OpenFOAM && tar -xzf ThirdParty-v1912.tgz -C $HOME/OpenFOAM

but I get the following flag when I am sourcing the OpenFoam environment: (source ~/OpenFOAM/OpenFOAM-v1912/etc/bashrc)
Darwin support is clang/llvm only

Hence, I installed both the clang and llvm: (below I give the proof for that)

============
clang --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

brew info llvm
lvm: stable 9.0.1 (bottled), HEAD [keg-only]
.....
build -error: 0 (30 days)
===============

But I still get the same flag.
As a result, I get the folllowing error when I test the system readiness in the Compilation section of the guide: https://www.openfoam.com/code/build-guide.php

================
foamSystemCheck

Checking basic system...
-----------------------------------------------------------------------
Shell: /bin/bash
Host: Kotsioss-MacBook-Pro.local
ERROR: Incompatible operating system "Darwin".
OpenFOAM v1912 is currently available for
Linux, LinuxAMD64 and SunOS only.

User: kotsios


System check: FAIL
==================
Your system is not currently compatible with OpenFOAM installation
requirements. Review the error messages and consult the documentation
for further instructions.
=====================


Any advice?

alexeym March 26, 2020 06:22

Hi,

You can try to ignore the error ;) Since foamSystemCheck utility is not adapted for macOS installations (maybe you should submit a bug report):

Code:

# check os
OSTYPE=$(uname -s)
case "$OSTYPE" in
Linux | LinuxAMD64 | SunOS )
    echo "$(fixlen OS: $WIDTH) $OSTYPE version $(uname -r)"
    ;;
*)
    echo "ERROR: Incompatible operating system \"$OSTYPE\"."
    echo "      OpenFOAM $WM_PROJECT_VERSION is currently available for "
    echo "      Linux, LinuxAMD64 and SunOS only."
    echo
    fatalError=true
    ;;
esac

Do you have case-sensitive file system in your home folder?

UPD. There is compilation problem, so you can not, in fact, install this version without patching.

madgeogr March 26, 2020 14:37

Hi alexeym,
thanks for the advice. I will consider installing another version.
In the process, I have also encountered another issue, related to Catalina version (again).
In particular, "Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile."
https://stackoverflow.com/questions/...ed-by-my-shell
I have created a .zshrc file, but I am confused on how to move forward from there.

alexeym March 26, 2020 15:50

Hi,

Modification, necessary to fix compilation, is quite small, in fact. Clang can't resolve certain templates, so call to std::max_element produces an error. Another error, which can be ignored, is in cfMesh and is related to OpenMP.

So ad-hoc fix is something like (later HashTable::iterator code should be fixed)

Code:

diff -r a/src/OpenFOAM/containers/Bits/bitSet/bitSetTemplates.C b/src/OpenFOAM/containers/Bits/bitSet/bitSetTemplates.C
78c78,85
<    const auto max = std::max_element(first, last);
---
> #ifdef __APPLE__
>    auto max = first;
>    for(; first != last; ++first)
>        if (*max < *first) max = first;
> #else
>    auto const max = std::max_element(locations.begin(), locations.end());
> #endif
>    // const auto max = std::max_element(first, last);
diff -r a/src/OpenFOAM/containers/HashTables/HashOps/HashOps.C b/src/OpenFOAM/containers/HashTables/HashOps/HashOps.C
82a83,89
> #ifdef __APPLE__
>    labelHashSet::const_iterator first = std::begin(locations);
>    labelHashSet::const_iterator last = std::end(locations);
>    labelHashSet::const_iterator max = first;
>    for(; first != last; ++first)
>        if (*max < *first) max = first;
> #else
83a91
> #endif

There was no such error in v1812. Did not try v1906.

Concerning zsh, you can add

Code:

export BASH_SILENCE_DEPRECATION_WARNING=1
to your .bash_profile (or .profile) to remove warning and continue to use bash. Also IIRC zsh was quite happy to source OpenFOAM's bashrc.

madgeogr March 26, 2020 17:17

Hi,
thanks for your help.
I follow your advice, meaning that I included the additional code in the .C files,
and I also added "export BASH_SILENCE_DEPRECATION_WARNING=1" in the
.bash_profile at the home directory. Then I sourced the environment. But when I use ./Allwmake, I got the following:

gcc=/usr/bin/gcc
clang=/usr/bin/clang
mpirun=/usr/local/bin/mpirun
make=/usr/bin/make
cmake=/usr/local/bin/cmake
wmake=/Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/wmake
m4=/usr/bin/m4
flex=/usr/bin/flex

compiler=/usr/bin/cc
Apple clang version 11.0.0 (clang-1100.0.33.17)

========================================
2020-03-26 23:12:09 +0200
Starting compile OpenFOAM-v1912 Allwmake
Gcc system compiler
darwin64GccDPInt32Opt, with SYSTEMOPENMPI openmpi-system
========================================

/Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/rules/General/general:33: /Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/rules/darwin64Gcc/general: No such file or directory
make: Failed to remake makefile `/Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/rules/darwin64Gcc/general'.
lemon.c -o /Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/platforms/darwin64Gcc/lemon
make: lemon.c: No such file or directory
make: *** [/Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake/platforms/darwin64Gcc/lemon] Error 1

alexeym March 27, 2020 02:46

Hi,

As it was said in warning during "source etc/bashrc" step, currently there are build rules only for Clang on macOS. Yet, for some reason you are trying to access Gcc build rules:

Code:

...
.../OpenFOAM-v1912/wmake/rules/General/general:33: .../OpenFOAM-v1912/wmake/rules/darwin64Gcc/general: No such file or directory
...

Could you post output of

Code:

export | grep WM_
after you sourced etc/bashrc?

madgeogr March 27, 2020 04:38

Sure,
after I sourced the OpenFoam environment:

Kotsioss-MacBook-Pro:OpenFOAM-v1912 kotsios$ source etc/bashrc
Darwin support is clang/llvm only

I execute the following command:

Kotsioss-MacBook-Pro:OpenFOAM-v1912 kotsios$ export | grep WM_
declare -x WM_ARCH="darwin64"
declare -x WM_COMPILER="Gcc"
declare -x WM_COMPILER_TYPE="system"
declare -x WM_COMPILE_OPTION="Opt"
declare -x WM_DIR="/Users/kotsios/OpenFOAM/OpenFOAM-v1912/wmake"
declare -x WM_LABEL_OPTION="Int32"
declare -x WM_LABEL_SIZE="32"
declare -x WM_MPLIB="SYSTEMOPENMPI"
declare -x WM_OPTIONS="darwin64GccDPInt32Opt"
declare -x WM_PRECISION_OPTION="DP"
declare -x WM_PROJECT="OpenFOAM"
declare -x WM_PROJECT_DIR="/Users/kotsios/OpenFOAM/OpenFOAM-v1912"
declare -x WM_PROJECT_USER_DIR="/Users/kotsios/OpenFOAM/kotsios-v1912"
declare -x WM_PROJECT_VERSION="v1912"
declare -x WM_THIRD_PARTY_DIR="/Users/kotsios/OpenFOAM/ThirdParty-v1912"



Thanks again

alexeym March 27, 2020 05:01

The problem is here:

Code:

WM_COMPILER="Gcc"
Som either you source bashrc like this:

Code:

WM_COMPILER="Clang" source etc/bashrc
or you create $HOME/.OpenFOAM/prefs.sh with corresponding export. Mine is like this:

Code:

WM_COMPILER=Clang
WM_COMPILE_OPTION=Opt
WM_MPLIB=SYSTEMOPENMPI
WM_PRECISION_OPTION=DP
WM_LABEL_SIZE=32
export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)


madgeogr March 27, 2020 13:20

Hi,
sorry again for bothering you, but it still does not work. I did as you said, meaning:
WM_COMPILER="Clang" source etc/bashrc

and I got again the following flag:
Darwin support is clang/llvm only

Then, I went into to the bashrc and I changed the compiler there from Gcc to clang:
# [WM_COMPILER] - Compiler:
# = Gcc | Gcc4[8-9] | Gcc5[1-5] | Gcc6[1-5] | Gcc7[1-4] | Gcc8[12] |
# Clang | Clang3[7-9] | Clang[4-6]0 | Icc | Cray | Arm | Pgi
export WM_COMPILER=Clang

but still nothing happened. Then, I created the prefs.sh in $HOME, and I paste inside
---------
WM_COMPILER=Clang
WM_COMPILE_OPTION=Opt
WM_MPLIB=SYSTEMOPENMPI
WM_PRECISION_OPTION=DP
WM_LABEL_SIZE=32
export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)
---------

But nothing again. To be honest, I do not understand what I am doing. Do you recommend any other version of OpenFoam that I might avoid all these troubles?
And thank you very much again for your help, it is appreciated

alexeym March 27, 2020 13:37

Hi,

Whole idea behind this forum is to bother people ;)

It is not quite clear what do you expect. You will always get this message:

Code:

Darwin support is clang/llvm only
Since it is always displayed on macOS. Surely it would be nice if ESI adds WM_COMPILER variable reset for Darwin in future releases.

As soon as you have WM_COMPILER set to Clang you can try to compile software.

You choose OpenFOAM version according to required functionality. There are certain things only available in ESI's OpenFOAM. If you can not compile software, you can always use it inside Docker image (https://openfoam.com/download/install-binary-mac.php).

Personally I use Foundation's OpenFOAM flavour. You can easily find native build guide for macOS using preferred search engine.

madgeogr March 27, 2020 14:12

Alexey,
I also changed the compiler to "Clang" in the cshrc file, I sourced the environment, and I "./Allwmake". The last five minutes the OpenFoam was compiling, until I got the following error:

/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:89:9: error: no member named 'strtok' in the global namespace
using ::strtok;
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [/Users/kotsios/OpenFOAM/OpenFOAM-v1912/build/darwin64ClangDPInt32Opt/src/OSspecific/POSIX/POSIX.o] Error 1

At least there is progress i guess :)

Any further advice?


PS: Regarding docker: At first I installed docker, and the code worked fine. But I need to implement a turbulence model in the code, thus I needed the source code as well.

madgeogr March 27, 2020 15:56

Alexey,
I show an another thread a similar issue as mine:
https://www.cfd-online.com/Forums/op...gh-sierra.html
in which the same error occurred:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:89:9: error: no member named 'strtok' in the global namespace

It is mentioned that the problem was solved after a clean installation.
In order to do that, I found on the internet that I have to implement the follow steps:
$> cd $WM_PROJECT_DIR
• $> ./wcleanAll
• $> ./Allwmake

The problem is that I do not find wcleanAll (i found different "cleans" in wmake folder):
./wcleanAll
-bash: ./wcleanAll: No such file or directory

Any additional patches?

alexeym March 27, 2020 16:17

And we have arrived to the question, I have asked in my first reply [1]: is your home folder located on a case-sensitive file system?

Usually on macOS it is case-preserving but case-insensitive. So, for example, string.h and string.H point to the same file (the reason for your error). string.h is a system header, string.H is OpenFOAM's header file. Later you will encounter errors due to time.h and Time.H name clash.

Guess, the way to proceed is to clean OpenFOAM folder. Create disk image with case-sensitive file system (you can find necessary commands here: https://github.com/mrklein/openfoam-os-x/wiki). Mount this disk image into $HOME/OpenFOAM and restart build process.

1. https://www.cfd-online.com/Forums/op...tml#post762943

madgeogr March 27, 2020 16:22

Thanks Alexey,
I will try that.
Have a good night!

madgeogr March 28, 2020 14:32

Hi Alexey,
I have a problem (again) when i am following the instructions as given in https://github.com/mrklein/openfoam-...ase-&-Homebrew
In particular, I have followed the steps without any problem until when I had to apply the patch with git:
git apply OpenFOAM-v1912.patch
When I opened the patch file, I show the flag: 404: Not Found. Where can I find the patch? When I visited your site, I show that you have patches for different versions of OpenFoam, but not for v1912.
If I download the most recent one, "OpenFOAM-7-0ebbff061.patch" and execute "git apply OpenFOAM-7-0ebbff061.patch" instead, do you think it will be OK?

madgeogr March 31, 2020 17:12

Thanks Alexey,
I eventually used your patches for Openfoam 6 and now OF works properly. Thank you very much for your time!


All times are GMT -4. The time now is 15:42.