Versions Compared

Key

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

 

 

Info

In this tutorial

  • what CPOs are
  • what UAL is
  • how can you integrate your code with UAL
  • how can you access data via UAL

Accessing data from UAL requires some modification to your code. In this part of tutorial, we will take a closer look on how to access CPO via UAL.

 

 

Warning

Warning

Stop here for a moment. Make sure you have followed the configuration setup before proceeding any further!

Configuration related tutorial is here -> Click me! <-

 

3.1 Accessing data using Python

...

What you can see here is a simple code that stores particular CPO into MDSPlus database using UAL.

Code Block
import sys
from pylab import *
import ual

cpo = ual.itm(12,2)
cpo.create()

if not cpo.isConnected():
    print 'error during itmdb entry creation'
    sys.exit(1)

cpo.equilibriumArray.resize(1)

equi = cpo.equilibriumArray
equi.array[0].time = 0.0

equi.array[0].datainfo.dataprovider = 'MKO'
equi.array[0].datainfo.putdate = '18/02/2013'
equi.array[0].codeparam.parameters = 'param'

equi.array[0].eqgeometry.boundary.resize(1)
equi.array[0].eqgeometry.boundary[0].r = sin(arange(0,2*pi,2*pi/100))
equi.array[0].eqgeometry.boundary[0].z = cos(arange(0,2*pi,2*pi/100))


print equi.array[0].eqgeometry.boundary[0].r
print equi.array[0].eqgeometry.boundary[0].z

equi.put()

cpo.close()

 

 

Let's check how to read these data in Fortran.

...

4. You should see code similar to following one


 
Code Block
program diagnostic
    use euitm_schemas
    use euitm_routines
    use write_structures
    implicit none

    integer :: idx
    type (type_equilibrium), pointer :: equilibrium(:)

    Integer x

    call euitm_open('euitm', 12, 2, idx)

    call euitm_get(idx, 'equilibrium', equilibrium)

    write (*,*) "Size of CPO: ", size(equilibrium)

    write (*,*) "Value of r: ", equilibrium(1)%eqgeometry%boundary(1)%r(1)
    write (*,*) "Value of z: ", equilibrium(1)%eqgeometry%boundary(1)%z(1)

    call euitm_close(idx)
    call euitm_disconnect()
end program

...

 

5. Run the code

Code Block
make clean
make
./readEquilibrium

 

 

6. You should see values that we have stored using Python based code.

...