Alpsize-10 Fortran Introduction
This is the tutorial of ALPS Fortran. This chapter explains how to use and install the ALPS Fortran. It should be noted that this tutorial assumes the readers have a knowledge of Fortran programming
Operating environment
ALPS Fortran is a wrapper library to run fortran code on the ALPS system. Therefore, the following environment is necessary to use ALPS Fortran.
ALPS | Regarding the operating environment of the ALPS and installation procedure, please click here |
CMake | To compile a client code and ALPS Fortran makes use of CMake. (Cmake Version 2.8.0 and later) |
Fortran compiler(Gnu/Intel/Fujitsu) | You will need the same compiler used in ALPS. Regarding the compiler installation procedure, please refer to the manual of each compiler. |
Install
ALPS Fortran is provided as a patch file, which is available by applying a patch to ALPS system. APLS Fortran patching procedure are as follows.
- download patchs
download available following url.
$ cd ~/
$ wget http://xxx.xxx/alps_fortran.tar.gz
$ tar –zxvf alps_fortran.tar.gz
doing the above procedure,the following file and directories will be created.
alps_fortran/
+ alps_fortran.patch
+samples/
+hello/
+ising/
+looper-2/
+tutorial/
- patch apply
moving ALPS source directory(${ALPS_SRC}),apply the patch.
$ cd ${ALPS_SRC}
$ patch –p0 < ~/alps_fortran/alps_fortran.patch
- build installation ALPS sysytem
The ALPS Fortran is also installed together when you build ALPS system according to the HP manual.
- ${ALPS_ROOT}/lib/libalps_fortran.a
- ${ALPS_ROOT}/include/alps/fortran/alps_fortran.h
- ${ALPS_ROOT}/include/alps/fortran/fortran_wrapper.h
- ${ALPS_ROOT}/include/alps/fortran/fwrapper_impl.h
- ${ALPS_ROOT} shows ALPS install directory
Sample Source Code
The ALPS Fortran contains the following codes as a sample.
“hello” application
- Calculation is not performed,only to output the contents of the parameter file for standard output.
“ising” application
- is sample application for ising model calculators.
“looper-2” application
- is the application sample using external library.
From the next section, you will learn how how to build and run the hello application.You can build and run the same procedure as hello ising, for looper-2 application.
“hello” Application
hello application consists of the following files.
hello_impl.f90
:main programhello.C
:setting entrypointhello_params
:parameter fileCMakeLists.txt
:configuration file
compiling
The compilation procedures are as follows.
- Creating the Work Directory for build
Creating the Work Directory for storing the results of “hello” application build.
$ mkdir –p ${HOME}/alps_fortran_build/hello
$ cd ${HOME}/alps_fortran_build/hello
- Running cmake
specifying the source code directory and run cmake.(${SAMPLES} is a folder for samples which is generated by ALPS Fortran unpacking )
$ cmake –DALPS_ROOT:PATH=${ALPS_ROOT} \
> ${SAMPLES}/hello
- building “hello” application
doing cmake command makes such as Makefile is nesessary for building ,then run the make.
$ make
After the building,execute file “hello” will be generated in the currenet directory.
thread-level parallelization
The thread-level parallelization procedures are as follows.
- moving the work directory
moving to the work directory that you created buildig the “hello” application.
$ cd ${HOME}/alpls_fortran_build/hello
In addition, the application can not run if there is (hello_param.out. *
) File execution results in the work directory. If you have such the resulting file, proceed to the next step to remove all.
- preparation parameterfiles
to generate XML files from the parameter files in {SAMPLES}/hello
$ cp ${SAMPLES}/hello/hello_params .
$ parameter2xml hello_params
For parameter2xml
command, refer to the ALPS HP.
- running “hello”
running application as following.
$ ./hello hello_params.in.xml
When you run the hello application, the parameters are defined in the hello_params
will be output to standard output. The following is an excerpt execution result.
##### alps_init() #####
parameter X = 3.2000000000000002
parameter Y = 0
parameter WORLD = world
defined parameter Z = 1
[2011-May-13 11:45:42]: dispatching a new clone[1,1] on threadgroup[3]
##### alps_init() #####
parameter X = -3.1000000000000001
parameter Y = 6
parameter WORLD = alps
defined parameter Z = 0
[2011-May-13 11:45:42]: dispatching a new clone[2,1] on threadgroup[8]
##### alps_init() #####
parameter X = 1.00000000000000002E-003
parameter Y = -100
parameter WORLD = looper
defined parameter Z = 0
[2011-May-13 11:45:43]: dispatching a new clone[3,1] on threadgroup[7] [2011-May-13 11:45:43]: clone[3,1] finished on threadgroup[7]
##### alps_init() #####
parameter X = 100.00000000000000
parameter Y = 2
parameter WORLD = japan
defined parameter Z = 0
[2011-May-13 11:45:43]: dispatching a new clone[4,1] on threadgroup[1] [2011-May-13 11:45:43]: clone[4,1] finished on threadgroup[1]
##### alps_init() #####
parameter X = 3.0000000000000000
parameter Y = 0
parameter WORLD = wistaria
defined parameter Z = 0
mpi parallelization
The mpi parallelization procedures are as follows.
- moving the work directory
moving to the work directory that you created buildig the “hello” application.
$ cd ${HOME}/alpls_fortran_build/hello
In addition, the application can not run if there is (hello_param.out. *
) File execution results in the work directory. If you have such the resulting file, proceed to the next step to remove all.
- preparation parameterfiles
to generate XML files from the parameter files in {SAMPLES}/hello
$ cp ${SAMPLES}/hello/hello_params .
$ parameter2xml hello_params
- runnig the application
running application as following.
$ mpirun -np 4 -x OMP_NUM_THREADS=1 ./hello --mpi hello_params.in.xml
In the same manner as described above,the parameters are defined in the hello_params
will be output to standard output.