!=========================================================================== ! subroutine der1_pre( ierror, error, upwind, & xbegin,xend,ybegin,yend,zbegin,zend, & bnd1A, bnd3A, bnd3B, bnd4C, bnd6D, & iperx,ipery,iperz, orderi, orderb, & biL, biR, bjL, bjR, bkL, bkR, & fiL, fiR, fjL, fjR, fkL, fkR, & iiL, iiR, ijL, ijR, ikL, ikR, & piL, piR, pjL, pjR, pkL, pkR, & viL, viR, vjL, vjR, vkL, vkR, & dfiL,dfiR,dfjL,dfjR,dfkL,dfkR, & nproLx,nproRx,nproLy,nproRy,nproLz,nproRz, & proL,proR,promax,dx,dy,dz,rdx,rdy,rdz) ! include 'der1_include.h' ! !====================================================================== ! ! Initialize IERROR to zero implying no errors ! ierror = 0 ! ! Boundaries of usable f patch piL = iiL - biL piR = iiR + biR pjL = ijL - bjL pjR = ijR + bjR pkL = ikL - bkL pkR = ikR + bkR ! ! Is the usable patch width larger than the width of f? if( min0(piL-fiL,fiR-piR,pjL-fjL,fjR-pjR,pkL-fkL,fkR-pkR) & .lt. 0) then ierror = -10 error = 'DER_1: Interior + Green width > function width' return endif ! ! Is the interior width larger than the width of df? if( min0(iiL-dfiL,dfiR-iiR,ijL-dfjL,dfjR-ijR,ikL-dfkL,dfkR-ikR) & .lt. 0) then ierror = -20 error = 'DER_1: Interior width > derivative width' return endif ! ! Is the width of vel larger than the width of the interior? if(( min0(iiL-viL,viR-iiR,ijL-vjL,vjR-ijR,ikL-vkL,vkR-ikR) & .lt. 0) .and. (upwind .ne. 0)) then ierror = -30 error = 'DER_1: Interior width > Velocity width' return endif ! ! Have the number of green cells gone negative anywhere? if( min0(biL,biR,bjL,bjR,bkL,bkR) .lt. 0 ) then ierror = -40 error = 'DER_1: Green cell width < zero' return endif ! ! Has the interior width gone negative? if( min0(iiR-iiL,ijR-ijL,ikR-ikL) .lt. 0 ) then ierror = -50 error = 'DER_1: Interior Width < zero' return endif ! ! Has the grid spacing gone negative? if(( dx .le. 0.d0 ) .or. & ( dy .le. 0.d0 ) .or. & ( dz .le. 0.d0 )) then ierror = -60 error = 'DER_1: dx or dy or dz =< zero' return endif ! ! Grid Spacing (reciprocal) rdx = 1.d0/dx rdy = 1.d0/dy rdz = 1.d0/dz ! ! Stencil Widths ! ! Centered stencils ! proL = -1 proR = -1 ! if( upwind .eq. 0) then if( orderi .eq. 2 ) then proL = 1 proR = 1 elseif( orderi .eq. 4 ) then proL = 2 proR = 2 elseif( orderi .eq. 6 ) then proL = 3 proR = 3 elseif( orderi .eq. 8 ) then proL = 4 proR = 4 endif width = proL + 1 + proR endif ! ! Simple upwind stencils ! if( abs(upwind) .eq. 1) then if( orderi .eq. 3 ) then proL = 1 proR = 2 elseif( orderi .eq. 4 ) then proL = 1 proR = 3 elseif( orderi .eq. 5 ) then proL = 2 proR = 3 elseif( orderi .eq. 6 ) then proL = 2 proR = 4 elseif( orderi .eq. 7 ) then proL = 3 proR = 4 endif width = proL + 1 + proR endif ! ! ``Super'' upwind stencils ! if( abs(upwind) .eq. 2) then if( orderi .eq. 4 ) then proL = 0 proR = 4 elseif( orderi .eq. 5 ) then proL = 1 proR = 4 endif width = proL + 1 + proR endif ! if( abs(upwind) .gt. 2 ) then ierror = -70 error = 'DER_1: upwind value too large; No such scheme' return endif ! if( ( proL .lt. 0) .or. ( proR .lt. 0) ) then ierror = -80 error = 'DER_1: No such scheme' return endif ! if( (iperx .lt. 0) .or. ( iperx .gt. 1) .or. & (ipery .lt. 0) .or. ( ipery .gt. 1) .or. & (iperz .lt. 0) .or. ( iperz .gt. 1) ) then ierror = -90 error = 'DER_1: Periodicity flags are set incorrectly' return endif ! ! Find maximum protrusion. ! promax = max0( proL, proR ) ! ! Determine where to begin Interior DO loops and how many ! boundary points need to be closed. Periodic domains ! will always (better) have enough green cells. ! ! X-direction if(( biL .ge. promax ) .or. (iperx .eq. 1)) then nproLx = 0 xbegin = iiL else nproLx = promax - biL xbegin = iiL + nproLx endif ! if(( biR .ge. promax ) .or. (iperx .eq. 1)) then nproRx = 0 xend = iiR else nproRx = promax - biR xend = iiR - nproRx endif ! ! Y-direction ! if(( bjL .ge. promax ) .or. (ipery .eq. 1)) then nproLy = 0 ybegin = ijL else nproLy = promax - bjL ybegin = ijL + nproLy endif ! if(( bjR .ge. promax ) .or. (ipery .eq. 1)) then nproRy = 0 yend = ijR else nproRy = promax - bjR yend = ijR - nproRy endif ! ! Z-direction ! if(( bkL .ge. promax ) .or. (iperz .eq. 1)) then nproLz = 0 zbegin = ikL else nproLz = promax - bkL zbegin = ikL + nproLz endif ! if(( bkR .ge. promax ) .or. (iperz .eq. 1)) then nproRz = 0 zend = ikR else nproRz = promax - bkR zend = ikR - nproRz endif ! ! Set up Boundary stencil coefficients ! bnd1A(1) = -( 1.d0) bnd1A(2) = +( 1.d0) ! bnd3A(1) = -(11.d0/6.d0) bnd3A(2) = +(18.d0/6.d0) bnd3A(3) = -( 9.d0/6.d0) bnd3A(4) = +( 2.d0/6.d0) ! bnd3B(1) = -( 2.d0/6.d0) bnd3B(2) = -( 3.d0/6.d0) bnd3B(3) = +( 6.d0/6.d0) bnd3B(4) = -( 1.d0/6.d0) ! 4E - Centered Difference bnd4C(1) = +( 1.d0/12.d0) bnd4C(2) = -( 8.d0/12.d0) bnd4C(3) = +( 0.d0/12.d0) bnd4C(4) = +( 8.d0/12.d0) bnd4C(5) = -( 1.d0/12.d0) ! 6E - Centered Difference bnd6D(1) = -( 1.d0/60.d0) bnd6D(2) = +( 9.d0/60.d0) bnd6D(3) = -(45.d0/60.d0) bnd6D(4) = -( 0.d0/60.d0) bnd6D(5) = +(45.d0/60.d0) bnd6D(6) = -( 9.d0/60.d0) bnd6D(7) = +( 1.d0/60.d0) ! return end !===========================================================================