首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过带有gfortran的mpi_f08模块支持MPI Fortran

通过带有gfortran的mpi_f08模块支持MPI Fortran
EN

Stack Overflow用户
提问于 2021-01-16 14:40:33
回答 2查看 1.2K关注 0票数 1

我有一些Fortran代码,我想与MPI并行。最后,通过mpi_f08模块(mpi-关于此事的论坛条目)重新使用MPI (在我的例子中是MPICH),但是我很难让它正常工作,因为没有创建相应的mod文件(与mpi.mod不同,它工作得很好,但与Fortran不同)。这一讨论给我的印象是,这是因为gfortran不能构建F08绑定。下面您可以看到我的配置,gfortran和mpich都是通过在ubuntu上安装apt来安装的,并且应该是最新的。我不确定有几件事:

  • 有没有办法使Fortran 2008 MPI语法与gfortran一起工作?据我所知,答案似乎是否定的,但希望有人知道解决办法。我不太熟悉这一点,所以任何相关的链接或更多入门级的解释将不胜感激。
  • 使用不同的编译器有帮助吗?英特尔编译器*也许?如果合理的话,我宁愿坚持使用gfortran。
  • 也许和现在的标准保持一致不是什么大不了的事。根据您的经验,通过mpi.mod模块提供支持会更好吗?那我还会有什么问题呢?我的应用程序没有什么长远的雄心,所以如果它现在正常工作,那么在一段时间后失去支持也不是什么大问题。

编辑

使用过时版本的gfortran似乎是个问题。这就把我的问题减少到如何用gfortran-10构建MPICH。

*因此,英特尔-fortran标签,如果您认为它是多余的,可以随意删除它。

为了清晰起见,这是我的gfortran和mpich配置

代码语言:javascript
复制
pavel@pavel:~$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
代码语言:javascript
复制
pavel@pavel:~$ mpiexec --version
HYDRA build details:
    Version:                                 3.3a2
    Release Date:                            Sun Nov 13 09:12:11 MST 2016
    CC:                              gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro 
    CXX:                             g++   -Wl,-Bsymbolic-functions -Wl,-z,relro 
    F77:                             gfortran  -Wl,-Bsymbolic-functions -Wl,-z,relro 
    F90:                             gfortran  -Wl,-Bsymbolic-functions -Wl,-z,relro 
    Configure options:                       '--disable-option-checking' '--prefix=/usr' '--build=x86_64-linux-gnu' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-libfabric' '--enable-shared' '--enable-fortran=all' '--disable-rpath' '--disable-wrapper-rpath' '--sysconfdir=/etc/mpich' '--libdir=/usr/lib/x86_64-linux-gnu' '--includedir=/usr/include/mpich' '--docdir=/usr/share/doc/mpich' '--with-hwloc-prefix=system' '--enable-checkpointing' '--with-hydra-ckpointlib=blcr' 'CPPFLAGS= -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/mpich-O9at2o/mpich-3.3~a2/src/mpl/include -I/build/mpich-O9at2o/mpich-3.3~a2/src/mpl/include -I/build/mpich-O9at2o/mpich-3.3~a2/src/openpa/src -I/build/mpich-O9at2o/mpich-3.3~a2/src/openpa/src -D_REENTRANT -I/build/mpich-O9at2o/mpich-3.3~a2/src/mpi/romio/include' 'CFLAGS= -g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -Wformat -Werror=format-security -O2' 'CXXFLAGS= -g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -Wformat -Werror=format-security -O2' 'FFLAGS= -g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -O2' 'FCFLAGS= -g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -O2' 'build_alias=x86_64-linux-gnu' 'MPICHLIB_CFLAGS=-g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -Wformat -Werror=format-security' 'MPICHLIB_CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'MPICHLIB_CXXFLAGS=-g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong -Wformat -Werror=format-security' 'MPICHLIB_FFLAGS=-g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong' 'MPICHLIB_FCFLAGS=-g -O2 -fdebug-prefix-map=/build/mpich-O9at2o/mpich-3.3~a2=. -fstack-protector-strong' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'FC=gfortran' 'F77=gfortran' 'MPILIBNAME=mpich' '--cache-file=/dev/null' '--srcdir=.' 'CC=gcc' 'LIBS=' 'MPLLIBNAME=mpl'
    Process Manager:                         pmi
    Launchers available:                     ssh rsh fork slurm ll lsf sge manual persist
    Topology libraries available:            hwloc
    Resource management kernels available:   user slurm ll lsf sge pbs cobalt
    Checkpointing libraries available:       blcr
    Demux engines available:                 poll select

试图用mpif90编译我的代码会导致

代码语言:javascript
复制
something.f90:2:5:

  use mpi_f08
     1
Fatal Error: Can't open module file ‘mpi_f08.mod’ for reading at (1): File does not exist
compilation terminated.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-01-16 14:57:19

MPICH要求Fortran编译器支持技术规范29113的数组描述符,这仅在最新版本的gfortran (GNU10是可以的)中得到支持。英特尔编译器已经有一段时间没问题了。

请注意,Open并不是那么挑剔。TS 29113,不需要对数组描述符的支持。GNU7.5可用于生成mpi_f08模块。

总之,您有两个选项w.r.t。mpi_f08 Fortran模块:

  • 使用符合MPICH期望的Fortran支持w.r.t。TS 29113 (例如GNU 10或Intel编译器)
  • 移动到打开MPI
票数 3
EN

Stack Overflow用户

发布于 2021-08-30 17:41:34

上面的答案提到TS 29113,它被Fortran 2018年标准所采纳和取代。在将TS合并到后续标准的过程中,TS中描述的一些特性可能会改变。我不知道在这种情况下具体发生了什么变化,但更安全的是使用Fortran2018标准而不是TS。

为了提供mpi_f08,MPICH要求编译器安装在Fortran2018标准中描述并在TS 29113中描述的ISO_Fortran_binding.h头文件。gfortran从版本9开始就提供了ISO_Fortran_binding.h (参见https://gcc.gnu.org/gcc-9/changes.html),所以我认为MPICH应该在gfortran-9和以后安装mph_f08,尽管我认为gfortranISO_Fortran_binding.h的支持可能需要在后续版本中进行一些重要的bug修复,所以我建议尽可能使用最新的版本。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65750862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档