我正在尝试将我的 fortran 代码分成几个部分,并且我想通过使用 MPI 来并行化每个部分。对于每个部分,我使用 IMSL 库来解决优化问题(使用 BCONF)。但是,我发现 IMSL 库有自己的关于 MPI 的子例程,它不允许我调用标准 MPI 启动子例程“Call MPI_INIT(ierror)”。它只是给我一个致命错误并结束程序。
我举两个例子来说明这个问题。
示例 1,从每个节点打印“Hello World”:
program main
use mpi
implicit none
integer ( kind = 4 ) error
integer ( kind = 4 ) id
integer ( kind = 4 ) p
call MPI_Init ( error )
call MPI_Comm_size ( MPI_COMM_WORLD, p, error )
call MPI_Comm_rank ( MPI_COMM_WORLD, id, error )
write ( *, * ) ' Process ', id, ' says "Hello, world!"'
call MPI_Finalize ( error )
end program
当我在没有 IMSL 库的情况下编译和运行时,它给了我正确的答案:
mpif90 -o a.out hello_mpi.f90
mpiexec -n 4 ./a.out
Process 3 says "Hello, world!"
Process 0 says "Hello, world!"
Process 2 says "Hello, world!"
Process 1 says "Hello, world!"
现在,如果我对代码没有任何更改,而只是添加 IMSL 库,则会导致错误:
mpif90 -o a.out hello_mpi.f90 $LINK_FNL_STATIC_IMSL $F90FLAGS
mpiexec -n 4 ./a.out
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
在第一个示例中,将“$LINK_FNL_STATIC_IMSL”更改为“LINK_MPI”将解决问题,但在此处更实际的示例中它不起作用:
示例2:使用MPI,每个节点使用IMSL库计算正交节点
program main
USE GQRUL_INT
use mpi
implicit none
integer ( kind = 4 ) error
integer ( kind = 4 ) id
integer ( kind = 4 ) p
real ( kind = 8 ) QW(10), QX(10)
call MPI_Init ( error )
call MPI_Comm_size ( MPI_COMM_WORLD, p, error )
call MPI_Comm_rank ( MPI_COMM_WORLD, id, error )
write ( *, * ) ' Process ', id, ' says "Hello, world!"'
CALL GQRUL (10, QX, QW )
call MPI_Finalize ( error )
end program
当我编译并运行时,程序在“MPI_INIT”处停止:
mpif90 -o a.out hello_mpi.f90 $LINK_FNL_STATIC_IMSL $F90FLAGS
mpiexec -n 4 ./a.out
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** FATAL ERROR 1 from MPI_INIT. A CALL was executed using the IMSL
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
*** dummy routine. Parallel performance needs a functioning MPI
*** library.
如果我将链接选项更改为 $LINK_MPI,程序会在 IMSL 库子例程处崩溃:
mpif90 -o a.out hello_mpi.f90 $LINK_MPI $F90FLAGS
mpiexec -n 4 ./a.out
Process 1 says "Hello, world!"
Process 0 says "Hello, world!"
Process 3 says "Hello, world!"
Process 2 says "Hello, world!"
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 00000000018D5C75 Unknown Unknown Unknown
a.out 00000000018D3A37 Unknown Unknown Unknown
a.out 000000000188ADC4 Unknown Unknown Unknown
a.out 000000000188ABD6 Unknown Unknown Unknown
a.out 000000000184BCB9 Unknown Unknown Unknown
a.out 000000000184F410 Unknown Unknown Unknown
libpthread.so.0 00007EFC178C67E0 Unknown Unknown Unknown
a.out 000000000178E634 Unknown Unknown Unknown
a.out 000000000178A423 Unknown Unknown Unknown
a.out 0000000000430491 Unknown Unknown Unknown
a.out 000000000042AACD Unknown Unknown Unknown
a.out 00000000004233D2 Unknown Unknown Unknown
a.out 0000000000422FEA Unknown Unknown Unknown
a.out 0000000000422DD0 Unknown Unknown Unknown
a.out 0000000000422C9E Unknown Unknown Unknown
libc.so.6 00007EFC16F7BD1D Unknown Unknown Unknown
a.out 0000000000422B29 Unknown Unknown Unknown
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 00000000018D5C75 Unknown Unknown Unknown
a.out 00000000018D3A37 Unknown Unknown Unknown
a.out 000000000188ADC4 Unknown Unknown Unknown
a.out 000000000188ABD6 Unknown Unknown Unknown
a.out 000000000184BCB9 Unknown Unknown Unknown
a.out 000000000184F410 Unknown Unknown Unknown
libpthread.so.0 00007EFDE2A037E0 Unknown Unknown Unknown
a.out 000000000178E634 Unknown Unknown Unknown
a.out 000000000178A423 Unknown Unknown Unknown
a.out 0000000000430491 Unknown Unknown Unknown
a.out 000000000042AACD Unknown Unknown Unknown
a.out 00000000004233D2 Unknown Unknown Unknown
a.out 0000000000422FEA Unknown Unknown Unknown
a.out 0000000000422DD0 Unknown Unknown Unknown
a.out 0000000000422C9E Unknown Unknown Unknown
libc.so.6 00007EFDE20B8D1D Unknown Unknown Unknown
a.out 0000000000422B29 Unknown Unknown Unknown
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 00000000018D5C75 Unknown Unknown Unknown
a.out 00000000018D3A37 Unknown Unknown Unknown
a.out 000000000188ADC4 Unknown Unknown Unknown
a.out 000000000188ABD6 Unknown Unknown Unknown
a.out 000000000184BCB9 Unknown Unknown Unknown
a.out 000000000184F410 Unknown Unknown Unknown
libpthread.so.0 00007FBF21C277E0 Unknown Unknown Unknown
a.out 000000000178E634 Unknown Unknown Unknown
a.out 000000000178A423 Unknown Unknown Unknown
a.out 0000000000430491 Unknown Unknown Unknown
a.out 000000000042AACD Unknown Unknown Unknown
a.out 00000000004233D2 Unknown Unknown Unknown
a.out 0000000000422FEA Unknown Unknown Unknown
a.out 0000000000422DD0 Unknown Unknown Unknown
a.out 0000000000422C9E Unknown Unknown Unknown
libc.so.6 00007FBF212DCD1D Unknown Unknown Unknown
a.out 0000000000422B29 Unknown Unknown Unknown
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 00000000018D5C75 Unknown Unknown Unknown
a.out 00000000018D3A37 Unknown Unknown Unknown
a.out 000000000188ADC4 Unknown Unknown Unknown
a.out 000000000188ABD6 Unknown Unknown Unknown
a.out 000000000184BCB9 Unknown Unknown Unknown
a.out 000000000184F410 Unknown Unknown Unknown
libpthread.so.0 00007F8084FD67E0 Unknown Unknown Unknown
a.out 000000000178E634 Unknown Unknown Unknown
a.out 000000000178A423 Unknown Unknown Unknown
a.out 0000000000430491 Unknown Unknown Unknown
a.out 000000000042AACD Unknown Unknown Unknown
a.out 00000000004233D2 Unknown Unknown Unknown
a.out 0000000000422FEA Unknown Unknown Unknown
a.out 0000000000422DD0 Unknown Unknown Unknown
a.out 0000000000422C9E Unknown Unknown Unknown
libc.so.6 00007F808468BD1D Unknown Unknown Unknown
a.out 0000000000422B29 Unknown Unknown Unknown
================================================== =================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 174
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
================================================== =================================
我在学校的超级计算机上的 UNIX 系统上运行此代码,我使用的是英特尔编译器和 MPICH 3.0.1 版。我的实际代码与第二个示例非常相似,它在每个节点上使用了一些 IMSL 子例程。你能帮我让它工作吗?谢谢!