I have fixed your code. I am not a Fortran programmer, I just checked various tutorials and references. So potentially there could be better ways to do this. :)
Problems
I have found a few problems with your code. Please, see them below.
Uninitialized Variables
The variables epos and opos had no initial values and therefore they contained random numbers (a.k.a. memory garbage).
Separating the Evens and Odds
Your doing it wrong. A typical solution would be to initialize the even and odd pointers (epos and opos) to the start of the array and put the evens and odds into the even_array and odd_array indexed by the epos and opos pointers, which also increment every time we add a new value in them.
Printing Out The Result
You print out the whole array of evens and odds up to the maximum possible length. Instead, you must only print as many as you've found to be even and odd (see the opos and epos variables).
A Solution
After modifying your code, this seems to work.
subroutine PrintArray(arrayName, array, length)
implicit none
character(len = *) :: arrayName
integer, dimension(10) :: array
integer :: length
integer :: i
print *
print *, trim(arrayName)
print *, "========================================"
do i = 1, length
print *, array(i)
end do
end subroutine PrintArray
program even_odd_array
implicit none
integer, dimension(10) :: a
integer, dimension(10) :: even_array
integer, dimension(10) :: odd_array
integer :: i
integer :: n = 0
integer :: epos = 0
integer :: opos = 0
! Read the array
do while (n <= 0 .or. 10 < n)
print *, "Enter a value of n (0 < n <= 10)"
read *, n
end do
do i = 1, n
print *, "enter number " , i
read *, a(i)
end do
! Separate the values into two different array
do i = 1, n
print *, a(i), i, epos, opos
if (mod(a(i), 2) == 0) then
epos = epos + 1
even_array(epos) = a(i)
else
opos = opos + 1
odd_array(opos) = a(i)
end if
end do
! Print the results
call PrintArray("Even numbers:", even_array, epos)
call PrintArray("Odd numbers:", odd_array, opos)
end program even_odd_array