REAL*8 in CWN


PAW version:2.09/18
Description
CWNs containing REAL*8 are not portable from small endian machines to big endian one.

The following test program shows the problem:

      Program PR8
*
      Parameter (Nhmax = 100000)
      Common /Pawc/ Hmemor(Nhmax)
      REAL*8 R8
      Common /P/ R8,R4
*
      Call Hlimit(Nhmax)
*
      Call Hbnt(100,'R8 Test',' ')
      Call Hbname(100,'P',R8,'R8:R*8,R4')
*
      Do N=1,9
         R8 = N*111111.
         R4 = N*111.
         Print*,' R8 = ',R8 ,' R4 = ',R4
         Call Hfnt(100)
      EndDo
*
      Call Hrput(0,'r8.hbook','N')
      Close(10)
*
      End
This program generate the file r8.hbook which you can look at with the following PAW macro:
hi/file 0 r8.hbook
nt/scan 100
If the file r8.hbook is generated on on a HPUX, IBMRT or SUN and if you look at it on DEC OSF or LINUX The macro gives:

+-------+-----------------------+--------------+
| Event |   R8                  |   R4         |
+-------+-----------------------+--------------+
|     1 |  5.3863020109007d-315 |  111.        |
|     2 |  5.3914826646872d-315 |  222.        |
|     3 |  5.3944674733548d-315 |  333.        |
|     4 |  5.3966633184738d-315 |  444.        |
|     5 |  5.3985502045818d-315 |  555.        |
|     6 |  5.3996481271413d-315 |  666.        |
|     7 |  5.4007460497008d-315 |  777.        |
|     8 |  5.4018439722603d-315 |  888.        |
|     9 |  5.4029418948198d-315 |  999.        |
+-------+-----------------------+--------------+
Which is obviously wrong. If you do the contrary: generate the file on DEC OSF or LINUX and look at it on HPUX, IBMRT or SUN you get also something wrong. All the other possibilities give a correct result.

It is a "word swapping" problem. In HBOOK code REAL*8 variables are stored in two REAL*4 without taking care of possible swapping.

This problem is fixed in the version 4.25/03 of HBOOK with the following limitations:

  • CWNs containing REAL*8 variables generated with the new HBOOK (4.25/03) on any kind of machine will be readable by the new PAW on little endian machines and all the PAW versions on the big endian machines.
  • CWNs containing REAL*8 variables generated with any HBOOK version on big endian machines will be readable by all PAW versions on big endian machines and only by the new PAW version on little endian machines.
  • CWNs containing REAL*8 variables generated with an old HBOOK version (before 4.25/03) on little endian machines will be readable ONLY by the old PAW versions on little endian machines.
Fixed in: HBOOK 4.25/03
Workaround
None


Release NotesKnown bugsFAQsContributionsTutorialReference manualDown loadMiscellaneous

Paw.Support@cern.ch