Fortran: printing the Printing the Hex contents of a character variable

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
1 reply · 6K views
physicsposter
Messages
1
Reaction score
0
Given a character variable

character*10 name

write (6,111) name

111 format (?)

what do I put in the format statement to print the hexadecimal contents of name?
 
Physics news on Phys.org
Hhhmmm...I have never had such need. I don't think there is such a shortcut in Fortran as there is in C; so, I am afraid you are going to have to write your own little function to do so.

First, you will have to convert the character to decimal; you can use ichar(letter) for that. But then, you need your own little recursive function to produce hex. Here is a simple explanation of how to go about it for any decimal.