Skip to content

Commit

Permalink
Add test compose file and code
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherwharrop-noaa committed Nov 9, 2024
1 parent 320c293 commit 882531f
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
109 changes: 109 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
services:
slurmfrontend:
build:
context: ./frontend
dockerfile: ./Dockerfile
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/frontend:latest
container_name: spack-stack-frontend
hostname: slurmfrontend
user: admin
volumes:
- home-vol:/home/admin
- opt-vol:/opt
- ./test:/home/admin/test
ports:
- 8888:8888
slurmmaster:
build:
context: ./master
dockerfile: ./Dockerfile
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/master:latest
container_name: spack-stack-master
hostname: slurmmaster
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_CPUS_ON_NODE=8
ports:
- 6817:6817
- 6818:6818
- 6819:6819
slurmnode1:
build:
context: ./node
dockerfile: ./Dockerfile
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest
container_name: spack-stack-node1
hostname: slurmnode1
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_NODENAME=slurmnode1
- SLURM_CPUS_ON_NODE=8
links:
- slurmmaster
slurmnode2:
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest
container_name: spack-stack-node2
hostname: slurmnode2
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_NODENAME=slurmnode2
- SLURM_CPUS_ON_NODE=8
links:
- slurmmaster
slurmnode3:
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest
container_name: spack-stack-node3
hostname: slurmnode3
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_NODENAME=slurmnode3
- SLURM_CPUS_ON_NODE=8
links:
- slurmmaster
slurmnode4:
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest
container_name: spack-stack-node4
hostname: slurmnode4
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_NODENAME=slurmnode4
- SLURM_CPUS_ON_NODE=8
links:
- slurmmaster
slurmnode5:
image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest
container_name: spack-stack-node5
hostname: slurmnode5
user: admin
volumes:
- home-vol:/home/admin:nocopy
- opt-vol:/opt:ro
- ./test:/home/admin/test
environment:
- SLURM_NODENAME=slurmnode5
- SLURM_CPUS_ON_NODE=8
links:
- slurmmaster
volumes:
home-vol:
opt-vol:
7 changes: 7 additions & 0 deletions test/hello.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Hello world from host slurmnode1, rank 0 out of 6
Hello world from host slurmnode1, rank 1 out of 6
Hello world from host slurmnode2, rank 2 out of 6
Hello world from host slurmnode2, rank 3 out of 6
Hello world from host slurmnode3, rank 4 out of 6
Hello world from host slurmnode3, rank 5 out of 6
foo
50 changes: 50 additions & 0 deletions test/mpi_hello.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
program mpi_hello

use iso_fortran_env, only : output_unit
use mpi

integer :: error
integer :: world_size, world_rank, name_len, i
character(len=MPI_MAX_PROCESSOR_NAME) :: host_name
character(len=6) :: rank
character(len=6) :: size

! Initialize the MPI environment
call MPI_Init(error)

! Get the number of processes
call MPI_Comm_size(MPI_COMM_WORLD, world_size, error)
write(size,'(I6)') world_size

! Get the rank of the process
call MPI_Comm_rank(MPI_COMM_WORLD, world_rank, error)
write(rank,'(I6)') world_rank

! Get the name of the processor
call MPI_Get_processor_name(host_name, name_len, error)

do i=0, world_size - 1

call MPI_Barrier(MPI_COMM_WORLD, error)

if (i==world_rank) then

! Print off a hello world message
write(*,"(A, A, A, A, A, A)") "Hello world from host ", &
TRIM(host_name), &
", rank ", &
TRIM(ADJUSTL(rank)), &
" out of ", &
TRIM(ADJUSTL(size))

! Flush stdout
flush(output_unit)

end if

end do

! Finalize the MPI environment.
call MPI_Finalize(error)

end program mpi_hello
13 changes: 13 additions & 0 deletions test/test_hello.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

module use /opt/spack-stack/envs/unified-env/install/modulefiles/Core
module load stack-gcc
module load stack-openmpi
module load stack-python

mpif90 -o hello.exe mpi_hello.f90
srun -N 3 --tasks-per-node=2 hello.exe | sort > hello.out

diff hello.out hello.baseline

0 comments on commit 882531f

Please sign in to comment.