Versions Compared

Key

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

...

putputSlice


Code Block
titleIMAS Fortran :: put
linenumberstrue
program diagnostictest
    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             :: run = 22
    character(len=20)   :: usr
    character(len=20)   :: imasVersion
    integer             :: idx, i

    integer :: i
    

    ! Gets user name and data version
    typecall (idsget_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, 11shot, 22run, -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%yids%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%yids%global_quantities%ip(i) = VALUE2*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
languagecpp
titleIMAS Fortran :: putSlice
linenumberstrue
program diagnostictest
    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             :: idx, i
    type (ids_core_profiles) :: ids ! <= Single object !

	shot = 12
    integer             :: 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, 11shot, 22run, -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 putstored 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%yids%global_quantities%ip(1))


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


	   if (i == 1) 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


...