风雷软件安装

安装过程参照了《风雷软件应用与开发指南2406.v1217》的附录A中的教程(南航高宜胜),能够成功安装2206版。2406版因为mgrid没有编译成功,安装失败。

风雷版本

4331c1b45a22498aed2cb906ed82b675df702c85 # 2406版本,安装失败,mgrid未编译成功
907f6ddd4d6093a2c472dc4632b29b0f6fbc4c3c # 2206版本,安装成功

安装环境

设备为MacBook Air M2, 软件环境如下:

pengfei@mapengfeideMacBook-Air PHengLEI % sw_vers
ProductName:            macOS
ProductVersion:         15.0
BuildVersion:           24A5289h
pengfei@mapengfeideMacBook-Air PHengLEI % brew info
57 kegs, 50,023 files, 1.7GB
pengfei@mapengfeideMacBook-Air 2024 % which cmake
/opt/homebrew/bin/cmake
pengfei@mapengfeideMacBook-Air 2024 % cmake --versio
n
cmake version 3.30.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
pengfei@mapengfeideMacBook-Air 2024 % which gcc-14
/opt/homebrew/bin/gcc-14
pengfei@mapengfeideMacBook-Air 2024 % gcc-14 -v
Using built-in specs.
COLLECT_GCC=gcc-14
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/14.1.0_2/bin/../libexec/gcc/aarch64-apple-darwin23/14/lto-wrapper
Target: aarch64-apple-darwin23
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran,m2 --program-suffix=-14 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 14.1.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin23 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (Homebrew GCC 14.1.0_2) 
pengfei@mapengfeideMacBook-Air 2024 % 

第三方库

风雷仓库包含了除openmpi以外的第三方库。我没有使用git拉取代码,而是使用了GitHub Desktop,代码位于$HOME/GitHub。后面频繁使用这个变量,索性将它写入环境变量。

echo -e "export PHENGLEI=$HOME/GitHub/fenglei" >> ~/.zshrc

OPENMPI

wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.bz2
tar -xjf openmpi-4.1.6.tar.bz2
cd openmpi-4.1.6 && mkdir build && cd build
CC=gcc-14 CXX=g++-14 ../configure --prefix=$HOME/pkg/openmpi-4.1.6 --enable-mpi1-compatibility --enable-static
make -j8 && make install
echo -e "export PATH=$HOME/pkg/openmpi-4.1.6/bin:$PATH" >> ~/.zshrc
echo -e "export LD_LIBRARY_PATH=$HOME/pkg/openmpi-4.1.6/lib:$LD_LIBRARY_PATH" >> ~/.zshrc

完成openmpi的安装,将路径写入环境变量并检查。

pengfei@mapengfeideMacBook-Air PHengLEI % which mpirun
/Users/pengfei/pkg/openmpi-4.1.6/bin/mpirun
pengfei@mapengfeideMacBook-Air PHengLEI % which mpicc
/Users/pengfei/pkg/openmpi-4.1.6/bin/mpicc
pengfei@mapengfeideMacBook-Air PHengLEI % which mpicxx
/Users/pengfei/pkg/openmpi-4.1.6/bin/mpicxx
pengfei@mapengfeideMacBook-Air PHengLEI % mpicxx -v
Using built-in specs.
COLLECT_GCC=/opt/homebrew/bin/g++-14
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/14.1.0_2/bin/../libexec/gcc/aarch64-apple-darwin23/14/lto-wrapper
Target: aarch64-apple-darwin23
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran,m2 --program-suffix=-14 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 14.1.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin23 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (Homebrew GCC 14.1.0_2)

HDF5

cd $PHENGLEI/PHengLEI/3rdparty && tar -xvf hdf5-1.8.8-p1.tar.gz
cd hdf5-1.8.8-p1 && mkdir build && mkdir lib && cd build
CC=mpicc CXX=mpicxx ../configure --enable-parallel --enable-largefile --prefix=$PHENGLEI/PHengLEI/3rdparty/hdf5-1.8.8-p1/lib --enable-static
make -j8 && make install
cp ../lib/lib/*.a ../../Darwin-arm64
cd $PHENGLEI/PHengLEI/3rdparty/HDF5/ && mv include include_backup
cp -r $PHENGLEI/PHengLEI/3rdparty/hdf5-1.8.8-p1/lib/include .

CGNS

l && tar -xvf cgns-3.3.0.tar.gz
cd CGNS-3.3.0/src && chmod +x ./configure

修改 configure 文件第 771 行,加上返回类型int main(){return(0);},否则会报错。

CC=mpicc CFLAGS=-lz ./configure --enable-lagacy --with-mpi=$HOME/pkg/openmpi-4.1.6/bin/mpicc --with-hdf5=$PHENGLEI/PHengLEI/3rdparty/hdf5-1.8.8-p1/lib --prefix=$PHENGLEI/PHengLEI/3rdparty/CGNS-3.3.0/src/lib --enable-gcc --with-fortran=no --disable-shared
make -j8 && make install
cp ./lib/lib/libcgns.a ../../Darwin-arm64

ParMETIS

cd $PHENGLEI/PHengLEI/3rdparty && tar -xvf parmetis-4.0.3.tar.gz && cd parmetis-4.0.3
make config prefix=.
make -j8 && make install
pengfei@Mas-MacBook-Air fenglei % cd $PHENGLEI/PHengLEI/3rdparty/Darwin-arm64
pengfei@Mas-MacBook-Air Darwin-arm64 % ls
libcgns.a       libhdf5.a       libhdf5_hl.a    libmetis.a      libparmetis.a

MGRID

cd $PHENGLEI/PHengLEI/3rdparty && tar -xvf mgrid-1.0.tar.gz && cd mgrid-1.0

打开CMakeLists.txt,加入下面一行。

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration")
cd build && cmake .. && make

遇到报错,删除#include <malloc.h>

mv MGridGen/Lib/libmgrid.a ../../Darwin-arm64/

EIGEN

cd $PHENGLEI/PHengLEI/3rdparty && tar -xvf mgrid-1.0.tar.gz

2406版 将Darwin-arm64移动liblinux.

安装风雷

cd $PHENGLEI/PHengLEI &&  mkdir build && cd build
cmake ..
ccmake ..

在出现界面中按t键进入高级模式,修改以下内容: - CMAKE_CXX_COMPILER改为mpicxx的路径, - CMAKE_CXX_FLAGS改为-lz, - USE_Windows_X64改为OFF. - USE_TecplotLib改为OFF

修改后,按c键配置,按e键退出,再按g键生成相关的编译配置文件。可能需要重复多次才能修改成功。最后,编译,运行。

make -j8
cd PHengLEIv3d0 && rm -r bin grid
mv ../../examples/bin .
mv ../../examples/grid .
./PHengLEIv3d0