Skip to content

Commit

Permalink
initial commit, working function call
Browse files Browse the repository at this point in the history
  • Loading branch information
cbcoutinho committed Nov 6, 2016
0 parents commit 7968e3e
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.ipynb_checkpoints

main

*.o
*.mod
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Makefile for generic_rk project

current_dir = $(shell pwd)
SRC=$(current_dir)/src
OBJ=$(current_dir)/obj
BIN=$(current_dir)/bin

# Compiler
FF = gfortran
FFLAGS = -Wall -std=f2008 -Wextra -fPIC -fmax-errors=1 -Wimplicit-interface
# Debug flags:
FFLAGS += -O0 -g -fcheck=all -fbacktrace #-ffpe-trap=zero,overflow,underflow
# Release flags:
# FFLAGS += -O3 -march=native -ffast-math -funroll-loops

FLIBS = -lblas -llapack

.DEFAULT_GOAL := $(BIN)/main

# Dependencies of main program
objects=$(OBJ)/misc.o

# Modules
$(OBJ)/misc.o: $(SRC)/misc.f90
$(FF) $(FFLAGS) -J$(OBJ) -c -o $@ $<

# Main program
$(OBJ)/main.o: $(SRC)/main.f90 $(objects)
$(FF) $(FFLAGS) -I$(OBJ) -c -o $@ $<
$(BIN)/main: $(OBJ)/main.o $(objects)
$(FF) $(FFLAGS) -o $@ $+ $(FLIBS)

clean:
rm -f $(OBJ)/*.o $(OBJ)/*.mod $(BIN)/main

run: $(BIN)/main
$(BIN)/main
229 changes: 229 additions & 0 deletions main.ipynb

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
program main
use iso_fortran_env, only: wp => real64
use misc, only: myfun
implicit none

integer :: ii
real(wp) :: t, y, dy

t = 0_wp
y = 0_wp

dy = myfun(t, y)

print *, t, y, dy

end program main
16 changes: 16 additions & 0 deletions src/misc.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module misc
use iso_fortran_env, only: wp => real64
implicit none

contains

elemental function myfun(t, y) result(dy)
real(wp), intent(in) :: t, y
real(wp) :: dy

dy = cos(t)

return
end function myfun

end module misc

0 comments on commit 7968e3e

Please sign in to comment.