program main
    use netcdf_io_module
    implicit none
    type(io_struct) :: ios
    real, dimension(10) :: time_data = (/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0/)
    real, dimension(10) :: series_data = (/10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0/)
    real, dimension(10, 10) :: timescan_data
    real, dimension(10) :: profile_data
    real, dimension(10, 20, 20) :: d2time_data
    real, dimension(10, 20, 20, 10) :: d3time_data
    real, dimension(20, 20) :: d2_data
    real, dimension(20, 20, 10) :: d3_data
    integer :: i, j, k, m

    ! Инициализация данных timescan, profile, d2time, d3time, d2, d3
    do i = 1, 10
        profile_data(i) = real(i)
        do j = 1, 10
            timescan_data(j, i) = real(j) + real(i)
        end do
    end do

    do i = 1, 10
        do j = 1, 20
            do k = 1, 20
                d2time_data(i, j, k) = real(i) + real(j) + real(k)
                do m = 1, 10
                    d3time_data(i, j, k, m) = real(i) + real(j) + real(k) + real(m)
                end do
            end do
        end do
    end do

    do i = 1, 20
        do j = 1, 20
            d2_data(i, j) = real(i) + real(j)
            do k = 1, 10
                d3_data(i, j, k) = real(i) + real(j) + real(k)
            end do
        end do
    end do

    call open_netcdf('series_data.nc', ios, 10, 10, 20, 20)
    if (ios%is_open) then
        call write_series(ios, time_data, series_data)
        call write_timescan(ios, timescan_data)
        call write_profile(ios, profile_data)
        call write_2Dtime(ios, d2time_data)
        call write_3Dtime(ios, d3time_data)
        call write_2D(ios, d2_data)
        call write_3D(ios, d3_data)
        call close_netcdf(ios)
    else
        print *, 'Failed to open NetCDF file.'
    endif
end program main
