!= HstNmlInfoOutputStep 縺ｮ辟｡蜉ｹ蛹�
!= Invalidate "HstNmlInfoOutputStep"
!
! Authors::   Yasuhiro MORIKAWA
! Version::   $Id: hstnmlinfooutputstepdisable.f90,v 1.1 2009-05-11 15:15:14 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2007-2009. All rights reserved.
! License::   See COPYRIGHT[link:../../../COPYRIGHT]
!
  subroutine HstNmlInfoOutputStepDisable( gthstnml, &
    & name, err )
    !
    ! 縺薙�繧ｵ繝悶Ν繝ｼ繝√Φ繧剃ｽｿ逕ｨ縺吶ｋ縺ｨ, *name* 縺ｫ髢｢縺励※,
    ! 莉･髯阪� HstNmlInfoOutputStep 縺悟ｸｸ縺ｫ .false. 繧定ｿ斐☆繧医≧縺ｫ縺ｪ繧翫∪縺�.
    !
    ! 繝��繧ｿ蜃ｺ蜉幃俣髫斐ｒ蜃ｺ蜉帙�蛻晄悄險ｭ螳壹°繧牙､画峩縺�,
    ! 繝��繧ｿ繧貞�蜉帙☆繧九◆縺ｳ縺ｫ譎ょ綾繧呈�遉ｺ逧�↓謖�ｮ壹☆繧句�ｴ蜷医↓蛻ｩ逕ｨ縺吶ｋ縺薙→繧�
    ! 諠ｳ螳壹＠縺ｦ縺�∪縺�.
    !
    ! HstNmlInfoEndDefine 縺ｧ螳夂ｾｩ繝｢繝ｼ繝峨°繧牙�蜉帙Δ繝ｼ繝峨↓
    ! 遘ｻ陦後＠縺溷ｾ後↓蜻ｼ縺ｳ蜃ｺ縺励※縺上□縺輔＞.
    ! HstNmlInfoEndDefine 繧貞他縺ｶ蜑阪↓縺薙�繧ｵ繝悶Ν繝ｼ繝√Φ繧剃ｽｿ逕ｨ縺吶ｋ縺ｨ,
    ! 繝励Ο繧ｰ繝ｩ繝�縺ｯ繧ｨ繝ｩ繝ｼ繧堤匱逕溘＆縺帙∪縺�.
    !
    ! *name* 縺ｫ髢｢縺吶ｋ諠��ｱ縺瑚ｦ句ｽ薙◆繧峨↑縺��ｴ蜷�,
    ! 繝励Ο繧ｰ繝ｩ繝�縺ｯ繧ｨ繝ｩ繝ｼ繧堤匱逕溘＆縺帙∪縺�.
    ! *name* 縺檎ｩｺ譁�ｭ励�蝣ｴ蜷医↓繧�,
    ! 繝励Ο繧ｰ繝ｩ繝�縺ｯ繧ｨ繝ｩ繝ｼ繧堤匱逕溘＆縺帙∪縺�.
    !
    ! 縺ｪ縺�, 荳弱∴繧峨ｌ縺� *gthstnml* 縺� HstNmlInfoCreate 縺ｫ繧医▲縺ｦ蛻晄悄險ｭ螳�
    ! 縺輔ｌ縺ｦ縺�↑縺��ｴ蜷医↓繧�, 繝励Ο繧ｰ繝ｩ繝�縺ｯ繧ｨ繝ｩ繝ｼ繧堤匱逕溘＆縺帙∪縺�.
    !
    ! After this subroutine is used,
    ! "HstNmlInfoOutputStep" returns .false. already
    ! corresponding to the *name*.
    !
    ! This subroutine expected to use when
    ! interval of data output is changed from initialization of output,
    ! and time is specified explicitly whenever data is output.
    !
    ! Use after state is changed from define mode to
    ! output mode by "HstNmlInfoEndDefine".
    ! If this subroutine is used before
    ! "HstNmlInfoEndDefine" is used, error is occurred.
    !
    ! When data correspond to *name* is not found, error is occurred.
    ! When *name* is blank, error is occurred too.
    !
    ! If *gthstnml* is not initialized by "HstNmlInfoCreate" yet,
    ! error is occurred.
    !
    use gtool_history_nmlinfo_types, only: GTHST_NMLINFO, GTHST_NMLINFO_ENTRY
    use gtool_history_nmlinfo_internal, only: ListSearch
    use dc_trace, only: BeginSub, EndSub
    use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar
    use dc_types, only: DP, STRING, TOKEN, STDOUT
    use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, DC_ENOENTRY, HST_EBADNAME, HST_EINDEFINE
    implicit none
    type(GTHST_NMLINFO), intent(in):: gthstnml
    character(*), intent(in):: name
                              ! 螟画焚蜷�.
                              ! 蜈磯�ｭ縺ｮ遨ｺ逋ｽ縺ｯ辟｡隕悶＆繧後∪縺�.
                              !
                              ! Variable identifier.
                              ! Blanks at the head of the name are ignored.
    logical, intent(out), optional:: err
                              ! 萓句､門�逅�畑繝輔Λ繧ｰ.
                              ! 繝�ヵ繧ｩ繝ｫ繝医〒縺ｯ, 縺薙�謇狗ｶ壹″蜀�〒繧ｨ繝ｩ繝ｼ縺�
                              ! 逕溘§縺溷�ｴ蜷�, 繝励Ο繧ｰ繝ｩ繝�縺ｯ蠑ｷ蛻ｶ邨ゆｺ�＠縺ｾ縺�.
                              ! 蠑墓焚 *err* 縺御ｸ弱∴繧峨ｌ繧句�ｴ蜷�,
                              ! 繝励Ο繧ｰ繝ｩ繝�縺ｯ蠑ｷ蛻ｶ邨ゆｺ�○縺�, 莉｣繧上ｊ縺ｫ
                              ! *err* 縺ｫ .true. 縺御ｻ｣蜈･縺輔ｌ縺ｾ縺�.
                              !
                              ! Exception handling flag.
                              ! By default, when error occur in
                              ! this procedure, the program aborts.
                              ! If this *err* argument is given,
                              ! .true. is substituted to *err* and
                              ! the program does not abort.

    !-----------------------------------
    !  菴懈･ｭ螟画焚
    !  Work variables
    type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
    integer:: stat
    character(STRING):: cause_c
    character(*), parameter:: subname = 'HstNmlInfoOutputStepDisable'
  continue
    call BeginSub( subname )
    stat = DC_NOERR
    cause_c = ''

    !-----------------------------------------------------------------
    !  蛻晄悄險ｭ螳壹�繝√ぉ繝�け
    !  Check initialization
    !-----------------------------------------------------------------
    if ( .not. gthstnml % initialized ) then
      stat = DC_ENOTINIT
      cause_c = 'GTHST_NMLINFO'
      goto 999
    end if

    if ( trim( name ) == '' ) then
      stat = HST_EBADNAME
      cause_c = ''
      goto 999
    end if

    if ( gthstnml % define_mode ) then
      stat = HST_EINDEFINE
      cause_c = 'OutputStepDisable'
      goto 999
    end if

    !-----------------------------------------------------------------
    !  *gthstnml* 蜀�°繧�, *name* 縺ｫ髢｢縺吶ｋ history 繧呈爾譟ｻ.
    !  Search "history" correspond to *name* in *gthstnml*
    !-----------------------------------------------------------------
    hptr => gthstnml % gthstnml_list
    call ListSearch( gthstnml_list = hptr, & ! (inout)
      &              name = name )           ! (in)

    if ( .not. associated( hptr ) ) then
      stat = DC_ENOENTRY
      cause_c = adjustl( name )
      goto 999
    end if

    hptr % output_step_disable = .true.

    nullify( hptr )

    !-----------------------------------------------------------------
    !  邨ゆｺ��逅�, 萓句､門�逅�
    !  Termination and Exception handling
    !-----------------------------------------------------------------
999 continue
    call StoreError( stat, subname, err, cause_c )
    call EndSub( subname )
  end subroutine HstNmlInfoOutputStepDisable