- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The post I made yesterday was not clear on many aspects as gurus have pointed out. The following is the code section inmy program:
FUNCTION FIND_LOC8(X,VAL,N)
INTEGER*8, INTENT(IN), DIMENSION(:) :: X
INTEGER*8, INTENT(IN) :: VAL
INTEGER*8 :: FIND_LOC8
INTEGER*8 :: I, N
! N = SIZE(X)
DO I=1, N
IF(X(I)==VAL) THEN
FIND_LOC8 = I
RETURN
END IF
END DO
FIND_LOC8 = 0
RETURN
END FUNCTION FIND_LOC8
My problem is, this simple function is inside 3-level of do-loops. As the loops become bigger, the time spent on this little function increase tramendously.
Can this simple code be optimized/vectorized/parallelized? Or, is there any more efficient internal routine/command that performs the same function but faster?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe that the question was answered satisfactorily in your previous thread on this topic, "How to optimize this simple code". It is expected on grounds of common courtesy that the originator of a question should read the answers given before posting a minor variation of the same question and starting a new thread.
By creating a new function such as FIND_LOC8 to determine the matching index, whereas the former code had inline Fortran code, you are making it more difficult for the compiler to optimize.
By creating a new function such as FIND_LOC8 to determine the matching index, whereas the former code had inline Fortran code, you are making it more difficult for the compiler to optimize.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By creating a new function such as FIND_LOC8 to determine the matching index, whereas the former code had inline Fortran code, you are making it more difficult for the compiler to optimize
So instead ofmaking the comparison aseparate function, make the comparison inline should make the conde runfaster?
So instead ofmaking the comparison aseparate function, make the comparison inline should make the conde runfaster?

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