Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fortran - find loc method - implicit type

I am learning fortran and need my program to find specific values in an array. A simple program like below:

program hello

implicit none
integer :: x
x = findloc([4,9,0,2,-9,9,1],9)

end program hello 

is giving me the following error:

Error: Function 'findloc' at (1) has no IMPLICIT type

I am compiling it using gfortran on macbook. Will really appreciate if I can get some help regarding findloc

like image 228
user1443613 Avatar asked Jul 24 '26 13:07

user1443613


1 Answers

The standard intrinsic findloc was introduced to Fortran in the 2008 revision. Support for this function first appeared in gfortran release 9.0.

The error message you see is an indication that the intrinsic is not supported in the version you are using.

You could attempt to use the required version, but at the moment this is still in development.

Fortunately, it is simple enough to loop over the elements of your array, effectively creating your own version of findloc.

like image 63
francescalus Avatar answered Jul 28 '26 15:07

francescalus