Update home authored by van Vliet's avatar van Vliet
...@@ -189,6 +189,68 @@ module purge ...@@ -189,6 +189,68 @@ module purge
## Compiling programs ## Compiling programs
```
#include <stdio.h>
#include <mpi.h>
int main (int argc, char *argv[])
{
int id, np, i;
char processor_name[MPI_MAX_PROCESSOR_NAME];
int processor_name_len;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &np);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Get_processor_name(processor_name, &processor_name_len);
for (i=1;i<2;i++)
printf ("Hello world from process %03d out of %03d, processor name %s \n", id, np, processor_name);
MPI_Finalize();
return 0;
}
```
```
#include "mpi.h"
#include "string.h"
#include <stdio.h>
int main( int argc, char *argv[] )
{
int numprocs, myrank, namelen, i;
char processor_name[MPI_MAX_PROCESSOR_NAME];
char greeting[MPI_MAX_PROCESSOR_NAME + 80];
MPI_Status status;
MPI_Init( &argc, &argv );
MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
MPI_Get_processor_name( processor_name, &namelen );
sprintf( greeting, "Hello world, from process %d of %d on %s",
myrank, numprocs, processor_name );
if ( myrank == 0 ) {
printf( "%s\n", greeting );
for ( i = 1; i < numprocs; i++ ) {
MPI_Recv( greeting, sizeof( greeting ), MPI_CHAR,
i, 1, MPI_COMM_WORLD, &status );
printf( "%s\n", greeting );
}
}
else {
MPI_Send( greeting, strlen( greeting ) + 1, MPI_CHAR,
0, 1, MPI_COMM_WORLD );
}
MPI_Finalize( );
return 0;
}
```
## Submitting jobs ## Submitting jobs
## More Slurm info ## More Slurm info
\ No newline at end of file