gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1565 Posts in 517 Topics by 752 Members - Latest Member: zaikunzhang September 25, 2021, 04:53:23 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Macintosh  |  Bitwise AND problem
gfx
gfxgfx
 

Author Topic: Bitwise AND problem  (Read 2777 times)

jonnygto

  • Newbie
  • *
  • Posts: 16
Bitwise AND problem
« on: August 03, 2012, 07:26:13 PM »
   Program AND_TEST
   IMPLICIT NONE
C   --------------------------------
   INTEGER ERRCODE
   INTEGER CSR

   CSR=O'777'   
   ERRCODE = CSR.AND.O'003'
C   ERRCODE = IAND (CSR,O'003')   

   WRITE (*,'("ERRCODE=",O4)') ERRCODE
    END

The above f77 program gives the compile error (referring to CSR.AND.O'003'): "The arguments to this bitwise intrinsic or operator must be the same size".
(Same message with either of the two "ERRCODE=" statements)

According to my reading of the F77 Reference Manual, the operands should already be the same size:
"An integer constant requires one numeric storage unit (four bytes)." (pg 16)
"INTEGER*4 is the default for INTEGER" (pg 38).
I also have INTEGER*4 selected as the Default Integer Size in Project Options|FORTRAN|Compatibility.
But the only way I can get rid of the error message is to change "INTEGER CSR" to "INTEGER*8 CSR"

Is this a documentation error or am I missing something?
If I want to do similar bitwise operations on other integer sizes, am I restricted to using a variable as the other operand?

(The compile command from absoft tools is :
f95 -c -nowdir -O2 -f77_compat -m32 -march=host -o "./Release/TEST_AND.o" "../xix_sources/_TESTPGMS/TEST_AND.f"")

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: Bitwise AND problem
« Reply #1 on: August 08, 2012, 09:11:15 AM »
BOZ constants are always 64-bits as there is no way to apply a KIND to them. Here are two work-arounds:

      ERRCODE = CSR.AND.int(O'003',4)
      ERRCODE = IAND (CSR,int(O'003',4))

jonnygto

  • Newbie
  • *
  • Posts: 16
Re: Bitwise AND problem
« Reply #2 on: August 15, 2012, 07:29:22 PM »
Thanks for the information.  The example was from legacy Vax Fortran 77 code, apparently older than this restriction.

Absoft User Forum  |  Support  |  Macintosh  |  Bitwise AND problem
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!