    module assim_vars
!
!  SYNOPSIS
!    use assim_vars
!
!  DESCRIPTION
!  ASSIM_VARS contains basic data assimilation variables. 
!  They are set by set_varname routines contained herein.
!  The array ERRCODES is the only "global" variable in the code, but it
!  looks enough like a function call that I've decided to leave it public
!  (though when F2003 compilers become widely available, it can be made
!  protected).
!
!  REQUIRED PACKAGES
!
!   precision, ferror, resolution - in support directory
!
!  ROUTINES IMPLEMENTED
!
!   subroutine set_ensemble_size(isol)
!   pure integer function ensemble_size()
!   subroutine set_verbosity(verb)
!   pure integer function verbosity()
!
!  AUTHOR
!   Eric Kostelich, kostelich@asu.edu, 480-965-5006.
!
    use precision
    use ferror
    implicit none
!
!  VERBLEV - 0:silent, 1:basics, 2:some status, 3:chatty
!  See set_verbosity and verbosity().
!
    integer,parameter::VERB_SILENT=0
    integer,parameter::VERB_TERSE=1
    integer,parameter::VERB_STATUS=2
    integer,parameter::VERB_CHATTY=3
    integer,save,private::verblev=VERB_TERSE
!
!  Number of Assimilated VARiables
!
    integer,parameter::NAVARS=4
!
! NSOL - number of ensemble solutions
!
    integer,save,private::nsol=40
    contains
!----------------------------
    subroutine set_ensemble_size(isol)
!  SET_ENSEMBLE_SIZE - set nsol.  Brian's method as implemented here assumes
!  that the local rank is nsol-1.
!
    integer,intent(in)::isol
    character(80)::Msg
!
    if(isol.lt.1) then
       write(msg,100) isol
100    format('set_ensemble_size: bad ensemble size: ',i0)
       call fabort(trim(msg))
    endif
    nsol=isol
    return
    end subroutine set_ensemble_size
!----------------------------
    pure integer function ensemble_size()
!  ENSEMBLE_SIZE - return the number of ensemble solutions.
! 
    ensemble_size=nsol
    return
    end function ensemble_size
!----------------------------
    subroutine set_verbosity(verb)
!  SET_VERBOSITY - we don't check the value, but the range of meaningful
!  ones is listed above.
!
    integer,intent(in)::verb
!
    if(verb.lt.VERB_SILENT) then
       verblev=VERB_SILENT
    else if(verb.gt.VERB_CHATTY) then
       verblev=VERB_CHATTY
    else
       verblev=verb
    endif
    return
    end subroutine set_verbosity
!----------------------------
    pure integer function verbosity()
!  VERBOSITY - return the verbosity level.
!
    verbosity=verblev
    return
    end function verbosity
!----------------------------
    end module assim_vars
