if the dummy argument of a subroutine(F77) is a asterisk, what does it mean

if the dummy argument of a subroutine(F77) is a asterisk, what does it mean

I have a F77 old style src code. Because having learn Fortran for 2 months, I dont understand some F77 grammar, one of which I describe on subject.

the src is given below:

SUBROUTINE STO3X(*,*)
...

CALL STO3X(NDAT(I),I) !call the subroutine in main program

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This is a feature called "alternate return", though the CALL is incorrect. Either the programmer didn't know what they were doing, or they were relying on the way a particular implementation worked.

Typically, the call would look like this:

CALL STO3X (&100,&200)

where 100 and 200 were statement labels in the calling routine. STO3X could then do a RETURN 1 or RETURN 2, which would return and then branch to label 100 or 200, respectively.

This is a "deleted feature" in Fortran 95 and should be avoided, though CVF does support it.

I can't begin to guess what the programmer intended by passing variables instead...

Steve

Steve - Intel Developer Support

why the statement label has '&' ? Is it a F77 grammar?

This is a FORTRAN IV (F66) syntax - the & is used to indicate that it is a statement label and not an integer constant.

In many implementations, nothing actually gets passed to the subroutine - a hidden return value of the RETURN index is tested and the appropriate label branched to.

Steve

Steve - Intel Developer Support

Thank u for ur keyword 'alternate return'! However, there's another uncertainty, why the CVF online

document use the '*' while in ur demo code above, there is a '&' instead?

Finally, I'm still confused by the use of 'alternate return' in the old F77 code. I paste the full

content of subroutine sto3x and a more detailed call statement.

C == +++++++++++++++++++++++++++++
SUBROUTINE STO3X(*,*)
C +++++++++++++++++++++++++++++
C IMPLICIT REAL*8 (A-H,O-Z)
COMMON/C1/F1(30),F2(30),F3(30),F4(30),T,NT,NR1,NR2,NR3,KV1
COMMON/CSTO3X/NCEX,NCEY(17),NCEZ(17)
DIMENSION NR(3)
C
C READ EXPERIMENTAL DATA IF DATA BANK IS NOT USED
C
READ(5,100)(NR(I),I=1,3),NT,KV1,T
100 FORMAT(5I4,F10.1)
WRITE(6,102)(NR(I),I=1,3),NT,KV1,T
102 FORMAT(7X,'G',11X,5I4,G12.5)
DO 1 J=1,3
KON=0
IF(NCEX.EQ.0) GO TO 1
DO 2 I=1,NCEX
IF(NR(J).NE.NCEZ(I)) GO TO 2
NR(J)=NCEY(I)
KON=1
2 CONTINUE
1 IF(KON.EQ.0) NR(J)=NR(J)+1400
NR1=NR(1)
NR2=NR(2)
NR3=NR(3)
READ(5,101) (F1(I),F2(I),F3(I),F4(I),I=1,NT)
101 FORMAT(4F10.1)
WRITE(6,103) (F1(I),F2(I),F3(I),F4(I),I=1,NT)
103 FORMAT(7X,'G',11X,4G12.5)
RETURN
END

DO 743 I=1,ND
IF(NDAT(I).GE.2000) CALL STO3X(NDAT(I),I) ! ND==1, NDAT(1)==2000
...
797 DO 743 J=1,NT
...
743 YEXP(I,J,3)=1.D0-YEXP(I,J,4)-F4(J)/100.D0

Sorry - * is correct. Not sure where & came from..

Your particular example never uses the alternate return feature (nor the arguments passed to STO3X) so it's a moot point.

Steve

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today