...
Code Block |
---|
subroutine distributiondisp(distributionin, output) use ids_schemas implicit none type (ids_distribution_sources) :: distributionin integer, intent(out) :: output output = 1 return end subroutine |
As you can see, we don't even access input data, yet. All we have, so far, is the API of the native code.
Creating library with native code
As you recall from previous session (dedicated to FC2K) we have to have library that contains native code we are supposed to run.
Let's prepare it. We will do it, by creating Makefile
project - library will be called libdistribution_disp.a
Code Block |
---|
# In this sample I will use ifort
# However, depending on target system (where IMAS is installed)
# it might be you have other options as well - e.g.: gfortran, pgi, NAG, etc.
F90 = ifort
COPTS = -g -O0 -assume no2underscore -fPIC -shared-intel
# Note that you should _always_ use pkg-config to obtain
# flags for compiler and linker
# do not pass hardcoded locations unless it's really unavoidable!
LIBS = `pkg-config --libs imas-ifort imas-lowlevel`
INCLUDES = `pkg-config --cflags imas-ifort imas-lowlevel`
all: distribution_disp.o libdistribution_disp.a
libdistribution_disp.a: distribution_disp.o
ar -rvs $@ $^
distribution_disp.o: distribution_disp.f90
$(F90) $(COPTS) -c -o $@ $^ ${INCLUDES} $(LIBS)
# try to provide _clean_ target, so you can easily
# cleanup source tree
clean:
rm -f *.o *.a |
Once we run make
we can use library inside the project
Code Block |
---|
> make
ifort -g -O0 -assume no2underscore -fPIC -shared-intel -c -o distribution_disp.o distribution_disp.f90 `pkg-config --cflags imas-ifort imas-lowlevel` `pkg-config --libs imas-ifort imas-lowlevel`
ar -rvs libdistribution_disp.a distribution_disp.o
ar: creating libdistribution_disp.a
a - distribution_disp.o |
Describing the actor
When we fill information regarding actor, we make it possible to create a bridge between Kepler (actor) and native code (in this case Fortran based library). I will fill the table following way
Field | Value | Description |
---|---|---|
Project | IMAS | This is the name of the project you will see later on inside Kepler - in the actor browser |
Name | distributiondisp | This is the name of the actor in Kepler. Once you place it on canvas this is what you will see. |