home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!usc!cs.utexas.edu!hermes.chpc.utexas.edu!michael
- From: michael@chpc.utexas.edu (Michael Lemke)
- Subject: Re: function name as an argument
- Message-ID: <1992Dec15.061743.20060@chpc.utexas.edu>
- Organization: The University of Texas System - CHPC
- References: <ADK.92Dec12114449@ds2.sun13.SCRI.FSU.EDU> <1992Dec14.193634.5231@newshost.lanl.gov> <1gj95eINNqgo@gap.caltech.edu>
- Date: Tue, 15 Dec 92 06:17:43 GMT
- Lines: 73
-
- In article <1gj95eINNqgo@gap.caltech.edu> shepard@sampson.ccsf.caltech.edu (Ron Shepard) writes:
- >I believe that the following is standard f77.
-
- I don't think so -- see below.
-
- >Note that the character
- >function is declared as (*) in the main program, and is declared, and
- >called, with different *(CONSTANT) values from the two subroutines.
- >
- >It is apparently because of the requirement of *(CONSTANT) declaration
- >in the referencing subprogram that this can be done legally without
- >recourse to runtime memory allocation.
- >
- > program dumb
- > character*30 cvar
- > character*(*) cfun
- > external cfun
- > cvar='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
- > call sub1( cvar, cfun )
- > write(*,*) 'cvar=', cvar
- > call sub2( cvar, cfun )
- > write(*,*) 'cvar=', cvar
- > stop
- > end
- >
- > subroutine sub1( cvar, cfun )
- > character*10 cvar
- > character*10 cfun
- >c # cfun() returns a 10-character value here.
- > cvar = cfun()
- > return
- > end
- >
- > subroutine sub2( cvar, cfun )
- > character*20 cvar
- > character*20 cfun
- >c # cfun() returns a 20-character value here.
- > cvar = cfun()
- > return
- > end
- >
- > function cfun
- > character*(*) cfun
- >c # assign a 30-character value, truncating as necessary.
- > cfun = '123456789012345678901234567890'
- > return
- > end
- >
- >Upon execution on a couple of machines, I get:
- >
- >cvar=1234567890xxxxxxxxxxxxxxxxxxxx
- >cvar=12345678901234567890xxxxxxxxxx
- >
- >which is what I thought I should get according to the previous discussion
- >in this thread.
- >
- >Are there any machines that give different results?
-
- Yes, VAX/VMS:
-
- $ for x
- %FORT-F-ADJLENUSE, Passed length character name used in invalid context
- [CFUN] in module DUMB
- %FORT-F-ENDNOOBJ, IO$DUC0:[MICHAEL]X.FOR;2 completed with 1 diagnostic - object
- deleted
-
- So what junky Fortran took this?
-
- Michael
- --
- Michael Lemke
- Astronomy, UT Austin, Texas
- (michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
-