#7465: %fortran in the notebook (and fortran.eval on command line) is completely
broken on OS X
--------------------------+-------------------------------------------------
   Reporter:  was         |       Owner:  was       
       Type:  defect      |      Status:  new       
   Priority:  major       |   Milestone:  sage-4.6.1
  Component:  interfaces  |    Keywords:            
     Author:              |    Upstream:  N/A       
   Reviewer:              |      Merged:            
Work_issues:              |  
--------------------------+-------------------------------------------------
Description changed by mvngu:

Old description:

> Try this in a notebook cell on OS X:
>
> {{{
> %fortran
> C FILE: FIB1.F
>       SUBROUTINE FIB(A,N)
> C
> C     CALCULATE FIRST N FIBONACCI NUMBERS
> C
>       INTEGER N
>       REAL*8 A(N)
>       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 FIB1.F
> }}}
>
> Boom!!  This despite us shipping a Fortran compiler.
>
> The problem is really that the doctests for {{{fortran.eval}}} were
> marked (by me, doh) as optional, and we don't test optional doctests
> frequently.

New description:

 Try this in a notebook cell on OS X:

 {{{
 %fortran
 C FILE: FIB1.F
       SUBROUTINE FIB(A,N)
 C
 C     CALCULATE FIRST N FIBONACCI NUMBERS
 C
       INTEGER N
       REAL*8 A(N)
       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 FIB1.F
 }}}

 Any use of f2py, e.g. following the examples at
 http://www.sagemath.org/doc/numerical_sage/f2py.html lead to a crash:

 {{{
 error: Command "sage_fortran -Wall -shared
 /var/folders/LQ/LQFRAKFTGCCurtDiHcxv1k++-5I/-Tmp-
 /tmpisjCMl/var/folders/LQ/LQFRAKFTGCCurtDiHcxv1k++-5I/-Tmp-
 /tmpisjCMl/src.macosx-10.6-i386-2.6/fortran_module_0module.o
 /var/folders/LQ/LQFRAKFTGCCurtDiHcxv1k++-5I/-Tmp-
 /tmpisjCMl/var/folders/LQ/LQFRAKFTGCCurtDiHcxv1k++-5I/-Tmp-
 /tmpisjCMl/src.macosx-10.6-i386-2.6/fortranobject.o
 /var/folders/LQ/LQFRAKFTGCCurtDiHcxv1k++-5I/-Tmp-
 /tmpisjCMl/Users/felix/.sage/temp/<my domain name>/52076/tmp_0.o -L"Using
 built-in specs.
 /Applications/sage-4.3.1.rc1/local/bin/../lib/gcc/i686-apple-
 darwin8/4.2.3/x86_64"
 -lgfortran -o ./fortran_module_0.so" failed with exit status 1

 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: unrecognized option '-shared'
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: unrecognized option '-shared'
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: unrecognized option '-shared'
 i686-apple-darwin8-gfortran-4.2: no input files
 i686-apple-darwin8-gfortran-4.2: unrecognized option '-shared'
 i686-apple-darwin8-gfortran-4.2: no input files
 Using built-in specs.
 Target: i686-apple-darwin8
 Configured with: /Builds/unix/gcc/gcc-4.2/configure --prefix=/usr/local
 --mandir=/share/man --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
 --build=i686-apple-darwin8 --host=i686-apple-darwin8 --target=i686-apple-
 darwin8 --enable-languages=fortran
 Thread model: posix
 gcc version 4.2.3

 <SNIP>
 }}}

 This is using 4.3.1rc1 on 10.6, 64-bit.

 The problem is that local/lib/python2.6/site-
 packages/numpy/distutils/fcompiler/gnu.py adds a "-shared" flag when
 linking, even though OS X doesn't support it.

 Mac OS X (Darwin) compilers do not support the "-shared" option. The class
 Sage_FCompiler_1 currently calls compilers on all platforms using the
 "-shared" option. So whenever this class is used on Mac, it fails. On my
 computer, this led to f2py failing. This is a five line patch (plus
 documentation) that changes the compiler options on Mac to be in line with
 those already used in Sage_FCompiler, while leaving the compiler options
 on other platforms such as Solaris unchanged. If you'd like to check it on
 Solaris, then go ahead, but the patch was intentionally written to avoid
 changing behaviour on platforms other than OS X.

 This breaks "on some mac systems" - f2py is broken on my 64-bit sage, but
 seems to be working on 32-bit mac systems without this patch. My guess is
 that 32-bit macs use Sage_FCompiler rather than Sage_FCompiler_1. Anyone
 who is familiar with the numpy spkg, please confirm or correct me!

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7465#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to