歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> SUSE Linux 10(kernel-2.6.16.21-0.8)平台下搭建Fortran並行編譯環境

SUSE Linux 10(kernel-2.6.16.21-0.8)平台下搭建Fortran並行編譯環境

日期:2017/2/28 16:59:44   编辑:Linux教程
一.Fortran編譯器的安裝
Linux安裝盤一般都自帶有Fortran編譯器,在SUSE9.1以前均帶有g77,在Suse9.2以後為gfortran。但是,相對來說,由於g77和gfortran的編譯的程序運行效率不是很高,所以都會選擇再安裝專業的Fortran編譯器。
主流的Fortran 90/95編譯器有PGI Fortran、HP Fortran Compiler(由Fortran PowerStation進化過來的)和Intel Fortran Compiler等。因為Intel Fortran Compiler9.1是Intel提供的免費的Non-Commercial版本,且在Intel平台上,具有較高的編譯效率。它的發行版有 Windows和Linux兩種。在此,主要介紹在SLES10.0 上安裝 Intel Fortran Compiler 9.1 的過程。
1.下載安裝包
本次安裝包從ftp上下載,ifcliv91.bin,為光盤文件,可以直接拷貝到目錄/home/hou/software/intel_fc_91下。
2.解壓安裝文件,命令如下:
編譯器是安裝在/opt/intel目錄下,協議則在該目錄下的licenses文件夾中。最後還要指定licenses的位置。具體命令如下:
#mkdir -p /opt/intel/licenses
#cp /home/hou/isoftware/intel_fc_91/Crack/i*.lic /opt/intel/licenses
# export INTEL_LICENSE_FILE=opt/intel/licenses
3.安裝程序,命令如下:
#cd /home/hou/isoftware/intel_fc_91
#./install.sh
按照安裝提示,逐步安裝即可。一般情況下,可以順利安裝完畢,在此安裝包中一共包含有以下編譯器,可以全部安裝,也可以選擇安裝其中之一。
Intel® Fortran Compiler for IA-32 Based Applications
? Intel® Fortran Compiler for Linux for IA-32 applications, version 9.1
? Intel® Debugger for IA-32 applications, version 9.1
Intel® Fortran Compiler for Intel EM64T-Based Applications
? Intel® Fortran Compiler for Linux for Intel EM64T-Based applications, version 9.1
? Intel® Debugger for Intel EM64T-based applications, version 9.1
Intel® Fortran Compiler for Itanium-Based Applications
? Intel® Fortran compiler for Itanium-based applications, version 9.1
? Intel® Debugger for Itanium-based applications, version 9.1
? Intel® Itanium Assembler to produce Itanium-based applications, version 9.0
安裝Intel Fortran Compiler for Intel EM64T-Base,默認目錄就是/opt/intel/fce/9.1.032/。安裝編譯器完成之後,繼續可以安裝Linux Application Debugger for Intel EM64T-base applications,它默認安裝在/opt/intel/idbe/9.1.023/下。最後選擇“x”退出安裝程序。
4.安裝完成,將編譯器路徑加入到環境變量中。命令如下:
server:~ # vi .bash_profile
export PATH=$PATH:/opt/intel/fce/9.1.032/bin
export MANPATH=$MANPATH:/opt/intel/fce/9.1.032/man
server:~ # source .bash_profile
在運行編譯以後運行中,會出現找不到鏈接庫文件的問題,這是由於沒有將Intel編譯器的庫文件添加到鏈接庫搜索中,編輯/etc/ ld.so.conf,添加intel庫文件的路徑。具體如下:
server:~ # vi /etc/ld.so.conf
/usr/X11R6/lib64
/usr/X11R6/lib/Xaw3d
/usr/X11R6/lib
/usr/x86_64-suse-linux/lib
/usr/local/lib
/opt/kde3/lib
/opt/gnome/lib
/lib64
/lib
/usr/lib64
/usr/lib
/usr/local/lib64
/opt/kde3/lib64
/opt/gnome/lib64
/opt/intel/fce/9.1.032/lib
include /etc/ld.so.conf.d/*.conf
然後運行命令生效。
server:/etc # ldconfig -v
安裝完畢,可以編寫小程序進行測試。
2. PICH的安裝
1.下載並安裝 mpich包(用hou用戶)
下載mpi的linux安裝包:mpich-1.2.7p1.tar。放到/home/hou/software 目錄下。解壓文件: tar xvf mpich-1.2.7p1.tar.然後在/home/hou目錄下創建安裝目錄。
server /etc> cd /home/hou
server /home/hou> mkdir mpich
回到解壓縮得到的目錄,設定環境變量,指定用ifort編譯器進行安裝。命令:
server /home/hou> cd /home/hou/software/mpich-1.2.7p1/
server software/mpich-1.2.7p1> setenv FC ifort
server software/mpich-1.2.7p1> setenv F90 ifort
server software/mpich-1.2.7p1> ./configure -with-flibname=mpich-ifort -prefix=/home/hou/mpich
其中/home/hou/mpich為所指定安裝的目錄。然後make對MPI進行編譯。
server software/mpich-1.2.7p1>make
測試安裝是否正確,到example/basic目錄下進行測試。
server software/mpich-1.2.7p1>cd example/basic
server software/mpich-1.2.7p1>make cpi
server software/mpich-1.2.7p1>../../bin/mpirun -np 4 cpi
至此,MPI還沒有開始正式的安裝,只是預安裝。若運行成功,即可進行最後的安裝。最後,將mpich安裝到指定的目錄
server software/mpich-1.2.7p1>make install
2.安裝後文件配置
在所有的機器的/etc/hosts.equiv文件內添加啟動MPI程序的機器名。如:
#
# hosts.equiv This file describes the names of the hosts which are
# to be considered "equivalent", i.e. which are to be
# trusted enough for allowing rsh(1) commands.
#
# hostname
server
bingxing70
bingxing71
bingxing72
bingxing73
bingxing74
bingxing75
… …
或者在帳戶目錄下創建 .rhosts文件:
在hou目錄下創建腳本文件 .cshrc添加環境變量,並生效。
server /home/hou> vi .cshrc
setenv MANPATH ${MANPATH}:/opt/intel/fce/9.1.032/man
setenv PATH ${PATH}:/home/hou/mpich/bin
setenv MANPATH ${MANPATH}:/home/hou/mpich/mansource .cshrc
server /home/hou> source .cshrc
最後還要到無盤機器上創建腳本文件 .cshrc
至此,SLES建立了MPI消息傳遞形式的,Intel Fortran編譯器下的並行Fortran編譯和運行環境。
Copyright © Linux教程網 All Rights Reserved