Ifort dialect options for very old code

I was unexpectedly provided with some very old fortran codes to compile and work in my research group. Using ifort while compiling the code, I get the following error:error #6526: A branch to a do-term-shared-stmt has occurred from outside the range of the corresponding inner-shared-do-construct.

Here's the bit of code that seems to be at fault:

...
      IF(THRU.GT.0.D0) GO TO 120                                        00011900
      L1=LL                                                             00012000
      A1=AA                                                             00012100
      DR1=DRR                                                           00012200
      RMAX1=RMAXX                                                       00012300
      RMIN1=RMINN                                                       00012400
      IF(DR1.EQ.0.D0) DR1=DRP                                           00012500
      KMAX1=(RMAX1-RMIN1)/DR1+1.D-08                                    00012600
      IF(KMAX1.GT.NN .OR. KMAX1.LE.0) KMAX1=NN                          00012700
      RINT1=RMAX1                                                       00012800
      IF(RMAX1.NE.0.D0)                                                 00012900
     2RMAX1=DR1*DFLOAT(KMAX1)+RMIN1                                     00013000
      IUP=KMAX1                                                         00013100
      R=RMIN1                                                           00013200
      DO 120 K1=1,KMAX1                                                  00013300
      R=R+DR1                                                           00013400
      XX(K1)=R                                                           00013500
120   CONTINUE                                                          00013600
      WRITE(IW,940) NAM1,IOPT1,L1,A1,DR1,RMAX1,RMIN1,ANU1,BNU1,CNU1     00013700
121   CONTINUE                                                          00013800
...

      

Being completely unfamiliar with fortran, I do some searching and I see that it doesn't like the IF statement branching into a DO loop terminal statement. Also, it seems that some older dialects or compilers supported this.

My questions are: Is there an option that will allow ifort to compile this successfully? IE Is there a specific dialect compatibility option on ifort that will make this legal?

What are the side effects of this particular code on the compiler that would accept it? Is it possible that besides the write statement, the side effects are identical to branching to line 121? Or maybe the do loop should go up to 121?

I would consider changing the code if it weren't for the fact that my advisor told me that I shouldn't make any changes without consulting him in the first place, and so I ask this question to find out if whether I should consult him or not. However, if my only option is to modify the code sentences, I'll be happy about that so that I have an idea of ​​what to do when I go to my advisor.

+3


source to share


1 answer


Note that this code is not valid even as Fortran 77, but people have become strange things again in the fog of time. I will give it to any historian or person with experience. In particular, one has to be very careful to understand any intricacies of the code in relation to my "answer" here.

If we assume that the intent is goto

to jump to the code after the loop has completed, then my answer is a minimal code change.

Strikethrough line number comments for clarity, then

      DO 120 K1=1,KMAX1
      R=R+DR1
      XX(K1)=R
 120  CONTINUE
      WRITE(IW,940) NAM1,IOPT1,L1,A1,DR1,RMAX1,RMIN1,ANU1,BNU1,CNU1

      



can be replaced with

      DO K1=1,KMAX1
      R=R+DR1
      XX(K1)=R
      END DO
 120  WRITE(IW,940) NAM1,IOPT1,L1,A1,DR1,RMAX1,RMIN1,ANU1,BNU1,CNU1

      

I would be quite surprised if the author of the code assumed that the loop would continue 121

: no variable referenced by the statement write

is updated in the loop. Possibly what was goto

meant to be referenced 121

, but I can see that many variables are not updated in the section to be skipped.

+1


source







All Articles