1.1.1. 4.6.1 Generating Python code
Whenever Kepler actor is created, associated Python actor is generated inside $HOME/kepler/itm/python
directory. You can use this code inside your Python based workflow. However, there are few things to remember.
Make sure to use:
IMAS |
---|
Most recent PyUAL release Make sure to import module from
|
Make sure to use most recent release of FC2K. In case you can't use most recent release of FC2K, the lowest version that supports Python code generation is: 4.2.6
|
1.1.2. 4.6.2 Sample code
Make sure to check how to generate actor, based on compiled library. You can find this information here:
IMAS |
---|
4.2 FC2K - Example 1 - Embedding Fortran codes into Kepler (no IDSes) |
4.3 FC2K - Example 2 - Embedding Fortran code into Kepler (IDSes) |
1.1.3. 4.6.3 How to use generated code
After generating the code, you can use it inside your Python workflow.
Let's take a simple case
subroutine noids(input, output) implicit none integer,parameter :: DP=kind(1.0D0) integer, intent(in):: input integer, intent(out):: output write(0,*) 'Entering subroutine noids. Input value: ',input output = input * 2 write(0,*) 'End Subroutine' return end subroutine
You can compile it using following Makefile
F90=gfortran COPTS= -g -fno-second-underscore -fPIC all: noids.o libnoids libnoids: noids.o ar -rvs libnoids.a noids.o noids.o: noids.f90 $(F90) $(COPTS) -c -o $@ $^ clean: rm -f *.o *.a
And then, after generating FC2K actor, you can access actor following way, from the Python
# the name of the actor (defined in fc2k) from actors import noids result = noids(1) print 'Hello! This is what I got: ', result