I have some fortran subroutines that I’m trying to convert to a Python extension module. One of the subroutines in my fortran code makes a call to another fortran subroutine which is compiled in a static library. I do not have the source code for the static library, as I received it from a third party. Something is wrong with my call to f2py, as the static library isn’t being linked properly. This is my first SO post, and i’m a mechanical engineer with little comp sci background, definitely not a fortran person (more Python/C++), so go easy! Thanks in advance, details ..

Read more

Read more

The program takes input parameters such as the number of elements (n) and a target value (t), as well as arrays representing distances (s) and velocities (v).
It aims to calculate a value ‘k’ such that the sum of distances divided by the adjusted velocities (‘realSpeed’) equals the target value ‘t’ as closely as possible.
The calculateK function computes the difference between the target value ‘t’ and the sum of distances divided by the adjusted velocities, given a candidate value ‘k’.
The findK function utilizes binary search to find the optimal value of ‘k’ that minimizes the difference between the target value ‘t’ and the calculated sum of distances divided by adjusted velocities.
The main function reads input values, invokes findK to determine the optimal ‘k’, and then prints the result.
Overall, the goal of the code seems to be to determine an optimal adjustment factor ‘k’ that minimizes the difference between the target value ‘t’ and the sum of distances divided by adjusted veloc..

Read more