Thanks for the reply Eddie. I get 'A ' as the second output so the Z is still missing. Perhaps I should give a little bit more background to indicate why this problem arises.
Let me change the program to the following:
PROGRAM p
IMPLICIT NONE
CHARACTER(LEN=26) :: c1
CHARACTER(LEN= 3) :: c2
!
c1='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
READ (UNIT=c1(26:),FMT=*) c2
WRITE (UNIT=*,FMT=*) c1(26:)
WRITE (UNIT=*,FMT=*) c2
READ (UNIT=c1(25:),FMT=*) c2
WRITE (UNIT=*,FMT=*) c1(25:)
WRITE (UNIT=*,FMT=*) c2
END PROGRAM p
The only difference from the original is that c2 is length 3 instead of 1. c1 typically is a line containing a string of information marked by tags. For example, c1 may look like the following:
'NAME=Simon, SEX=M, OCCUPATION=scientist'
I search for the keywords written in bold and then read the corresponding values. The keywords are not necessarily always present, and can be in any order, and the length of the value string is not fixed (for example, SEX could be 'Male' or 'M').
In the example above, I can read all the values OK, but if the order is reversed:
'NAME=Simon, OCCUPATION=scientist, SEX=M'
then I may fail to read M if there are no trailing blanks.
I have to use READ with FMT=* rather than FMT='(A)' because otherwise when the values are in the original order I would read past the comma separators, and would then have to check to delete any extraneous text.
It is not too difficult to think of work-arounds, but it seems circuitous to have to be checking whether one is left trying to read only the last character.