Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



Problem in Fortran code

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 15-01-2010
Member
 
Join Date: Dec 2009
Posts: 202
Problem in Fortran code

Hello,
I have done a program which solves each iteration of a, but it is giving me an error, here is my source code, please check it.
Quote:
real k, z, y (500), x, Da, Q, v, a
k = 0.0005
Q = 0.026
v = 52
z = 0.0048
x = 0.003
Da = 0.2
do
a = 0.41
y (a) = y (a) + ((k * (z-(2 * y)) * (x-y) * Da) / (v + (Q * a)))
enddo
if (a.le.45) ahen
a = a +0.1
endif
wriae (*,*) y (a)
end

Last edited by ISAIAH : 15-01-2010 at 10:32 AM.
Reply With Quote
  #2  
Old 15-01-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
Re: Problem in Fortran code

Hello,
Quote:
real k, z, y (500), x, Da, Q, v, a
...
a = 0.41
...
Well, I think this is a recognition of Pascal. "a" seem to be real, but it is assigned with a comma, should scream. What happens if you assign-est by a = 0.41?
Reply With Quote
  #3  
Old 15-01-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,362
Re: Problem in Fortran code

Hi,
Quote:
Well, I think this is a recognition of Pascal.
No, in Pascal, we would have written
Quote:
... k, z, y (500), x, Dt, Q, v, a: real
as well as the type real of Pascal, which is actually from Borland's Turbo, Pascal is not recommended to use in a specific type, 6-byte, and for which the compiler does not use the FPU, but only with the CPU, and the injury time calculations.
Quote:
"a" seem to be real, but it is assigned with a comma, should scream.
Unless the compiler is smart enough to use representations which are via localization.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 15-01-2010
Member
 
Join Date: Dec 2009
Posts: 202
Re: Problem in Fortran code

Hello
Thank you for your reply.
Quote:
as well as the type real of Pascal, which is actually from Borland's Turbo, Pascal is not recommended to use in a specific type, 6-byte, and for which the compiler does not use the FPU, but only with the CPU, and the injury time calculations.
So now, if I take a = 0.41, it will consider that the value of a is 0.41. But I think a varies from 0 to 41. Am I correct? Please guide me with this. I think I have not understood the concept, so please give me some suggestion on my code.
Reply With Quote
  #5  
Old 15-01-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
Re: Problem in Fortran code

Hi,
I find some of the problems, first
Quote:
do
a = 0.45
y (a) = y (a) + ((k * (z-(2 * y)) * (x-y) * Da) / (v + (Q * a)))
enddo
As I understand you intend to loop a, a is ranging from 0 to 45. In this case, I recommend you to write a single line.
Quote:
do a = 0.41
In this case, T must be declared as an integer. If a is actually real, you have a loop "infinite", of which you will never leave if you do not add a condition "exit" somewhere between "do" and "enddo". Moreover, if t is real, it must be initialized as,
Quote:
a = 0.45
You should not use a comma, as reported before.
Reply With Quote
  #6  
Old 15-01-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
Re: Problem in Fortran code

Hello,
Correct the above mentioned. Other problems are, you iterate over the array y. Let a be an integer, or it's real. In the latter case, the assignment to a real value will cause big problems with its use as an index of an array.
Another problem: you use y (a) to define y (a). Now, y (a) is not initialized, it can take a zero value at best and at worst based on any compiler that you use.
Subsequently:
Quote:
if (a.le.45) then
a = a +0.1
endif
Again, in writing the condition of "if", we understand that a is an integer, otherwise you would rather something like
Quote:
if (a.le.45.)
However, just after you add 0.1 to a, as if it was real.
Finally:
Quote:
write (*,*) y (a)
He will write to the screen the value of y (a), for actual value of a it knows, Since a is real, it will not know how to make an array index. If you want to write the entire table, you must either pass through a loop "enddo do ...", you simply write
Quote:
write (*,*) y
but it will write the entire table (500 numbers), which are obviously not all interesting. The most delicate, in my opinion, is to disambiguate between a and a real world, using two different variables.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem in Fortran code"
Thread Thread Starter Forum Replies Last Post
Fortran compilation problem under Mac Rubero Software Development 7 25-09-2010 10:17 PM
Intel Fortran problem with intel9 Anja Software Development 3 23-09-2010 09:04 PM
problem installing intel fortran compiler on Mac Pro Hibiscus5 Motherboard Processor & RAM 3 22-09-2010 02:41 PM
Appcrash problem with Force2.0.8 program - Fortran Compiler and Editor Stefani Vista Setup and Install 2 15-03-2009 05:14 AM
Problem with User Breakpoint in Fortran Sachit Software Development 3 29-01-2009 11:19 PM


All times are GMT +5.5. The time now is 11:31 AM.