Skip to content

Commit

Permalink
Adds makefile and small readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Gierz committed Dec 29, 2022
1 parent 6689df0 commit 1504bca
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Directories for build and binary
build/
bin/
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FC = gfortran
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single

all: esm_dummy_model.o libesm_dummy_model.a app_main.f90.o
mkdir bin
$(FC) $(FFLAGS) build/$(FC)/esm_dummy_model/app_main.f90.o build/gfortran/esm_dummy_model/libesm_dummy_model.a -o bin/esm_dummy_model

prepare:
mkdir -p build/dependencies
mkdir -p build/$(FC)
mkdir -p build/$(FC)/esm_dummy_model/

esm_dummy_model.o: prepare
$(FC) -c ././src/esm_dummy_model.f90 $(FFLAGS) -J build/$(FC) -Ibuild/$(FC) -o build/$(FC)/esm_dummy_model/src_esm_dummy_model.f90.o

libesm_dummy_model.a: esm_dummy_model.o
ar -rs build/$(FC)/esm_dummy_model/libesm_dummy_model.a build/$(FC)/esm_dummy_model/src_esm_dummy_model.f90.o

app_main.f90.o:
$(FC) -c app/main.f90 $(FFLAGS) -J build/$(FC) -Ibuild/$(FC) -o build/$(FC)/esm_dummy_model/app_main.f90.o

clean:
rm -rf build bin
69 changes: 67 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@
# esm_dummy_model
My cool new project!
# `esm_dummy_model`: A Minimal Fortran "Model" for Testing

This is a minimal `FORTRAN` program, made with
[`fpm`](https://fpm.fortran-lang.org/en/index.html). It counts to 5 while
sleeping.

# Install

First, you can download the code via git:
```console
$ git clone https://github.com/esm-tools/esm_dummy_model.git
$ cd esm_dummy_model
```

If you have [`fpm` installed (see link for
instructions)](https://fpm.fortran-lang.org/en/install/index.html#install)
you can build and then run it with simple `fpm` commands:

```console
$ fpm build # <-- will build the binary
+ mkdir -p build/gfortran_2A42023B310FA28D
+ mkdir -p build/gfortran_2A42023B310FA28D/esm_dummy_model/
+ gfortran -c ././src/esm_dummy_model.f90 -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -J build/gfortran_2A42023B310FA28D -Ibuild/gfortran_2A42023B310FA28D -o build/gfortran_2A42023B310FA28D/esm_dummy_model/src_esm_dummy_model.f90.o
+ ar -rs build/gfortran_2A42023B310FA28D/esm_dummy_model/libesm_dummy_model.a build/gfortran_2A42023B310FA28D/esm_dummy_model/src_esm_dummy_model.f90.o
ar: creating archive build/gfortran_2A42023B310FA28D/esm_dummy_model/libesm_dummy_model.a
+ gfortran -c app/main.f90 -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -J build/gfortran_2A42023B310FA28D -Ibuild/gfortran_2A42023B310FA28D -o build/gfortran_2A42023B310FA28D/esm_dummy_model/app_main.f90.o
+ mkdir -p build/gfortran_2A42023B310FA28D/app/
+ gfortran -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single build/gfortran_2A42023B310FA28D/esm_dummy_model/app_main.f90.o build/gfortran_2A42023B310FA28D/esm_dummy_model/libesm_dummy_model.a -o build/gfortran_2A42023B310FA28D/app/esm_dummy_model
$ fpm run # <-- will build if needed, and immediately run the program
Hello, esm_dummy_model!
Sleeping... 1
Sleeping... 2
Sleeping... 3
Sleeping... 4
Sleeping... 5
Goodbye, esm_dummy_model!
$ fpm install # <-- will put the binary into ${HOME}/.local/bin
# Update: build/gfortran_2A42023B310FA28D/app/esm_dummy_model -> /Users/pgierz/.local/bin
```

For testing use with the ESM Tools, we also have a small Makefile:

```console
$ make clean
rm -rf build bin
$ make
mkdir -p build/dependencies
mkdir -p build/gfortran
mkdir -p build/gfortran/esm_dummy_model/
gfortran -c ././src/esm_dummy_model.f90 -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -J build/gfortran -Ibuild/gfortran -o build/gfortran/esm_dummy_model/src_esm_dummy_model.f90.o
ar -rs build/gfortran/esm_dummy_model/libesm_dummy_model.a build/gfortran/esm_dummy_model/src_esm_dummy_model.f90.o
ar: creating archive build/gfortran/esm_dummy_model/libesm_dummy_model.a
gfortran -c app/main.f90 -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -J build/gfortran -Ibuild/gfortran -o build/gfortran/esm_dummy_model/app_main.f90.o
mkdir bin
gfortran -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single build/gfortran/esm_dummy_model/app_main.f90.o build/gfortran/esm_dummy_model/libesm_dummy_model.a -o bin/esm_dummy_model
```
You can now run the program (found in `bin/`):
```console
$ ./bin/esm_dummy_model
Hello, esm_dummy_model!
Sleeping... 1
Sleeping... 2
Sleeping... 3
Sleeping... 4
Sleeping... 5
Goodbye, esm_dummy_model!
```

0 comments on commit 1504bca

Please sign in to comment.