Feel free to join the next Helmholtz Hacky Hour #30 on Wednesday, June 16, 2021 from 2PM to 3PM!

Commit 116b1c1f authored by Sebastian Müller's avatar Sebastian Müller 🎸
Browse files

EDK_driver: use new edk_dist class; reformat for readability

parent 9fcedbf7
...@@ -29,7 +29,7 @@ program ED_Kriging ...@@ -29,7 +29,7 @@ program ED_Kriging
grid, gridMeteo, & ! grid properties of input and output grid grid, gridMeteo, & ! grid properties of input and output grid
nCell, MetSta, & nCell, MetSta, &
noDataValue noDataValue
use kriging , only: dCS, dS, cell use kriging , only: edk_dist, cell
use mo_setVario , only: setVario, dMatrix use mo_setVario , only: setVario, dMatrix
use mo_netcdf , only: NcDataset, NcVariable use mo_netcdf , only: NcDataset, NcVariable
use mo_write , only: open_netcdf use mo_write , only: open_netcdf
...@@ -71,9 +71,9 @@ program ED_Kriging ...@@ -71,9 +71,9 @@ program ED_Kriging
loop_factor = 10 ! factor for setting openMP loop size loop_factor = 10 ! factor for setting openMP loop size
n_threads = 1 n_threads = 1
!$OMP PARALLEL !$omp PARALLEL
!$ n_threads = OMP_GET_NUM_THREADS() !$ n_threads = OMP_GET_NUM_THREADS()
!$OMP END PARALLEL !$omp END PARALLEL
!$ print *, 'Run with OpenMP with ', trim(num2str(n_threads)), ' threads.' !$ print *, 'Run with OpenMP with ', trim(num2str(n_threads)), ' threads.'
! initialize timers ! initialize timers
...@@ -109,7 +109,6 @@ program ED_Kriging ...@@ -109,7 +109,6 @@ program ED_Kriging
call message(' in ', trim(num2str(timer_get(itimer), '(F9.3)')), ' seconds.') call message(' in ', trim(num2str(timer_get(itimer), '(F9.3)')), ' seconds.')
call message('') call message('')
itimer = 3 itimer = 3
call timer_start(itimer) call timer_start(itimer)
call message(' >>> Estimate variogram') call message(' >>> Estimate variogram')
...@@ -123,7 +122,7 @@ program ED_Kriging ...@@ -123,7 +122,7 @@ program ED_Kriging
call message(' in ', trim(num2str(timer_get(itimer), '(F9.3)')), ' seconds.') call message(' in ', trim(num2str(timer_get(itimer), '(F9.3)')), ' seconds.')
call message('') call message('')
!write(*,*), "jStart = ",jStart !write(*,*), "jStart = ",jStart
if (interMth .gt. 0) then if (interMth .gt. 0) then
itimer = 4 itimer = 4
...@@ -133,7 +132,6 @@ program ED_Kriging ...@@ -133,7 +132,6 @@ program ED_Kriging
! open netcdf if necessary ! open netcdf if necessary
call open_netcdf(nc_out, nc_data, nc_time) call open_netcdf(nc_out, nc_data, nc_time)
do iCell = 1, nCell do iCell = 1, nCell
! initialize cell ! initialize cell
allocate(cell(iCell)%Nk_old(nSta)) allocate(cell(iCell)%Nk_old(nSta))
...@@ -148,7 +146,7 @@ program ED_Kriging ...@@ -148,7 +146,7 @@ program ED_Kriging
write(*,*),"Total Number of Time Buffers = ",iTime write(*,*),"Total Number of Time Buffers = ",iTime
t = 0 t = 0
bufferloop: do iTemp = 1, iTime bufferloop: do iTemp = 1, iTime
write(*,*)," >>> Started buffer #", iTemp
jStartTmp = jStart + (iTemp - 1) * tBuffer jStartTmp = jStart + (iTemp - 1) * tBuffer
if (iTemp .lt. iTime) then if (iTemp .lt. iTime) then
jEndTmp = jStartTmp + tBuffer - 1 jEndTmp = jStartTmp + tBuffer - 1
...@@ -165,9 +163,9 @@ program ED_Kriging ...@@ -165,9 +163,9 @@ program ED_Kriging
!print *, iTemp, iTime !print *, iTemp, iTime
!$OMP parallel default(shared) & !$omp parallel default(shared) &
!$OMP private(iThread, iCell, X, Nk_old) !$omp private(iThread, iCell, X, Nk_old)
!$OMP do SCHEDULE(dynamic) !$omp do SCHEDULE(dynamic)
do iThread = 1, loop_factor * n_threads do iThread = 1, loop_factor * n_threads
! print *, 'thread: ', iThread, " start" ! print *, 'thread: ', iThread, " start"
...@@ -179,19 +177,13 @@ program ED_Kriging ...@@ -179,19 +177,13 @@ program ED_Kriging
cycle cycle
end if end if
! interploation ! interploation
select case (interMth) call EDK(iCell, jStartTmp, jEndTmp, edk_dist, MetSta, cell, cell(iCell)%W, cell(iCell)%Nk_old, doOK=(interMth==1))
case (1)
call EDK(iCell, jStartTmp, jEndTmp, dCS, MetSta, dS, cell, cell(iCell)%W, cell(iCell)%Nk_old, doOK=.True.)
case (2)
call EDK(iCell, jStartTmp, jEndTmp, dCS, MetSta, dS, cell, cell(iCell)%W, cell(iCell)%Nk_old)
end select
end do ncellsloop end do ncellsloop
! print *, 'thread: ', iThread, " end" ! print *, 'thread: ', iThread, " end"
end do end do
!$OMP end do !$omp end do
!$OMP end parallel !$omp end parallel
if (DEMNcFlag == 1) then if (DEMNcFlag == 1) then
! write output ! write output
...@@ -234,7 +226,6 @@ program ED_Kriging ...@@ -234,7 +226,6 @@ program ED_Kriging
allocate(tmp_array(gridMeteo%ncols, gridMeteo%nrows, jEndTmp - jStartTmp + 1)) allocate(tmp_array(gridMeteo%ncols, gridMeteo%nrows, jEndTmp - jStartTmp + 1))
allocate(tmp_time(jEndTmp - jStartTmp + 1)) allocate(tmp_time(jEndTmp - jStartTmp + 1))
k = 0 k = 0
do i = 1, gridMeteo%ncols do i = 1, gridMeteo%ncols
! do j = 1, gridMeteo%nrows ! do j = 1, gridMeteo%nrows
...@@ -276,7 +267,6 @@ program ED_Kriging ...@@ -276,7 +267,6 @@ program ED_Kriging
call nc_data%setData(values=tmp_array,start=(/1,1,sttemp/),cnt=(/size(tmp_array,1),size(tmp_array,2),cnttemp/)) call nc_data%setData(values=tmp_array,start=(/1,1,sttemp/),cnt=(/size(tmp_array,1),size(tmp_array,2),cnttemp/))
end if end if
deallocate(tmp_array, tmp_time) deallocate(tmp_array, tmp_time)
!deallocate(cell) !deallocate(cell)
...@@ -286,11 +276,9 @@ program ED_Kriging ...@@ -286,11 +276,9 @@ program ED_Kriging
!cell(iCell)%z = noDataValue !cell(iCell)%z = noDataValue
end do end do
! close netcdf if necessary ! close netcdf if necessary
!call nc_out%close() ! outside !call nc_out%close() ! outside
end do bufferloop end do bufferloop
! close netcdf if necessary ! close netcdf if necessary
...@@ -307,4 +295,3 @@ program ED_Kriging ...@@ -307,4 +295,3 @@ program ED_Kriging
call print_end_message() call print_end_message()
! !
end program ED_Kriging end program ED_Kriging
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