“DATA INT / 'STRING' /” problem when compiling with gfortran

后端 未结 1 1346
野性不改
野性不改 2021-01-15 00:23

I have some old (~1995) legacy fortran code which is compiled with g77 compiler and fails on gfortran. The problem is in following lines (incompatible types conversion, char

相关标签:
1条回答
  • 2021-01-15 00:54

    Wow - and this was written in 1995? Eep.

    As far as I can tell, this is basically Hollerith encoding, encoding character constants in integers (from back before there was a CHARACTER data type). As a quick test, setting one of those integers equal to 4HKYAN seems to give the same answer.

    The reason for this here just seems to be to set a flag equal to some constant to test against afterwards. If you want to do the same thing, the modern way to do this is ckyan = transfer('KYAN',ckyan), which takes the bit representation of the character string, converts it to the format of the variable passed as it's second parameter, and returns it.

    But here, it looks like the value of the named constant isn't critical as long as the values IWVTX can take on for the different cases are distinct...

    By the way, you may already know about this, but the Fortran Wiki has a very handy page on Modernizing Old Fortran; it doens't cover everything (like this one, which I hadn't seen in quite this form before), but it has help for translating a lot of old, non-standard contstructs into modern Fortran.

    0 讨论(0)
提交回复
热议问题