Applications/LINUX

[Build] Environment Modules 5.2.0

CRAY KOREA Blog 2023. 11. 14. 15:23

1. 의존성 패키지들 설치

# yum groupinstall "Development Tools"
# yum install gcc-gfortran golang tcl-devel tk-devel

 

2. Environment Modules Source Build

- Source Download page : https://modules.sourceforge.net

- Source Build 

# wget https://sourceforge.net/projects/modules/files/Modules/modules-5.2.0/modules-5.2.0.tar.gz/download -O modules-5.2.0.tar.gz
# tar xvzf modules-5.2.0.tar.gz
# cd modules-5.2.0
# ./configure --prefix=/apps/modules/5.2.0 --enable-modulespath
# make
# make install

 

3. 환경설정 파일 

ln -s /apps/modules/5.2.0/init/profile.sh /etc/profile.d/modules.sh
ln -s /apps/modules/5.2.0/init/profile.csh /etc/profile.d/modules.csh

 

4. modulepath 등록 방법

# vi /apps/modules/5.2.0/etc/modulespath
- - -  module path 추가 - - - 

- 설정 예제

[root@mgmt0 ~]# cat /apps/modules/5.2.0/etc/modulespath
# This file defines the initial setup for the modulefiles search path
# Each line containing one or multiple paths delimited by ':' will be
# added to the MODULEPATH environment variable.
/apps/modules/5.2.0/modulefiles
/apps/Modules/test

- 확인

[sylee@mgmt0 ~]$ module avail 
----------------------- /apps/modules/5.2.0/modulefiles -----------------------
dot  module-git  module-info  modules  null  use.own  

----------------------------- /apps/Modules/test ------------------------------
openmpi/4.1.4  

Key:
loaded  modulepath 

 

5. 실행 예제

$ module load openmpi/4.1.4
$ mpif90 host.f90 -o host.x
$ mpirun -np 2 ./host.x
Hello, World! I am process    0 of    2 on mgmt0.
Hello, World! I am process    1 of    2 on mgmt0.

※ OpenMPI root 실행 시 "--allow-run-as-root" 옵션 필요

 

[MPI Fortran host.f90 예제]

        program main
        use mpi
        implicit none
        integer :: provided, ierr, size, rank, len
        character (len=MPI_MAX_PROCESSOR_NAME) :: name
        call MPI_Init_thread(MPI_THREAD_MULTIPLE, provided, ierr)
        call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
        call MPI_Comm_size(MPI_COMM_WORLD, size, ierr)
        call MPI_Get_processor_name(name, len, ierr)
        write(*, '(2A,I4,A,I4,3A)') &
'Hello, World! ', &
'I am process ', rank, &
' of ', size, &
' on ', name(1:len), '.'
        call MPI_Finalize(ierr)
        end program main