anchor.diff:        CALL MEMMAN(KLISCR,NTOOB,   'ADDL  ',1,'KLISCR ')
         CALL MEMMAN(KLH1D ,NTOOB,   'ADDL  ',2,'KLH1D ')
   *. Space for blocks of strings
  -      MAXA = IMNMX(WORK(KNSTSO(IATP)),NSMST*NOCTPA,2)
  -      MAXB = IMNMX(WORK(KNSTSO(IBTP)),NSMST*NOCTPB,2)
  +      MAXA = IMNMX(int_mb(KNSTSO(IATP)),NSMST*NOCTPA,2)
  +      MAXB = IMNMX(int_mb(KNSTSO(IBTP)),NSMST*NOCTPB,2)
         CALL MEMMAN(KLRJKA,MAXA,'ADDL  ',2,'KLRJKA')
         CALL MEMMAN(KLASTR,MAXA*NAEL,'ADDL  ',1,'KLASTR')
         CALL MEMMAN(KLBSTR,MAXB*NBEL,'ADDL  ',1,'KLBSTR')
  
positive.code: *
        RETURN
        END
        FUNCTION IFRMR(WORK,IROFF,IELMNT)
  *
  * An integer array is stored in real array WORK,
  * starting from WORK(IROFF). Obtain element
  * IELMNT of this array
  *
        INTEGER WORK(*)
  *
        INCLUDE 'irat.inc'
  *. offset when work is integer array
        IIOFF = 1 + IRAT * (IROFF-1)
        IFRMR = WORK(IIOFF-1+IELMNT)
  *
        RETURN
        END
  
negative.code: **. Diagonal of one-body integrals and coulomb and exchange integrals
  *   One-body integrals stored in KINT1 are used
  *
        CALL GT1DIA(dbl_mb(KLH1D))
        CALL GTJK(dbl_mb(KLJ),dbl_mb(KLK),NTOOB,dbl_mb(KLSCR2),IREOTS)
  *
        IF( LUDIA .GT. 0 ) CALL REWINO(LUDIA)
        IF(IEXP_PH.EQ.0) THEN
  *. Good old version where PH is not used for diagonal
          CALL GASDIAS(NAEL,int_mb(KLASTR),NBEL,int_mb(KLBSTR),
       &       NACOB,DIAG,NSMST,dbl_mb(KLH1D),
       &       dbl_mb(KLXA),dbl_mb(KLXB),dbl_mb(KLSCR),dbl_mb(KLJ),
       &       dbl_mb(KLK),int_mb(KNSTSO(IATP)),int_mb(KNSTSO(IBTP)),
       &       LUDIA,ECORE,PLSIGN,PSSIGN,IPRDIA,NTOOB,ICISTR,
       &       dbl_mb(KLRJKA),I12,IBLTP,NBLOCK,IBLKFO)
        ELSE
  *. use also ph in diagonal construction
          CALL GASDIAS_PH(NAEL,int_mb(KLASTR),NBEL,int_mb(KLBSTR),
       &       NACOB,DIAG,NSMST,dbl_mb(KLH1D),
       &       dbl_mb(KLXA),dbl_mb(KLXB),dbl_mb(KLSCR),dbl_mb(KLJ),
       &       dbl_mb(KLK),int_mb(KNSTSO(IATP)),int_mb(KNSTSO(IBTP)),
       &       LUDIA,ECORE,PLSIGN,PSSIGN,IPRDIA,NTOOB,ICISTR,
       &       dbl_mb(KLRJKA),I12,IBLTP,NBLOCK,IBLKFO,IPHGAS,ITPFTO,
       &       int_mb(KLPHSTR),NPHELFSPGP,IOCTPA,IOCTPB,NINOB,
       &       int_mb(KLISCR))
        END IF
  
  *.Flush local memory
  