!= gtool_historyauto  (dc_calendar ä½¿ç”¨ç‰ˆ) ã®ãƒ†ã‚¹ãƒˆãƒ—ãƒã‚°ãƒ©ãƒ  (MPI ç‰ˆ)
!= Test program of "gtool_historyauto" with MPI (using dc_calendar)
!
! Authors::   Yasuhiro MORIKAWA
! Version::   $Id: histauto2_mpi.f90,v 1.4 2010-12-28 09:29:09 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2009. All rights reserved.
! License::   See COPYRIGHT[link:../../COPYRIGHT]
!

program histauto2_mpi
  use dc_trace, only: SetDebug
  use dc_types, only: DP, STDERR
  use dc_test, only: AssertEqual
  use dc_calendar, only: DC_CAL, DC_CAL_DATE, DCCalCreate, DCCalDateCreate, &
    & DCCalConvertByUnit
  use dc_message, only: MessageNotify
  use gtool_historyauto, only: HistoryAutoCreate, &
    & HistoryAutoAddAttr, HistoryAutoAddWeight, HistoryAutoPutAxis, &
    & HistoryAutoClose, HistoryAutoPut, HistoryAutoAllVarFix, &
    & HistoryAutoAddVariable, HistoryAutoPutAxisMPI, &
    & HistoryAutoChkOutput, HistoryAutoChkOutputTiming
  use mpi
  implicit none
  integer:: err_mpi, myrank_mpi, nprocs_mpi

  integer:: i, j, k
  logical:: err
!  real, allocatable:: u(:,:,:)
  real(DP):: secd
  integer, allocatable:: dimsizes1(:)
  real(DP), allocatable:: axis1(:), axis2(:), axis3(:)
  real(DP), allocatable:: axis1_all(:), axis2_all(:), axis3_all(:)
  real(DP), allocatable:: xyz_U(:,:,:)
  character(*), parameter:: source = 'histauto.f90'
  character(*), parameter:: institution = 'gtool project'
  real(DP):: time1, time2, time3
  real(DP):: deltime1
  real(DP):: endtime1, inttime1
  real(DP), allocatable:: deltime2(:)
  type(DC_CAL):: cal1
  type(DC_CAL_DATE):: caldate1
  logical:: chkout

continue

  ! MPI åˆæœŸè¨å®š
  ! Initialize MPI
  !
  call MPI_Init(err_mpi)
  call MPI_Comm_Rank(MPI_COMM_WORLD, myrank_mpi, err_mpi)
  call MPI_Comm_Size(MPI_COMM_WORLD, nprocs_mpi, err_mpi)

  if ( nprocs_mpi /= 4 ) then
    call MessageNotify( 'E', 'histauto_mpi', 'Test must be done with 4 node')
  end if

  call SetDebug

!  goto 1500

!!$  call DCCalCreate( 'noleap', cal1 )
!!$  call DCCalDateCreate( &
!!$    & year = 2008, month = 10, day = 10, &
!!$    & hour = 12, min = 0, sec = 0.0_DP, &
!!$    & zone ='+09:00', date = caldate1 )
!!$  call DCCalCreate( 1, (/ 700 /), 12, 1, 1000.0_DP, cal = cal1 )
!!$  call DCCalDateCreate('2000-1-123T23:0:2000', caldate1 )

