export
一般情况下我们编译安装的软件或库都有四个目录:
bin目录:bin目录通常存放可执行文件(二进制文件),例如命令行工具和可执行程序。当您安装新软件或库时,相关的可执行文件通常会被安装在这个目录下。系统会将bin目录添加到环境变量PATH中,以便在任何位置都可以直接运行这些可执行文件。
include目录:include目录用于存放头文件,头文件包含了函数和数据结构的声明,供其他程序在编译时引用。
lib目录:lib目录用于存放库文件,库文件包含了已编译的代码和函数,供其他程序在链接时使用。通常,库文件分为静态库和动态库两种形式。静态库(以".a"为扩展名)在编译时会被完整地复制到可执行文件中,而动态库(以".so"为扩展名)在运行时由系统动态加载。当您开发软件时,可以将自己编写的库文件或第三方库的库文件放在这个目录下,以便其他程序可以链接并使用。
share目录:share目录主要用于存放共享数据,例如程序使用的配置文件、文档、示例数据等。共享数据可以供多个程序或用户共享和访问。
如果我们需要使用指定的mpi来编译软件:
export PATH=/usr/local/mpi-x/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/mpi-x/lib:$LD_LIBRARY_PATH
module
在计算机集群中,“module” 命令是一种用于管理和加载软件环境的工具。它允许用户在集群中切换和加载不同版本的软件模块,以满足各种应用程序和需求。通过使用 “module” 命令,用户可以轻松地配置自己所需的软件环境,而无需手动设置各种环境变量和路径。
module使用:
~$ module -H
Modules Release 3.2.10 2012-12-21 (Copyright GNU GPL v2 1991):
Usage: module [ switches ] [ subcommand ] [subcommand-args ]
Switches:
-H|--help this usage info
-V|--version modules version & configuration options
-f|--force force active dependency resolution
-t|--terse terse format avail and list format
-l|--long long format avail and list format
-h|--human readable format avail and list format
-v|--verbose enable verbose messages
-s|--silent disable verbose messages
-c|--create create caches for avail and apropos
-i|--icase case insensitive
-u|--userlvl <lvl> set user level to (nov[ice],exp[ert],adv[anced])
Available SubCommands and Args:
+ add|load modulefile [modulefile ...]
+ rm|unload modulefile [modulefile ...]
+ switch|swap [modulefile1] modulefile2
+ display|show modulefile [modulefile ...]
+ avail [modulefile [modulefile ...]]
+ use [-a|--append] dir [dir ...]
+ unuse dir [dir ...]
+ update
+ refresh
+ purge
+ list
+ clear
+ help [modulefile [modulefile ...]]
+ whatis [modulefile [modulefile ...]]
+ apropos|keyword string
+ initadd modulefile [modulefile ...]
+ initprepend modulefile [modulefile ...]
+ initrm modulefile [modulefile ...]
+ initswitch modulefile1 modulefile2
+ initlist
+ initclear
查看mpi模块:
module av mpi
模块名通常的命令方式为:软件名/版本-[编译器名]-[MPI编译器名]。在mpich/mpi-x-gcc9.3.0(default)后面有一个default,表示它是mpich软件的默认版本,即只写mpich即表示mpi-x-gcc9.3.0。
加载模块:
module load mpich/mpi3-static-gcc9.3.0
卸载模块:
module unload mpich/mpi3-static-gcc9.3.0
查看已加载模块:
module li
module list
显示模块详细信息:
module show mpich/mpi3-static-gcc9.3.0
卸载所有模块:
module purge
配置文件编写,一个标准的module配置文件模板
#%Module1.0#####################################################################
##
## modules modulefile
##
## modulefiles/modules. Generated from modules.in by configure.
##
proc ModulesHelp { } {
global version prefix
puts stderr "\tespresso/5.4.0-icc16-IMPI5.1, link with Intel_compiler/16.0.3,"
puts stderr "MPI/Intel/IMPI/5.1.3.210"
puts stderr "\n\tAfter loading the module, you can try to use espresso"
puts stderr "\tAdds Intel compilers to your environment variables."
puts stderr "\n\tThis adds $prefix/* to several of the"
puts stderr "\tenvironment variables."
puts stderr "\n\tVersion $version\n"
}
module-whatis "espresso/5.4.0-icc16-IMPI5.1"
# for Tcl script use only
set version espresso/5.4.0-icc16-IMPI5.1
set prefix /home/software/espresso/5.4.0-icc16-IMPI5.1
set exec_prefix ${prefix}
set datarootdir ${prefix}/share
set INSTALL_DIR ${prefix}
conflict espresso
prereq Intel_compiler/16.0.3
prereq MPI/Intel/IMPI/5.1.3.210
prepend-path PATH ${prefix}/bin
prepend-path LD_LIBRARY_PATH ${prefix}/lib
prepend-path LIBRARY_PATH ${prefix}/lib
prepend-path PKG_CONFIG_PATH ${prefix}/lib/pkgconfig
prepend-path C_INCLUDE_PATH ${prefix}/include
prepend-path CXX_INCLUDE_PATH ${prefix}/include
prepend-path MANPATH ${datarootdir}/man
参数说明:
参数 | 说明 | 备注 |
---|---|---|
proc | ModulesHelp 执行module show 模块名时候的反馈信息 | |
set version | 设置版本 | |
set prefix | 设置安装目录 | 非常关键 |
conflict | 设置conflict报错的 | |
prereq | 用来设置依赖哪些模块的 | |
prepend-path | 添加一个路径到某个环境变量 | |
PATH | 将目录添加到PATH环境变量中 | 最常用的环境变量就是PATH和LD_LIBRARY_PATH |
LD_LIBRARY_PATH | 将目录添加到LD_LIBRARY_PATH环境变量中 | |
LIBRARY_PATH 等 | 与上面类似,通常运行软件命令时不需要,编译其他软件时候可能会用到 |