*DECK DONDRV
      INTEGER FUNCTION DONDRV(HMODUL,NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
*
*-----------------------------------------------------------------------
*
*Purpose:
* module-dependent driver for DONJON.
*
*Copyright:
* Copyright (C) 2007 Ecole Polytechnique de Montreal
*
*Author(s): D. Sekki
*
*Parameters: input/output
* HMODUL  name of module to process.
* NENTRY  number of LCM objects or files used by the operator.
* HENTRY  name of each LCM object or file.
* IENTRY  type of each LCM object or file:
*         =1 LCM memory object; =2 XSM file; =3 sequential binary file;
*         =4 sequential ascii file.
* JENTRY  access of each LCM object or file:
*         =0 the LCM object or file is created;
*         =1 the LCM object or file is open for modifications;
*         =2 the LCM object or file is open in read-only mode.
* KENTRY  LCM object address or file unit number.
*
*Parameters: output
* DONDRV  completion flag: =0 module exists; =1 does not exists.
*
*-----------------------------------------------------------------------
*
      USE GANLIB
*----
*  SUBROUTINE ARGUMENTS
*----
      CHARACTER HMODUL*(*),HENTRY(NENTRY)*12
      INTEGER IENTRY(NENTRY),JENTRY(NENTRY)
      TYPE(C_PTR) KENTRY(NENTRY)
*----
*  LOCAL VARIABLES
*----
      PARAMETER(IOUT=6)
      REAL TBEG,TEND
      CHARACTER DSR*72,NAM*72,COD*12
      LOGICAL :: DONMOD
*
      DONDRV=0
      DONMOD=.TRUE.
      CALL KDRCPU(TBEG)
*----
*  CALL MODULE AND PRINT CREDITS
*----
      IF(HMODUL.EQ.'NCR:')THEN
        COD='DRAGON'
        DSR='ACCESS MULTI-PARAMETER REACTOR COMPOSITION DATABASE'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL NCR(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'CRE:')THEN
        COD='DONJON'
        DSR='ACCESS MONO-PARAMETER REACTOR COMPOSITION DATABASE'
        NAM='A. HEBERT, D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL CRE(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'USPLIT:')THEN
        COD='DONJON'
        DSR='LINK MATERIAL INDEX AND REACTOR GEOMETRY'
        NAM='J. KOCLAS, D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL USPLIT(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'MACINI:')THEN
        COD='DONJON'
        DSR='EXPAND MACROLIB OVER THE REACTOR GEOMETRY'
        NAM='J. KOCLAS, E. VARIN, D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL MACINI(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'RESINI:')THEN
        COD='DONJON'
        DSR='FUEL LATTICE GEOMETRY AND PROPERTIES'
        NAM='E. VARIN, D. SEKKI, R. CHAMBON'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL RESINI(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'FLPOW:')THEN
        COD='DONJON'
        DSR='COMPUTE FLUXES AND POWERS'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL FLPOW(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'DEVINI:')THEN
        COD='DONJON'
        DSR='MODELING OF ROD-DEVICES IN THE REACTOR CORE'
        NAM='D. SEKKI '
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL DEVINI(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'DSET:')THEN
        COD='DONJON'
        DSR='UPDATE DEVICES PARAMETERS'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL DSET(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'MOVDEV:')THEN
        COD='DONJON'
        DSR='MOVE DEVICES IN THE REACTOR CORE'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL MOVDEV(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'NEWMAC:')THEN
        COD='DONJON'
        DSR='UPDATE MACROLIB FOR DEVICES PROPERTIES'
        NAM='J. KOCLAS, D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL NEWMAC(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'DETINI:')THEN
        COD='DONJON'
        DSR='CONSTRUCT 2D AND 3D DETECTORS IN THE CORE'
        NAM='J. KOCLAS, E. VARIN, M. GUYOT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL DETINI(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'DETECT:')THEN
        COD='DONJON'
        DSR='COMPUTE DETECTORS READING'
        NAM='J. KOCLAS, M. GUYOT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL DETECT(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'TAVG:')THEN
        COD='DONJON'
        DSR='TIME-AVERAGE CALCULATION'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL TAVG(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'TINST:')THEN
        COD='DONJON'
        DSR='INSTANTANEOUS CALCULATION'
        NAM='B. TOUEG'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL TINST(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'CVR:')THEN
        COD='DONJON'
        DSR='UPDATE DATA FOR VOIDING SIMULATION'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL CVR(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'LZC:')THEN
        COD='DONJON'
        DSR='MODELING OF LIQUID ZONE CONTROLLERS'
        NAM='D. SEKKI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL LZC(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'HST:')THEN
        COD='DONJON'
        DSR='HISTORY BASED CALCULATION SUPPORT'
        NAM='G. MARLEAU AND E. VARIN'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL HST(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'XENON:')THEN
        COD='DONJON'
        DSR='COMPUTE THE XENON DISTRIBUTION'
        NAM='M. GUYOT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL XENON(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSEIF(HMODUL.EQ.'AFM:')THEN
        COD='DONJON'
        DSR='MULTI-PARAMETER FEEDBACK MODEL'
        NAM='T. SISSAOUI'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL AFM(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'NCR:') THEN
        COD='DONJON'
        DSR='ACCESS MULTI-PARAMETER REACTOR COMPOSITION DATABASE'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL NCR(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'SCR:') THEN
        COD='DONJON'
        DSR='ACCESS MULTI-PARAMETER REACTOR SAPHYB DATABASE'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL SCR(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'T16CPO:') THEN
        COD='DONJON'
        DSR='INTERFACE FOR WIMS-AECL'
        NAM='G. MARLEAU'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL T16CPO(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'THM:') THEN
        COD='DONJON'
        DSR='SIMPLIFIED THERMAL-HYDRAULICS CALCULATION'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL THM(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'DLEAK:') THEN
        COD='DONJON'
        DSR='COMPUTE A DELTA MACROLIB RELATIVE TO LEAKAGE INFORMATION'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL DLEAK(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'GRAD:') THEN
        COD='DONJON'
        DSR='COMPUTE GRADIENTS OF SYSTEM CHARACTERISTICS'
        NAM='A. HEBERT'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL GRAD(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'PLQ:') THEN
        COD='DONJON'
        DSR='LINEAR OPTIMIZATION PROBLEM WITH A QUADRATIC CONSTRAINT'
        NAM='A. HEBERT AND R. CHAMBON'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL PLQ(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'SIM:') THEN
        COD='DONJON'
        DSR='PWR FUELLING SIMULATOR'
        NAM='A. HEBERT AND V. SALINO'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL SIM(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'NAP:') THEN
        COD='DONJON'
        DSR='PIN POWER RECONSTRUCTION AND ENRICHED L_COMPO CONSTRUCTION'
        NAM='R. CHAMBON'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL NAP(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE IF(HMODUL.EQ.'D2P:') THEN
        COD='DONJON'
        DSR='PMAXS INTERFACE FILE GENERATION'
        NAM='J. TAFOREAU'
        WRITE(IOUT,1000)HMODUL,COD,DSR,NAM
        CALL D2P(NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ELSE
        DONMOD=.FALSE.
        DONDRV=KDRDRV(HMODUL,NENTRY,HENTRY,IENTRY,JENTRY,KENTRY)
      ENDIF
      IF(DONMOD)THEN
        WRITE(IOUT,1001)HMODUL
        CALL KDRCPU(TEND)
        WRITE(IOUT,1002) HMODUL,(TEND-TBEG)
      ENDIF
      RETURN
*
 1000 FORMAT(/1X,15('~')/
     2 1X,'@BEGIN MODULE -> ',A12/
     3 1X,'@FROM CODE    -> ',A12/
     4 1X,'@DESCRIPTION  -> ',A72/
     5 1X,'@CREDITS      -> ',A72/
     6 1X,'@COPYRIGHTS   -> ECOLE POLYTECHNIQUE DE MONTREAL'/
     7 18X,'GNU LESSER GENERAL PUBLIC LICENSE'/1X,15('~')/)
 1001 FORMAT(1X,'@END MODULE -> ',A12)
 1002 FORMAT('-->>TIME SPENT IN MODULE ',A12,': ',F10.3)
      END