100 continue
  ! çµ±åˆå‡ºåŠ›ãƒ†ã‚¹ãƒˆ
  ! Integrated output test
  !
  allocate( dimsizes1(1:4), axis1(1:2), axis2(1:2), axis3(1:2) )
  allocate( axis1_all(1:2), axis2_all(1:4), axis3_all(1:4) )
  allocate( xyz_U(1:2,1:2,1:2) )
  select case( myrank_mpi )
  case(0) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/ 45.0,  90.0/)
    axis3(:) = (/  0.0, 100.0/)
  case(1) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/ 45.0,  90.0/)
    axis3(:) = (/200.0, 300.0/)
  case(2) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/135.0, 180.0/)
    axis3(:) = (/  0.0, 100.0/)
  case(3) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/135.0, 180.0/)
    axis3(:) = (/200.0, 300.0/)
  case default
    call MessageNotify( 'E', 'histauto_mpi', 'Test must be done with 4 node')
  end select
  axis1_all(1:2) = (/-10.0,  10.0/)
  axis2_all(1:4) = (/ 45.0,  90.0, 135.0, 180.0/)
  axis3_all(1:4) = (/  0.0, 100.0, 200.0, 300.0/)

  time1    = DCCalConvertByUnit(   0.0_DP, 'min' , 'min' )
  inttime1 = DCCalConvertByUnit(   1.0_DP, 'hrs' , 'min' )
  endtime1 = DCCalConvertByUnit(   3.0_DP, 'hrs' , 'min' )

  call HistoryAutoCreate( &
    &       title = 'Test01 for gtool_historyauto MPI', & ! (in)
    &      source = source, &                       ! (in)
    & institution = institution, &                  ! (in)
    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
    &  dimsizes = dimsizes1, &                            ! (in)
    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
    &     units = (/ 'm   ', 'm   ', 'deg.', 'min ' /), & ! (in)
    &    xtypes = (/ 'double' /), &                       ! (in) optional
    &     interval = inttime1, &                          ! (in) optional
    &       origin = time1, &                             ! (in) optional
    &     terminus = endtime1, &                          ! (in) optional
    &  file_prefix = 'xhistauto2_mpi/test01-', &          ! (in) optional
!!$    &  start_date = caldate1, &                           ! (in) optional
!!$    &         cal = cal1, &                               ! (in) optional
    & flag_mpi_gather = .true. )                          ! (in) optional

  time1    = DCCalConvertByUnit(   0.0_DP, 'min' , 'sec' )
  deltime1 = DCCalConvertByUnit(  10.0_DP, 'min' , 'sec' )

  call HistoryAutoPutAxis( 'x', axis1 )  ! (in)
  call HistoryAutoPutAxis( 'y', axis2 )  ! (in)
  call HistoryAutoPutAxis( 'z', axis3 )  ! (in)

  call HistoryAutoPutAxisMPI( 'x', axis1_all ) ! (in)
  call HistoryAutoPutAxisMPI( 'y', axis2_all ) ! (in)
  call HistoryAutoPutAxisMPI( 'z', axis3_all ) ! (in)

  call HistoryAutoAddWeight( &
    & dim = 'y', weight = (/ 1.5, 2.5 /) * myrank_mpi )  ! (in)

  call HistoryAutoAddWeight( &
    & dim = 'z', &                            ! (in)
    & weight = (/ 10.0, 25.0 /) * myrank_mpi, & ! (in)
    & units = 'deg.*2' , xtype = 'double' )   ! (in) optional

  call HistoryAutoAddAttr( &
    & varname = 'x', attrname = 'test_attr', &   ! (in)
    & value = 'test_attr_value' )                ! (in)

  call HistoryAutoAddVariable( &
    & 'u', (/'x   ', 'y   ', 'z   ', 'time'/), 'u', 'm s-1' ) ! (in)

  call HistoryAutoAddVariable( &
    & 'v', (/'x   ', 'y   ', 'z   ', 'time'/), 'v', 'm s-1', & ! (in)
    & time_average = .true. )                                  ! (in) optional

  call HistoryAutoAllVarFix

  do k = 1, 2
    do j = 1, 2
      do i = 1, 2
        xyz_U(i,j,k) = axis1(i) * 1.0 + axis2(j) * 100.0 + axis3(k) * 1000.0
      end do
    end do
  end do

  do i = 0, 30
    call HistoryAutoPut( time1, 'u', xyz_U + i * 2 )
    call HistoryAutoPut( time1, 'v', xyz_U + i * 2 )
    time1 = time1 + deltime1
  end do

  call HistoryAutoClose

  deallocate( dimsizes1, axis1, axis2, axis3 )
  deallocate( axis1_all, axis2_all, axis3_all )
  deallocate( xyz_U )

200 continue
  ! åˆ†æ•£å‡ºåŠ›ãƒ†ã‚¹ãƒˆ
  ! Discrete output test
  !
  allocate( dimsizes1(1:4), axis1(1:2), axis2(1:2), axis3(1:2) )
  allocate( axis1_all(1:2), axis2_all(1:4), axis3_all(1:4) )
  allocate( xyz_U(1:2,1:2,1:2) )
  select case( myrank_mpi )
  case(0) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/ 45.0,  90.0/)
    axis3(:) = (/  0.0, 100.0/)
  case(1) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/ 45.0,  90.0/)
    axis3(:) = (/200.0, 300.0/)
  case(2) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/135.0, 180.0/)
    axis3(:) = (/  0.0, 100.0/)
  case(3) ; dimsizes1(:) = (/2,2,2,0/)
    axis1(:) = (/-10.0,  10.0/)
    axis2(:) = (/135.0, 180.0/)
    axis3(:) = (/200.0, 300.0/)
  case default
    call MessageNotify( 'E', 'histauto_mpi', 'Test must be done with 4 node')
  end select
  axis1_all(1:2) = (/-10.0,  10.0/)
  axis2_all(1:4) = (/ 45.0,  90.0, 135.0, 180.0/)
  axis3_all(1:4) = (/  0.0, 100.0, 200.0, 300.0/)

  time1    = DCCalConvertByUnit(   0.0_DP, 'min' , 'min' )
  inttime1 = DCCalConvertByUnit(   1.0_DP, 'hrs' , 'min' )
  endtime1 = DCCalConvertByUnit(   3.0_DP, 'hrs' , 'min' )

  call HistoryAutoCreate( &
    &       title = 'Test02 for gtool_historyauto MPI', & ! (in)
    &      source = source, &                       ! (in)
    & institution = institution, &                  ! (in)
    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
    &  dimsizes = dimsizes1, &                            ! (in)
    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
    &     units = (/ 'm   ', 'm   ', 'deg.', 'min ' /), & ! (in)
    &    xtypes = (/ 'double' /), &                       ! (in) optional
    &     interval = inttime1, &                          ! (in) optional
    &       origin = time1, &                             ! (in) optional
    &     terminus = endtime1, &                          ! (in) optional
    &  file_prefix = 'xhistauto2_mpi/test02-', &           ! (in) optional
!!$    &  start_date = caldate1, &                           ! (in) optional
!!$    &         cal = cal1, &                               ! (in) optional
    & flag_mpi_split = .true. )                           ! (in) optional

  time1    = DCCalConvertByUnit(   0.0_DP, 'min' , 'sec' )
  deltime1 = DCCalConvertByUnit(  10.0_DP, 'min' , 'sec' )

  call HistoryAutoPutAxis( 'x', axis1 )  ! (in)
  call HistoryAutoPutAxis( 'y', axis2 )  ! (in)
  call HistoryAutoPutAxis( 'z', axis3 )  ! (in)

  call HistoryAutoPutAxisMPI( 'x', axis1_all ) ! (in)
  call HistoryAutoPutAxisMPI( 'y', axis2_all ) ! (in)
  call HistoryAutoPutAxisMPI( 'z', axis3_all ) ! (in)

  call HistoryAutoAddWeight( &
    & dim = 'y', weight = (/ 1.5, 2.5 /) * myrank_mpi )  ! (in)

  call HistoryAutoAddWeight( &
    & dim = 'z', &                            ! (in)
    & weight = (/ 10.0, 25.0 /) * myrank_mpi, & ! (in)
    & units = 'deg.*2' , xtype = 'double' )   ! (in) optional

  call HistoryAutoAddAttr( &
    & varname = 'x', attrname = 'test_attr', &   ! (in)
    & value = 'test_attr_value' )                ! (in)

  call HistoryAutoAddVariable( &
    & 'u', (/'x   ', 'y   ', 'z   ', 'time'/), 'u', 'm s-1' ) ! (in)

  call HistoryAutoAddVariable( &
    & 'v', (/'x   ', 'y   ', 'z   ', 'time'/), 'v', 'm s-1', & ! (in)
    & time_average = .true. )                                  ! (in) optional

  call HistoryAutoAllVarFix

  do k = 1, 2
    do j = 1, 2
      do i = 1, 2
        xyz_U(i,j,k) = axis1(i) * 1.0 + axis2(j) * 100.0 + axis3(k) * 1000.0
      end do
    end do
  end do

  do i = 0, 30
    chkout = HistoryAutoChkOutputTiming( time1, 'u' )
    write(*,*) '[HistoryAutoChkOutputTiming test] var = u', ', time = ', time1, ', OutputTiming = ', chkout

    call HistoryAutoPut( time1, 'u', xyz_U + i * 2 )
    call HistoryAutoPut( time1, 'v', xyz_U + i * 2 )
    time1 = time1 + deltime1
  end do

  call HistoryAutoClose

