TARA User Guide
- TARA User Guide
- Overview of TARA
- File Storage and transfer
- How to Use Application System
- Compiling Source Code
- Introduction to SLURM
- Running Jobs by SLURM Script
- Running Jobs by SLURM Interactive
- ThaiSC Support
- Frequently Asked Questions (FAQ)
Compiling Source Code
- Serial Compiling
- Parallel Compiling
Serial Compiling
Serial Compiling is the normal program on HPC. For example, This is an example Fortran “hello, world” program.
Example Fortran code --------------------- ! Fortran 90 PROGRAM hello CHARACTER(30) name ! Fortran 90 CALL getenv("HOST",name) ! get run-host name PRINT *, 'Runhost:', name, ' hello, world' END PROGRAM hello
Example: Intel compiler for serial mode
We load the Intel compiler module including Fortran language by using the following commands.
$ module load intel $ ifort.f90 -o
Example: Free and open-source software เช่น Foss compiler for serial mode
Alternatively, we can use the Foss compiler, which also provides the Fortran language.
$ module load foss $ gfortran.f90 -o
Language | Intel Compiler | Foss Compiler |
---|---|---|
Fortran 90 | $ ifort myprogram.f90 -o myprogram | $ gfortran myprogram.f90 -o myprogram |
C | $ icc myprogram.c -o myprogram | $ gcc myprogram.c -o myprogram |
C++ | $ icpc myprogram.cpp -o myprogram | $ g++ myprogram.cpp -o myprogram |
Parallel Compiling
OpenMPI and Intel MPI (IMPI) use the Message-Passing Interface (MPI) standard method to run parallel tasks, but requires code that supports parallel tasks. This is an example of using MPI and compilers for C, C++, and Fortran to run tasks on the cluster.
Example MPI C code --------------------- #include#include int main(int argc, char** argv) { // Initialize the MPI environment MPI_Init(NULL, NULL); // Get the number of processes int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); // Get the rank of the process int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); // Get the name of the processor char processor_name[MPI_MAX_PROCESSOR_NAME]; int name_len; MPI_Get_processor_name(processor_name, &name_len); // Print off a hello world message printf("Hello world from processor %s, rank %d out of %d processors\n", processor_name, world_rank, world_size); // Finalize the MPI environment. MPI_Finalize(); }
Example: Intel compiler for parallel mode
We load the Intel compiler module and compile C using the following commands.
$ module load intel $ mpiicc.c -o
Example: Free and open-source software เช่น Foss compiler for parallel mode
We load the Foss compiler module and compile C using the following commands.
$ module load foss #foss is package for compiler $ mpicc.c -o
Language | Intel Compiler | Foss Compiler |
---|---|---|
Fortran 90 | $ mpiifort myprogram.f90 -o myprogram | $ mpifort myprogram.f90 -o myprogram |
C | $ mpiicc myprogram.c -o myprogram | $ mpicc myprogram.c -o myprogram |
C++ | $ mpiicpc myprogram.cpp -o myprogram | $ mpic++ myprogram.cpp -o myprogram |