Re: [f2py] line length

Al Niessner <[email protected]> Mon, 09 Aug 2010 13:16:02 -0700
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
I am going to pretend this is a bug because it happens with all f90 code
too. Here is my command (source attached):

f2py -c kinds.f90 constants.f90 checks.f90 
<...snip...>
Reading fortran codes...
	Reading file 'kinds.f90' (format:free)
	Reading file 'constants.f90' (format:free)
	Reading file 'checks.f90' (format:free)
<...snip...>
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on
'6.283185307179586476925286766559005768394_pr'
In: :untitled:constants.f90:constants
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on
'3.141592653589793238462643383279502884197_pr'
In: :untitled:constants.f90:constants
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on
'1.570796326794896619231321691639751442099_pr'
In: :untitled:constants.f90:constants
<...snip...>

Since they are marked as format::free, I would not expect these errors.

On Mon, 2010-08-09 at 12:50 -0700, Pearu Peterson wrote:
> On Mon, Aug 9, 2010 at 7:02 PM, Al Niessner <[email protected]> wrote:
> >
> > I get a lot of these messages:
> >
> > get_parameters: got "EOL while scanning string literal (<string>, line
> > 1)" on 'kind("(1e0'
> 
> This may also indicate a bug. If telling f2py that the file is in free format
> (see below) does not eliminate these messages, send me an example file
> that reproduces this issue.
> 
> > I can tell gfortran to allow more than 72 characters with
> > -ffixed-line-length-none. However, I have not seen a switch in the f2py
> > for that layer. Am I missing it or is there a better way to signal f2py
> > to ignore the fixed format?
> 
> Here are two ways to tell f2py that the Fortran source is in free format:
> 
> 1) Add the following line
> 
> ! -*- f90 -*-
> 
> as the first line of .f file.
> 
> 2) or rename .f files to .f90 files.
> 
> HTH,
> Pearu
> 
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users

-- 
Al Niessner
818.354.0859

--------
|  dS  | >= 0
--------

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users
checks.f90 (text/x-fortran, 582 B)
MODULE Checks

Contains

  SUBROUTINE Check_Kinds()
    USE Kinds

    REAL(pr) :: a,b,c
    INTEGER  :: k
    ! --------------------
    a = 2e0_pr
    b = 3e0_pr

    c = a*b       ! c = 6e0_pr
    k = KIND(c)   ! k = 8

  END SUBROUTINE Check_Kinds
  !
  ! ---------------------------------
  !
  SUBROUTINE Check_Constants()
    USE Constants

    REAL(pr) :: a,b,c,d,e
    INTEGER  :: k
    ! --------------------
    a = HALFPI
    b = PI
    c = TWOPI

    d = 2*a+b-c   ! d = 0e0_pr
    e = EPS
    k = KIND(d)   ! k = 8

  END SUBROUTINE Check_Constants

END MODULE Checks
constants.f90 (text/x-fortran, 371 B)
MODULE Constants

  USE Kinds

  REAL(pr), PARAMETER :: PI      = 3.141592653589793238462643383279502884197_pr
  REAL(pr), PARAMETER :: TWOPI   = 6.283185307179586476925286766559005768394_pr
  REAL(pr), PARAMETER :: HALFPI  = 1.570796326794896619231321691639751442099_pr

  REAL(pr), PARAMETER :: EPS     = EPSILON(1.0_pr) ! ~2.2204e-16 for REAL*8

END MODULE Constants
kinds.f90 (text/x-fortran, 174 B)
MODULE Kinds
   INTEGER, PARAMETER :: dp  = KIND( 1.0d0 )  ! Double precision, real
   INTEGER, PARAMETER :: pr  = dp             ! Default precision, real
END MODULE Kinds