I would like to create an array with a dimension based on the number of elements meeting a certain condition in another array. This would require that I initialize an array
Try this
real, dimension(50) :: some_array
real, dimension(:), allocatable :: other_array
integer :: status
...
allocate(other_array(count(some_array>0)),stat=status)
at the end of this sequence of statements other_array will have the one element for each element of some_array greater than 0, there is no need to write a loop to count the non-zero elements of some_array.
Following @AlexanderVogt's advice, do check the status of the allocate statement.