Versions Compared

Key

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

Main purpose of FC2K is to embed native code inside Kepler workflow. This way, you are able to connect various, physics based, calculations into chain of execution. There are few rules you have to follow while embedding native code inside Kepler:

  • your routine signature must be exactly the same as one suggested by FC2K
  • in order to access IDSes, you have to use IMAS based modules inside your Fortran code
  • you can pass data into and outside of the code in the form of:
    • primitive types
    • IDSes
    • code parameters
  • you should avoid accessing external files unless it's really impossible to run the simulation without external source of data
  • all physics related information should be exchanged only via IDSes

In this tutorial, I will show show you how to build simple native code and plug it inside Kepler using FC2K.

Sample, shown below, will access IDS data and print it on console.

Preparing the code

First of all, we need simple code that will read data. In this sample, we will use very simple code that reads distribution IDS, shows some info, and output scalar value

Code Block
IDS -> actor code [we treat the actor as a black box] -> integer

When you talk about actor, most important is the interface. It's API defines how actor interacts with other actors in the workflow.

What interface should I provide

Info

You can always start with FC2K in order to make sure how native interface should be implemented like.

Let's start with running FC2K. It's little bit counterintuitive, but will help us to properly prepare the code.

First of all, let's add two ports into actor. Input port - IDS, and output port - integer.

Image Added

Now, let's take a look how the native code should look like in order to provide correct implementation of the actor's API.

Image Added

Now, once we know how our interface looks like, we can start developing the code

Source code of the actor

In our case, we can start with providing very basic implementation

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