!!$400 continue
!!$  ! NAMELIST ã‚’ç”¨ã„ãŸ, å‡ºåŠ›è¨å®šãƒ†ã‚¹ãƒˆ 1
!!$  ! Output settings test 1 with NAMELIST
!!$  !
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 1 )                       ! (in)
!!$  call DCDiffTimeCreate( endtime1, &  ! (out)
!!$    & hour = -1 )                     ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 30.0_DP )                 ! (in)
!!$  call DCDiffTimeCreate( inttime1, &  ! (out)
!!$    & hour = 1 )                      ! (in)
!!$
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test04 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'hrs'  /), & ! (in)
!!$    & namelist_filename = 'histauto_nml04.nml', &         ! (in) optional
!!$    &     interval = inttime1, &                          ! (in) optional
!!$    &       origin = time1, &                             ! (in) optional
!!$    &     terminus = endtime1 )                           ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u1', (/'x   ', 'time'/), 'u1', 'm s-1' ) ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u2', (/'y   ', 'time'/), 'u2', 'm s-1' ) ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u3', (/'z   ', 'time'/), 'u3', 'm s-1' ) ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), 'v', 'm s-1', & ! (in)
!!$    & time_average = .true. )                  ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), 'z', 'm s-1', & ! (in)
!!$    & xtype = 'double' )                       ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 41
!!$    call HistoryAutoPut( time1, 'u1', (/ ( real(j), j = 1, 2 ) /) * i )
!!$    call HistoryAutoPut( time1, 'u2', (/ ( real(j), j = 1, 3 ) /) * i )
!!$    call HistoryAutoPut( time1, 'u3', (/ ( real(j), j = 1, 4 ) /) * i )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) * i )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$500 continue
!!$  ! ç©ºé–“åˆ‡ã‚Šå‡ºã—ãƒ†ã‚¹ãƒˆ 1 (NAMELIST ä½¿ç”¨ã›ãš)
!!$  ! Slices of spaces test 1 (without NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test05 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                         ! (in)
!!$    & institution = institution, &                    ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 4, 6, 8, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'sec'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test05-', &               ! (in) optional
!!$    & slice_start  = (/  1,  1, 3 /), &                   ! (in) optional
!!$    & slice_end    = (/ -1, -1, 6 /), &                   ! (in) optional
!!$    & slice_stride = (/  1,  2, 1 /) )                    ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 1.0_DP )                  ! (in)
!!$
!!$  call HistoryAutoPutAxis( &
!!$    & dim = 'y', array = (/ -10.0, -2.0, 0.0, 3.0, 6.0, 10.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddWeight( &
!!$    & dim = 'y', weight = (/ 4.0, 5.0, 2.5, 3.0, 3.5, 2.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'y   ', 'time'/), 'v', 'm s-1', & ! (in)
!!$    & time_average = .true. )                          ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'y   ', 'z   ', 'time'/), 'z', 'm s-1', & ! (in)
!!$    & xtype = 'double' )                               ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'ns', (/'x   ', 'y   ', 'z   ', 'time'/), & ! (in)
!!$    & 'no slice', 'm s-1', &                      ! (in)
!!$    & slice_start  = (/  1,  1,  1 /), &          ! (in) optional
!!$    & slice_end    = (/ -1, -1, -1 /), &          ! (in) optional
!!$    & slice_stride = (/  1,  1,  1 /) )           ! (in) optional
!!$
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'u1', (/'x   ', 'time'/), 'u1', 'm s-1', &  ! (in)
!!$!    & file = 'xhistauto2_mpi/test05-u.nc', &           ! (in) optional
!!$!    & slice_start  = (/  1,  2,  1 /) )           ! (in) optional
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'u2', (/'x   ', 'time'/), 'u1', 'm s-1', &  ! (in)
!!$!    & file = 'xhistauto2_mpi/test05-u.nc', &           ! (in) optional
!!$!    & slice_start  = (/  1,  1,  2 /) )           ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 3
!!$    call HistoryAutoPut( time1, 'v', &
!!$      &    reshape( (/ ( real(j), j = 1, 24 ) /) + 100 * i, (/ 4, 6 /) ) )
!!$    call HistoryAutoPut( time1, 'w', &
!!$      &    reshape( (/ ( real(j), j = 1, 48 ) /) + 100 * i, (/ 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'ns', &
!!$      &    reshape( (/ ( real(j), j = 1, 192 ) /) + 1000 * i, (/ 4, 6, 8 /) ) )
!!$
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!    call HistoryAutoPut( time1, 'u1', (/ ( real(j), j = 1, 4 ) /) * i )
!!$!    call HistoryAutoPut( time1, 'u2', (/ ( real(j), j = 1, 6 ) /) * i )
!!$
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$600 continue
!!$  ! ç©ºé–“åˆ‡ã‚Šå‡ºã—ãƒ†ã‚¹ãƒˆ 2 (NAMELIST ä½¿ç”¨)
!!$  ! Slices of spaces test 2 (with NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test06 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 4, 6, 8, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'sec'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test06-', &               ! (in) optional
!!$    & namelist_filename = 'histauto_nml06.nml' )          ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 1.0_DP )                  ! (in)
!!$
!!$  call HistoryAutoPutAxis( &
!!$    & dim = 'y', array = (/ -10.0, -2.0, 0.0, 3.0, 6.0, 10.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddWeight( &
!!$    & dim = 'y', weight = (/ 4.0, 5.0, 2.5, 3.0, 3.5, 2.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'y   ', 'time'/), 'v', 'm s-1' )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'y   ', 'z   ', 'time'/), 'z', 'm s-1' )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'ns', (/'x   ', 'y   ', 'z   ', 'time'/), & ! (in)
!!$    & 'no slice', 'm s-1' )                       ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 3
!!$    call HistoryAutoPut( time1, 'v', &
!!$      &    reshape( (/ ( real(j), j = 1, 24 ) /) + 100 * i, (/ 4, 6, 1 /) ) )
!!$    call HistoryAutoPut( time1, 'w', &
!!$      &    reshape( (/ ( real(j), j = 1, 48 ) /) + 100 * i, (/ 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'ns', &
!!$      &    reshape( (/ ( real(j), j = 1, 192 ) /) + 1000 * i, (/ 4, 6, 8 /) ) )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$700 continue
!!$  ! ç©ºé–“å¹³å‡ãƒ†ã‚¹ãƒˆ 1 (NAMELIST ãªã—)
!!$  ! Average of spaces test 1 (without NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test07 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 4, 6, 8, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'sec'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test07-', &               ! (in) optional
!!$    & space_average = (/ .false., .false., .false. /) )   ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 1.0_DP )                  ! (in)
!!$
!!$  call HistoryAutoPutAxis( &
!!$    & dim = 'y', array = (/ -8.0, -4.0, 0.0, 4.0, 6.0, 8.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddWeight( &
!!$    & dim = 'y', weight = (/ 5.0,  4.0, 4.0, 3.0, 2.0, 2.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u1', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u1', 'm s-1', &                  ! (in)
!!$    & file = 'xhistauto2_mpi/test07-u.nc', & ! (in) optional
!!$    & space_average = (/ .true. /) )    ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u2', (/'y   ', 'time'/), &              ! (in)
!!$    & 'u2', 'm s-1', &                         ! (in)
!!$    & file = 'xhistauto2_mpi/test07-u.nc', &        ! (in) optional
!!$    & space_average = (/ .false., .true. /) )  ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'y   ', 'z   ', 'time'/), &     ! (in)
!!$    & 'v', 'm s-1', &                                ! (in)
!!$    & space_average = (/ .true., .true., .true. /) ) ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w1', (/'x   ', 'y   ', 'z   ', 'time'/), &    ! (in)
!!$    & 'w1', 'm s-1', &                               ! (in)
!!$    & file = 'xhistauto2_mpi/test07-w.nc', &              ! (in) optional
!!$    & slice_start  = (/  1,  1, 3 /), &              ! (in) optional
!!$    & slice_end    = (/ -1, -1, 6 /), &              ! (in) optional
!!$    & slice_stride = (/  2,  1, 1 /), &              ! (in) optional
!!$    & space_average = (/ .true., .true., .true. /) ) ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w2', (/'x   ', 'y   ', 'z   ', 'time'/), &    ! (in)
!!$    & 'w2', 'm s-1', &                               ! (in)
!!$    & file = 'xhistauto2_mpi/test07-w.nc', &              ! (in) optional
!!$    & slice_start  = (/  1,  1, 3 /), &              ! (in) optional
!!$    & slice_end    = (/ -1, -1, 6 /), &              ! (in) optional
!!$    & slice_stride = (/  2,  1, 1 /) )               ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 3
!!$    call HistoryAutoPut( time1, 'u1', (/ ( real(j), j = 1, 4 ) /) * 2 + 100 * i )
!!$    call HistoryAutoPut( time1, 'u2', (/ 2.0, 3.0, 4.0, 6.0, 7.0, 15.0 /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'v', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'w1', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'w2', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$800 continue
!!$  ! ç©ºé–“å¹³å‡ãƒ†ã‚¹ãƒˆ 2 (NAMELIST ä½¿ç”¨)
!!$  ! Average of spaces test 2 (with NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test08 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 4, 6, 8, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'sec'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test08-', &               ! (in) optional
!!$    & namelist_filename = 'histauto_nml08.nml' )          ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 1.0_DP )                  ! (in)
!!$
!!$  call HistoryAutoPutAxis( &
!!$    & dim = 'y', array = (/ -8.0, -4.0, 0.0, 4.0, 6.0, 8.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddWeight( &
!!$    & dim = 'y', weight = (/ 5.0,  4.0, 4.0, 3.0, 2.0, 2.0 /) )  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u1', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u1', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u2', (/'y   ', 'time'/), &       ! (in)
!!$    & 'u2', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'y   ', 'z   ', 'time'/), &     ! (in)
!!$    & 'v', 'm s-1' )                                 ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w1', (/'x   ', 'y   ', 'z   ', 'time'/), &    ! (in)
!!$    & 'w1', 'm s-1' )                                ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w2', (/'x   ', 'y   ', 'z   ', 'time'/), &    ! (in)
!!$    & 'w2', 'm s-1' )                                ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 3
!!$    call HistoryAutoPut( time1, 'u1', (/ ( real(j), j = 1, 4 ) /) * 2 + 100 * i )
!!$    call HistoryAutoPut( time1, 'u2', (/ 2.0, 3.0, 4.0, 6.0, 7.0, 15.0 /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'v', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'w1', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$    call HistoryAutoPut( time1, 'w2', &
!!$      &    reshape( (/ ( real(j * 10), j = 1, 192 ) /) + 10000 * i, (/ 4, 6, 8 /) ) )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$900 continue
!!$  ! å‡ºåŠ›é–‹å§‹, çµ‚äº†æ™‚åˆ»è¨å®šãƒ†ã‚¹ãƒˆ 1 (NAMELIST ãªã—)
!!$  ! Start and stop of output timing setting test 1 (without NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test09 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'min'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test09-', &               ! (in) optional
!!$    &     interval =  2.0, &                              ! (in) optional
!!$    &       origin =  5.0,   terminus = 10.0 )            ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 1 )                       ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 30.0_DP )                 ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1', &                  ! (in)
!!$    & time_average = .true., &         ! (in) optional
!!$    & terminus = 15.0 )                ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), &       ! (in)
!!$    & 'w', 'm s-1', &                  ! (in)
!!$    & origin = -1.0, terminus = -1.0 ) ! (in) optional
!!$
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'err1', (/'x   ', 'time'/), 'err1', 'm s-1', &  ! (in)
!!$!    & file = 'xhistauto2_mpi/test09-err.nc', &             ! (in) optional
!!$!    & origin = 2.0, terminus = 10.0 )                 ! (in) optional
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'err2', (/'x   ', 'time'/), 'err2', 'm s-1', &  ! (in)
!!$!    & file = 'xhistauto2_mpi/test09-err.nc', &             ! (in) optional
!!$!    & origin = 2.0, terminus = 9.0 )                  ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 30
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 5 * ( i + 1 ) )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) + 50 * ( i + 1 ) )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) + 5 * ( i + 1 ) )
!!$
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!    call HistoryAutoPut( time1, 'err1', (/ ( real(j), j = 1, 2 ) /) + 5 * ( i + 1 ) )
!!$!    call HistoryAutoPut( time1, 'err2', (/ ( real(j), j = 1, 2 ) /) + 5 * ( i + 1 ) )
!!$
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1000 continue
!!$  ! å‡ºåŠ›é–‹å§‹, çµ‚äº†æ™‚åˆ»è¨å®šãƒ†ã‚¹ãƒˆ 2 (NAMELIST ä½¿ç”¨)
!!$  ! Start and stop of output timing setting test 2 (with NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test10 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'hrs'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test10-', &               ! (in) optional
!!$    & namelist_filename = 'histauto_nml10.nml' )          ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 1 )                       ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 30.0_DP )                 ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), &       ! (in)
!!$    & 'w', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 30
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 5 * ( i + 1 ) )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) + 50 * ( i + 1 ) )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) + 5 * ( i + 1 ) )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1100 continue
!!$  ! ãƒ•ã‚¡ã‚¤ãƒ«åˆ†å‰²å‡ºåŠ›ãƒ†ã‚¹ãƒˆ 1 (NAMELIST ãªã—)
!!$  ! Separately output file test 1 (without NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test11 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                         ! (in)
!!$    & institution = institution, &                    ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'day'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test11-', &               ! (in) optional
!!$    &     interval =  0.25, &                             ! (in) optional
!!$    & newfile_interval = 1 )                              ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & hour = 1 )                      ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  !
!!$  ! åˆ†å‰²ã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«ã®æœ€åˆã®ãƒ‡ãƒ¼ã‚¿ã¯, å¹³å‡å€¤ã«ãªã‚‰ãªã„.
!!$  ! (ãƒã‚°ã¨è¨€ãˆã°ãƒã‚°ã ãŒ, ã¨ã‚Šã‚ãˆãšæ”¾ç½® 2008/07/26 morikawa)
!!$  !
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1', &                  ! (in)
!!$    & time_average = .true., &         ! (in) optional
!!$    & interval = 0.5, &                ! (in) optional
!!$    & origin = 1.5, terminus = 3.5 )   ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), &       ! (in)
!!$    & 'w', 'm s-1', &                  ! (in)
!!$    & interval = 0.5, &                ! (in) optional
!!$    & origin = 1.5, terminus = 3.5 )   ! (in) optional
!!$
!!$!
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'err', (/'z   ', 'time'/), &       ! (in)
!!$!    & 'err', 'm s-1', &                  ! (in)
!!$!    & newfile_interval = 1, &            ! (in) optional
!!$!    & time_units = 'min' )               ! (in) optional
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'err2', (/'z   ', 'time'/), &       ! (in)
!!$!    & 'err2', 'm s-1', &                  ! (in)
!!$!    & file = 'xhistauto2_mpi/test11-err.nc' )  ! (in) optional
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'err3', (/'z   ', 'time'/), &       ! (in)
!!$!    & 'err3', 'm s-1', &                  ! (in)
!!$!    & file = 'xhistauto2_mpi/test11-err.nc' ) ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 0, 100
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) + 100 * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$
!!$1200 continue
!!$  ! ãƒ•ã‚¡ã‚¤ãƒ«åˆ†å‰²å‡ºåŠ›ãƒ†ã‚¹ãƒˆ 2 (NAMELIST ä½¿ç”¨)
!!$  ! Separately output file test 2 (with NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test12 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'day'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test12-', &               ! (in) optional
!!$    & namelist_filename = 'histauto_nml12.nml' )          ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & day = 0 )                       ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & day = 1 )                       ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), &       ! (in)
!!$    & 'w', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 0, 100
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) + 100 * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1300 continue
!!$  ! ãƒ©ãƒ³ã‚¯ã®åç§°ã‚’ãƒ•ã‚¡ã‚¤ãƒ«åã«åæ˜ ã™ã‚‹ãƒ†ã‚¹ãƒˆ1 (NAMELIST ãªã—)
!!$  ! Reflect of rank name to file name test 1 (with NAMELIST)
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test13 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'y   ', 'z   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'm  ',  'm  ',  'min'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test13-', &               ! (in) optional
!!$    &     interval = 10.0, &                              ! (in) optional
!!$    &         rank = '01' )                               ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 0 )                       ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & min = 10 )                      ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'y   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1', &                  ! (in)
!!$    & file = 'xhistauto2_mpi/test13-v.nc' ) ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'z   ', 'time'/), &       ! (in)
!!$    & 'w', 'm s-1', &                  ! (in)
!!$    & newfile_interval = 100 )         ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 0, 30
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 3 ) /) + 100 * i )
!!$    call HistoryAutoPut( time1, 'w', (/ ( real(j), j = 1, 4 ) /) + 100 * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1400 continue
!!$  ! 7 æ¬¡å…ƒã«ä¾å˜ã™ã‚‹å¤‰æ•°ã®å‡ºåŠ›ãƒ†ã‚¹ãƒˆ
!!$  ! Output of variables depended on 7 dimensions test
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test14 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'd1  ', 'd2  ', 'd3  ', 'd4  ', 'd5  ', &
!!$    &                'd6  ', 'd7  ', 'd8  ', 'd9  ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 3, 4, 3, 2, 3, 4, 3, 2, 0 /), &   ! (in)
!!$    & longnames = (/ 'd1  ', 'd2  ', 'd3  ', 'd4  ', 'd5  ', &
!!$    &                'd6  ', 'd7  ', 'd8  ', 'd9  ', 'time' /), & ! (in)
!!$    &     units = (/ '1   ', '1   ', '1   ', '1   ', '1   ', &
!!$    &                '1   ', '1   ', '1   ', '1   ', 'sec ' /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test14-' )                ! (in) optional
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & sec = 0.0_DP )                  ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & sec = 1.0_DP )                  ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'d1  ', 'd2  ', 'd3  ', 'd4  ', 'd5  ', &
!!$    &        'd6  ', 'd7  ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                                   ! (in)
!!$
!!$!
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!  call HistoryAutoAddVariable( &
!!$!    & 'v', (/'d1  ', 'd2  ', 'd3  ', 'd4  ', 'd5  ', &
!!$!    &        'd6  ', 'd7  ', 'd8  ', 'time'/), &       ! (in)
!!$!    & 'v', 'm s-1' )                                   ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'d3  ', 'd4  ', 'd5  ', 'd6  ', 'd7  ', &
!!$    &        'd8  ', 'd9  ', 'time'/), &             ! (in)
!!$    & 'w', 'm s-1', &                                ! (in)
!!$    & space_average = &
!!$    &   (/ .false., .false., .true., .true., .false., .true., .true., .true. /) ) ! (in) optional
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 0, 2
!!$    call HistoryAutoPut( time1, 'u', &
!!$      & reshape( (/ ( real(j), j = 1, 2*3*4*3*2*3*4 ) /), &
!!$      &                            (/ 2,3,4,3,2,3,4 /)     ) + 10000 * i )
!!$    call HistoryAutoPut( time1, 'w', &
!!$      & reshape( (/ ( real(j)*10, j = 1, 4*3*2*3*4*3*2 ) /), &
!!$      &                               (/ 4,3,2,3,4,3,2 /)     ) + 100000 * i )
!!$
!!$!
!!$! ã‚¨ãƒ©ãƒ¼ãƒã‚§ãƒƒã‚¯ç”¨
!!$!
!!$!    call HistoryAutoPut( time1, 'v', &
!!$!      & reshape( (/ ( real(j), j = 1, 2*3*4*3*2*3*4 ) /), &
!!$!      &                            (/ 2,3,4,3,2,3,4 /)     ) + 10000 * i )
!!$
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1500 continue
!!$  ! å‡ºåŠ›é–‹å§‹, çµ‚äº†æ™‚åˆ»è¨å®šãƒ†ã‚¹ãƒˆ 2 (å¼•æ•° + NAMELIST ä½¿ç”¨)
!!$  ! Start and stop of output timing setting test 2 (with arguments and NAMELIST)
!!$  !
!!$  call DCDiffTimeCreate( endtime1, &  ! (out)
!!$    & hour = 1 )                      ! (in)
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 10 )                      ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & min = 5 )                       ! (in)
!!$  call DCDiffTimeCreate( inttime1, &  ! (out)
!!$    & min = 5 )                       ! (in)
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test15 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &           ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'min'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test15-01-', &            ! (in) optional
!!$    &       origin =  time1, terminus = endtime1, &       ! (in) optional
!!$    &     interval =  inttime1, &                         ! (in) optional
!!$    &   all_output = .true., &                            ! (in) optional
!!$    & namelist_filename = 'histauto_nml15-01.nml' )       ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 0 )                       ! (in)
!!$  call DCDiffTimeCreate( endtime1, &  ! (out)
!!$    & hour = -1 )                     ! (in)
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1', &                  ! (in)
!!$    & origin = time1, terminus = endtime1 ) ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 0 )                       ! (in)
!!$  do i = 1, 21
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 5 * ( i + 1 ) )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 2 ) /) + 50 * ( i + 1 ) )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$  call DCDiffTimeCreate( endtime1, &  ! (out)
!!$    & day = 3 )                       ! (in)
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & hour = 24 )                     ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & hour = 6 )                      ! (in)
!!$  call DCDiffTimeCreate( inttime1, &  ! (out)
!!$    & hour = 12 )                     ! (in)
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test15 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), & ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &           ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), & ! (in)
!!$    &     units = (/ 'm  ',  'day'  /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test15-02-', &            ! (in) optional
!!$    &       origin =  time1, terminus = endtime1, &       ! (in) optional
!!$    &     interval =  inttime1, &                         ! (in) optional
!!$    &   all_output = .true., &                            ! (in) optional
!!$    & namelist_filename = 'histauto_nml15-02.nml' )       ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), &       ! (in)
!!$    & 'u', 'm s-1' )                   ! (in)
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & hour = 0 )                      ! (in)
!!$  call DCDiffTimeCreate( endtime1, &  ! (out)
!!$    & hour = -1 )                     ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'time'/), &       ! (in)
!!$    & 'v', 'm s-1', &                  ! (in)
!!$    & origin = time1, terminus = endtime1 ) ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & min = 0 )                       ! (in)
!!$  do i = 1, 25
!!$    call HistoryAutoPut( time1, 'u', (/ ( real(j), j = 1, 2 ) /) + 10 * ( i - 1 ) )
!!$    call HistoryAutoPut( time1, 'v', (/ ( real(j), j = 1, 2 ) /) + 10 * ( i - 1 ) )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1600 continue
!!$  ! æ™‚åˆ»ã‚’å…¥ã‚Œæ›¿ãˆã¦ã®å‡ºåŠ›ãƒ†ã‚¹ãƒˆ
!!$  ! Output test with switch of time
!!$  !
!!$  call DCDiffTimeCreate( time1, & ! (out)
!!$    & min = 0 )                   ! (in)
!!$  call DCDiffTimeCreate( time2, & ! (out)
!!$    & min = 1 )                   ! (in)
!!$  call DCDiffTimeCreate( time3, & ! (out)
!!$    & min = 2 )                   ! (in)
!!$  call DCDiffTimeCreate( deltime1, & ! (out)
!!$    & min = 1 )                      ! (in)
!!$  call DCDiffTimeCreate( inttime1, & ! (out)
!!$    & min = 10 )                     ! (in)
!!$  call DCDiffTimeCreate( endtime1, & ! (out)
!!$    & min = 35 )                     ! (in)
!!$
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test16 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &  ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &  ! (in)
!!$    &     units = (/ 'm  ', 'min'  /), & ! (in)
!!$    &       origin =  time3, terminus = endtime1, &       ! (in) optional
!!$    &     interval =  inttime1, &                         ! (in) optional
!!$    &  file_prefix = 'xhistauto2_mpi/test16-' )                ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1' ) ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'time'/), 'v', 'm s-1', & ! (in)
!!$    & time_average = .true., xtype = 'double' )        ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'x   ', 'time'/), 'w', 'm s-1' )  ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 1, 31
!!$    call HistoryAutoPut( time1, 'u', (/ 10.0, 20.0 /) * i )
!!$    call HistoryAutoPut( time2, 'v', (/ 10.0, 20.0 /) * i  )
!!$    call HistoryAutoPut( time3, 'w', (/ 10.0, 20.0 /) * i  )
!!$    time1 = time1 + deltime1
!!$    time2 = time2 + deltime1
!!$    time3 = time3 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$
!!$1700 continue
!!$  ! æ™‚é–“ã®æ¬¡å…ƒã« "since 20XX-XX-XX .." ã¨ã„ã£ãŸæƒ…å ±ã‚’ä¸Žãˆã‚‹ãƒ†ã‚¹ãƒˆ
!!$  ! Test for check that "since 20XX-XX-XX .." is given to unit of time
!!$  !
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test17 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &  ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &  ! (in)
!!$    &     units = (/ 'm                                  ', &
!!$    &                'day since 2008-10-05T00:00:00+00:00' /), & ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test17-' )                ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1' ) ! (in)
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  call DCDiffTimeCreate( time1, &     ! (out)
!!$    & day = 0 )                       ! (in)
!!$  call DCDiffTimeCreate( deltime1, &  ! (out)
!!$    & day = 1 )                       ! (in)
!!$
!!$  do i = 1, 3
!!$    call HistoryAutoPut( time1, 'u', (/ 10.0, 20.0 /) * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$1800 continue
!!$  ! Î”t ã¨å‡ºåŠ›é–“éš”ãŒä¸€è‡´ã—ãªã„å ´åˆã®ãƒ†ã‚¹ãƒˆ
!!$  ! Test for output interval is not equal to delta t
!!$  !
!!$  call DCDiffTimeCreate( time1, & ! (out)
!!$    & min = 0 )                   ! (in)
!!$
!!$  allocate( deltime2(1:3) )
!!$  call DCDiffTimeCreate( deltime2(1), & ! (out)
!!$    & sec = 20.0_DP )                   ! (in)
!!$  call DCDiffTimeCreate( deltime2(2), & ! (out)
!!$    & sec = 30.0_DP )                   ! (in)
!!$  call DCDiffTimeCreate( deltime2(3), & ! (out)
!!$    & sec = 40.0_DP )                   ! (in)
!!$
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test18 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &  ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &  ! (in)
!!$    &     units = (/ 'm  ', 'min'  /), & ! (in)
!!$    &     interval = 1.0, &                         ! (in) optional
!!$    &  file_prefix = 'xhistauto2_mpi/test18-' )          ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1', &  ! (in)
!!$    & interval = 60.0, time_units = 'sec' )     ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'v', (/'x   ', 'time'/), 'v', 'm s-1', &  ! (in)
!!$    & interval = 100.0, time_units = 'sec' )    ! (in)
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'w', (/'x   ', 'time'/), 'w', 'm s-1',&   ! (in)
!!$    & interval = 30.0, time_units = 'sec', &    ! (in)
!!$    & time_average = .true., xtype = 'double' ) ! (in) optional
!!$
!!$  call HistoryAutoAllVarFix
!!$
!!$  do i = 0, 10
!!$    call HistoryAutoPut( time1, 'u', (/ 10.0, 20.0 /) * i )
!!$    call HistoryAutoPut( time1, 'v', (/ 10.0, 20.0 /) * i )
!!$    call HistoryAutoPut( time1, 'w', (/ 10.0, 20.0 /) * i )
!!$    time1 = time1 + deltime2( mod(i,3) + 1 )
!!$  end do
!!$
!!$  call HistoryAutoClose
!!$
!!$  deallocate( deltime2 )
!!$
!!$
!!$1900 continue
!!$  ! æ—¥æ™‚è¨å®šãƒ†ã‚¹ãƒˆ
!!$  ! Date configuration test
!!$  !
!!$  call DCDiffTimeCreate( time1, & ! (out)
!!$    & sec = 0.0_DP )              ! (in)
!!$  call DCDiffTimeCreate( deltime1, & ! (out)
!!$    & sec = 1.0_DP )                 ! (in)
!!$
!!$  call DCDateTimeCreate( date1, &                  ! (out)
!!$    & year = 2008, mon = 10, day = 10, hour = 12 ) ! (in)
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test19 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &           ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &           ! (in)
!!$    &     units = (/ 'm  ', 'sec'  /), &            ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test19-none-', &    ! (in) optional
!!$    &  origin_date = date1, &                       ! (in) optional
!!$    &  origin_date_invalid = .true. )               ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1' ) ! (in)
!!$  call HistoryAutoAllVarFix
!!$  do i = 1, 2
!!$    call HistoryAutoPut( time1, 'u', (/ 1.0, 2.0 /) * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$  call HistoryAutoClose
!!$
!!$
!!$  call DCDateTimeCreate( date1, &                  ! (out)
!!$    & year = 2008, mon = 10, day = 10, hour = 12 ) ! (in)
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test19 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &           ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &           ! (in)
!!$    &     units = (/ 'm  ', 'sec'  /), &            ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test19-gregorian-', & ! (in) optional
!!$    &  origin_date = date1 )                          ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1' ) ! (in)
!!$  call HistoryAutoAllVarFix
!!$  do i = 1, 2
!!$    call HistoryAutoPut( time1, 'u', (/ 1.0, 2.0 /) * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$  call HistoryAutoClose
!!$
!!$
!!$  call DCDateTimeCreate( date1, &                   ! (out)
!!$    & year = 2008, mon = 10, day = 10, hour = 12, & ! (in)
!!$    & caltype_str = 'noleap' )                      ! (in)
!!$  call HistoryAutoCreate( &
!!$    &       title = 'Test19 for gtool_historyauto', & ! (in)
!!$    &      source = source, &                       ! (in)
!!$    & institution = institution, &                  ! (in)
!!$    &      dims = (/ 'x   ', 'time' /), &           ! (in)
!!$    &  dimsizes = (/ 2, 0 /), &                     ! (in)
!!$    & longnames = (/ 'x   ', 'time' /), &           ! (in)
!!$    &     units = (/ 'm  ', 'sec'  /), &            ! (in)
!!$    &  file_prefix = 'xhistauto2_mpi/test19-noleap-', &  ! (in) optional
!!$    &  origin_date = date1, &                       ! (in) optional
!!$    &  origin_date_invalid = .false. )              ! (in) optional
!!$
!!$  call HistoryAutoAddVariable( &
!!$    & 'u', (/'x   ', 'time'/), 'u', 'm s-1' ) ! (in)
!!$  call HistoryAutoAllVarFix
!!$  do i = 1, 2
!!$    call HistoryAutoPut( time1, 'u', (/ 1.0, 2.0 /) * i )
!!$    time1 = time1 + deltime1
!!$  end do
!!$  call HistoryAutoClose

  ! MPI çµ‚äº†å‡¦ç†
  ! Finalize MPI
  !
  call MPI_Finalize(err_mpi)

end program histauto2_mpi