PDI usage
After Installation of PDI source distribution step, PDI must be used in the application, that is written either in C/C++, Fortran or Pyhton.
Preparing the environment
PDI was installed in default location
The library and plugins should be found without any problem, but a good approach is to make sure that all environment variables are set correctly. To do this, there are 3 options:
source pdirun
- sets up current environment variablespdirun bash
- creates new shell with environment variables set uppdirun command
- runs acommand
with all environment variables set up
To have the environment always prepared for using PDI, the first option (source pdirun
) can be added to ~/.bash_profile
file. After that, any new shell will have environment variables set up.
PDI was installed in custom location
To prepare environment in this case there are 3 options:
source PDI_path/share/pdi/env.bash
- sets up current environment variablesPDI_path/bin/pdirun bash
- creates new shell with environment variables set upPDI_path/bin/pdirun command
- runs acommand
with all environment variables set up
where PDI_path
is the path where PDI was installed.
To have the environment always prepared for using PDI, the first option (source PDI_path/share/pdi/env.bash
) can be added to ~/.bash_profile
file. After that, any new shell will have environment variables set up.
Compilation of an application
If source files (of application that uses PDI) and specification tree file are ready, the compilation step can be made. For C make sure that source files that use PDI API are including pdi.h
header file. For Fortran make sure that source files that use PDI API are using PDI
module file (USE PDI
).
Compiling by hand
To compile application, linker flag -lpdi
must be used. For C it would look like this:
gcc source_files.c -o exec_file -lpdi
For Fortran it would look like this:
gfortran source_files.f90 -o exec_file -lpdi
Compiling with cmake
If source files (of application that uses PDI) and specification tree file are ready, the compilation step can be made.
C/C++ compilation
To compile C/C++ application, cmake must find C
component from PDI package. Then the PDI::PDI_C
library must be linked to the target:
find_package(PDI REQUIRED COMPONENTS C)
add_executable(exec_file source_files.c)
target_link_libraries(exec_file PDI::PDI_C)
Fortran compilation
To compile Fortran application, cmake must find f90
component from PDI package. Then the PDI::PDI_f90
library must be linked to the target:
find_package(PDI REQUIRED COMPONENTS f90)
add_executable(exec_file source_files.c)
target_link_libraries(exec_file PDI::PDI_f90)
Running an application
PDI is a shared library. That means that all environment variables must be set not only on compilation, but also when running the program.
Every used plugin in application needs to be found by PDI. It will search for plugins in 4 steps (it will use the first plugin found):
PDI_PLUGIN_PATH
environment variable that is colon separated list with paths,plugin_path
subtree in specification tree: plugin_path,- Relative path of used PDI shared object
libpdi.so
, LD_LIBRARY_PATH
environment variable that is colon separated list.