From 14dd5039abdfe44151fa2eb5675f16d7b2d122f3 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Fri, 12 Nov 2021 14:08:04 -0300 Subject: [PATCH] Revert "SOURCES: Use workspace in refinement criterion calculation." This reverts commit 1860fe97b093cb825171d495ab075bee0a51bc03. This comming introduced a circular dependency. --- sources/refinement.F90 | 160 ++++++++++------------------------------- 1 file changed, 36 insertions(+), 124 deletions(-) diff --git a/sources/refinement.F90 b/sources/refinement.F90 index dc36fb3..6b1823b 100644 --- a/sources/refinement.F90 +++ b/sources/refinement.F90 @@ -606,13 +606,12 @@ module refinement ! function vorticity_magnitude(pdata) result(wmax) - use blocks , only : block_data - use coordinates , only : nn => bcells - use coordinates , only : nbl, neu - use equations , only : ivx, ivz - use iso_fortran_env, only : error_unit - use mesh , only : work, nwork, work_in_use - use operators , only : curl + use blocks , only : block_data + use coordinates, only : nn => bcells + use coordinates, only : nbl, neu + use equations , only : inx, inz + use equations , only : ivx, ivz + use operators , only : curl implicit none @@ -620,66 +619,24 @@ module refinement real(kind=4) :: wmax - logical, save :: first = .true. - - integer :: i, j, k = 1, status + integer :: i, j, k = 1 real(kind=8) :: vort - real(kind=8), dimension(3), save :: dh - - real(kind=8), dimension(:,:,:,:), pointer, save :: w - - character(len=*), parameter :: loc = 'REFINEMENT:vorticity_magnitude()' + real(kind=8), dimension(3) :: dh = 1.0d+00 !------------------------------------------------------------------------------- ! + call curl(dh(:), pdata%q(ivx:ivz,:,:,:), pdata%du(inx:inz,:,:,:)) + wmax = 0.0e+00 - if (first) then - status = 0 - if (work_in_use) then - write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), & - "Workspace is already occupied!" - return - else - i = 3 * nn**NDIMS - - if (i > nwork) then - write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), & - "Workspace has too be increased!" - nwork = i - deallocate(work) - allocate(work(nwork), stat=status) - if (status /= 0) then - write(error_unit,"('[',a,']: ',a)") trim(loc), & - "Cannot increase the workspace's size!" - return - end if - end if - -#if NDIMS == 3 - w(1:3,1:nn,1:nn,1:nn) => work(1:i) -#else /* NDIMS == 3 */ - w(1:3,1:nn,1:nn,1: 1) => work(1:i) -#endif /* NDIMS == 3 */ - - dh(:) = 1.0d+00 - end if - - first = .false. - end if - - work_in_use = .true. - - call curl(dh(:), pdata%q(ivx:ivz,:,:,:), w(:,:,:,:)) - #if NDIMS == 3 do k = nbl, neu #endif /* NDIMS == 3 */ do j = nbl, neu do i = nbl, neu - vort = sum(w(:,i,j,k)**2) + vort = sum(pdata%du(inx:inz,i,j,k)**2) wmax = max(wmax, real(vort, kind=4)) @@ -689,8 +646,6 @@ module refinement end do #endif /* NDIMS == 3 */ - work_in_use = .false. - wmax = sqrt(wmax) !------------------------------------------------------------------------------- @@ -713,14 +668,13 @@ module refinement ! function current_density_magnitude(pdata) result(jmax) - use blocks , only : block_data - use coordinates , only : nn => bcells - use coordinates , only : nbl, neu - use equations , only : magnetized - use equations , only : ibx, ibz - use iso_fortran_env, only : error_unit - use mesh , only : work, nwork, work_in_use - use operators , only : curl + use blocks , only : block_data + use coordinates, only : nn => bcells + use coordinates, only : nbl, neu + use equations , only : magnetized + use equations , only : inx, inz + use equations , only : ibx, ibz + use operators , only : curl implicit none @@ -728,81 +682,39 @@ module refinement real(kind=4) :: jmax - logical, save :: first = .true. - - integer :: i, j, k = 1, status + integer :: i, j, k = 1 real(kind=8) :: jabs - real(kind=8), dimension(3), save :: dh - - real(kind=8), dimension(:,:,:,:), pointer, save :: w - - character(len=*), parameter :: loc = 'REFINEMENT:current_density_magnitude()' + real(kind=8), dimension(3) :: dh = 1.0d+00 !------------------------------------------------------------------------------- ! jmax = 0.0e+00 - if (.not. magnetized) return + if (magnetized) then - if (first) then - status = 0 - if (work_in_use) then - write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), & - "Workspace is already occupied!" - return - else - i = 3 * nn**NDIMS - - if (i > nwork) then - write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), & - "Workspace has too be increased!" - nwork = i - deallocate(work) - allocate(work(nwork), stat=status) - if (status /= 0) then - write(error_unit,"('[',a,']: ',a)") trim(loc), & - "Cannot increase the workspace's size!" - return - end if - end if + call curl(dh(:), pdata%q(ibx:ibz,:,:,:), pdata%du(inx:inz,:,:,:)) #if NDIMS == 3 - w(1:3,1:nn,1:nn,1:nn) => work(1:i) -#else /* NDIMS == 3 */ - w(1:3,1:nn,1:nn,1: 1) => work(1:i) + do k = nbl, neu +#endif /* NDIMS == 3 */ + do j = nbl, neu + do i = nbl, neu + + jabs = sum(pdata%du(inx:inz,i,j,k)**2) + + jmax = max(jmax, real(jabs, kind=4)) + + end do ! i = nbl, neu + end do ! j = nbl, neu +#if NDIMS == 3 + end do ! k = nbl, neu #endif /* NDIMS == 3 */ - dh(:) = 1.0d+00 - end if + jmax = sqrt(jmax) - first = .false. end if - work_in_use = .true. - - call curl(dh(:), pdata%q(ibx:ibz,:,:,:), w(:,:,:,:)) - -#if NDIMS == 3 - do k = nbl, neu -#endif /* NDIMS == 3 */ - do j = nbl, neu - do i = nbl, neu - - jabs = sum(w(:,i,j,k)**2) - - jmax = max(jmax, real(jabs, kind=4)) - - end do ! i = nbl, neu - end do ! j = nbl, neu -#if NDIMS == 3 - end do ! k = nbl, neu -#endif /* NDIMS == 3 */ - - work_in_use = .false. - - jmax = sqrt(jmax) - !------------------------------------------------------------------------------- ! end function current_density_magnitude