Versions Compared

Key

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

...

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

Warning
titlesource code

Source code for this sample can be found at following location

/afs/gw/swimas/resources/tutorials/2019-12-PSNC/FC2K/simple_IMAS_code 

Note that workflow is running such way it reads data from pulse file of user g2michal - it means you don't have to copy input data into your public/imasdb  folder.


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

...

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

Image Modified

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 Modified

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

...

As you recall from previous session (dedicated to FC2K) we have to have library that contains native code we are supposed to run.

Image Modified

Let's prepare it. We will do it, by creating Makefile  project - library will be called libdistribution_disp.a 

...

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

Image Modified

Describing the actor

...

Now, go ahed and take a look at Interface again. You can observe that now, interface is complete and perfectly matches your code (can you spot the difference?).

Image Modified

Choosing compiler

The only thing that is left is to set proper values for the compiler. Make sure we are using Fortran and the vendor is set to Intel

Image Modified

We have all we need to build our first, IMAS based, actor. Press Generate.

...

Now it's time to put all the things together. Start your Kepler and create following workflow.

Image ModifiedNow we can run it.

Image Modified

As you can see, the result is exactly the same as we have expected. Now, let's try to get some data from the IDS.

...

we can run workflow again. This time, the value is coming from the IDS.

Image Modified