Re: How to pass a string to/from a function in 77
- From: "Gary L. Scott" <garyscott@xxxxxxx>
- Date: Sun, 29 Jan 2006 11:38:30 -0600
Gary L. Scott wrote:
Sorry, probably should have been declared with length 5 rather than 10 in this example.jane.sync@xxxxxxxxx wrote:
I'm trying to pass strings between functions in Fortran 77, but I can't find any reference for this... Can anyone help with explaining how to send a string to a function and have the function return a string? So far I have this:
PROGRAM HELLOWORLD IMPLICIT NONE Character*256 MyFunc
PRINT *, 'Hello ' FunctionString()
END PROGRAM
FUNCTION FunctionString() RESULT(String) Implicit None Character(*) String String = "World" Return End
The below is a little closer and works with a particular F95 compiler (not F77). I would probably write the function more generically than this.
PROGRAM HELLOWORLD
IMPLICIT NONE
character(10) functionstring
PRINT *, 'Hello ',FunctionString()
END PROGRAM
FUNCTION FunctionString() RESULT(String)
Implicit None
Character(10) String
String = "World"
Return
End
--
Gary Scott mailto:garyscott@xxxxxxx
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If you want to do the impossible, don't hire an expert because he knows it can't be done.
-- Henry Ford .
- References:
- How to pass a string to/from a function in 77
- From: jane . sync
- Re: How to pass a string to/from a function in 77
- From: Gary L. Scott
- How to pass a string to/from a function in 77
- Prev by Date: Re: How to pass a string to/from a function in 77
- Next by Date: Nested dummy procedures
- Previous by thread: Re: How to pass a string to/from a function in 77
- Next by thread: Re: How to pass a string to/from a function in 77
- Index(es):
Relevant Pages
|
|