Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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`

# It is little bit messy here, but we need two different targets
# for the purpose of the tutorial
# first  - builds very basic code that doesn't touch IDSes data
# second - builds the code that will read IDSed data
#

first: distribution_disp.oall: libdistribution_disp.a

second: distribution_disp_2.o libdistribution_disp_2.a

libdistribution_disp.a: distribution_disp.o
  	ar -rvs libdistribution_disp.a $^

libdistribution_disp_2.a: distribution_disp_2.o
  ar -rvs libdistribution_disp.a $^

distribution_disp.o: distribution_disp.f90
  $(F90) $(COPTS) -c -o $@ $^ ${INCLUDES} $(LIBS)

distribution_disp_2.o: distribution_disp_2.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 first
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

...