Allocate memory for a metric_dict_type
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(metric_dict_type), | intent(out), | dimension(:) | :: | input |
Instance of metric data |
|
| type(metric_dict_type), | intent(in), | optional, | dimension(:) | :: | source |
Source of the metric data to copy |
| integer, | intent(in), | optional | :: | length |
Length of the metric data |
subroutine metric_dict_alloc(input, source, length) !! Allocate memory for a metric_dict_type implicit none ! Arguments type(metric_dict_type), dimension(:), intent(out) :: input !! Instance of metric data type(metric_dict_type), dimension(:), optional, intent(in) :: source !! Source of the metric data to copy integer, optional, intent(in) :: length !! Length of the metric data ! Local variables integer :: i !! Loop index if(present(length))then do i=1,size(input,dim=1) allocate(input(i)%history(length)) end do else if(present(source))then do i=1, size(input,dim=1) input(i)%key = source(i)%key allocate(input(i)%history(size(source(i)%history,dim=1))) input(i)%threshold = source(i)%threshold end do else call stop_program( & "metric_dict_alloc requires either a source or length" & ) end if end if input%num_entries = 0 end subroutine metric_dict_alloc