      SUBROUTINE D2PHEL( IPHEL,  IPDAT,  STAVEC,    FC1,    FC2,    NGP,
     >                     FC3,    FC4,     XSC, IPRINT                )
*
*-----------------------------------------------------------------------
*
*Purpose:
* store the header of HELIOS.dra file - (independant data compared with
* branching calculation) at phase 1
* WARNING: 04/2014 : the format of this file respect the HELIOS format
* (it cannot be changed)
* The information is recovered from the input file (.x2m) and stored in
* the INFO DATA block. The user can change any values in the input file
*
*Author(s): J. Taforeau
*
*parameters: input
* IPHEL   file unit of HELIOS like file
* IPDAT   adress of info data block
* STAVEC  various parameters associated with the IPDAT structure
* NGP     number of energy groups
* FC1     FILE_CONT_1 recovered from D2P: input
* FC2     FILE_CONT_2 recovered from D2P: input
* FC3     FILE_CONT_3 recovered from D2P: input
* FC4     FILE_CONT_4 recovered from D2P: input
* XSC     XS_CONT     recovered from D2P: input
* IPRINT  control the printing on screen
*
*-----------------------------------------------------------------------
*
      USE GANLIB
*----
*  SUBROUTINE ARGUMENTS
*----
      TYPE(C_PTR) IPDAT
      INTEGER IPHEL
      INTEGER STAVEC(40)
      INTEGER NGP
      ! FILE_CONT DATA BLOC ( CF D2P: DOCUMENTATION)
      REAL FC1(5)
      REAL FC2(NGP)
      REAL FC3(7)
      REAL FC4(3)
      REAL XSC(3)
