Fortran Why Does My Fortran Program Have an Integer Overflow on Assignment?

AI Thread Summary
The discussion revolves around troubleshooting a Fortran program designed to read student grades, sort them alphabetically, and determine pass/fail status. The user encountered an 'integer overflow' error on line 87 and sought assistance. Key points include confusion over the use of multiple nested 'do while' loops and the return values of functions M1(x) and M2(x), which are intended to read student registrations and names, respectively. Participants highlighted the complexity and potential issues with the loop structure, suggesting that it might not exit correctly. They recommended printing values for debugging and emphasized the importance of meaningful variable names and comments for code clarity. Ultimately, the user resolved the issue by realizing the loop structure was inappropriate for their commands, leading to a successful program execution.
joao_mart
Messages
3
Reaction score
0
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
 
Technology news on Phys.org
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:
ChrisVer said:
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?
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.
 
joao_mart said:
I did all the do while g<i because the program has to read grades of 5 classes.
Correct me if I'm wrong but I read something like:
Code:
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:
  • Like
Likes joao_mart
ChrisVer said:
Correct me if I'm wrong but I read something like:
Code:
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?
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Back
Top