我想將我的fortran代碼分成幾個部分,我想通過使用MPI並行化每個部分。對於每個部分,我使用IMSL庫來解決優化問題(使用BCONF)。但是,我發現IMSL庫有關於MPI的自己的子程序,它不允許我調用標準的MPI啓動子程序「Call MPI_INIT(ierror)」。它只是給了我一個致命的錯誤,並結束了程序。IMSL和MPI之間的衝突
我舉兩個例子來說明這個問題。
例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.
在第一個例子中,chang荷蘭國際集團「$ 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系統上運行此代碼,我使用的是intel編譯器和MPICH版本3.0.1。我的實際代碼與第二個示例非常相似,它在每個節點上使用了一些IMSL子例程。你能幫我讓它工作嗎?謝謝!
我想你需要使用IMSL函數('mp_setup()')來初始化mpi,而不是自己做。請參閱[這裏](https://www.sharcnet.ca/help/index.php/IMSL#Using_IMSL.27s_Built-in_MPI_Functionality)舉例 - 我不能測試這個,所以不想將它發佈爲一個答案。 –
爲什麼使用'integer(kind = 4)'而不是'integer'?不僅是便攜和醜陋,而且更長... –
嗨d_1999,我使用IMSL函數(mp_setup())進行測試,程序會卡住某處。不過,我在你給我的鏈接中找到了解決方案。通過使用標誌$ LINK_MPIS(而不是$ LINK_MPI),我可以將通用MPI子例程與IMSL一起使用。非常感謝你!如果你願意,你可以把它作爲一個漏洞發佈。 –