This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
guide:compiling [2013/05/09 17:41] andyr [OpenMP] |
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: |
| ====Intel==== | ====Intel==== | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | ====GNU==== | + | ====GNU |
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | |||
| - | < | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| =====Environment===== | =====Environment===== | ||
| Line 20: | Line 15: | ||
| * Check which modules are available < | * Check which modules are available < | ||
| * Add a module to the current environment < | * Add a module to the current environment < | ||
| - | * Remove a module from the environment < | + | |
| + | | ||
| =====Compiling===== | =====Compiling===== | ||
| Line 32: | 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 44: | Line 68: | ||
| ===C=== | ===C=== | ||
| < | < | ||
| + | ===C with MPI=== | ||
| + | < | ||
| + | |||
| ===Fortran=== | ===Fortran=== | ||
| < | < | ||
| - | ====Sun Studio==== | ||
| - | The following code snippets demonstrate how to compile the above code examples use the Sun Studio compiler suite: | ||
| - | ===C=== | ||
| - | < | ||
| - | ===Fortran=== | ||
| - | < | ||
| =====OpenMP===== | =====OpenMP===== | ||
| Line 65: | Line 86: | ||
| < | < | ||
| + | ===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===== | ||
| - | MPI is provided using the OpenMPI libraries. | + | MPI (Message Passing Interface -- [[http:// |
| - | To run an MPI job see the [[guide: | + | 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 | ||
| + | </ | ||