CHARACTER(LEN=4) FUNCTION label4(indx) Implicit None !================================================================= ! Function to obtain a character string used to label files from an ! integer iterator. !CHARACTER(LEN=4) :: label4 INTEGER :: indx IF (indx.lt.10) WRITE(label4,'("000",I1)') indx IF (indx.ge.10.and.indx.lt.100) WRITE(label4,'("00",I2)') indx IF (indx.ge.100.and.indx.lt.1000) WRITE(label4,'("0",I3)') indx IF (indx.ge.1000) WRITE(label4,'(I4)') indx End Function label4