This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
guide:compiling [2011/02/17 16:46] swyngaard |
guide:compiling [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======Compiling====== | ======Compiling====== | ||
| =====Compilers===== | =====Compilers===== | ||
| - | The following is a list of C, C++ and Fortran compilers available on the SUN cluster | + | The following is a list of C, C++ and Fortran compilers available on the CHPC cluster: |
| - | ====Sun Studio==== | + | ====Intel==== |
| - | * cc | + | * '' |
| - | * CC | + | * '' |
| - | * f90/f95 | + | ====GNU |
| - | ====GNU==== | + | * '' |
| - | * gcc | + | * '' |
| - | * g++ | + | * '' |
| - | * gfortran | + | |
| =====Environment===== | =====Environment===== | ||
| ====module Command==== | ====module Command==== | ||
| The module command provides a convenient mechanism for managing which environment variables are set in your shell session. The following is a list of the basic usage of the module command: | The module command provides a convenient mechanism for managing which environment variables are set in your shell session. The following is a list of the basic usage of the module command: | ||
| - | * < | + | * Check which modules are available |
| - | * < | + | * Add a module to the current environment |
| - | * < | + | * Show loaded modules |
| + | * Remove a module from the environment | ||
| =====Compiling===== | =====Compiling===== | ||
| Line 28: | Line 29: | ||
| printf(" | printf(" | ||
| return 0; | return 0; | ||
| + | } | ||
| + | </ | ||
| + | ===C with MPI=== | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | int | ||
| + | main(argc, argv) | ||
| + | |||
| + | int argc; | ||
| + | char *argv[]; | ||
| + | |||
| + | { | ||
| + | int rank, size, len; | ||
| + | char name[MPI_MAX_PROCESSOR_NAME]; | ||
| + | |||
| + | MPI_Init(& | ||
| + | MPI_Comm_rank(MPI_COMM_WORLD, | ||
| + | MPI_Comm_size(MPI_COMM_WORLD, | ||
| + | |||
| + | MPI_Get_processor_name(name, | ||
| + | printf (" | ||
| + | |||
| + | MPI_Finalize(); | ||
| + | exit(0); | ||
| } | } | ||
| </ | </ | ||
| Line 36: | Line 64: | ||
| END PROGRAM Hello | END PROGRAM Hello | ||
| </ | </ | ||
| - | ====Sun Studio==== | + | ====GNU==== |
| - | The following code snippets demonstrate how to compile the above code examples use the Sun Studio | + | The following code snippets demonstrate how to compile the above code examples use the GNU compiler suite: |
| ===C=== | ===C=== | ||
| - | < | + | < |
| + | ===C with MPI=== | ||
| + | < | ||
| ===Fortran=== | ===Fortran=== | ||
| - | < | + | < |
| - | ====GNU==== | + | |
| + | =====OpenMP===== | ||
| + | The above compilers include support for OpenMP. | ||
| + | < | ||
| + | |||
| + | code from https:// | ||
| + | ====Intel Compilers==== | ||
| + | The following code snippets demonstrate how to compile OpenMP examples with the Intel compilers: | ||
| ===C=== | ===C=== | ||
| - | < | + | < |
| ===Fortran=== | ===Fortran=== | ||
| - | < | + | < |
| + | ===Java=== | ||
| + | |||
| + | An example of compiling and executing a simple Java program: | ||
| + | ====MyFirstJavaProgram.java==== | ||
| + | < | ||
| + | public class MyFirstJavaProgram { | ||
| + | public static void main(String []args) { | ||
| + | System.out.println(" | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | To compile this, make sure you have the java module loaded, then: | ||
| + | < | ||
| + | javac MyFirstJavaProgram.java</ | ||
| + | |||
| + | A bytecode-compiled file should be created, named MyFirstJavaProgram.class | ||
| + | |||
| + | To execute it, run as follows: | ||
| + | < | ||
| + | java MyFirstJavaProgram | ||
| + | </ | ||
| + | =====MPI===== | ||
| + | MPI (Message Passing Interface -- [[http:// | ||
| + | |||
| + | To run an MPI job see the man pages for PBS Pro. On the login node, type "man qsub". To obtain an interactive node, | ||
| + | use '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | To test it: | ||
| + | |||
| + | < | ||
| + | |||
| + | You should see something similar to: | ||
| + | < | ||
| + | Hello world! I'm 7 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 6 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 5 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 1 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 0 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 3 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 2 of 8 on cnode-2-6 | ||
| + | Hello world! I'm 4 of 8 on cnode-2-6 | ||
| + | </ | ||