From fc699247c1ac90463f6aa14ed9f0340974b39d47 Mon Sep 17 00:00:00 2001
From: Kyle Shores <kyle.shores44@gmail.com>
Date: Wed, 13 Mar 2024 12:31:12 -0500
Subject: [PATCH] adding nvhpc dockerfile

---
 .github/workflows/docker.yml    |  1 +
 docker/Dockerfile.fortran-nvhpc | 58 +++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 docker/Dockerfile.fortran-nvhpc

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 8f1ae38d..b8f818bd 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -19,6 +19,7 @@ jobs:
           - Dockerfile
           - Dockerfile.fortran-intel
           - Dockerfile.fortran-gcc
+          - Dockerfile.fortran-nvhpc
           - Dockerfile.openmp
           - Dockerfile.mpi
           - Dockerfile.mpi_openmp
diff --git a/docker/Dockerfile.fortran-nvhpc b/docker/Dockerfile.fortran-nvhpc
new file mode 100644
index 00000000..9c21239a
--- /dev/null
+++ b/docker/Dockerfile.fortran-nvhpc
@@ -0,0 +1,58 @@
+# nvidia rate limits requests. You can get around this by restarting docker if for 
+# some reason you have to build this image many times
+# https://stackoverflow.com/a/75757516/5217293
+#
+# Container versions, and sizes, can be found at https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nvhpc/tags
+#
+FROM nvcr.io/nvidia/nvhpc:23.7-devel-cuda12.2-ubuntu22.04
+
+RUN apt update \
+    && apt -y install \
+    cmake \
+    curl \
+    gcc \
+    gfortran \
+    git \
+    lcov \
+    libcurl4-openssl-dev \
+    libhdf5-dev \
+    libnetcdff-dev \
+    m4 \
+    make \
+    nlohmann-json3-dev \
+    valgrind \ 
+    vim \
+    zlib1g-dev \
+    && apt clean 
+
+# Set environment variables to install MUSICA using gcc
+ENV FC=gfortran
+ENV FFLAGS="-I/usr/include/"
+
+# Copy the musica code
+COPY . musica
+
+# Build and install MUSICA
+RUN cd musica \
+    && cmake -S . \
+             -B build \
+             -D MUSICA_ENABLE_TESTS=ON \
+             -D MUSICA_ENABLE_TUVX=OFF \
+             -D CMAKE_BUILD_TYPE=Debug \
+    && cd build \
+    && make install
+
+# Set environment variables to build MUSICA-Fortran using intel compilers
+ENV CXX=nvc++
+ENV CC=nvc
+ENV FC=nvfortran
+
+RUN cd musica/fortran/test/fetch_content_integration \
+    && mkdir build && cd build \
+    && cmake .. \
+        -D CMAKE_BUILD_TYPE=Debug \
+    && make
+
+RUN cp -r /musica/configs/chapman musica/fortran/test/fetch_content_integration/build
+
+WORKDIR musica/fortran/test/fetch_content_integration/build
\ No newline at end of file