C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 8th, 2008, 09:29 AM
m_naseer m_naseer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 24 m_naseer Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 43 sec
Reputation Power: 0
Fortran to C

I am new to both FOrtran and C language. I need help in converting the following line of code from Fortran to C.

==============================================
Do
READ(handle, rec=I) tempstr
If (tempstr(1:10) == "END_HEADER") EXIT
upperstring = to_upper(tempstr(1:name_len))
IF (upperstring(1:name_len) == UpperName(1:name_len)) THEN

!Svalue_temp(1: 44) = tempstr(37:80)
Svalue_temp(1: bytes_left_1st_ln) = tempstr(value_1st_pos:REC_LEN)

! For attributes take more than one 80-bytes record
low_end = bytes_left_1st_ln + 1 ! 45
up_end = low_end + REC_LEN -1
DO
i = I +1
READ(handle, rec=I) tempstr1
! hit another attribute
IF ((tempstr1(eq_pos : eq_pos) == "=") .or. &
(tempstr1(1:10) == "END_HEADER")) THEN
EXIT
END IF
!! Svalue (low_end : up_end) = tempstr1(1:REC_LEN)
Svalue_temp (low_end : up_end) = tempstr1(1:REC_LEN)
low_end = up_end +1
up_end = low_end + REC_LEN -1
END DO
found = 1
EXIT
END IF
I = I +1
END DO
============================================

Thanks
Naseer
Comments on this post
sizablegrin disagrees: Please read the "New Users - HOW TO POST A QUESTION - READ THIS FIRST" thread.

Reply With Quote
  #2  
Old May 8th, 2008, 01:33 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 2,374 clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 55 m 11 sec
Reputation Power: 306
Is it coincidence that two different members are posting questions asking fortran to be converted to C?

None of this code is very complex or long, it would not take much time to learn enough of either language to translate this code.

If you are new to both, why do you need to do this at all?

Reply With Quote
  #3  
Old May 8th, 2008, 01:41 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 2,374 clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level)clifford User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 55 m 11 sec
Reputation Power: 306
You could try f2c or there is a shareware program of the same name for $10 that might be worth a try.

Clifford

Reply With Quote
  #4  
Old May 8th, 2008, 01:53 PM
m_naseer m_naseer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 24 m_naseer Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 43 sec
Reputation Power: 0
fortran to C

I have done C++. It is a new project and I took it as challenge. I have converted about 5000 lines. but this is something came new in the code.

Naseer

Reply With Quote
  #5  
Old May 8th, 2008, 02:55 PM
sizablegrin's Avatar
sizablegrin sizablegrin is online now
Stubborn ol' L'User
Click here for more information.
 
Join Date: Jun 2005
Posts: 3,036 sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 23 h 52 m 33 sec
Reputation Power: 1440
Hard to believe that if you've converted 5000 lines, you can't convert that. Where's your "challenge" if we do it for you? Besides, you're looking at variables and such that you aren't showing us.
__________________
C/C++ pointers (Original in the "Commonly Asked Questions" thread).

Reply With Quote
  #6  
Old May 8th, 2008, 03:06 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,793 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 6 h 53 m 57 sec
Reputation Power: 434
Quote:
Originally Posted by m_naseer
I am new to both FOrtran and C language. I need help in converting the following line of code from Fortran to C.

[snipped]



Which line are you referring to as "the following line of code"? There are about 30 lines there. Which one is it?

Also, what's the formatting? By not using code tags, you lost all indentation. My experience was with FORTRAN IV, in which specific columns had specific meaning. All that is lost in your post.

Reply With Quote
  #7  
Old May 8th, 2008, 03:15 PM
m_naseer m_naseer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 24 m_naseer Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 43 sec
Reputation Power: 0
Fortran to C

I apologize for the mistyping. I have converted 500 lines.

Reply With Quote
  #8  
Old May 8th, 2008, 03:17 PM
m_naseer m_naseer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 24 m_naseer Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 43 sec
Reputation Power: 0
Fortran to C

Do
READ(handle, rec=I) tempstr
If (tempstr(1:10) == "END_HEADER") EXIT
.........

Reply With Quote
  #9  
Old May 8th, 2008, 03:20 PM
sizablegrin's Avatar
sizablegrin sizablegrin is online now
Stubborn ol' L'User
Click here for more information.
 
Join Date: Jun 2005
Posts: 3,036 sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 23 h 52 m 33 sec
Reputation Power: 1440
So you're new to Fortran and you're new to C (what is your language?) and your boss has brought around some legacy code and asked for a volunteer to translate it.

Your boss should probably start a thread in the "Hire a Programmer" forum.

Reply With Quote
  #10  
Old May 8th, 2008, 03:46 PM
m_naseer m_naseer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 24 m_naseer Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 43 sec
Reputation Power: 0
If you cannot answer the question, then please avoid asking irrevalent questions. ou need to go to "manners forum"
Comments on this post
dwise1_aol disagrees: No, you need to go there. Refusing to read the "READ THIS FIRST" sticky for new posters
and then also insisting on making your code unreadable by refusing to use code
tags
is extremely rude and goes beyond bad manners.
sizablegrin disagrees!

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Fortran to C


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway