Put IDS into Non-default OccurrenceΒΆ

This example focuses on putting IDS into another occurrence.

See also

API documentation for: list_all_occurrences()

subroutine put_into_non_default_occurrence()
    use ids_routines
    implicit none

    type(ids_equilibrium) :: equilibrium
    integer(ids_int) :: data_entry, status
    integer :: i

    character(len=:), allocatable :: node_content_list(:)
    integer, allocatable :: occurrence_list(:)

    ! NOTE: this block of code uses FORCE_CREATE_PULSE mode in order to create example data
    call imas_open('imas:mdsplus?path=./testdb_mdsplus', FORCE_CREATE_PULSE, data_entry, status)
    ! default occurrence for get/put is 0
    ! list of available occurrences can be found inside Data Dictionary documentation.

    ! set mandatory field
    equilibrium%ids_properties%homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS

    ! when ids_properties.homogeneous_time is set to IDS_TIME_MODE_HOMOGENEOUS,
    ! all time-dependent fields values correspond to <ids>.time vector.
    allocate(equilibrium%time(3))
    equilibrium%time = (/ 1.0, 2.0, 3.0 /)

    ! fill fields with some data
    allocate(equilibrium%ids_properties%comment(1))
    equilibrium%ids_properties%comment = '1st comment';

    ! put IDS into occurrence 1
    call ids_put(data_entry, 'equilibrium/1', equilibrium)

    ! modify data, so differences between occurrences can be spotted
    equilibrium%ids_properties%comment = '2nd comment';

    ! put IDS into occurrence 2
    call ids_put(data_entry, 'equilibrium/2', equilibrium)

    ! NOTE: there is ids_properties/occurrence_type structure
    ! it stores additional information about specific occurrence

    ! occurrences can be listed with list_all_occurrences() function
    ! list_all_occurrences also returns content of IDS pointed by node_path argument
    call list_all_occurrences(data_entry, "equilibrium", "ids_properties/comment", node_content_list, occurrence_list)

    if(allocated(occurrence_list)) then 
        write(*,*) "i     occurrence_list(i)      node_content_list(i)"
        do i = 1, size(occurrence_list)
            write(*,*) i,occurrence_list(i),"'"//node_content_list(i)//"'"
        end do
    else 
        write(*,*) "node_content_list, occurrence_list are empty"
    end if 
end subroutine put_into_non_default_occurrence