Bootstrap: docker
From: ubuntu:22.04

%post
    echo America/Buenos_Aires > /etc/localtime
    apt-get update
    apt-get install -y libopenmpi-dev
    apt-get clean
    rm -rf /var/lib/apt/lists/*

    cd /opt
    cat << EOF > hello_mpi.c
    #include <mpi.h>
    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char** argv) {
        int world_size, world_rank;
        char processor_name[MPI_MAX_PROCESSOR_NAME];

        MPI_Init(NULL, NULL);
        MPI_Comm_size(MPI_COMM_WORLD, &world_size);
        MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
        int name_len;
        MPI_Get_processor_name(processor_name, &name_len);

        printf("Hello world! Processor %s, Rank %d of %d\n", processor_name, world_rank, world_size);

        MPI_Finalize();
    }
EOF

    mpicc -o hello_mpi hello_mpi.c
