adamtuft/otter

Fortran interface to otter-serial

Opened this issue · 0 comments

I have created a set of code that works based on my fork.

I will move this code into the v0.1.0 tagged release next.

The current structure of the code is the following files:

  • include/otter/otter-serial.F90 - this is a set of preprocessor macros for using the defined functions. These need to be included in any fortran program using #include. Must be visible on the include path (i.e. -Iinclude/otter).
  • src/otter/events/serial/otter-serial.F90 - this contains the module to call the C code from Fortran. Rather than overlap the names, they have their own names in Fortran, which are fortran_otterBaseName. This file is added inthe the add_library(otter-events-serial part of the CMakeLists, and the resulting output is a otter_serial.mod file which also needs to be visible on the -I path in any building from Fortran. It is used by use otter_serial from a Fortran Program/subroutine/etc.
  • src/otter/examples/otter-serial-fib.F90 - this contains the example fibonacci example, with no automatic compilation so far. On my machine (from the otter root directory), I can build it with: gfortran -std=f2003 src/otter/examples/otter-serial-fib.F90 -Iinclude/otter/ -Lbuild/lib/ -lotter-serial -Ibuild, and the output I get is as follows:
[achalk@glados otter]$ ./a.out 4
[i] [otterTraceInitialise_i          ] Otter environment variables:
[i] [otterTraceInitialise_i          ] host                           glados.dl.ac.uk
[i] [otterTraceInitialise_i          ] OTTER_TRACE_PATH               trace
[i] [otterTraceInitialise_i          ] OTTER_TRACE_NAME               otter_trace
[i] [otterTraceInitialise_i          ] OTTER_APPEND_HOSTNAME          No
Trace output path:             trace/otter_trace.3908223
[d] [otterTraceInitialise_i          ] src/otter/examples/otter-serial-fib.F90:47 in FORTRAN_FUNCTION
[d] [otterParallelBegin_i            ] src/otter/examples/otter-serial-fib.F90:50 in FORTRAN_FUNCTION
[d] [otterTaskSingleBegin_i          ] src/otter/examples/otter-serial-fib.F90:53 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:13 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:13 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:13 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:18 in FORTRAN_FUNCTION
[d] [otterSynchroniseChildTasks_i    ] src/otter/examples/otter-serial-fib.F90:23 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:18 in FORTRAN_FUNCTION
[d] [otterSynchroniseChildTasks_i    ] src/otter/examples/otter-serial-fib.F90:23 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:18 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:13 in FORTRAN_FUNCTION
[d] [otterTaskBegin_i                ] src/otter/examples/otter-serial-fib.F90:18 in FORTRAN_FUNCTION
[d] [otterSynchroniseChildTasks_i    ] src/otter/examples/otter-serial-fib.F90:23 in FORTRAN_FUNCTION
[d] [otterSynchroniseChildTasks_i    ] src/otter/examples/otter-serial-fib.F90:23 in FORTRAN_FUNCTION
           4           3
OTTER_TRACE_FOLDER=/home/achalk/otter/trace/otter_trace.3908223

I haven't inspected the trace/am not quite sure how to do that with the changes in Otter right now, so I'll focus on fixing up the commit and then we can double check the output.

Regarding the .mod file - I feel like there must be a way to have this appear in the include directory, but I am not good with CMake so I'm not sure how to do that.