1

I have a simple fortran code as follows:

    subroutine square_cube(i, isquare, icube)
        integer, intent(in)  :: i
        integer, intent(out) :: isquare, icube
        isquare = i**2
        icube   = i**3
    end subroutine square_cube

    subroutine hellofortran (n)
        integer n

        do 100 i=0, n
            print *, "Fortran says hello"
100     continue
    end subroutine hellofortran

    program xx
        implicit none
        integer :: i, isq, icub
        i = 4
        call square_cube(i, isq, icub)
        print*, "i,i^2,i^3=", i, isq, icub
        call hellofortran (i)
    end program xx

This program runs perfectly when I build and run it on Code::Blocks 13.12. This and this post suggest to change the name of the python module or the extension of the fortran source. I renamed the source with extensions .f90 and '.f95' and still it does not give errors on Code::Blocks.

I am using Cygwin for all this. When Fortran source is compiled I get a .o and a .exe file. When I try to build fortran code using f2py -c -m fmod test1.f95 I am always getting some assembler errors like:

....
E:\cygwin64\tmp/cc6Dk38U.s:34: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:35: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:39: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:41: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:43: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:58: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:59: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:62: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:63: Error: invalid instruction suffix for `push'
E:\cygwin64\tmp/cc6Dk38U.s:66: Error: invalid instruction suffix for `push'
....
error: Command "/cygdrive/e/g95/bin/g95 -ffixed-form -fno-second-underscore -O -I/tmp/tmpKd7WH9/src.cygwin-1.7.33-x86_64-2.7 -I/usr/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c -c test1.f95 -o /tmp/tmpKd7WH9/test1.o" failed with exit status 1

I have g95 fortran compiler.

What could be the issue?

1
  • Do not use version specific tags without the main tag (fortran) next time. Commented Dec 25, 2014 at 10:03

1 Answer 1

1

I was using the g95 compiler which was generating a 32 bit code and all other tools that I was using were generating 64 bit code. I used gfortran instead of g95 and I got the right output. I had to separately install gfortran using MinGW.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.