Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop crashing in a weird way...

Status
Not open for further replies.

ghisino

Technical User
Aug 7, 2009
6
FR
Hi everyone.

I have this program with 6 nested loops, the objective of it is opening some data-files, reading some values, doing some operations on these values and writing the results in some output files...

now, the outer loop (loop 11) is supposed to run some 900 times. Instead it will run about 10 times, and then the program will end without any error message (see attached screenprint).

I am printing loop indexes at each iteration, it seems that the crash happens somewhere in the two inner loops.

It also seems that there are no weird issues with the various loop indexes, prior to the crash.

I am also checking for I/O errors via IOSTAT, but either there is no I/O error or the program fails going to the specified line (105 in the screenprint) and writing the specified IERR variables on screen...


Also, note that if the crash happened say at iteration #10, I can run it again from iteration #9 and it will go fine until iteration #19, and so on...This means that it will pass thru the input data lines where the problem occurred last time with no problem, if only it gets there with a limited number of iterations.

Last : at the moment of the crash, the innermost loop will have turned some 2'500'000 times. COuld this matter somehow???

I am attaching a screenprint of the crash and the code...


any idea of how this could happen???
 
so, i took the two loops where I was crashing without a reason, plus some required lines, and it seems to work, or at least to work for more iterations than before...

I was "smelling" that it could be a solution but really I cannot theoretically justify it, computer science is not my discipline...

anyone has a clue of what kind of thing is/was going on here??? I'd like to learn from this...

 
no, it just went on a bit longer... duh!
 
I tried to compile the code you posted, but without success, your code is bad formatted (neither free-form nor fixed-form) and pretty spaghetti.
But as I have seen on your screenprint you are using an IDE, which probably have a graphical debugger too. Have you tried to debug your code?

 
in its original format it compiles and links, at least on my compiler (compaq developer studio)!
it was fixed form : regionalise.for
I copied and pasted to a text editor and changed the extension...because the website I used to attach it does not allow anything but text and image extensions...

I had a debugging session with a more expert user and we could not find anything obvious with the loop indexes, I/O, and arrays.

so what ???
 
After I formatted your source I still get these errors
Code:
$ g77 regionalisemodels_formatted.for -ffixed-line-length-none
regionalisemodels_formatted.for: In program `regionalise':
regionalisemodels_formatted.for:76: 
          Ivois(:,:)=0                     ! tableau des rangs entre bassins versants
          1     2
Null element at (1) for array reference at (2)
regionalisemodels_formatted.for:76: 
          Ivois(:,:)=0                     ! tableau des rangs entre bassins versants
          1     2
Too few elements (1 missing) as of (2) for array reference at (1)
regionalisemodels_formatted.for:76: 
          Ivois(:,:)=0                     ! tableau des rangs entre bassins versants
          1     2
Invalid token at (2) in expression or subexpression at (1)
regionalisemodels_formatted.for:77: 
          Dvois(:,:)=300000.              ! tableau des distances entre bassins versants
          1     2
Null element at (1) for array reference at (2)
regionalisemodels_formatted.for:77: 
          Dvois(:,:)=300000.              ! tableau des distances entre bassins versants
          1     2
Too few elements (1 missing) as of (2) for array reference at (1)
regionalisemodels_formatted.for:77: 
          Dvois(:,:)=300000.              ! tableau des distances entre bassins versants
          1     2
Invalid token at (2) in expression or subexpression at (1)
regionalisemodels_formatted.for:90: 
            call clasC2(NVX,Dvois(i,:),d,Ivois(i,:),j,k)
                            1       2
Null element at (1) for array reference at (2)
regionalisemodels_formatted.for:90: 
            call clasC2(NVX,Dvois(i,:),d,Ivois(i,:),j,k)
                            1       2
Invalid token at (2) in expression or subexpression at (1)
regionalisemodels_formatted.for:90: 
            call clasC2(NVX,Dvois(i,:),d,Ivois(i,:),j,k)
                                         1       2
Null element at (1) for array reference at (2)
regionalisemodels_formatted.for:90: 
            call clasC2(NVX,Dvois(i,:),d,Ivois(i,:),j,k)
                                         1       2
Invalid token at (2) in expression or subexpression at (1)
regionalisemodels_formatted.for:143: warning:
          OPEN(31,FILE=TRIM(ADJUSTL(CHEMININ1))//CODMOD//'_'//tbv(ibv)
                       ^
Reference to unimplemented intrinsic `TRIM' at (^) (assumed EXTERNAL)
regionalisemodels_formatted.for:143: warning:
          OPEN(31,FILE=TRIM(ADJUSTL(CHEMININ1))//CODMOD//'_'//tbv(ibv)
                            ^
Reference to unimplemented intrinsic `ADJUSTL' at (^) (assumed EXTERNAL)
regionalisemodels_formatted.for:143: 
          OPEN(31,FILE=TRIM(ADJUSTL(CHEMININ1))//CODMOD//'_'//tbv(ibv)
                       1                       2
Concatenation operator at (2) must operate on two subexpressions of character type, but the subexpression at (1) is not of character type
regionalisemodels_formatted.for:157: 
          OPEN(31,FILE=TRIM(ADJUSTL(CHEMININ1))//CODMOD//'_'//tbv(ibv)
                       1                       2
Concatenation operator at (2) must operate on two subexpressions of character type, but the subexpression at (1) is not of character type
regionalisemodels_formatted.for:162: 
          OPEN(32,FILE=TRIM(ADJUSTL(CHEMINOUT))//CODMOD//
                       1                       2
Concatenation operator at (2) must operate on two subexpressions of character type, but the subexpression at (1) is not of character type
regionalisemodels_formatted.for:179: 
          OPEN(30,FILE=TRIM(ADJUSTL(CHEMININ2))//CODMOD//
                       1                       2
Concatenation operator at (2) must operate on two subexpressions of character type, but the subexpression at (1) is not of character type
 
...never seen something like that.

what compiler are you using?
 
It seems that g77 doesn't support something like
Code:
Ivois(:,:)=0
instead it shoud be written in 2 loops.

But I could compile your code in gfortran and g95. But when I tried to run it I get
Code:
$ regionalisemodels                            
At line 51 of file regionalisemodels.for (unit = 10, file = '')
Fortran runtime error: File '_bv2.vaz' does not exist
I have not the file _bv2.vaz
 
In the nested loops 11, 111 and 112 you open several other files, which you didn't provide. So, I cannot help you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top