I am using f2py
to implement some fortran 77 routines. Specifically, I want to implement the column-wise autoscale function for a 2D array.
SUBROUTINE AUTOSCALE(E,NR,NC,EA,N,M,MX,SX,SSX)
INTEGER NR,NC,N,M,I,J
REAL*8 E(NR,NC),EA(N,M),MX(M),SX(M),SSX(M)
DO 1 I=1,NC
MX(I)=0D0
SX(I)=0D0
1 SSX(I)=0D0
DO 3 I=1,NR
DO 2 J=1,NC
MX(J)=MX(J)+E(I,J)
2 SX(J)=SX(J)+E(I,J)**2
3 CONTINUE
DO 4 J=1,NC
MX(J)=MX(J)/NR
SX(J)=(SX(J)-NR*MX(J)**2)/(NR-1)
SX(J)=DSQRT(SX(J))
4 CONTINUE
DO 6 I=1,NR
DO 5 J=1,NC
EA(I,J)=E(I,J)-MX(J)
EA(I,J)=EA(I,J)/SX(J)
SSX(J)=SSX(J)+E(I,J)**2
5 CONTINUE
6 CONTINUE
RETURN
END
The routine is correctly translate to python only if I comment the line with the DSQRT
call. If I replace it with equivalent functions, such as SQRT
, **(0.5)
, **(1./2.)
I always get a strange link error. See details below.
Found executable C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe mingw32.lib(lib32_libmingw32_a-pesect.o) : error LNK2005: ValidateImageBase already defined in MSVCRT.lib(pesect.obj) mingw32.lib(lib32_libmingw32_a-pesect.o) : error LNK2005: __FindPESection already defined in MSVCRT.lib(pesect.obj) mingw32.lib(lib32_libmingw32_a-pesect.o) : error LNK2005: __IsNonwritableInCurrentImage already defined in MSVCRT.lib(pesect.obj) Creating library C:\Users\PolGia0\AppData\Local\Temp\tmpvzoar0ou\Release\Users\PolGia0\AppData\Local\Temp\tmpvzoar0ou\src.win32-3.4\foo.lib and object C:\Users\PolGia0\AppData\Local\Temp\tmpvzoar0ou\Release\Users\PolGia0\AppData\Local\Temp\tmpvzoar0ou\src.win32-3.4\foo.exp mingw32.lib(lib32_libmingw32_a-pesect.o) : error LNK2019: unresolved external symbol __image_base referenced in function __FindPESectionByName .\foo.pyd : fatal error LNK1120: 1 unresolved externals
I don't understand it. Maybe something is wrong in the set up of my system ? Any suggestions? Thanks PS In case it helps, I use Anaconda 2.3.0 at 32 bit on a Windows 7 64 bit pc.