*----
*  LOCAL VARIABLES
*----
      INTEGER NBU
      REAL FILE_CONT_1(2)
      REAL,DIMENSION(8) :: FILE_CONT_2 = 0

      NBU=STAVEC(4)
      IF (STAVEC(1).NE. NGP) THEN
         WRITE(6,*) "@D2PHEL: ERROR IN FILE_CONT_2"
         WRITE(6,*) "THE NUMBER OF ENERGY GROUPS IN SAP (",
     1   STAVEC(1),") IS DIFFERENT FROM D2P INPUT (",NGP,")."
         CALL XABORT('')
      ENDIF

      FILE_CONT_2(1:NGP)=FC2(1:NGP)

      FILE_CONT_1(1)=FC1(4)
      FILE_CONT_1(2)=FC1(5)

      ! RECOVER INFORMATION FROM INFO/HELIOS_HEAD DATA BLOCK

      CALL LCMSIX(IPDAT,' ',0)
      CALL LCMSIX(IPDAT,'HELIOS_HEAD',1)
      CALL LCMPUT(IPDAT,'FILE_CONT_1',2,2,FILE_CONT_1)
      CALL LCMPUT(IPDAT,'FILE_CONT_2',8,2,FILE_CONT_2)
      CALL LCMPUT(IPDAT,'FILE_CONT_3',7,2,FC3)
      CALL LCMPUT(IPDAT,'FILE_CONT_4',3,2,FC4)
      CALL LCMPUT(IPDAT,'XS_CONT',3,2,XSC)

      ! WRITE FILE_CONT DATA in HELIOS.dra file
      IF(IPRINT > 0) WRITE(6,*) "STEP 1 : EDIT THE HEADER "
      CALL SET_INFO(IPHEL)
      IF(IPRINT > 0) WRITE(6,*) "STEP 2 : EDIT THE CONT1 BLOCK "
      CALL SET_CONT1(IPHEL,STAVEC,FILE_CONT_1,IPRINT)
      IF(IPRINT > 0) WRITE(6,*) "STEP 3 : EDIT THE CONT2 BLOCK "
      CALL SET_CONT2(IPHEL,FILE_CONT_2,NGP,IPRINT)
      IF(IPRINT > 0) WRITE(6,*) "STEP 4 : EDIT THE CONT3 BLOCK "
      CALL SET_CONT3(IPHEL,FC3,IPRINT)
      IF(IPRINT > 0) WRITE(6,*) "STEP 5 : EDIT THE CONT4 BLOCK "
      CALL SET_CONT4(IPHEL,FC4,IPRINT)

      ! MOVE TO GENPMAXS_INP DIRECTORY
      CALL LCMSIX(IPDAT,' ',0)
      CALL LCMSIX(IPDAT,'GENPMAXS_INP',1)
      END

      SUBROUTINE SET_CONT1(IPHEL,STAVEC,FILE_CONT_1,IPRINT)
      INTEGER STAVEC(40)
      REAL FILE_CONT_1(2)

      WRITE(IPHEL,*) 'List name       : PMAX_FILE_DATA'
      WRITE(IPHEL,*) 'Labels Array    : KINF'
      WRITE(IPHEL,*) 'List Title(s)  1) ==========================='
      WRITE(IPHEL,*) '               2) %FILE_CONT 1'
      WRITE(IPHEL,*) '               3) ==========================='
      WRITE(IPHEL,*) '               4) Meaning : NGROUP, NCOLS, NR'
     1 //'OWS, PART,'
      WRITE(IPHEL,*) '                  HM Density, Bypass Density '
      CALL SET_RIEGO(IPHEL)
      WRITE(IPHEL,120) 'NGROUP','NCOLS','NROWS','PART',
     1 'DenHM','DenByp'
      WRITE(IPHEL,125) 'Label E','.-.-E-.-.','.-.-E-.-.','.-.-E-.-.',
     1 '.-.-E-.-.','1-.-E-.-.','.-.-E-.-.'
      WRITE(IPHEL,130) '   1 tHST  1(sHST ):    0',STAVEC(1),
     1 STAVEC(8),STAVEC(9), STAVEC(10),
     2 FILE_CONT_1(1),FILE_CONT_1(2)
      WRITE(IPHEL,'()')
      IF(IPRINT > 1)  THEN
        WRITE(6,*)
        WRITE(6,*) "CONTENT : NGROUP, NCOLS, NROWS, PART,",
     1  " HM Density, Bypass Density "
        WRITE(6,*) "VALUES  :",STAVEC(1),STAVEC(8:10),FILE_CONT_1
        WRITE(6,*)
      ENDIF
  120 FORMAT(30X,A,9X,A,9X,A,10X,A,9X,A,8X,A)
  125 FORMAT(6X,A,17X,A,5X,A,5X,A,5X,A,5X,A,5X,A)
  130 FORMAT(A,12X,I2,12X,I2,12X,I2,12X,I2,7X,F7.5,7X,F7.5)
      END

      SUBROUTINE  SET_CONT2(IPHEL,FILE_CONT_2,NGROUP,IPRINT)
      INTEGER NGROUP
      REAL FILE_CONT_2(8)

      WRITE(IPHEL,*) 'List name       : PMAX_FILE_DATA'
      WRITE(IPHEL,*) 'Labels Array    : KINF'
      WRITE(IPHEL,*) 'List Title(s) 1) ==========================='
      WRITE(IPHEL,*) '              2) %FILE_CONT 2'
      WRITE(IPHEL,*) '              3) ==========================='
      WRITE(IPHEL,*) '              4)Meaning : Lower Energy of Neu'
     1 //'tron Groups'
      CALL SET_RIEGO(IPHEL)

      IF(NGROUP .EQ. 2) THEN
        WRITE(IPHEL,220) 'EMIN','EMIN'
        WRITE(IPHEL,225) 'Label E','.-.-E-1-.','.-.-E-2-.'
        WRITE(IPHEL,230) '   1 tHST  1(sHST ):    0',FILE_CONT_2(1),
     1 FILE_CONT_2(2)
      ELSE
        CALL XABORT ("@D2PHEL: NUMBER OF ENERGY GROUPS MUST BE 2")
      ENDIF

      IF(IPRINT > 1)  THEN
        WRITE(6,*)
        WRITE(6,*) "CONTENT : Lower Energy of Neutron Groups"
        WRITE(6,*) "VALUES  :",FILE_CONT_2 (1:NGROUP)
        WRITE(6,*)
      ENDIF

  220 FORMAT(32X,A,10X,A)
  225 FORMAT(6X,A,17X,A,5X,A)
  230 FORMAT(A,3X,ES11.5E2,3X,ES11.5E2)
      END

      SUBROUTINE  SET_CONT3(IPHEL,FILE_CONT_3,IPRINT)
      REAL FILE_CONT_3(7)

      WRITE(IPHEL,'()')
      WRITE(IPHEL,*) 'List name       : PMAX_FILE_DATA'
      WRITE(IPHEL,*) 'Labels Array    : KINF'
      WRITE(IPHEL,*) 'List Title(s)  1) ==========================='
      WRITE(IPHEL,*) '               2) %FILE_CONT 3'
      WRITE(IPHEL,*) '               3) ==========================='
      WRITE(IPHEL,*) '               4)Meaning : Regions Volume'

      CALL SET_RIEGO(IPHEL)

      WRITE(IPHEL,320) 'VCool','VWatR','VModr','VCnRd','VFuel',
     1 'VClad','VChan'
      WRITE(IPHEL,310) 'Label E','1-.-E-.-.','.-.-E-.-.','1-.-E-.-.',
     1 '1-.-E-.-.','1-.-E-.-.','1-.-E-.-.','1-.-E-.-.'
      WRITE(IPHEL,390) '   1 tHST  1(sHST ):    0',FILE_CONT_3(1),
     1  FILE_CONT_3(2),FILE_CONT_3(3),FILE_CONT_3(4),FILE_CONT_3(5),
     2  FILE_CONT_3(6),FILE_CONT_3(7)


      IF(IPRINT > 1)  THEN
        WRITE(6,*)
        WRITE(6,*) "CONTENT : VCool, VWatR, VModr, VCnRd, VFuel,",
     1  " VClad, VChan"
        WRITE(6,*) "VALUES  :",FILE_CONT_3
        WRITE(6,*)
      ENDIF

  310 FORMAT(6X,A,10X,A,5X,A,5X,A,5X,A,5X,A,5X,A,5X,A)
  320 FORMAT(31X,A,2X,A,9X,A,9X,A,9X,A,9X,A,9X,A,9X,A)
  390 FORMAT(A,3X,ES11.5E2,3X,ES11.5E2,3X,ES11.5E2,3X,ES11.5E2,
     1 3X,ES11.5E2,3X,ES11.5E2,3X,ES11.5E2,3X,ES11.5E2)
      END

      SUBROUTINE  SET_CONT4(IPHEL,FILE_CONT_4,IPRINT)
      REAL FILE_CONT_4(3)

      WRITE(IPHEL,'()')
      WRITE(IPHEL,*) 'List name       : PMAX_FILE_DATA'
      WRITE(IPHEL,*) 'Labels Array    : KINF'
      WRITE(IPHEL,*) 'List Title(s)  1) ==========================='
      WRITE(IPHEL,*) '               2) %FILE_CONT 4'
      WRITE(IPHEL,*) '               3) ==========================='
      WRITE(IPHEL,*) '               4) Cell Pitch and X,Y Pos of F'
     1 //'irst Cell'

      CALL SET_RIEGO(IPHEL)

      WRITE(IPHEL,320) 'PITCH','XBE','YBE'
      WRITE(IPHEL,410) 'Label E','.-.-E-.-.','.-.-E-.-.','.-.-E-.-.'
      WRITE(IPHEL,390) '   1 tHST  1(sHST ):    0',FILE_CONT_4(1),
     1  FILE_CONT_4(2),FILE_CONT_4(3)

      IF(IPRINT > 1)  THEN
        WRITE(6,*)
        WRITE(6,*) "CONTENT : PITCH ,XBE , YBE"
        WRITE(6,*) "VALUES  :", FILE_CONT_4
        WRITE(6,*)
      ENDIF

  320 FORMAT(24X,A,11X,A,11X,A)
  390 FORMAT(A,3X,ES11.5E2,3X,ES11.5E2,3X,ES11.5E2)
  410 FORMAT(6X,A,10X,A,5X,A,5X,A)
      END

      SUBROUTINE SET_INFO(IPHEL)
      WRITE(IPHEL,*) '<<< DRAGON >>> Version: 5.0.0 <<< DRAGON >>>'
      WRITE(IPHEL,*) 'Pre-processing for PMAXS Generation'
      DO I=1, 18
        WRITE(IPHEL,*) '*'
      ENDDO
      WRITE(IPHEL,*) '<<< DRAGON >>> Version: 5.0.0 <<< DRAGON >>>'
      WRITE(IPHEL,*) 'DRAGON CALCULATION BY J.TAFOREAU'

      WRITE(IPHEL,*) 'HELIOS Cases Used:'
      WRITE(IPHEL,'()')
      WRITE(IPHEL,*) '        1) IMP-operator name : kkk'
      WRITE(IPHEL,*) '        DRAGON case       : kkk'
      WRITE(IPHEL,*) '        Title(s)      1   : kkk'
      WRITE(IPHEL,'()')
      END

      SUBROUTINE  SET_RIEGO(IPDRA)
      WRITE(IPDRA,'()')
      WRITE(IPDRA,*) '(R) Area/Face names     :   unlabeled'
      WRITE(IPDRA,*) '(I) Isotope Identifiers :   unlabeled'
      WRITE(IPDRA,*) '(E) Path (STATE) idents : *            '
      WRITE(IPDRA,*) '(G) Group name          :   unlabeled'
      WRITE(IPDRA,*) '(O) Originating Group   :   unlabeled'
      WRITE(IPDRA,'()')
      END
