Results 1 to 6 of 6

Thread: Problem in Fortran code

  1. #1
    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.
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Problem in Fortran code

    Hello,
    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?

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Problem in Fortran code

    Hi,
    Well, I think this is a recognition of Pascal.
    No, in Pascal, we would have written
    ... 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.
    "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.

  4. #4
    Join Date
    Dec 2009
    Posts
    202

    Re: Problem in Fortran code

    Hello
    Thank you for your reply.
    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.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Problem in Fortran code

    Hi,
    I find some of the problems, first
    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.
    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,
    a = 0.45
    You should not use a comma, as reported before.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    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:
    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
    if (a.le.45.)
    However, just after you add 0.1 to a, as if it was real.
    Finally:
    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
    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.

Similar Threads

  1. Fortran compilation problem under Mac
    By Rubero in forum Software Development
    Replies: 7
    Last Post: 25-09-2010, 09:17 PM
  2. Intel Fortran problem with intel9
    By Anja in forum Software Development
    Replies: 3
    Last Post: 23-09-2010, 08:04 PM
  3. problem installing intel fortran compiler on Mac Pro
    By Hibiscus5 in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 22-09-2010, 01:41 PM
  4. Using Fortran on Mac OS X
    By Kantimoy in forum Software Development
    Replies: 4
    Last Post: 27-05-2010, 04:50 PM
  5. Problem with User Breakpoint in Fortran
    By Sachit in forum Software Development
    Replies: 3
    Last Post: 29-01-2009, 11:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,547,900.90562 seconds with 17 queries