diff --git a/.gitignore b/.gitignore index db0984b6c6b0f612e3c708ac3d67bd154628173a..ecb83700cb4f01a8442484d33b4b02010c8592a6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ build/cluster/* build/sphere/* build/trapping/* doc/build/* - diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f65a992ee4d49692a786354bc3f4b1b91d651b19..dbe3ed281eeaac3547edda212a9679e827d5a055 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,8 @@ building_stage: paths: - build/cluster/* - build/sphere/* - #- build/trapping/* + - build/trapping/* + - doc/build/* exclude: - ".git*" - ".git/**/*" @@ -45,7 +46,8 @@ building_stage: - cat /etc/os-release - cd src - echo "Running make ..." - - make + - make -j + - make docs -j && make -C ../doc/build/latex -j running_stage: stage: run diff --git a/build/README.md b/build/README.md index f19cbc7826a56952be3e239407e6f26e9c8f4a4c..01d8f651732368753e65a697064164fd789ae3ac 100644 --- a/build/README.md +++ b/build/README.md @@ -13,15 +13,15 @@ This section describes the use of the pre-existing programs, once the binaries h ### cluster 1. cd to the `build/cluster` folder. -2. Run `edfb`: +2. Run `edfb_clu`: - > ./edfb + > ./edfb_clu 3. Run `clu`: > ./clu -*NOTE:* both `edfb` and `clu` expect an input which is assumed to be in a folder named `../../test_data/cluster/` (i.e. two levels above the current execution path) +*NOTE:* both `edfb_clu` and `clu` expect an input which is assumed to be in a folder named `../../test_data/cluster/` (i.e. two levels above the current execution path) 4. Run `np_cluster`: @@ -31,22 +31,22 @@ This section describes the use of the pre-existing programs, once the binaries h 5. Check the consistency between the output files (the default output file for the *FORTRAN* code is named `OCLU`, while the corresponding *C++* output has the default name of `c_OCLU`). -The default behaviour of `np_cluster` is to take the same input files as `edfb` and `clu` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments: +The default behaviour of `np_cluster` is to take the same input files as `edfb_clu` and `clu` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments: > ./np_cluster PATH_TO_DEDFB PATH_TO_DCLU OUTPUT_PATH ### sphere 1. cd to the `build/sphere` folder. -2. Run `edfb`: +2. Run `edfb_sph`: - > ./edfb + > ./edfb_sph 3. Run `sph`: > ./sph -*NOTE:* both `edfb` and `sph` expect an input which is assumed to be in a folder named `../../test_data/sphere/` (i.e. two levels above the current execution path) +*NOTE:* both `edfb_sph` and `sph` expect an input which is assumed to be in a folder named `../../test_data/sphere/` (i.e. two levels above the current execution path) 4. Run `np_sphere`: @@ -56,7 +56,7 @@ The default behaviour of `np_cluster` is to take the same input files as `edfb` 5. Check the consistency between the output files (the default output file for the *FORTRAN* code is named `OSPH`, while the corresponding *C++* output has the default name of `c_OSPH`). -The default behaviour of `np_sphere` is to take the same input files as `edfb` and `sph` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments: +The default behaviour of `np_sphere` is to take the same input files as `edfb_sph` and `sph` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments: > ./np_sphere PATH_TO_DEDFB PATH_TO_DSPH OUTPUT_PATH diff --git a/containers/docker/Dockerfile b/containers/docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..013c483ca45052c15956e6e50409a698bd260c0a --- /dev/null +++ b/containers/docker/Dockerfile @@ -0,0 +1,58 @@ +# syntax=docker/dockerfile:1 + +FROM debian:bookworm-slim AS np-tmcode-dev +WORKDIR /root + +# make sure the debian bullseye us up to date, install needed packages +RUN DEBIAN_FRONTEND=noninteractive apt update && DEBIAN_FRONTEND=noninteractive apt -y upgrade +# install packages needed to build binaries +RUN DEBIAN_FRONTEND=noninteractive apt -y install g++ gfortran make gcc-offload-nvptx libhdf5-dev +# install packages needed to run python scripts for checks +RUN DEBIAN_FRONTEND=noninteractive apt -y install python3 python-is-python3 python3-regex +# install packages needed to run doxygen to create html docs +RUN DEBIAN_FRONTEND=noninteractive apt -y install doxygen +# install packages needed to run pdflatex to create pdf docs +RUN DEBIAN_FRONTEND=noninteractive apt -y install texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-font-utils +# clean up apt lists +RUN rm -rf /var/lib/apt/lists/* + + +# create the container on which the gitlab pipeline runs, making sure to squash +# all layers to save space +FROM scratch AS np-tmcode +COPY --from=np-tmcode-dev / / + + +# create the container actually containing the code +FROM np-tmcode-dev AS np-tmcode-run-dev +WORKDIR /root +# copy the parent dir to a temporary dir in the container, so we can compile everything +ADD src /root/np-tmcode/src +ADD doc /root/np-tmcode/doc +ADD build /root/np-tmcode/build +ADD test_data /root/np-tmcode/test_data +RUN cd np-tmcode/src && make wipe && make -j && cd ../doc/src && doxygen config.dox && cd ../build/latex && make -j + + +# create the container on which the np-tmcode is installed, restarting from +# a minimal distro and adding strictly only the needed runtime +FROM debian:bookworm-slim AS np-tmcode-run-minimal +WORKDIR /root +# install the strictly needed runtime libraries needed to run the executables +# and the python check scripts +RUN DEBIAN_FRONTEND=noninteractive apt update && DEBIAN_FRONTEND=noninteractive apt upgrade && DEBIAN_FRONTEND=noninteractive apt -y install libgfortran5 libgcc-s1 libhdf5-103-1 libstdc++6 libssl3 libcurl4 libsz2 zlib1g libnghttp2-14 libidn2-0 librtmp1 libssh2-1 libpsl5 libgssapi-krb5-2 libldap-2.5-0 libzstd1 libbrotli1 libaec0 libunistring2 libgmp10 libkrb5-3 libk5crypto3 libcom-err2 libkrb5support0 libsasl2-2 libp11-kit0 libtasn1-6 libkeyutils1 libffi8 python3 python-is-python3 python3-regex hdf5-tools && rm -rf /var/lib/apt/lists/* +COPY --from=np-tmcode-run-dev /root /root +# remove everything which is not needed to run the codes +RUN cd /root/np-tmcode && find build -name "*.o" -exec rm -v \{\} \; && find build -name "*.gcno" -exec rm -v \{\} \; && cd src && rm -rvf cluster libnptm trapping include sphere Makefile make.inc README.md && cd .. && rm -rvf containers && cd doc && rm -rvf src && cd build/latex && rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf +# move the installed software to /usr/local +RUN mv /root/np-tmcode /usr/local + + +# create the container on which the np-tmcode is installed, +# squashing all layers from previous stage +FROM scratch AS np-tmcode-run +WORKDIR /root + +COPY --from=np-tmcode-run-minimal / / + + diff --git a/containers/docker/README.md b/containers/docker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c6bf1c9e9fc5bfbab6156a968259e6c0f66c386a --- /dev/null +++ b/containers/docker/README.md @@ -0,0 +1,12 @@ +# Docker support for the NP-TMcode project + +This Dockerfile allows to create mainly: + +- the np-tmcode image that is used by the gitlab pipeline runner to test compile and execution of requested merges +- the np-tmcode-run image, that contains only the pre-built executables, python test scripts, compiled documentation, and the minimal runtime to run them + +In order for the docker build to correctly set the context, so that it can access the directories containing source codes, docker build must be invoked from this directory as: + + > docker build -f Dockerfile ../.. --target \<image name\> + +where `<image name>` is either `np-tmcode` or `np-tmcode-run`. One may also add the docker build option `-t tagname` to specify the `tagname` the built image should have in his/her registry. \ No newline at end of file diff --git a/containers/singularity/README.md b/containers/singularity/README.md new file mode 100644 index 0000000000000000000000000000000000000000..04cfdfe1108d63f93ebe707d6f35a5eb1956d580 --- /dev/null +++ b/containers/singularity/README.md @@ -0,0 +1,19 @@ +# Singularity support for the NP-TMcode project + +This `np-tmcode-run.def` file allows to create a np-tmcode-run image, that contains only the pre-built executables, python test scripts, compiled documentation, and the minimal runtime to run them + +In order for the singularity build to create the image, singularity build must be invoked from this directory as: + + > singularity build \<image name\> np-tmcode-run.def + +where `<image name>` is the name one wants to give to the image, e.g. `np-tmcode-run.sif`. Depending on the singularity installation, the additional `--fakeroot` option may be needed (see singularity documentation). + +The image thus built can be run either as + + > singularity run \<image name\> \<np-tmcode command\> + +or directly as + + > \<full path to image name\> \<np-tmcode command\> + +where `<full path to image name>` is the name of the sif image, including full or relative path to it, and `<np-tmcode command>` is one of the executables built in np-tmcode project, or the `pycompare.py` script used to compare results between the Fortran and C++ versions of the code. These executables, as well as the minimum runtime for them to execute correctly, are embedded in the image, and "see" the current directory the image is run in (which technically is automatically bind-mounted by singularity in the running image instance). \ No newline at end of file diff --git a/containers/singularity/np-tmcode-run.def b/containers/singularity/np-tmcode-run.def new file mode 100644 index 0000000000000000000000000000000000000000..da7025e0dd6899c8bf0698ec4615cb923bcc01ad --- /dev/null +++ b/containers/singularity/np-tmcode-run.def @@ -0,0 +1,62 @@ +Bootstrap: docker +From: debian:bookworm-slim +Stage: np-tmcode-run-dev + +%files + ../../src /usr/local/np-tmcode/src + ../../doc /usr/local/np-tmcode/doc + ../../build /usr/local/np-tmcode/build + ../../test_data /usr/local/np-tmcode/test_data + +%post + apt update + apt -y upgrade + apt -y install g++ gfortran make gcc-offload-nvptx libhdf5-dev + apt -y install python3 python-is-python3 python3-regex + apt -y install doxygen + apt -y install texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-font-utils + rm -rf /var/lib/apt/lists/* + cd /usr/local/np-tmcode/src + make wipe + make -j + make docs -j && make -C ../doc/build/latex -j + + +Bootstrap: docker +From: debian:bookworm-slim +Stage: np-tmcode-run-minimal + +%files from np-tmcode-run-dev + /usr/local/np-tmcode /usr/local/np-tmcode + +%post + apt update + apt -y upgrade + apt -y install libgfortran5 libgcc-s1 libhdf5-103-1 libstdc++6 libssl3 libcurl4 libsz2 zlib1g libnghttp2-14 libidn2-0 librtmp1 libssh2-1 libpsl5 libgssapi-krb5-2 libldap-2.5-0 libzstd1 libbrotli1 libaec0 libunistring2 libgmp10 libkrb5-3 libk5crypto3 libcom-err2 libkrb5support0 libsasl2-2 libp11-kit0 libtasn1-6 libkeyutils1 libffi8 python3 python-is-python3 python3-regex hdf5-tools + rm -rf /var/lib/apt/lists/* + cd /usr/local/np-tmcode + find build -name "*.o" -exec rm -v \{\} \; + find build -name "*.gcno" -exec rm -v \{\} \; + cd src + rm -rvf cluster libnptm trapping include sphere Makefile make.inc README.md + cd .. + rm -rvf containers + cd doc + rm -rvf src/cluster /src/include /src/libntpm /src/sphere /src/trapping /src/Makefile /src/make.inc + cd build/latex + rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf + cp -a /usr/bin/ld.so /usr/bin/sh /usr/bin/dash /usr/bin/mkdir /usr/bin/rm /usr/bin/cp /usr/bin/python* /usr/bin/h5* /usr/local/bin/ + rm -rvf /bin/* /usr/bin/* /sbin /usr/sbin /usr/games /usr/local/games + /usr/local/bin/mkdir -p /bin + /usr/local/bin/cp -av /usr/local/bin/* /bin/ + rm -rvf /usr/local/bin/* /bin/cp /bin/rm /bin/mkdir + + +Bootstrap: scratch +Stage: np-tmcode-run + +%files from np-tmcode-run-minimal + / / + +%runscript + PATH=/bin:/usr/local/np-tmcode/src/scripts:/usr/local/np-tmcode/build/trapping:/usr/local/np-tmcode/build/cluster:/usr/local/np-tmcode/build/sphere $* diff --git a/containers/singularity/np-tmcode-run.sif b/containers/singularity/np-tmcode-run.sif new file mode 100755 index 0000000000000000000000000000000000000000..ef165c012d75f3722d7921179f09c9aea22ef58f Binary files /dev/null and b/containers/singularity/np-tmcode-run.sif differ diff --git a/src/cluster/Makefile b/src/cluster/Makefile index 37c271251f2eff079354ab9610d1c6e4adc9fcc8..49e2fe59d5bc48d6fadbaac1a30415c218474b19 100644 --- a/src/cluster/Makefile +++ b/src/cluster/Makefile @@ -3,13 +3,13 @@ BUILDDIR=../../build/cluster include ../make.inc -all: clu edfb np_cluster +all: clu edfb_clu np_cluster clu: clu.o $(FC) $(FCFLAGS) -o $(BUILDDIR)/clu $(BUILDDIR)/clu.o $(LDFLAGS) -edfb: edfb.o - $(FC) $(FCFLAGS) -o $(BUILDDIR)/edfb $(BUILDDIR)/edfb.o $(LDFLAGS) +edfb_clu: edfb_clu.o + $(FC) $(FCFLAGS) -o $(BUILDDIR)/edfb_clu $(BUILDDIR)/edfb_clu.o $(LDFLAGS) np_cluster: $(BUILDDIR)/np_cluster.o $(BUILDDIR)/Commons.o $(BUILDDIR)/Configuration.o $(BUILDDIR)/file_io.o $(BUILDDIR)/Parsers.o $(BUILDDIR)/sph_subs.o $(BUILDDIR)/clu_subs.o $(BUILDDIR)/cluster.o $(CXX) $(CXXFLAGS) -o $(BUILDDIR)/np_cluster $(BUILDDIR)/np_cluster.o $(BUILDDIR)/Commons.o $(BUILDDIR)/Configuration.o $(BUILDDIR)/file_io.o $(BUILDDIR)/Parsers.o $(BUILDDIR)/sph_subs.o $(BUILDDIR)/clu_subs.o $(BUILDDIR)/cluster.o $(CXXLDFLAGS) @@ -42,5 +42,5 @@ clean: rm -f $(BUILDDIR)/*.o wipe: - rm -f $(BUILDDIR)/clu $(BUILDDIR)/edfb $(BUILDDIR)/*.o + rm -f $(BUILDDIR)/clu $(BUILDDIR)/edfb_clu $(BUILDDIR)/*.o diff --git a/src/cluster/edfb.f b/src/cluster/edfb_clu.f similarity index 100% rename from src/cluster/edfb.f rename to src/cluster/edfb_clu.f diff --git a/src/make.inc b/src/make.inc index ac95b212b05534d9318db6149ea347705b09c73c..4dd67a1420877749f14490f4463781f788be16aa 100644 --- a/src/make.inc +++ b/src/make.inc @@ -1,32 +1,43 @@ +# FC defines the fortran compiler to use. If undefined, GNU Make tries to use `f77` ifndef FC override FC=gfortran endif +# FCFLAGS defines the compilation options for the fortran compiler ifndef FCFLAGS override FCFLAGS=-std=legacy -O3 endif +# LDFLAGS defines the default linker flags ifndef LDFLAGS override LDFLAGS= endif +# CXX defines the default C++ compiler to use. If undefined, GNU Make tries to use g++ ifndef CXX override CXX=g++ endif +# HDF5_INCLUDE defines the default path to the HDF5 include files to use ifndef HDF5_INCLUDE override HDF5_INCLUDE=/usr/include/hdf5/serial endif +# CXXFLAGS defines the default compilation options for the C++ compiler ifndef CXXFLAGS -override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE) +#override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE) +override CXXFLAGS=-O3 -I$(HDF5_INCLUDE) endif +# HDF5_LIB defines the default path to the HDF5 libraries to use +# CXXLDFLAGS defines the default linker flags to use for C++ codes ifndef CXXLDFLAGS ifndef HDF5_LIB override HDF5_LIB=/usr/lib/x86_64-linux-gnu/hdf5/serial endif override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(LDFLAGS) +#else +#override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(CXXLDFLAGS) endif %.o : %.f diff --git a/src/sphere/Makefile b/src/sphere/Makefile index 384a85b9ede135f920d78585c0f924495e9d13f9..c2e8b5c5fb609308557866c19ec08850b17b27ba 100644 --- a/src/sphere/Makefile +++ b/src/sphere/Makefile @@ -9,10 +9,10 @@ include ../make.inc #CXXFLAGS=-O2 -ggdb -pg -coverage #CXXLFLAGS=-L/usr/lib64 -lhdf5_hl -lhdf5 -all: edfb sph np_sphere +all: edfb_sph sph np_sphere -edfb: edfb.o - $(FC) $(FCFLAGS) -o $(BUILDDIR)/edfb $(BUILDDIR)/edfb.o $(LDFLAGS) +edfb_sph: edfb_sph.o + $(FC) $(FCFLAGS) -o $(BUILDDIR)/edfb_sph $(BUILDDIR)/edfb_sph.o $(LDFLAGS) sph: sph.o $(FC) $(FCFLAGS) -o $(BUILDDIR)/sph $(BUILDDIR)/sph.o $(LDFLAGS) @@ -45,5 +45,5 @@ clean: rm -f $(BUILDDIR)/*.o wipe: - rm -f $(BUILDDIR)/edfb $(BUILDDIR)/sph $(BUILDDIR)/*.o + rm -f $(BUILDDIR)/edfb_sph $(BUILDDIR)/sph $(BUILDDIR)/*.o diff --git a/src/sphere/edfb.f b/src/sphere/edfb_sph.f similarity index 100% rename from src/sphere/edfb.f rename to src/sphere/edfb_sph.f