Read/ Write ot/from variable

I have a read statement which is like this:

do 150 i = 1, 10
pos = (i-1)*4+1
read(unit=cvar(pos : pos+3), FMT = 210) rvar(i)
150 continue

210 format(A4)

here cvar is a character array
rvar is real array.
pos and i are integers

I intend to group the text in cvar into a word of 4 characters and copy it into rvar(which is of type real). But it is copying only the first byte into rvar.

for eg. if cvar(1) in hexadecimal format is 454D4F53
then I would want rvar(1) also to be the same, but it after the read is executed once rvar(1) is only 53

if I write a separate fortran program just to test the working of the read it works fine. but I am using this code snippet in another application and only in this application read is behaving like this.

Please anybody, tell me why this is happening and why I am not able to reproduce this in a separate program.

If rvar is a real variable, you should read it using an appropriate format – A4 is not such a format – and the internal file from which you are reading the value should contain a properly formatted real number: aaa.bbbEnnn.

If you want to read from a hexadecimal string, the format to use is Z8 for 32 bit integers and Z16 for 64 bit integers. Standard Fortran does not let you directly use hexadecimal representations for real constants.