program conv_to_netcdf_temperature

  use gtool_history

 implicit none

 real(8)                ::Ob_Temp(100,89),Temp(89)
 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)/)
! real(8), dimension(100,89) :: Ob_Temp

! t = 0.0                                       ! 初期時刻設定


 do i = 1,89
   open(10, file='Init_Temp.dat')
   read (10,*) Temp(i)
 end do                          

 call HistoryCreate( &                        ! ヒストリー作成
    & file='Ob_Temp.nc', title='Observed Temperature',   &
    & source='Sample program of gtool_history/gtool5',   &
    & institution='GFD_Dennou Club davis project',       &
    & dims=(/'x','z'/), dimsizes=(/100,89/),             &
    & 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_Temp', dims=(/'x','z'/), &
    & longname='Observed temperature', units='K', xtype='double')

  call HistoryPut('Ob_Temp',Ob_Temp)

 do i = 1,89
  do a = 1,100
   Ob_Temp(a,i) = Temp(i)

   call HistoryPut('Ob_Temp',Ob_Temp)

  end do
 end do

 do i=1,89
  do a=1,100
   write(6,*) Ob_Temp(a,i)
  end do
   write(6,*)
   write(6,*)
 end do

 call HistoryClose
end program conv_to_netcdf_temperature
