Home > Archive > Fortran > February 2005 > Help with understanding Interface body
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help with understanding Interface body
|
|
|
|
I am writing some scripts to analyse our code, directory by directory.
One of these scripts is to generate a file for each directory which will
contain the interface bodies for each Fortran file in the directory. Then
another script edits each fortran file and adds an include statement for the
interface file for that directory. Of course this means that each fortran
routine will also include the interface to itself.
Mostly it's going well, but I have some problems.
(1)
If a subroutine has an "alternate return" (did I see you wince?
Unfortunately there are lots of routines with this and part of the exercise
is to determine the work required to drag the code into the 21st century)
how is that specified in the interface body? If indeed it is possible. On my
system (CVF, Win XP) I left out any reference to the alternate return and
got "internal compiler error" so I have skipped making the interface bodies
for these routines so far.
(2)
Functions passed as arguments. example :
subroutine robin(pooh, piglet, tigger)
implicit none
integer :: pooh, piglet
external logical tigger
.....
end subroutine
Interface to subroutine robin (pooh, piglet, tigger)
integer :: pooh
integer :: piglet
??? tigger
end interface
In the interface body for robin how do I specify "tigger"?
If I have "logical tigger" or "external tigger" then all the files compile
ok except for robin.f90 where I get
"Error: The characteristics of the procedure's arguments differ from those
of the same procedure's arguments that are redefined in the INTERFACE
statement. [tigger]"
If I have "external logical tigger" then I get, for every file :
"Error: Syntax error, found IDENTIFIER 'tigger' when expecting one of: ,
<END-OF-STATEMENT> ;"
If I leave it out altogether I get, for every file, "Warning This name has
not been given an explicit type [tigger]"
thanks for any help
Les
| |
| beliavsky@aol.com 2005-02-15, 4:03 pm |
|
Les wrote:
> I am writing some scripts to analyse our code, directory by
directory.
> One of these scripts is to generate a file for each directory which
will
> contain the interface bodies for each Fortran file in the directory.
The convert.f90 program of Michael Metcalf at
http://www.slac.stanford.edu/comp/fortran/convert.f90 optionally
generates interface blocks.
| |
| Steve Lionel 2005-02-15, 4:03 pm |
| On Tue, 15 Feb 2005 14:46:51 -0000, "Les" <l.neilson@progs_acecad.co.uk>
wrote:
>If a subroutine has an "alternate return" (did I see you wince?
>Unfortunately there are lots of routines with this and part of the exercise
>is to determine the work required to drag the code into the 21st century)
>how is that specified in the interface body? If indeed it is possible. On my
>system (CVF, Win XP) I left out any reference to the alternate return and
>got "internal compiler error" so I have skipped making the interface bodies
>for these routines so far.
I would be interested to see the source that caused an internal compiler error
in CVF. Please e-mail it to me (steve dot lionel at intel dot com) I can't
come up with an example that causes a problem.
You can specify alternate return in an interface body just as you do in the
actual routine. For example:
interface
subroutine foo (a,b,*)
integer a,b
end subroutine foo
end interface
>If I have "external logical tigger" then I get, for every file :
>"Error: Syntax error, found IDENTIFIER 'tigger' when expecting one of: ,
><END-OF-STATEMENT> ;"
You want:
external, logical :: tigger
You could also have an explicit interface for tigger - it is just a nested
interface. For example:
subroutine robin(pooh, piglet, tigger)
implicit none
integer :: pooh, piglet
interface
logical function tigger (a,b)
real, intent(in) :: a,b
end function tigger
end interface....
end subroutine
Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH
User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/
| |
|
|
<beliavsky@aol.com> wrote in message
news:1108480182.021794.21340@c13g2000cwb.googlegroups.com...
>
> Les wrote:
> directory.
> will
>
> The convert.f90 program of Michael Metcalf at
> http://www.slac.stanford.edu/comp/fortran/convert.f90 optionally
> generates interface blocks.
>
Thanks
I downloaded the code and had to make some mods as all our files are now
..f90 (converted some time ago by Spag long before I joined the company) I
also made it loop while reading a control file listing the files to process
but it failed on a "data" statement somewhere in a file down the list. I
might do some more "tweaking" if I get the chance later.
Les
| |
|
|
>
> I would be interested to see the source that caused an internal compiler
error
> in CVF. Please e-mail it to me (steve dot lionel at intel dot com) I
can't
> come up with an example that causes a problem.
>
> You can specify alternate return in an interface body just as you do in
the
> actual routine. For example:
>
> interface
> subroutine foo (a,b,*)
> integer a,b
> end subroutine foo
> end interface
>
For anyone else interested :
!---------------------------------------------------------------------------
-
subroutine usermenu(imode,ityp,value,*)
implicit none
include 'xcad3d.menulib.interface.ins'
! define a menu based on cadmac/menu/config.men
! Arguments
integer :: IMODE, ITYP
character(*) :: VALUE
intent (in) IMODE, ITYP
! Local variables
character(132) :: buff
character(80) :: config
integer :: funit, ier, irow, jtyp, mlen, nfld, numrow
character(10) :: model
character(80), dimension(20) :: field
! External Functions
integer, external :: ASCTOINT4
! <code elided>
end subroutine USERMENU
and in the include file :
INTERFACE to subroutine usermenu (imode,ityp,value,*)
integer, intent (in) :: imode
integer, intent (in) :: ityp
character value
END
| |
| Rich Townsend 2005-02-15, 4:03 pm |
| Les wrote:
<snip>
Les, a quick questrion: why aren't you putting your subroutines in
modules? That way, all of the interfaces get defined automatically, and
can be pulled in via a USE statement.
cheers,
Rich
| |
| Michael Metcalf 2005-02-15, 4:03 pm |
|
> but it failed on a "data" statement somewhere in a file down the list. I
> might do some more "tweaking" if I get the chance later.
>
Curious. So might I. Please send me the suspect code (haven't had an error
reported in over a decade!).
Regards,
Mike Metcalf
| |
| Steve Lionel 2005-02-15, 9:00 pm |
| On Tue, 15 Feb 2005 17:45:37 -0000, "Les" <l.neilson@progs_acecad.co.uk>
wrote:
>-
> subroutine usermenu(imode,ityp,value,*)
> implicit none
> include 'xcad3d.menulib.interface.ins'
>
>and in the include file :
>
>INTERFACE to subroutine usermenu (imode,ityp,value,*)
> integer, intent (in) :: imode
> integer, intent (in) :: ityp
> character value
>END
First, why are you using the Microsoft Fortran PowerStation 1 extension
INTERFACE TO? Use the standard Fortran syntax instead.
Second, it is incorrect to include an interface to the routine you're in. I
can reproduce the compiler error, though. Thanks.
Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH
User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/
| |
|
|
"Steve Lionel" <Steve.Lionel@REMOVEintelME.com> wrote in message
news:qdp4115vro61b56i93nvgmpb0al7uf2hoj@
4ax.com...
> On Tue, 15 Feb 2005 17:45:37 -0000, "Les" <l.neilson@progs_acecad.co.uk>
> wrote:
>
>
>
>
> First, why are you using the Microsoft Fortran PowerStation 1 extension
> INTERFACE TO? Use the standard Fortran syntax instead.
Oh I hadn't realised it was an MS extension. I should have checked, merely
saw it somewhere else and in my perl script sub function (for printing the
interface block) I output this after gathering all the info for the dummy
arguments.
>
> Second, it is incorrect to include an interface to the routine you're in.
I mentioned this to my boss (I thought it was illegal) but he said he had
done it (for routines with elemental arguments) without problem and I must
admit apart from alternate return and functions passed as arguments, there
have been no problems - <pause> yet!
> I
> can reproduce the compiler error, though. Thanks.
>
Thanks Steve
I had to post the code here as our firewall refused to email you directly
:-(
| |
|
|
"Rich Townsend" <rhdt@barVOIDtol.udel.edu> wrote in message
news:42123DCE.2010806@barVOIDtol.udel.edu...
> Les wrote:
>
> <snip>
>
> Les, a quick questrion: why aren't you putting your subroutines in
> modules? That way, all of the interfaces get defined automatically, and
> can be pulled in via a USE statement.
>
I thought of that too. It started off as a small request for a script to do
some initial analysis and then grew. Over the years others have module'ised
parts of the code. (Original programmers left some time ago, I've only been
here over a year, the other two programmers have been here just over two
years) But there are some 300 directories and I'm not sure what timescale we
have left to make any more changes before we issue the next release. I may
get asked to "write a little script" to do exactly as you say however. Maybe
for the next version.
Les
> cheers,
>
> Rich
| |
|
|
"Michael Metcalf" <metcalfmetcalf@compuserve.com> wrote in message
news:cuterd$i7j$01$1@news.t-online.com...
>
>
> Curious. So might I. Please send me the suspect code (haven't had an error
> reported in over a decade!).
>
> Regards,
>
> Mike Metcalf
>
>
Thanks - it could well be our code or (more likely) something I did. If and
when I identify the problem I'll pass it on.
Les
| |
|
| Thanks for all the responses.
Does anyone have a solution for the function passed as argument problem?
Les
>
> (2)
> Functions passed as arguments. example :
>
> subroutine robin(pooh, piglet, tigger)
> implicit none
>
> integer :: pooh, piglet
> external logical tigger
> ....
> end subroutine
>
>
> Interface to subroutine robin (pooh, piglet, tigger)
> integer :: pooh
> integer :: piglet
> ??? tigger
> end interface
>
>
> In the interface body for robin how do I specify "tigger"?
>
> If I have "logical tigger" or "external tigger" then all the files compile
> ok except for robin.f90 where I get
> "Error: The characteristics of the procedure's arguments differ from those
> of the same procedure's arguments that are redefined in the INTERFACE
> statement. [tigger]"
>
> If I have "external logical tigger" then I get, for every file :
> "Error: Syntax error, found IDENTIFIER 'tigger' when expecting one of: ,
> <END-OF-STATEMENT> ;"
>
> If I leave it out altogether I get, for every file, "Warning This name has
> not been given an explicit type [tigger]"
>
> thanks for any help
> Les
>
>
| |
| Michael Metcalf 2005-02-17, 9:02 am |
|
"Les" <l.neilson@progs_acecad.co.uk> wrote in message
news:cv1p09$rvh$1@newsreaderg1.core.theplanet.net...
[color=darkred]
The correct syntax for this is
logical, external :: tigger
Regards,
Mike Metcalf
| |
| Steve Lionel 2005-02-17, 4:05 pm |
| On Thu, 17 Feb 2005 09:29:34 -0000, "Les" <l.neilson@progs_acecad.co.uk>
wrote:
>
>I mentioned this to my boss (I thought it was illegal) but he said he had
>done it (for routines with elemental arguments) without problem and I must
>admit apart from alternate return and functions passed as arguments, there
>have been no problems - <pause> yet!
It is non-standard. Our compiler accepts it but flags it as an extension. Of
course, there are many, myself included, who would argue that one OUGHT to be
able to do this, as it makes building interfaces so much easier. Then again,
if one uses modules, the matter doesn't come up.
Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH
User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/
| |
|
|
"Michael Metcalf" <metcalfmetcalf@compuserve.com> wrote in message
news:cv1v3v$e52$04$1@news.t-online.com...
>
> "Les" <l.neilson@progs_acecad.co.uk> wrote in message
> news:cv1p09$rvh$1@newsreaderg1.core.theplanet.net...
>
,[color=darkred]
>
> The correct syntax for this is
>
> logical, external :: tigger
>
> Regards,
>
> Mike Metcalf
>
>
Sorry - of course it is, somehow I missed the , *and* :: out talk about not
seeing the wood for the trees :-)
Thanks for your help.
Les
| |
| Richard E Maine 2005-02-17, 4:05 pm |
| In article <cv1os7$rtr$1@newsreaderg1.core.theplanet.net>,
"Les" <l.neilson@progs_acecad.co.uk> wrote:
> but it failed on a "data" statement somewhere in a file down the list. I
> might do some more "tweaking" if I get the chance later....
> "Michael Metcalf" <metcalfmetcalf@compuserve.com> wrote in message
> news:cuterd$i7j$01$1@news.t-online.com...
[color=darkred]
As a largely random guess... DATA statements are one of the only two
places where the F77 appendix suggested allowing Holleriths. Holleriths
can make parsing much more "interesting". Any chance that this might
explain the problem?
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| Michael Metcalf 2005-02-17, 4:05 pm |
|
"Richard E Maine" <nospam@see.signature> wrote in message
news:nospam-243A77.10274817022005@news.supernews.com...
> In article <cv1os7$rtr$1@newsreaderg1.core.theplanet.net>,
> As a largely random guess... DATA statements are one of the only two
> places where the F77 appendix suggested allowing Holleriths. Holleriths
> can make parsing much more "interesting". Any chance that this might
> explain the problem?
>
Well, convert has been used on millions of lines of ancient code, so I think
not by now.
Regards,
Mike Metcalf
| |
|
|
"Michael Metcalf" <metcalfmetcalf@compuserve.com> wrote in message
news:cuterd$i7j$01$1@news.t-online.com...
>
>
> Curious. So might I. Please send me the suspect code (haven't had an error
> reported in over a decade!).
>
Still no error to report :-)
As I mentioned elsewhere the code has already been passed through a f77 to
f90/f95 process so is now in free format. The failing code has had a DATA
statement added which begins in column 1 so failed the internal read
expecting fixed format f77 code of <label> <continuation> <field>
My "tweaking" of your code will need to be increased.
Les
> Regards,
>
> Mike Metcalf
>
>
|
|
|
|
|