KevinKillion

01-15-2011, 02:11 AM

Help! I am trying to port an old statistical routine, and have run into a hard roadblock. (This is not about NR specifically, but I own three of the NR books, so please look kindly upon me!)

The problem is in "KYST", an old program to do multidimensional scaling. Here is an excerpt of where I'm tearing my hair out:

SUBROUTINE CONFIG(N,ND)

C

DIMENSION DATA(1800),WW(1800),IJ(1800),X(100,6)

DIMENSION STORE(494),RWMEAN(100),ROOTS(6),XBEST(100,6)

REAL MEAN

COMMON /KYST1/ DATA,WW,X,IJ

COMMON /KYST2/ STORE,RWMEAN,ROOTS,XBEST

C

ISUB(I1,I2)=((I2-1)*(I2-2))/2+I1

MEAN=0.0

FN=N

C

DO 130 J=1,N

RWMEAN(J)=0.0

DO 129 I=1,N

IF(I-J) 126,129,127

126 IJC=ISUB(I,J)

GO TO 128

127 IJC=ISUB(J,I)

128 RWMEAN(J)=DATAIN(IJC)**2+RWMEAN(J)

129 CONTINUE

...

...

...

(Posting here removes the FORTRAN-style formatting for the first 6 card columns; in the original the statements start in card column 7 and the statement numbers are where they should be.)

Here's the problem: What on earth is that line that starts "ISUB(I1,I2)=..."??????? It looks like ISUB is an array, but it isn't defined anywhere in the source code. Moreover, the variables I1 and I2 aren't defined or assigned anywhere, and yet they are used in the first assignment in this routine! Worse, the values in ISUB are used later, in the statements numbered as 126 and 127. (It almost looks like some kind of one-line subroutine definition, but I've never heard of anything like that in FORTRAN, yes?)

If you want to see the full source listing, it is at:

http://www.netlib.org/mds/kyst2a.f

Many thanks for any help!!!

Kevin Killion

The problem is in "KYST", an old program to do multidimensional scaling. Here is an excerpt of where I'm tearing my hair out:

SUBROUTINE CONFIG(N,ND)

C

DIMENSION DATA(1800),WW(1800),IJ(1800),X(100,6)

DIMENSION STORE(494),RWMEAN(100),ROOTS(6),XBEST(100,6)

REAL MEAN

COMMON /KYST1/ DATA,WW,X,IJ

COMMON /KYST2/ STORE,RWMEAN,ROOTS,XBEST

C

ISUB(I1,I2)=((I2-1)*(I2-2))/2+I1

MEAN=0.0

FN=N

C

DO 130 J=1,N

RWMEAN(J)=0.0

DO 129 I=1,N

IF(I-J) 126,129,127

126 IJC=ISUB(I,J)

GO TO 128

127 IJC=ISUB(J,I)

128 RWMEAN(J)=DATAIN(IJC)**2+RWMEAN(J)

129 CONTINUE

...

...

...

(Posting here removes the FORTRAN-style formatting for the first 6 card columns; in the original the statements start in card column 7 and the statement numbers are where they should be.)

Here's the problem: What on earth is that line that starts "ISUB(I1,I2)=..."??????? It looks like ISUB is an array, but it isn't defined anywhere in the source code. Moreover, the variables I1 and I2 aren't defined or assigned anywhere, and yet they are used in the first assignment in this routine! Worse, the values in ISUB are used later, in the statements numbered as 126 and 127. (It almost looks like some kind of one-line subroutine definition, but I've never heard of anything like that in FORTRAN, yes?)

If you want to see the full source listing, it is at:

http://www.netlib.org/mds/kyst2a.f

Many thanks for any help!!!

Kevin Killion