*DECK DOORFB3
      SUBROUTINE DOORFB3(IPSYS,IPTRK,IMPX,NBMIX,NREG,NUN,KEYFLX,SUNKNO,
     1 FUNKNO)
*
*-----------------------------------------------------------------------
*
*Purpose:
* double heterogeneity treatment (part 3). One-group version.
*
*Copyright:
* Copyright (C) 2007 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version
*
*Author(s): A. Hebert
*
*Parameters: input
* IPSYS   pointer to the assembly LCM object (L_PIJ signature). IPSYS is
*         a list of directories.
* NPSYS   index array pointing to the IPSYS list component corresponding
*         to each energy group. Set to zero if a group is not to be
*         processed. Usually, NPSYS(I)=I.
* IPTRK   pointer to the tracking (L_TRACK signature).
* IMPX    print flag (equal to zero for no print).
* NBMIX   number of composite mixtures in the domain. Equal to the
*         number of mixtures in the internal library.
* NREG    number of volumes in the composite geometry.
* NUN     total number of unknowns in vector SUNKNO.
* KEYFLX  index of flux components in unknown vector.
* SUNKNO  equivalent macro-sources.
* FUNKNO  equivalent macro-fluxes.
*
*Parameters: output
* FUNKNO  composite fluxes.
*
*-----------------------------------------------------------------------
*
      USE GANLIB
*----
*  SUBROUTINE ARGUMENTS
*----
      TYPE(C_PTR) IPSYS,IPTRK
      INTEGER IMPX,NBMIX,NREG,NUN,KEYFLX(NREG)
      REAL SUNKNO(NUN)
*----
*  LOCAL VARIABLES
*----
      PARAMETER(IOUT=6)
      INTEGER IPAR(8)
*----
*  ALLOCATABLE ARRAYS
*----
      TYPE(C_PTR) NS_PTR,IBI_PTR,FRACT_PTR,VOLK_PTR,IDIL_PTR,MIXGR_PTR,
     > NCO_PTR,RRRR_PTR,QKOLD_PTR,QKDEL_PTR,PKL_PTR,COEF_PTR
      INTEGER, DIMENSION(:), POINTER :: NS,IBI,IDIL,MIXGR,NCO
      REAL, DIMENSION(:), POINTER :: FRACT,VOLK,RRRR,QKOLD,QKDEL,PKL
      REAL, DIMENSION(:), ALLOCATABLE :: SGAR,SGAS
      DOUBLE PRECISION, DIMENSION(:), POINTER :: COEF
*----
*  RECOVER DOUBLE HETEROGENEITY DATA
*----
      IF(IMPX.GT.50) THEN
         WRITE(6,'(/38H DOORFB3: DOUBLE HETEROGENEITY OPTION.)')
      ENDIF
      CALL LCMSIX(IPTRK,'BIHET',1)
      CALL LCMGET(IPTRK,'PARAM',IPAR)
      IR1=IPAR(1)
      IR2=IPAR(2)
      NREG2=IPAR(3)
      NG=IPAR(4)
      NSMAX=IPAR(5)
      IBIHET=IPAR(6)
      IF(IR1.NE.NBMIX) CALL XABORT('DOORFB3: INVALID DATA IN TRACKING.')
      IF(NREG2.GT.NUN) CALL XABORT('DOORFB3: NUN OVERFLOW.')
      NMILG=IR2-IR1
      CALL LCMGPD(IPTRK,'NS',NS_PTR)
      CALL LCMGPD(IPTRK,'IBI',IBI_PTR)
      CALL LCMGPD(IPTRK,'FRACT',FRACT_PTR)
      CALL LCMGPD(IPTRK,'VOLK',VOLK_PTR)
      CALL LCMGPD(IPTRK,'IDIL',IDIL_PTR)
      CALL LCMGPD(IPTRK,'MIXGR',MIXGR_PTR)
      CALL LCMSIX(IPTRK,' ',2)
*
      CALL C_F_POINTER(NS_PTR,NS,(/ NG /))
      CALL C_F_POINTER(IBI_PTR,IBI,(/ NREG2 /))
      CALL C_F_POINTER(FRACT_PTR,FRACT,(/ NG*(NBMIX+NMILG) /))
      CALL C_F_POINTER(VOLK_PTR,VOLK,(/ NG*NSMAX /))
      CALL C_F_POINTER(IDIL_PTR,IDIL,(/ NMILG /))
      CALL C_F_POINTER(MIXGR_PTR,MIXGR,(/ NSMAX*NG*NMILG /))
*----
*   RECOVER GROUP-DEPENDENT BIHET INFORMATION
*----
      CALL LCMGPD(IPSYS,'NCO',NCO_PTR)
      CALL LCMGPD(IPSYS,'RRRR',RRRR_PTR)
      CALL LCMGPD(IPSYS,'QKOLD',QKOLD_PTR)
      CALL LCMGPD(IPSYS,'QKDEL',QKDEL_PTR)
      CALL LCMGPD(IPSYS,'PKL',PKL_PTR)
      CALL LCMGPD(IPSYS,'COEF',COEF_PTR)
*
      CALL C_F_POINTER(NCO_PTR,NCO,(/ NMILG /))
      CALL C_F_POINTER(RRRR_PTR,RRRR,(/ NMILG /))
      CALL C_F_POINTER(QKOLD_PTR,QKOLD,(/ NG*NSMAX*NMILG /))
      CALL C_F_POINTER(QKDEL_PTR,QKDEL,(/ NG*NSMAX*NMILG /))
      CALL C_F_POINTER(PKL_PTR,PKL,(/ NG*NSMAX*NSMAX*NMILG /))
      CALL C_F_POINTER(COEF_PTR,COEF,(/ NMILG*(1+NG*NSMAX)**2 /))
*----
*  COMPUTE THE EQUIVALENT CROSS SECTIONS IN COMPOSITE REGIONS
*----
      CALL LCMSIX(IPSYS,'BIHET',1)
      NB1=NBMIX+1
      CALL LCMLEN(IPSYS,'DRAGON-S0XSC',ILONG,ITYLCM)
      NANI=ILONG/(NB1+NMILG)
      ALLOCATE(SGAR(NB1+NMILG),SGAS((NB1+NMILG)*NANI))
      CALL XDRSET(SGAS,(NB1+NMILG)*NANI,0.0)
      CALL LCMGET(IPSYS,'DRAGON-TXSC',SGAR)
      CALL LCMGET(IPSYS,'DRAGON-S0XSC',SGAS)
      CALL LCMSIX(IPSYS,' ',2)
*----
*   DOUBLE HETEROGENEITY TREATMENT -- PART 2
*----
      CALL XDRHT4(IBIHET,NUN,NBMIX,NMILG,NREG,NREG2,NG,NSMAX,KEYFLX,
     > NS,IDIL,MIXGR,IBI,FRACT,VOLK,SGAR,SGAS,NCO,RRRR,QKOLD,QKDEL,
     > PKL,COEF,SUNKNO,FUNKNO)
*----
*   MEMORY RELEASE
*----
      DEALLOCATE(SGAS,SGAR)
      RETURN
      END
