= MPI C = == Hello World == {{{#!C /* hello_mpi.c: display a message on the screen */ #include #include int main (int argc, char *argv[]) { int myid,numproc; /* Initialize */ MPI_Init(&argc,&argv); /* get myid and # of processors */ MPI_Comm_size(MPI_COMM_WORLD,&numproc); MPI_Comm_rank(MPI_COMM_WORLD,&myid); printf("hello from %d\n", myid); /* wait until all processors come here */ MPI_Barrier (MPI_COMM_WORLD); if ( myid == 0 ) { /* only id = 0 do this */ printf("%d processors said hello!\n",numproc); } MPI_Finalize(); } }}} [[Image(HelloC_MPI_Flow.png)]] === Compile === {{{ module load intel-psxe mpicc hello_mpi.c }}} == Example of Jobscript == {{{#!sh #!/bin/bash #SBATCH --job-name=HelloC_MPI #SBATCH --qos=normal #SBATCH --time=0-00:10:00 #SBATCH --nodes=4 #SBATCH --ntasks-per-node=1 ########## THE JOB ITSELF ########### echo Start Job pwd echo $SLURM_JOB_NODELIST echo Number of tasks: $SLURM_NTASKS mpirun ./a.out echo End job }}}