For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2005 > translating method calls to Fortran 95









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 translating method calls to Fortran 95
beliavsky@aol.com

2005-04-06, 12:21 pm

I am trying to translate some Python code I have written to Fortran in
a semi-automatic way (some polishing will be required). Code in Python
and other OO languages has lines such as

xx.set(nobs=10,nvar=3)
xx.show()
y = xx.func(a,b)

that I would translate in F95 to

call set(xx,nobs,nvar)
call show(xx)
y = func(xx,a,b)

Do these idioms make sense? I will need to translate the code for the
method calls to the appropriate functions and subroutines, of course.

I suppose the Fortran 2003 equivalents of the first two lines using
type-bound procedures would be

call xx%set(nobs,nvar)
call xx%show()

Gary L. Scott

2005-04-06, 12:21 pm

beliavsky@aol.com wrote:

> I am trying to translate some Python code I have written to Fortran in
> a semi-automatic way (some polishing will be required). Code in Python
> and other OO languages has lines such as
>
> xx.set(nobs=10,nvar=3)
> xx.show()
> y = xx.func(a,b)


Why is above syntax better than below? In what way is the function
"bound" to the type?

>
> that I would translate in F95 to
>
> call set(xx,nobs,nvar)
> call show(xx)
> y = func(xx,a,b)
>
> Do these idioms make sense? I will need to translate the code for the
> method calls to the appropriate functions and subroutines, of course.
>
> I suppose the Fortran 2003 equivalents of the first two lines using
> type-bound procedures would be
>
> call xx%set(nobs,nvar)
> call xx%show()
>



--

Gary Scott
mailto:garyscott@ev1.net

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 electricity comes from electrons, does morality come from morons?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com