!+MCINT
subroutine mkcalt

    implicit none
    !-----------------------------------------------------------------------
    ! Description: Generates the caldbinit file
    !
    ! Arguments:   NONE
    !
    ! Origin:      written for the Calibration Database
    !
    ! Authors/Modification History:
    !  Ron Zellar    (1.0.0: 94 Sep 20) Original Version
    !  Ian M George  (1.1.0: 95 Dec 21) added wtinfo & friends
    !  MFC (1.2.0 20 Apr 16) f90 version
    character(7) version
    parameter (version = '1.1.0')
    !-----------------------------------------------------------------------
    !-
    ! Internals
    character(40) taskname
    integer errstat, chatter
    character(160) configdir

    ! Initialize
    taskname = 'mkcalinit'
    errstat = 0

    ! Go get the parameters
    call gmkclnt(configdir, chatter, errstat)
    if(errstat.NE.0) goto 148

    ! Start-up Main
    call wtbegm(taskname, version, chatter)

    ! Construct the caldbinit file
    call mkcint(configdir, chatter, errstat)
    if (errstat .ne. 0) goto 148

    ! Sign-Off
    148     continue
    call wtendm(taskname, version, errstat, chatter)

    return
end
! -----------------------------------------------------------------
!+GMKCLNT
subroutine gmkclnt(configdir, chatter, status)

    implicit none
    character*(*) configdir
    integer status, chatter

    ! Description:
    !  Gets the parameters for the task mkcalinit
    !
    ! Arguments:
    !   CONFIGDIR        r : Path to the caldb.config file
    !   CHATTER          r : Chattiness Flag
    !   STATUS           r : Error flag (zero = OK)
    !
    ! Origin:
    !   Written for the Calibration Database by Ron Zellar (as gpmcb), then
    ! seriously hacked to include all the latest gizzmos by Ian M George
    !
    ! Authors/Modification History:
    !  Ron Zellar    (1.1.0: 94 Sep 28) -- Original Version (of gpmcb)
    !  Ian M George  (1.1.1: 95 Dec 29) converted for the mkcalinit task
    character(7) version
    parameter (version = '1.1.1')
    !-----------------------------------------------------------------------
    !-
    ! Internals
    character(7) subname
    parameter (subname = 'gmkclnt')
    integer errstat
    character(160) contxt
    ! Initialize
    status = 0

    ! Get the configdir
    call uclgst('configdir', configdir, errstat)
    if(errstat.ne.0) then
        call wterrm(subname, version, &
                'Problem getting CONFIGDIR parameter')
        status = 1
        goto 999
    endif

    ! Get the chattiness flag
    call uclgsi('chatter', chatter, errstat)
    if(errstat.NE.0) then
        call wtwarm(subname, version, 1, 1, &
                'Problem getting CHATTER parameter')
        errstat = 0
        call wtinfo(1, 1, 1, 'setting CHATTER = 10')
        chatter = 10
    endif

    ! Give user info if requested
    contxt = ' using ' // subname // ' ' // version
    call wtinfo(chatter, 20, 1, contxt)

    999     if(status.ne.0) then
        call wterrm(subname, version, ' unable to continue')
    endif

    return
end

! -------------------------------------------------------------
