ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Feb 2013 02:50:49 +0100Cannot make inline Fortran compiler (f2py) workhttps://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/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 Tue, 12 Feb 2013 11:25:39 +0100https://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/Answer by Sergey for <p>Hello! <br/>
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.</p>
<p>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!</p>
<p>Please, could anyone try to help me.</p>
<pre><code>%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
</code></pre>
<p>None</p>
<p>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("# -<em>- coding: utf-8 -</em>-\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZmliKDUp"),globals())+"\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module></p>
<p>File "/tmp/tmpBVbhBE/___code___.py", line 3, in <module>
exec compile(u'fib(_sage_const_5 )
File "", line 1, in <module></p>
<p>NameError: name 'fib' is not defined</p>
<p>Best wishes,
Sergey </p>
https://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/?answer=14542#post-id-14542Hello 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)
Tue, 12 Feb 2013 17:07:08 +0100https://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/?answer=14542#post-id-14542Comment by ppurka for <p>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)</p>
https://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/?comment=18241#post-id-18241There is work being done towards upgrading numpy, but it is not as straightforward as it seems. See http://trac.sagemath.org/sage_trac/ticket/11334Wed, 13 Feb 2013 02:50:49 +0100https://ask.sagemath.org/question/9773/cannot-make-inline-fortran-compiler-f2py-work/?comment=18241#post-id-18241