PROGRAM renum IMPLICIT NONE REAL, DIMENSION (-3:4) :: ra INTEGER, DIMENSION (1) :: locmax1, locmax2 ! Assign elements of array ra: ra = (/ 1.2, 3.4, 5.4, 11.2, 1.0, 3.7, 1.0, 1.0 /) WRITE(*,*) " RA(-3:4) = ",ra WRITE(*,*) "" WRITE(*,*) " LBOUND(ra), UBOUND(ra) = ",LBOUND(ra), UBOUND(ra) WRITE(*,*) "" ! Find location of maximum value of whole array: ! (Note value given assumes first element has location 1.) locmax1 = MAXLOC(ra) WRITE(*,*) ' MAXLOC(ra) = ', locmax1(1) WRITE(*,*) "" ! Find location of maximum value of array section: locmax2 = MAXLOC(ra(1:3)) WRITE(*,*) ' MAXLOC(ra(1:3)) = ', locmax2(1) WRITE(*,*) ! Find value of element with maximum value of whole array from location: WRITE(*,*) 'Maximum value of whole array is: ', & ra(LBOUND(ra) + locmax1(1) - 1) WRITE(*,*) "" ! Check with MAXVAL: WRITE(*,*) 'Maximum value of whole array using MAXVAL is: ', MAXVAL(ra) WRITE(*,*) ! Find value of element with maximum value of array section from location: WRITE(*,*) 'Maximum value of ra(1:3) is: ', ra(locmax2(1)) ! ( Value is ra(1 + locmax2(1) - 1) ) WRITE(*,*) "" ! Check with MAXVAL: WRITE(*,*) 'Maximum value of ra(1:3) using MAXVAL is: ', MAXVAL(ra(1:3)) STOP END PROGRAM renum