Skip to content
Snippets Groups Projects
Commit 8b671639 authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

added documentation

parent cc49aef6
No related branches found
No related tags found
No related merge requests found
......@@ -2,9 +2,8 @@ image: ubuntu:18.04
stages:
- build
- test
build:
ubuntu-build:
stage: build
before_script:
......@@ -20,12 +19,30 @@ build:
paths:
- ./src/main
test:
ubuntu-test:
stage: test
needs:
- build
script:
before_script:
- apt-get update -qq && apt-get install -y -qq libnetcdff* netcdf-bin
script:
- ./src/main
- test -f pres_temp_4D.nc
- ncdump -h pres_temp_4D.nc
jet-build:
image: almalinux:8.5
stage: build
when: never
before_script:
- dnf install -yq netcdf-fortran-devel.x86_64 eccodes-devel.x86_64 netcdf.x86_64
script:
- export FC=gfortran
- export LIBRARY_PATH=/usr/lib64
- export INCLUDE=/usr/include
- make -C src
......@@ -2,17 +2,73 @@
Example of Continuous Integration in Gitlab + Gitlab Runner @ IMGW
## Fortran
## Contributing
We add a src directory with some fortran netcdf code inside from [ucar unidata](https://www.unidata.ucar.edu/software/netcdf/examples/programs/).
Please write an email to the [service desk](mailto:gitlab.phaidra+flexpart-example-ci-817-issue-@univie.ac.at) and an issue will be created. This does not require an account on GitLab!
files:
- src/Makefile
- src/main.f90
## Makefile
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
In order to build the application we need to define a Makefile with some special things:
## License
For open source projects, say how it is licensed.
```makefile
# use the environmental variable $INCLUDE
# split the paths separated by :
INC = $(subst :, ,$(INCLUDE))
# add a -I/path/to/include
INC := $(INC:%=-I%)
# use the environmental variable $LIBRARY_PATH
LIBS = $(subst :, ,$(LIBRARY_PATH))
LIBS := $(LIBS:%=-L%)
```
that allow to read environmental flags for include and library path. the next part is just to compile all sources to objects and link the application:
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
```makefile
# build main from main.o using netcdf library
main: main.o
${FC} $< $(INC) $(LIBS) -lnetcdff -o $@
# build source files to objects with include paths
%.o %.mod %.smod: %.f90
${FC} ${INC} -c -o $*.o $<
```
## Gitlab-CI
The gitlab-ci (continous integration) allows to define some jobs. Every jobs runs on its own, but you can use artifacts or cache to transfer files between jobs.
We can setup a default image to start off and install some necessary libraries for building the application.
```yaml
image: ubuntu:18.04
stages:
- build
build-ubuntu:
stage: build
before_script:
- apt-get update -qq && apt-get install -y -qq gfortran libnetcdf-dev libnetcdff-dev libeccodes-dev netcdf-bin
script:
- export FC=gfortran
- export LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu
- export INCLUDE=/usr/include
- make -C src
artifacts:
paths:
- ./src/main
```
We use the package manager and install the libraries, which you need to find out what names they have, use a site like [pkgs.org](https://pkgs.org) to find out what libraries contains whcih files and versions, so that you can build your container as you need.
Here we use the an LTS ubuntu container with some older version that are provides via the package manager. At a later stage we can build images that have the exact same versions as on some HPC centers.
We need to give some relevant paths to the MAkefile in order to link the netcdf library to our application.
Then we can run our first pipeline and see if everything works.
......@@ -11,6 +11,7 @@ all: clean main
main: main.o
${FC} $< $(INC) $(LIBS) -lnetcdff -o $@
%.o %.mod %.smod: %.f90
${FC} ${INC} -c -o $*.o $<
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment