nicolasessisbreton / fython

Fython is Fortran with a Python syntax
Other
40 stars 1 forks source link

hello world #5

Closed freevryheid closed 8 years ago

freevryheid commented 8 years ago

Not sure this is working for me. When (load)ing the following program: [Note: github is stripping the indentation in the source below] ` def main: print("Hello world!")

` it generates the following output: compilation_error: compilation error fortran_code_path /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug/hello.f90 compilation_error hello.f90:9:1:

  call init_frame('home.grassy.fy.src.tst01.tst01.hello:main')
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:11:1:

  if ( advance_line(2) ) then
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:12:1:

  call print('Hello world!') ! 2
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:14:1:

  end if
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:11:6:

  if ( advance_line(2) ) then
      1
Error: IF clause at (1) requires a scalar LOGICAL expression

cmd cd /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug gfortran hello.f90 -g -fbacktrace -Wall -fbounds-check -ffpe-trap=zero,overflow -I/home/grassy/fy/fython/fython/traceback/pycache/fycache/gfortran/debug -fpic -c

module home.grassy.fy.src.tst01.tst01.hello

The generated f90 file: ` module home.grassy.fy.src.tst01.tst01.hello use fython.traceback.traceback

implicit none

contains subroutine main() ! 1

call init_frame('home.grassy.fy.src.tst01.tst01.hello:main')

if ( advance_line(2) ) then
call print('Hello world!') ! 2

end if

call del_frame() end subroutine

end module `

nicolasessisbreton commented 8 years ago

The print syntax is slightly different. It is     print 'hello world' (No parenthesis) Also, you need indentation before the print, if it is a statement within a function. On Aug 21, 2016 10:05 AM, Andre Smit notifications@github.com wrote:Not sure this is working for me. When (load)ing the following program:

def main: print("Hello world!")

it generates the following output: compilation_error: compilation error fortran_code_path /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug/hello.f90 compilation_error hello.f90:9:1:

call init_frame('home.grassy.fy.src.tst01.tst01.hello:main') 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:11:1:

if ( advance_line(2) ) then 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:12:1:

call print('Hello world!') ! 2 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:14:1:

end if 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:11:6:

if ( advance_line(2) ) then 1 Error: IF clause at (1) requires a scalar LOGICAL expression

cmd cd /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug gfortran hello.f90 -g -fbacktrace -Wall -fbounds-check -ffpe-trap=zero,overflow -I/home/grassy/fy/fython/fython/traceback/pycache/fycache/gfortran/debug -fpic -c

module home.grassy.fy.src.tst01.tst01.hello

The generated f90 file: `module home.grassy.fy.src.tst01.tst01.hello use fython.traceback.traceback

implicit none

contains subroutine main() ! 1

call init_frame('home.grassy.fy.src.tst01.tst01.hello:main')

if ( advance_line(2) ) then call print('Hello world!') ! 2

end if

call del_frame() end subroutine

end module `

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

freevryheid commented 8 years ago

Thanks, fixed the print and sent an associated pull request. Though, still getting a compilation error due to this use statement:

use fython.traceback.traceback

which I presume is referring to /home/grassy/fy/fython/fython/traceback/pycache/fycache/gfortran/debug/fb2250377d.mod

On Sun, Aug 21, 2016 at 10:20 AM, Nicolas Essis-Breton < notifications@github.com> wrote:

The print syntax is slightly different. It is print 'hello world' (No parenthesis) Also, you need indentation before the print, if it is a statement within a function. On Aug 21, 2016 10:05 AM, Andre Smit notifications@github.com wrote:Not sure this is working for me. When (load)ing the following program:

def main: print("Hello world!")

it generates the following output: compilation_error: compilation error fortran_code_path /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug/hello.f90 compilation_error hello.f90:9:1:

call init_frame('home.grassy.fy.src.tst01.tst01.hello:main') 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:11:1:

if ( advance_line(2) ) then 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:12:1:

call print('Hello world!') ! 2 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:14:1:

end if 1 Warning: Nonconforming tab character at (1) [-Wtabs] hello.f90:11:6:

if ( advance_line(2) ) then 1 Error: IF clause at (1) requires a scalar LOGICAL expression

cmd cd /home/grassy/fy/src/tst01/tst01/pycache/fycache/gfortran/debug gfortran hello.f90 -g -fbacktrace -Wall -fbounds-check -ffpe-trap=zero,overflow -I/home/grassy/fy/fython/ fython/traceback/pycache/fycache/gfortran/debug -fpic -c

module home.grassy.fy.src.tst01.tst01.hello

The generated f90 file: `module home.grassy.fy.src.tst01.tst01.hello use fython.traceback.traceback

implicit none

contains subroutine main() ! 1

call init_frame('home.grassy.fy.src.tst01.tst01.hello:main')

if ( advance_line(2) ) then call print('Hello world!') ! 2

end if

call del_frame() end subroutine

end module `

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nicolasessisbreton/fython/issues/5#issuecomment-241263617, or mute the thread https://github.com/notifications/unsubscribe-auth/AARZLhNVW7u2TvGqMG6l-PuJVc3o7fzYks5qiGzRgaJpZM4JpTdm .

Andre

nicolasessisbreton commented 8 years ago

Thanks for the pull request.

What is the compilation error?

freevryheid commented 8 years ago

Syntax error in use statement: use fython.traceback.traceback

compilation_error hello.f90:9:1:

  call init_frame('hello:main')
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:11:1:

  if ( advance_line(2) ) then
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:13:1:

  if ( advance_line(2) ) then
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:14:1:

  write(*, "(a)") 'Hello world!' ! 2
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:16:1:

  end if
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:19:1:

  end if
 1
Warning: Nonconforming tab character at (1) [-Wtabs]
hello.f90:11:6:

  if ( advance_line(2) ) then
      1
Error: IF clause at (1) requires a scalar LOGICAL expression
hello.f90:13:6:

  if ( advance_line(2) ) then
      1
Error: IF clause at (1) requires a scalar LOGICAL expression

fortran_code_path

nicolasessisbreton commented 8 years ago

does the following work for you?

#python
import fython
fython.hello()

The traceback module is automatically generated by fython, before any other module. So, if there is a bug, I would expect a compilation error for the traceback module, before a compilation error for any other module.