Versions Compared

Key

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

Table of Contents

...

06.2.2.

...

2 "put" and "putSlice" functions

putputSlice


Code Block
titleIMAS Fortran :: put
linenumberstrue
program 
diagnostic
test
    use ids_schemas
    use ids_routines
    implicit none


    type (ids_core_profiles) :: ids ! <= IDS object

    character(len=3)    :: treename = 'ids'
    character(len=20)   :: database = 'test'
    integer             :: shot = 12
    integer 
idx, i
            :: run = 22
    character(len=20)   :: usr
    character(len=20)   :: imasVersion
    integer             :: idx

    integer :: i
    

    ! Gets user name and data version
    
type
call 
(ids
get_
core_profiles): ids <= Single object !!
environment_variable("USER",usr)
    call get_environment_variable("IMAS_VERSION", imasVersion)

    ! Open a database
    call imas_create_env(
'ids'
treename, 
11
shot, 
22
run, -1,
-1, idx, usr, database, imasVersion)

 
   ! Mandatory to define this property
    ids%ids_properties%homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS

    allocate(ids%ids_properties%comment(1))
    ids%ids_properties%comment(1) = 'IDS stored by put (FORTRAN)'

    ! IDS structure allocation - vectors of size N (!)
    allocate(ids%time(10))
    allocate(
ids%x%y
ids%global_quantities%ip(10))

 !SCALARS (!)
    ! --------- THE LOOP -----------------
    do i=1, 10
        ! Do 
not forget to set-up time!!
        ids%time(i) =
VALUE
 i
        
        ! Setting values of data
        
ids%x%y
ids%global_quantities%ip(i) = 
VALUE
2*i
    enddo
!
 
VECTORS
   
ids%time = timeVector ids%x%y = valueVector
! --------- THE LOOP -----------------

    ! Save data in the database
    call ids_put(idx, 'core_profiles', ids)


    ! Cleaning up
    call ids_deallocate(ids)

    ! Close a pulse file
    call imas_close(idx)
end program



Code Block
titleIMAS Fortran :: putSlice
linenumberstrue
program 
diagnostic
test
    use ids_schemas
    use ids_routines
    implicit none


    type (ids_core_profiles) :: ids ! <= IDS object

    character(len=3)    :: treename = 'ids'
    character(len=20)   :: database = 'test'
    integer             :: shot 
idx,
= 
i
12
    integer   
type (ids_core_profiles) :: ids ! <= Single object !
          :: run = 23
    character(len=20)   :: usr
    character(len=20)   :: imasVersion
    integer             :: idx

    integer :: i
    

    ! Gets user name and data version
    call get_environment_variable("USER",usr)
    call get_environment_variable("IMAS_VERSION", imasVersion)

    ! Open a database
    call imas_create_env(
'ids'
treename, 
11
shot, 
22
run, -1,
-1, idx, usr, database, imasVersion)

 
   
! Mandatory to define this property
   
 ids%ids_properties%homogeneous_time = 
1
IDS_TIME_MODE_HOMOGENEOUS

    ! Time NOT dependent data
    allocate(ids%ids_properties%comment(1))
  
  ids%ids_properties%comment(1) = 'IDS 
put
stored by put_slice
'
 
call ids_put_non_timed(idx,"core_profiles",ids)  
(FORTRAN)'

    ! IDS structure allocation
 - vectors of size 1 (!)
    allocate(ids%time(1))
    allocate(
ids%x%y
ids%global_quantities%ip(1))


    ! --------- THE LOOP -----------------
    do i=1, 10
        ! Do not forget to set-up time!!
        ids%time(1) = 
VALUE
i
        
        ! Setting values of data
        ids%global_quantities%ip = 2*i
        
        ! Save data in the database
        if 
ids%x%y
(i == 1)
= VALUE
 then
            call ids_put(idx, 'core_profiles', ids)
         else
            call ids_put_slice(idx, 'core_profiles', ids)

        end if
    enddo
    ! --------- THE LOOP -----------------

    ! Cleaning up
    call ids_deallocate(ids)

    ! Close a pulse file
    call imas_close(idx)
end program

...


06.2.2.3 "get" and "getSlice" functions

getgetSlice


Code Block
titleIMAS Fortran :: get
linenumberstrue
program 
diagnostic
test
    use ids_schemas
    use ids_routines
    implicit none

integer :: idx, i, arraySize

    type (ids_core_profiles) :: ids ! <= 
Single
IDS object
!!


! Open a database call imas_open('ids', 14, 4, idx)  ! Get data call ids_get(idx, 'core_profiles', ids) ! Check array size  arraySize = size(ids%time) ! <= time vector ! SCALARS (!) do i=1, arraySize write (*,*) "Time : ", ids%time(i) write (*,*) "Value: ", ids%x%y(i) enddo ! VECTORS
    character(len=3)    :: treename = 'ids'
    character(len=20)   :: database = 'test'
    integer             :: shot = 12
    integer             :: run = 22
    character(len=20)   :: usr
    character(len=20)   :: imasVersion
    integer             :: idx

    integer :: i

    ! Gets user name and data version
    call get_environment_variable("USER",usr)
    call get_environment_variable("IMAS_VERSION", imasVersion)

    ! Open a database
    call imas_open_env(treename, shot, run, idx, usr, database, imasVersion)


    ! Get data
    call ids_get(idx, 'core_profiles', ids)

    write (*,*) "Time : ", ids%time
    write (*,*) "Value: ", 
ids%x%y
ids%global_quantities%ip

    ! Close a pulse file
   
 call
 call imas_close(idx)
end program



Code Block
titleIMAS Fortran :: getSlice
linenumberstrue
program 
diagnostic
test
    
! UAL library
use ids_schemas
    
 use
use ids_
schemas
routines
    implicit none


    
use
type (ids
_routines implicit none
_core_profiles) :: ids ! <= IDS object

    character(len=3)    :: treename = 'ids'
    character(len=20)   :: database = 'test'
    integer             :: shot = 12
    integer             :: run 
idx
= 22
    
type (ids_core_profiles)
character(len=20)   :: usr
    character(len=20)   :: imasVersion
    integer             :: 
ids
idx

    integer :: i

    ! Gets user name and data version
    call get_environment_variable("USER",usr)
    call get_environment_variable("IMAS_VERSION", imasVersion)

    ! Open a database
    call imas_open_env(
'ids'
treename, 
11
shot, 
22
run, idx
)
, usr, database, 
imasVersion)

    ! Get data
    call ids_get_slice(idx, 'core_profiles', ids, 
4
3.0, 1)

    write (*,*) "
Time
Time  : ", ids%time
    write (*,*) "Value : ", 
ids%x%y
ids%global_quantities%ip

    ! Memory clean-up
    call ids_deallocate(ids)

    ! Close a pulse file
   
 call
 call imas_close(idx)
end program




Code Block
languagebash
titleBuilding the code
F90=ifort
COPTS = -g `pkg-config imas-ifort --cflags` 
LIBS=`pkg-config imas-ifort --libs` 

all: ids_get.exe ids_put.exe ids_getSlice.exe ids_putSlice.exe

%.exe: %.f90
	$(F90) $(COPTS) -o $@ $< $(LIBS)

clean:
	rm -f *.o *.exe