program conv_to_netcdf_humidity

  use gtool_history

 implicit none

 real(8)                ::Ob_Humidity(100,88),Humidity(88)
 integer                ::i,a,b
! integer, parameter     :: nx=100
! integer, parameter     :: nz=89
! real(8), parameter     :: dx=240
! real(8), parameter     :: dz=250
 real(8), dimension(100) :: x=(/(120+240*(b-1),b=1,100)/)
 real(8), dimension(89) :: z=(/(250*(b-1),b=1,89)/)


! t = 0.0                                       ! 初期時刻設定

 do i = 1,88
   open(11, file='Init_Humidity.dat')
   read (11,*) Humidity(i)
 end do

 call HistoryCreate( &                        ! ヒストリー作成
    & file='Ob_Humidity.nc', title='Observed Humidity',  &
    & source='Sample program of gtool_history/gtool5',   &
    & institution='GFD_Dennou Club davis project',       &
    & dims=(/'x','z'/), dimsizes=(/100,88/),             &
    & longnames=(/'X-coordinate','Z-coordinate'/),       &
    & units=(/'m','m'/),                                 &
    & origin=real(0), interval=real(0) )

  call HistoryPut('x',x)
  call HistoryPut('z',z)

  call HistoryAddVariable( &                   ! 変数定義
    & varname='Ob_Humidity', dims=(/'x','z'/), &
    & longname='Observed Humidity', units='%', xtype='double')

  call HistoryPut('Ob_Humidity',Ob_Humidity)

 do i = 1,88
  do a = 1,100
   Ob_Humidity(a,i) = Humidity(i)

   call HistoryPut('Ob_Humidity',Ob_Humidity)

  end do
 end do

 do i=1,88
  do a=1,100
   write(6,*) Ob_Humidity(a,i)
  end do
   write(6,*)
   write(6,*)
 end do

 call HistoryClose
end program conv_to_netcdf_humidity
