Ask Your Question
0

Cannot make inline Fortran compiler (f2py) work

asked 2013-02-12 11:25:39 +0100

Sergey gravatar image

Hello!
I am trying to make the inline Fortran compiler work. It gave some long errors in Sage 5.5. Now I try in Sage 5.6 (Ubuntu 11.10 64 bit): The evaluation of %fortran cell returns None , but no symbols seem to be defined.

I tried the simple Fibonacci example from the documentation and it did not work as it should. The ordinary command-line compilation with f2py works ok!

Please, could anyone try to help me.

%fortran
C FILE: FIB3.F
      SUBROUTINE FIB(A,N)
C
C     CALCULATE FIRST N FIBONACCI NUMBERS
C
      INTEGER N
      REAL*8 A(N)
Cf2py intent(in) n
Cf2py intent(out) a
Cf2py depend(n) a
      DO I=1,N
         IF (I.EQ.1) THEN
            A(I) = 0.0D0
         ELSEIF (I.EQ.2) THEN
            A(I) = 1.0D0
         ELSE
            A(I) = A(I-1) + A(I-2)
         ENDIF
      ENDDO
      END
C END FILE FIB3.F

None

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_41.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZmliKDUp"),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpBVbhBE/___code___.py", line 3, in <module> exec compile(u'fib(_sage_const_5 ) File "", line 1, in <module>

NameError: name 'fib' is not defined

Best wishes, Sergey

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-02-12 17:07:08 +0100

Sergey gravatar image

updated 2013-02-12 17:09:32 +0100

Hello again! I've found the answer to my question: the problem was due to different versions of numpy in my system and in sage package! It's a shame that Sage's version is so old! I had to update the numpy in Sage to version 1.7 This is done by installing numpy to ...sage-5.6/local folder (see the numpy building manual)

edit flag offensive delete link more

Comments

There is work being done towards upgrading numpy, but it is not as straightforward as it seems. See http://trac.sagemath.org/sage_trac/ticket/11334

ppurka gravatar imageppurka ( 2013-02-13 02:50:49 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-02-12 11:25:39 +0100

Seen: 803 times

Last updated: Feb 12 '13