I got an 'Access-Violation' error with MAXVAL ( or MINVAL) when I compile my code with the /check option (only 64bit). See the following example:
program Test_maxval
integer*4,parameter :: size_1_of_array = 5
integer*4,parameter :: size_2_of_array = 10
integer*4,parameter :: max_ref = 10
real*4 :: r_maxval
real*4,ALLOCATABLE,DIMENSION(:,:) :: real_array
integer*4 :: i, ierror
integer*4,dimension(max_ref) :: n_points
ALLOCATE (real_array(size_1_of_array,size_2_of_array),STAT = ierror)
real_array = 1.
real_array(2,3) = 2.
i = 3
n_points = 4
r_maxval = maxval(real_array(1:4,3))
write(*,*)'r_maxval=',r_maxval
stop
end