Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

interfacing Lapack subroutine

Status
Not open for further replies.

Pfor

Technical User
Aug 11, 2010
22
IT
Dear all,
I would like to interface a Lapack subroutine with my code.

There is a point I don't understand.
As far as I know in principle a f90
compiler should compile all the f77 codes,
however I have a problem with commented sentences.

When there is a * at the beginning of a line it is considered as commented if the extension of the file is .f,
(for example gvim turns it blue to show it is a comment)
while a error message is returned if the code is labelled as f90 (and gvim doesn't turn the line blue)

I am using gfortran as a compiler.

The lapack subroutine I would like to implement has a lot of * at the beginning.
Do you have any suggestion (I hope there is an option in the compiler to get rid of this problem but I can't find it)

thank you
cheers,
Paolo
 
Change the suffix of the source file : .f instead of .f90

Indeed, FORTRAN has two different formats :
- the fixed form which accepts several kinds of comments, in particular the * in column 1
- the free form which only accept the bang comment starting by ! (the rest of the line is a comment).

By default, a compiler considers that a source file with the suffix .f is in fixed format, and a source file with the suffix .f90 is a free format.
 
Thank you fot the hint;
however it doesn't work since I
have to interface a fixed format part of
a code (the Lapack subroutine for example) with a
free form one (my code).

I have been checking some converter like
the convert.f90 ; but so far I didn't succeed in
converting the form.

Do you have any suggestion?
cheers,
thank you
Paolo
 
Michael Metcalf's convert.f90 works for me -- how did you not succeed in converting the form?

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
however it doesn't work since I
have to interface a fixed format part of
a code (the Lapack subroutine for example) with a
free form one (my code).

What do you mean by "interface" ? Why do you want to put Lapack code into sources files having the .f90 suffix ?

You can keep in the same time sources files in fixed format (with the suffix .f) and source files in free format (with suffix .f90). Both are valid FORTRAN-90 source files !

To compile and link with gfortran :

Code:
gfortran *.f *.f90
 
Thank you all for your answers.

I tried to use "convert.f90" but at some point there
was a error message:

>At line 953 of file convert.f90
>Fortran runtime error: Bad value during integer read

I figured out that the problem is in the fortran file to be converted.

If I open it with gvim editor at the beginning of the "problematic" line there are some spaces whose color is red, and this jams the convert.f90.

I am trying to get rid of these "red spacess".

Regarding the idea of compiling a subroutine without writing it in the main code...I have never done this procedure, I will try it,
thank you,
cheers
Paolo

 
Those red spaces in gvim are TAB character(s). Just replace it with the appropriate number of spaces.

--------------------------------------
Background: Chemical engineer, familiar mostly with MATLAB, but now branching out into real programming.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top