Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Help --- continued code conversion
I am trying to learn FORTRAN so that I can convert 200 lines of FORTRAN to C
++.

----------------------------------------------------------------
program kmc

1.     implicit double precision (a-h,o-z)
2.     parameter(mmax = 300)
3.     integer   height(mmax*mmax),iper(0:mmax+1), idx(4), idy(4)
4.     dimension rho(mmax,mmax)
5.     data idx/1, 0, -1, 0/, idy/0, 1, 0, -1/
6.     common/iseed/idum

----------------------------------------------------------------

//c++ code maybe
1.      double  a,b,c,d,e,f,g,h,o,p,q,r,s,t,u,v,w,x,y,z;

2.      int mmax = 300;
3.      int height[mmax][mmax];
int iper[mmax+1];
int idx[4];
int idy[4];
4.      --------I am not sure how to handle this
5.      idx[0] = 1; idx[1] = 0; idx[2] = -1; idx[3] = 0;
idy[0] = 0; idy[1] = 1; idy[2] = 0; idy[3] = -1;
6.      --------I am not sure how to handle this

-------------------------------------------------------------------

Any suggestions?

Report this thread to moderator Post Follow-up to this message
Old Post
Jason
10-20-04 09:06 PM


Re: Help --- continued code conversion
"Jason" <jspaldin@umflint.edu> wrote in message
news:975427f0.0410201118.b431300@posting.google.com...

> I am trying to learn FORTRAN so that I can convert 200 lines of FORTRAN to
C++.

The first mistake -- you should be trying to find some way to
link the Fortran code to the C++.

> 1.      double  a,b,c,d,e,f,g,h,o,p,q,r,s,t,u,v,w,x,y,z;


No.  Don't put in any superfluous declarations like this, just
declare variables by hand when the C++ compiler tells you they
are required.  For only 200 lines of Fortran this is probably
the easiest method.

> 2.      int mmax = 300;

No.  Declare mmax as a const.

> 3.      int height[mmax][mmax];

No.  should be [mmax*mmax], a 1-d array.

>         int iper[mmax+1];

No.  Should be mmax+2.

>         int idx[4];

No. int idx[4] = {1,0,-1,0};

>         int idy[4];

See idx[4].

> 4.      --------I am not sure how to handle this

double rho[mmax][mmax];

> 5.      idx[0] = 1; idx[1] = 0; idx[2] = -1; idx[3] = 0;
>         idy[0] = 0; idy[1] = 1; idy[2] = 0; idy[3] = -1;

See above note on initialization.

> 6.      --------I am not sure how to handle this

Declare a global type with an instance called iseed.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end



Report this thread to moderator Post Follow-up to this message
Old Post
James Van Buskirk
10-20-04 09:06 PM


Re: Help --- continued code conversion
James Van Buskirk wrote:

<snip lots of good advice>

Not meaning to be rude to the original poster, but a similar result
could be achieved if he took the time and the effort to become competent
in C++ and Fortran. Give a man a fish etc etc...

cheers,

Rich

--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware

[ Delete VOID for valid email address ]

Report this thread to moderator Post Follow-up to this message
Old Post
Rich Townsend
10-20-04 09:06 PM


Re: Help --- continued code conversion
"James Van Buskirk" <not_valid@comcast.net> writes:
 
>
> No.  Don't put in any superfluous declarations like this,...

Besides, this is just plain an incorrect translation anyway.
Independent of whether this is a good idea or not, it is wrong.
As others have mentioned, there *ISN"T* a direct translation.
The implicit statement applies to all otherwise untyped names
beginning with the specified letters.

The "beginning with" part is important; it is not restricted to just
one-letter names.

The "otherwise untyped" part is also important. Just because you
have an implicit mapping doesn't mean that names necessarily get
that type - just names that are otherwise untyped.

--
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

Report this thread to moderator Post Follow-up to this message
Old Post
Richard E Maine
10-21-04 01:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:58 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.