1
votes

I was given some Fortran code (90, I believe) and I'm trying to figure out what it does. I know no Fortran, but do know Perl.

Here is a snippet that I've not been able to figure out:

  fmly='I:\CEX\Fmly'
  fmlyfile=fmly(1:23)//yearqtr(qtrcnt)
  open(unit=13,file=fmlyfile)

I know that // is a concatenation operator, but I'm confused about what the fmly(1:23) part is doing.

2

2 Answers

4
votes

fmly(1:23) is slicing a character string fmly from position 1 to position 23. Note that in Fortran, string indexing begins from 1 and not from 0. fmly(1:23) is equivalent to fmly(:23).

3
votes

string(A:B) is a substring, selecting characters A to B of string string. fmly is initialized with fewer than 23 characters, so the trailing characters will be blanks. After that it will be concatenated with an element of the string array yearqtr (or possibly a string-valued function yearqtr).