!= 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