Create IDS with Arrays of Structures (AoS)ΒΆ

See also

API documentation for ids_deallocate()

This example focuses on creating empty IDS and allocating arrays inside IDS structure.

subroutine creating_completly_new_ids()

    use ids_routines
    implicit none

    ! empty IDS structures can be created without opening data entry
    ! all you have to do is to instantiate IDS object
    type(ids_core_profiles) :: empty_core_profiles

    ! Note! Every IDS must have <ids>/ids_properties/homogeneous_time field set with one of possible values
    ! Possible homogeneous_time values are:
    !  IDS_TIME_MODE_HETEROGENEOUS: All time-dependent quantities in the IDS may have different time coordinates.
    !  IDS_TIME_MODE_HOMOGENEOUS: All time-dependent quantities in this IDS use the same time coordinate, namely <ids>/time
    !  IDS_TIME_MODE_INDEPENDENT: The IDS stores no time-dependent data.
    empty_core_profiles%ids_properties%homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS

    ! it is also recommended to provide basic information regarding data source
    ! even though this information is not required to store IDS, it is highly recommended
    ! to fill these fields.
    !  <ids>/ids_properties/comment
    !  <ids>/ids_properties/provider
    !  <ids>/ids_properties/creation_date

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

    ! size of time dependent variables must be equal to the size of time vector
    allocate(empty_core_profiles%global_quantities%ip(3))
    empty_core_profiles%global_quantities%ip = (/ 1.0, 2.0, 3.0 /)

    ! IDSs fields can br printed using write or print statement
    write(*,*) 'printing empty_core_profiles%time from creating_completly_new_ids() function'
    write(*,'(F5.2)') empty_core_profiles%time

    ! some fields are automatically written by AL during 'put' procedure
    ! AL adds some information behind your back. This is particularly important
    ! in case you want later on find out what particular version of AL was used when data were stored.
    ! examples of this type of fields are <ids>/ids_properties/version_put and <ids>/ids_properties/plugins

    ! free memory
    call ids_deallocate(empty_core_profiles)

end subroutine creating_completly_new_ids

Output

printing empty_core_profiles%time from creating_completly_new_ids() function
1.00
2.00
3.00