Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran Integer overflow on assignment

  1. Dec 26, 2016 #1
    Hey guys, I have an assignment on fortran, which basically is supposed to read grades of a class and print them in alphabetical order and wether if the student failed or passed the class. We're supposed to do everything using our basic knowledge of fortran.
    When I run it it says 'integer overflow on line 87'. Can anyone help me out?
    Link for the program:
    http://pastebin.com/naZpzCA2
    http://pastebin.com/NnARY1Mu - example of what the program reads
    PS.: All the names are in portuguese
     
  2. jcsd
  3. Dec 26, 2016 #2

    ChrisVer

    User Avatar
    Gold Member

    I have some questions, what are the return values of M1(x) or M2(x) ? also I am not sure why you use so many do while G<i ... is it safe without incrementing it?
     
    Last edited: Dec 26, 2016
  4. Dec 29, 2016 #3
    I did all the do while g<i because the program has to read grades of 5 classes. My bad, i uploaded one with only 3 classes.
    I'm not sure what you meant by return values, but the M1 is supossed to read all the students 'Registrations', and M2 is a array for all the students names.
     
  5. Dec 29, 2016 #4

    ChrisVer

    User Avatar
    Gold Member

    Correct me if I'm wrong but I read something like:
    Code (Text):

    G=0
    do while G <= 5
      do while G<=4
         do while G<=3
            do while G<=2
               do while G<=1
                     [your code]
                     G= G+1
              enddo
           enddo
        enddo
      enddo
    enddo
     
    it looks pretty weird as a construct, in fact I am not sure how it's ever going to leave G<=2, but maybe I am misreading your code.

    I meant before checking in the referenced line the condition M2[I ]<M2[J], you could try to print them out and see what is being checked? just by looking at the type of error you get, it's an error that appears when the integer type is very long to be represented; and for students' matrikulation numbers that is weird.
    Maybe [I am not a fortran expert] there is something wrong when I=A , and J=I+1 to A...
    An auxilary comment is that it would be easier to read your code if you gave your variables meaningful names for a second party reader, who reads your code, understands what they are...and supply some comments between your code?
     
    Last edited: Dec 29, 2016
  6. Dec 29, 2016 #5
    Thanks a lot for the help. I spent some time and finally figured out that the type of loop that I was trying to do wasn't possible with the commands I was using. but i got the program to run perfectly in the end. Thanks so much for the help and advices, i really appreciate the time you spent trying to understant my horrible code xD
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Integer overflow on assignment
  1. C++ assignment (Replies: 7)

Loading...