The UFZ services GitLab and Mattermost will be unavailable on Monday, October 25 from 06:00 AM to 08:00 AM due to maintenance work.

Commit 429c0d0f authored by Stephan Thober's avatar Stephan Thober
Browse files

starting to update writing of netcdf file

parent f45746c1
......@@ -31,6 +31,7 @@ program ED_Kriging
grid, gridMeteo, & ! grid properties of input and output grid
nCell ! number of cells
use mo_setVario , only: setVario
use mo_netcdf , only: NcDataset, NcVariable
use kriging
implicit none
......@@ -42,6 +43,8 @@ program ED_Kriging
integer(i4) :: netcdfid ! id of netcdf files
real(dp), dimension(:,:), allocatable :: tmp_array ! temporal array for output
real(dp) :: param(3) ! variogram parameters
type(NcDataset) :: nc_out
type(NcVariable) :: nc_data, nc_time
call Timer
call ReadDataMain
......@@ -64,7 +67,7 @@ program ED_Kriging
!
if (flagEDK) then
! open netcdf if necessary
if (outputformat=='nc') call WriteFluxStateInit(netcdfid)
call open_netcdf(fname, ncols, nrows, nc_out, nc_data, nc_time)
timeloop: do jday = jStart, jEnd
......@@ -94,13 +97,16 @@ program ED_Kriging
! write output
allocate(tmp_array(gridMeteo%nrows, gridMeteo%ncols)); tmp_array=real(grid%nodata_value, dp)
tmp_array = real(reshape(cell(:)%z,(/gridMeteo%nrows, gridMeteo%ncols/)), dp)
call WriteFluxState((jday-jStart+1), netcdfid, transpose(tmp_array))
! call WriteFluxState((jday-jStart+1), netcdfid, transpose(tmp_array))
call nc_time%setData(jday, start=(/jday/))
call nc_data%setData(tmp_array, start=(/1, 1, jday/))
deallocate(tmp_array)
end do timeloop
! close netcdf if necessary
if (outputformat=='nc') call CloseFluxState_file(netcdfid)
call nc_out%close()
end if
! deallocate memory
......
This diff is collapsed.
module mo_write
implicit none
PRIVATE
PUBLIC :: open_netcdf
CONTAINS
subroutine open_netcdf(fname, ncols, nrows, nc_id, var_id, var_time)
use mo_kind, only: i4, sp, dp
use mo_netcdf, only: NcDataset, NcDimension, NcVariable
implicit none
character(256), intent(in) :: fname
integer(i4), intent(in) :: ncols
integer(i4), intent(in) :: nrows
type(NcDataset), intent(out) :: nc
type(NcVariable), intent(out) :: var_time, var_data
type(NcDimension) :: dim_x, dim_y, dim_time
type(NcVariable) :: var_lon, var_lat
! 1.1 create a file
nc = NcDataset(trim(fname), "w")
! create dimensions
dim_x = nc%setDimension("x", ncols)
dim_y = nc%setDimension("y", nrows)
dim_time = nc%setDimension("time", -1)
! create variables
var_time = nc%setVariable(vname_time, "i32", (/dim_time/))
! var_lat = nc%setVariable(vname_lat, "f32", (/dim_x, dim_y/))
! var_lon = nc%setVariable(vname_lon , "f32", (/dim_x, dim_y/))
var_data = nc%setVariable(vname_data, "f64", (/dim_x, dim_y, dim_time/))
! add some variable attributes
call var_time%setAttribute("units", "days since " // trim(num2str(yearstart - 1, form='(I4)')) // "-12-31 12:00:00")
! ! write data of static variables
! call var_lat%setData(wlat)
! call var_lon%setData(wlon)
! ! append data within a loop
! do i=1, ntime
! call var_time%setData(wtime(i), start=(/i/))
! call var_data%setData(wdata(:,:,i), start=(/1,1,i/))
! end do
! add some more variable attributes
call var_data%setAttribute("units", "mm/d")
call var_data%setAttribute("scaling", 0.1_dp)
! add global attributes
call nc%setAttribute("Author", trim(author_name))
end subroutine open_netcdf
end module mo_write
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment