Menu

#91 MFRS gotta whole lotta bugs

v1.0 (example)
open
None
5
2019-05-11
2019-04-10
seismick
No

Process MFRS has an array out of bounds at line 1394 of mfrs.f90
The index is zero, meaning variable io=1:
atest=(opick1-apoff(io-1))/(xo+1-io)
if(io.eq.1)atest=((apoff(2)-opick1))/(2-xo)

Notice this is followed by an if for the case io.eq.1
So it needs to be rearranged like so:
if(io.eq.1) then
atest=((apoff(2)-opick1))/(2-xo)
else
atest=(opick1-apoff(io-1))/(xo+1-io)
endif

After this patch, get same bug at line 1577. So search for array
apoff and found 3 similar bugs at line 1595, 1722, 1821.
(These line numbers are after fixing the previous mistake, not
where it was in original code).

But then another array out of bounds: ivel with index= -11!
if((i+j.ge.1).and.(ivel(i+j).gt.0)&
.and.(i+j.le.obj%off_tot))then
This compound if needs to be rewritten as a nested if
if((i+j.ge.1).and.(i+j.le.obj%off_tot))then
if(ivel(i+j).gt.0) then
nj=nj+1
sumj(i)=sumj(i)+ivel(i+j)
end if
end if

Wait, there's more! Later on array out of bounds for sumj
The following was inside a do loop starting at 1:
if(((sumj(i)-sumj(i-1)).le.0)&
.or.(sumj(i).gt.obj%vel_corr))&
then
So add an extra if(i.gt.1) to that to avoid i-1=0

Next problem: a fortran runtime error for the .diag.ref file.

Fortran runtime error: Expected REAL for item 7 in formatted transfer, got INTEGER
(5i6,f7.3,i10)

This write using that format is for 6 integers. Intel compiler tolerates
more descriptors than variables, but gfortran does not. The format label (13)
is not used by any other read or write. So change the format to
13 format(5i6)

Then another array out of bounds: eshift. The index ia1 could be zero in
do loop 300
This code:
if(ia1.ne.0) ia2 = nint(te1 / te1a)
if(ia1.eq.0) ia2 = 0
state(i) = ia2 * eshift(ia1)
should be rewritten like this:
if(ia1.ne.0) then
ia2 = nint(te1 / te1a)
state(i) = ia2 * eshift(ia1)
else
ia2=0
state(i)=0
end if

Next failure, another array out of bounds stats1. But this time the index was
too big. Increasing the allocation by 4 will keeping it running. Simply add
4 to lgishw just before this allocate:
call mem_alloc(stats1,lgishw)

Finally, MFRS almost gets to the end, it outputs all files, but generates
an error message:
++++++++++fatal error+++++++++++
keyword NUMTR not found
++++++++++fatal error+++++++++++

It seems the runtime engine wants this, even for a SETUP ONLY process.
So as a kludge, add one line to mfrs_update subroutine:
call pc_put_global('NUMTR',1)

The attached fortran file has patches for the above flaws.

1 Attachments

Discussion

  • Bill Menger

    Bill Menger - 2019-05-11
    • assigned_to: Bill Menger
     
  • Bill Menger

    Bill Menger - 2019-05-11

    I could really use some data files and pick files to test this if anyone has something not too large. If needed I'll send a writeable filesystem link on google for you to drop your files into.

     

Log in to post a comment.

MongoDB Logo MongoDB