- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
following adapted from Help on MINLOC
INTEGER i, minl(1)
INTEGER array(2, 3)
INTEGER, ALLOCATABLE :: AR1(:)
! put values in array
array = RESHAPE((/-7, 1, -2, -9, 5, 0/),(/2, 3/))
! array is -7 -2 5
! 1 -9 0
i = SIZE(SHAPE(array)) ! Get the number of dimensions
! in array
ALLOCATE (AR1 (i) ) ! Allocate AR1 to number
! of dimensions in array
AR1 = MINLOC (array, MASK = array .GT. -5) ! Get the
! location (subscripts) of
! smallest element greater
! than -5 in array
!
! MASK = array .GT. -5 creates a mask array the same
! size and shape as array whose elements are .TRUE. if
! the corresponding element in array is greater than
! -5, and .FALSE. if it is not. This mask causes MINLOC
! to return the index of the element in array with the
! smallest value greater than -5.
!
!array is -7 -2 5 and MASK= array .GT. -5 is F T T
! 1 -9 0 T F T
! and AR1 = MINLOC(array, MASK = array .GT. -5) returns
! (1, 2), the location of the element with value -2
minl = MINLOC((/-7,2,-7,5/)) ! returns 1, first
! occurrence of minimum
print *,min1
END
The result is 0.
Why?
Thank you in advance.
Mike
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have changed the spelling from minl to min1, and you may have meant to use the form of MINLOC with a 2nd argument MINLOC(array,dim=1). IMPLICIT NONE should have forced the compiler to perform some checking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have changed the spelling from minl to min1, and you may have meant to use the form of MINLOC with a 2nd argument MINLOC(array,dim=1). IMPLICIT NONE should have forced the compiler to perform some checking.
Oh! so embarrassing.
Thank you.
Mike

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page