Search code examples
fortran

Colon in a Fortran output statement with an implied DO


We are having to convert some old Fortran 77 code to VB.net. With none of us knowing any Fortran, we have made significant progress. However, we have come across the following write statement which has a couple of nested implied do loops. We are familiar with implied do loops but do not know what the significance of the colon in MN:MN is. We've only ever seen implied do loops using commas such as the latter one in this statement (NREC,MN).

Logical*1 DECLN(492)

WRITE(6,9238)NPERMN(NREC),CUSIPS(NREC),TICKRS(NREC),NAMES(NREC),(DECLN(MN:MN),MN=1,30),(SCORES(NREC,MN),MN=1,30))

format(I7, 1X, A8, 1X, A8, 1X, A20, 1X, 12A1, 1X, 12A1, 1X, 6A1/(12F10.5))

Solution

  • DECLN(MN:MN)
    

    looks like a 1-character extract from a character variable called DECLN. The expression

    (DECLN(MN:MN),MN=1,30)
    

    (which is an io-implied-do expression) causes the program to write the first 30 characters of DECLN as 30 separate characters. The form

    (DECLN(1:30))
    

    writes the same characters in one 30-character long go.

    It might be that DECLN(MN:MN) is a 1-element section of the rank-1 array DECLN, in which case it's an odd way to write DECLN(MN)