Look into RESULT
keyword with FUNCTION
declarations in Fortran, that helps in many a context including what you have now:
..
function MaxMin(n,L,P1,P2,P3,P4,a1,a2,a3,t) result(r)
implicit none
integer :: ia, ix
integer, intent(in) :: n
real, intent(in) :: L
real, intent(in) :: P1
real, intent(in) :: P2
real, intent(in) :: P3
real, intent(in) :: P4
real, intent(in) :: a1
real, intent(in) :: a2
real, intent(in) :: a3
real, intent(in) :: t
! Function result
real :: r(2)
..
r = [ maxmom, minmom ]
..
P.S.> Obviously the function result can be any valid Fortran name. as per the author’s fancy/style. r
is just an illustration