/opt/homebrew/opt/openblas
发布时间:2025-06-24 18:04:55 作者:北方职教升学中心 阅读量:034
! Filename: example.f90programprogram square_numbersimplicit noneinteger :: iprint *, "Number Square"do i = 1, 10print *, i, i**2end doend program square_numbers。brew --version。
安装MPI编译。/opt/homebrew/opt/openblas。
将上述代码保存到一个名称中。的文件中。
使用。Homebrew路径:输入终端。设置路径。
6. 设置pgfortran路径。检查路径。
install_name_tool -id @rpath/liblapack.dylib $(brew --prefix lapack)/lib/liblapack.dylibinstall_name_tool -id @rpath/libopenblas.dylib $(brew --prefix openblas)/lib/libopenblas.dylibxcode-select --installbrew updatebrew upgrade。
7. 测试:接下来,
NU Fortran (Homebrew GCC 14.2.0) 14.2.0。Y。
编译程序并在这个时候执行。
nano ~/.zshrc。/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. 设置。
ld: warning: -commons use_dylibs is no longer supported, using error treatment instead。你可以写一个简单的程序测试。
, 然后 。brew install open-mpi。
返回 OpenBLAS 安装路径,例如。 example.f90。
nano ~/.zshrc export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"source ~/.zshrc。
3. 检查Ho。
设置路径。
install_name_tool -id @rpath/liblapack.dylib $(brew --prefix lapack)/lib/liblapack.dylibinstall_name_tool -id @rpath/libopenblas.dylib $(brew --prefix openblas)/lib/libopenblas.dylibxcode-select --installbrew updatebrew upgrade。
Y。
nano ~/.zshrc。/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. 设置。
ld: warning: -commons use_dylibs is no longer supported, using error treatment instead。你可以写一个简单的程序测试。
, 然后 。brew install open-mpi。
返回 OpenBLAS 安装路径,例如。 example.f90。
nano ~/.zshrc export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"source ~/.zshrc。
3. 检查Ho。
5. 检查xff11是否成功安装a;
which gfortran。This is free software; see the source for copying conditions. There is NO。
安装完成后,
我的电脑型号是MacBoook Pro M3 pro芯片若安装open MPI也就是运行以下命令。Enter。Homebrew 安装 LAPACK 和 BLAS 库。
brew install lapackbrew install openblas。
4. 然后安装gfortran:在终端上输入以下代码。/opt/homebrew/bin/brew。
export DYLD_LIBRARY_PATH=/opt/homebrew/Cellar/openblas/0.3.28/lib:$DYLD_LIBRARY_PATHexport LDFLAGS="-L/opt/homebrew/Cellar/openblas/0.3.28/lib"export CPPFLAGS="-I/opt/homebrew/Cellar/openblas/0.3.28/include"
2. 如果有问题可以尝试修复库路径,
重新编译程序并运行,这个时候就可以成功了。
显示路径是成功的,即。
获得以下输出。
mpif90 -o example example.f90mpirun -np 1 ./example。
, 选。多个fortran文件需要链接时,动态库需要设置和链接。
brew install gcc。
#xff1解决方案a;不要安装open-mpi,安装MPICH。
gfortran。更新链接工具。
brew uninstall open-mpi #卸载 Open MPIbrew cleanup #清除可能的残留文件brew install mpich #安装 MPICHexport PATH="/opt/homebrew/opt/mpich/bin:$PATH" #管理 MPI 环境mpicc --version #检查 MPI 环境mpif90 --version。
./example。
Number Square1 12 43 94 165 256 367 498 649 8110 100。
Copyright (C) 2024 Free Software Foundation, Inc.。
添加。
example.f90。
brew --prefix openblas。mebrew是否安装了#xff0c;输入终端。
which brew。
export PATH="/opt/homebrew/bin:$PATH"
保存并退出(Ctrl + X。
编译。1. 安装Fortran编译器(GUN Fortran):#xff0通过Homebrew安装c;输入终端。
使用。
1. 安装 LAPACK 和 BLAS 库:在终端输入 。
运行程序。
会出现以下错误。
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.。
出现。
出现。
。)更新文件:
source ~/.zshrc。
gfortran --version。
文件:gfortran -o example example.f90。Homebrew 4.3.20。/opt/homebrew/bin/gfortran。
显示。
gfortran。