<div class="gmail_quote">After the help last week on openmp, I got inspired and bought a dual-quad opteron machine for the department to show 8-way scaling for my students (&quot;Hey, its much cheaper than something new in the optics lab&quot;, my dept. chair laughed).<br>
<br>I&#39;ve been working on said machine over the past few days and found something really weird in an OpenMP example program I descrobed to the list.<br><br>The machine is a dual-proc AMD Opteron 2350, Tyan n3600T (S2937) mainboard, w/ 8GB ram.&nbsp; Initially, I installed the i386 version of Scientific Linux 5.2, but then realized that only half of the RAM was usable, and re-installed SL5.2 x86_64 this morning.<br>

<br>The example program is appended to the end of this email.&nbsp; Again, it is a 2-d finite-difference solution to the laplace equation (the context being to &quot;predict&quot; lightning strikes based on the potential between the ground and some clouds overhead).<br>

<br>The program scales beautifully up to OMP_NUM_THREADS~6 or 7, but when I set the number of threads to 8, something weird happens, and instead of taking the normal 241 iterations to converge, the program converges after 1 step.&nbsp; This reeks of numerical instability to me, but my programming experience in x86_64 is very limited.&nbsp; <br>

<br>I&#39;m using gfortran, with the simple compile string, <br>&nbsp;&nbsp;&nbsp;&nbsp; gfortran clouds_example_OpenMP.f90 -m64 -fopenmp<br><br>Any insight into what obvious mistake I&#39;m making would be wonderful!&nbsp; <br><br>The stability of the output seems erratic to me.&nbsp; Sometimes when OMP_NUM_THREADS=7 the result converges normally after 241 iterations and at other times, the result converges after 1 iteration (indicating some sort of problem with hardware???)<br>

<br>This didn&#39;t occur yesterday when the machine was running SL5.2, i386.<br><br><br><br><br>Simulation Output:<br><br>[nmoore@aykroyd clouds]$ OMP_NUM_THREADS=1<br>[nmoore@aykroyd clouds]$ export OMP_NUM_THREADS<br>
[nmoore@aykroyd clouds]$ ./a.out <br>
&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>&nbsp;There are&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 threads<br>...<br>convergence criteria is \Delta V &lt;&nbsp;&nbsp; 0.250000003725290&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; iterations necessary,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 241<br>&nbsp; initialization time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>

&nbsp; simulation time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 57<br><br><br><br><br>[nmoore@aykroyd clouds]$ OMP_NUM_THREADS=2<br>[nmoore@aykroyd clouds]$ export OMP_NUM_THREADS<br>[nmoore@aykroyd clouds]$ ./a.out <br>&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>

&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;There are&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 threads<br>&nbsp;...<br>convergence criteria is \Delta V &lt;&nbsp;&nbsp; 0.250000003725290&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; iterations necessary,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 241<br>&nbsp; initialization time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>

&nbsp; simulation time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 28<br><br><br><br><br>[nmoore@aykroyd clouds]$ OMP_NUM_THREADS=4<br>[nmoore@aykroyd clouds]$ export OMP_NUM_THREADS<br>[nmoore@aykroyd clouds]$ ./a.out <br>&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3<br>

&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<br>&nbsp;There are&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 threads<br>&nbsp;...<br>convergence criteria is \Delta V &lt;&nbsp;&nbsp; 0.250000003725290&nbsp;&nbsp;&nbsp;&nbsp; <br>

&nbsp; iterations necessary,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 241<br>&nbsp; initialization time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>&nbsp; simulation time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 14<br><br><br><br><br>[nmoore@aykroyd clouds]$ OMP_NUM_THREADS=8<br>[nmoore@aykroyd clouds]$ export OMP_NUM_THREADS<br>

[nmoore@aykroyd clouds]$ ./a.out <br>&nbsp;Hello World from thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<br>&nbsp;...<br>
convergence criteria is \Delta V &lt;&nbsp;&nbsp; 0.250000003725290&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; iterations necessary,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp; initialization time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>&nbsp; simulation time,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br><br>Code listing:<br><br>nmoore@aykroyd clouds]$ cat clouds_example_OpenMP.f90 <br>

!<br>!<br>use omp_lib<br>!<br>IMPLICIT NONE<br>integer,parameter::Nx=2000<br>integer,parameter::Ny=2000<br>real*8 v(Nx,Ny), dv(Nx,Ny)<br>integer boundary(Nx,Ny)<br>integer i,j,converged,i1,i2<br>integer t0,t1,t2<br>real*8 convergence_v, v_cloud, v_ground, max_dv<br>

real*8 bump_P,old_v<br>real*8 Lx,Ly,dx,dy,v_y<br>!<br>real*8 lightning_rod_center, lightning_rod_height<br>!<br>real*8 house_center, house_height, house_width <br>integer num_iterations<br>! <br>integer:: id, nthreads<br>

!$omp parallel private(id)<br>id = omp_get_thread_num()<br>write (*,*) &#39;Hello World from thread&#39;, id<br>!$omp barrier<br>if ( id == 0 ) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nthreads = omp_get_num_threads()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (*,*) &#39;There are&#39;, nthreads, &#39;threads&#39;<br>

end if<br>!$omp end parallel<br><br>! initial time<br>t0 = secnds(0.0)<br><br>dx =0.1d0 ! differential lengths, m<br>dy =0.1d0<br>Lx = Nx*dx ! system sizes, m<br>Ly = Ny*dy<br><br>print *,&quot;\nSimulation has bounds:\n\tX: 0,&quot;,Lx,&quot;\n\tY: 0,&quot;,Ly<br>

print *,&quot;\tNx = &quot;,Nx,&quot;\n\tNy = &quot;,Ny<br>print *,&quot;\tdx = &quot;,dx,&quot;\n\tdy = &quot;,dy<br><br>v_cloud = -10000.d0&nbsp;&nbsp;&nbsp;&nbsp; ! volts<br>v_ground = 0.d0<br><br>! initialize the the boundary conditions<br>

!<br>! first, set the solution function (v), to look like a <br>! parallel-plate capacitor<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; note that there is one large parallel section and several <br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parallel do&#39;s inside that region<br>!$OMP PARALLEL<br>

!<br>!$OMP DO<br>!$OMP&amp; SHARED(Nx,Ny,boundary,v_cloud,v_ground,Ly,dy,v)<br>!$OMP&amp; PRIVATE(i,j)<br>do j=1,Ny<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=1,Nx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(i,j)=0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v(i,j) = v_ground + (v_cloud-v_ground)*(j*dy/Ly)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>end do<br>!$OMP END DO<br>!<br>!$OMP DO<br>!$OMP&amp; SHARED(Nx,Ny,boundary) <br>!$OMP&amp; PRIVATE(i)<br>do i=1,Nx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(i,1)=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ! we need to ensure that the edges of <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(i,Ny)=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ! the domain are held as boundary<br>

end do<br>!$OMP END DO<br>!<br>!$OMP DO <br>!$OMP&amp; SHARED(boundary,Nx) <br>!$OMP&amp; PRIVATE(j)<br>do j=1,Ny<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(1,j)=1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(Nx,j)=1<br>end do<br>!$OMP END DO<br>!$OMP END PARALLEL<br>
<br>
<br>! set up an interesting feature on the lower boundary&nbsp; <br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do this in parallel with SECTIONS directive<br>!<br>!$OMP PARALLEL<br>!$OMP&amp; SHARED(v,boundary,Nx,Ny,dx,dy,Lx,Ly,lightning_rod_height)<br>!$OMP&amp; PRIVATE(lightning_rod_center,house_center,house_height,house_width))<br>

!$OMP SECTIONS<br><br>!$OMP&nbsp; SECTION <br>! Lightning_rod<br>lightning_rod_center = Lx*0.6d0<br>lightning_rod_height = 5.0d0<br>call create_lightning_rod(v_ground,lightning_rod_center,lightning_rod_height,dx,dy,Nx,Ny,v,boundary)<br>

<br>!$OMP&nbsp; SECTION <br>lightning_rod_center = Lx*0.5d0<br>call create_lightning_rod(v_ground,lightning_rod_center,lightning_rod_height,dx,dy,Nx,Ny,v,boundary)<br><br>!$OMP&nbsp; SECTION <br>lightning_rod_center = Lx*0.7d0<br>
call create_lightning_rod(v_ground,lightning_rod_center,lightning_rod_height,dx,dy,Nx,Ny,v,boundary)<br>
<br>!$OMP&nbsp; SECTION <br>! house<br>house_center = 0.4d0*Lx<br>house_height = 5.0d0 <br>house_width = 5.0d0<br>call create_house(v_ground,house_center,house_height,house_width,dx,dy,Nx,Ny,v,boundary)<br><br>!$OMP END SECTIONS <br>

!$OMP END PARALLEL<br><br>! initialization done<br>t1 = secnds(0.0)<br><br><br><br><br><br>! main solution iteration<br>!<br>! repeat the recursion relation until the maximum change <br>! from update to update is less than a convergence epsilon,<br>

convergence_v = (0.05)*dabs(v_ground-v_cloud)/(1.d0*Ny)<br>print *,&quot;\nconvergence criteria is \Delta V &lt; &quot;,convergence_v<br>num_iterations = 0<br><br>!<br>! iteration implemented with a goto&nbsp; or a do-while<br>

converged=0<br>do while( converged .eq. 0)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; converged = 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num_iterations = num_iterations + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP PARALLEL <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP DO <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP&amp; PRIVATE(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP&amp; SHARED(Ny,Nx,dv,v,boundary))<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do j=2,(Ny-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=2,(Nx-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dv(i,j) = 0.25d0*(v(i-1,j)+v(i+1,j)+v(i,j+1)+v(i,j-1)) - v(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dv(i,j) = dv(i,j)*(1.d0-DFLOAT(boundary(i,j)))<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END DO<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_dv = 0.d0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP DO <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP&amp; PRIVATE(i,j) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP&amp; SHARED(NX,NY,dv,v))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP&amp; REDUCTION(MAX:max_dv)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do j=2,(Ny-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=2,(Nx-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v(i,j) = v(i,j) + dv(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(dv(i,j) .gt. max_dv) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_dv = dv(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END DO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END PARALLEL<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(max_dv .ge. convergence_v) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; converged = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif<br><br>end do<br><br><br>
<br>
<br><br><br><br>! simulation finished<br>t2 = secnds(0.0)<br><br>print *,&quot; iterations necessary, &quot;,num_iterations<br>print *,&quot; initialization time, &quot;,t1-t0<br>print *,&quot; simulation time, &quot;,t2-t1<br>

<br><br>open(unit=10,file=&quot;v_output.dat&quot;)<br>write(10,*) &quot;# x\ty\tv(x,y)&quot;<br>do j=1,Ny<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !do i=1,Nx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ! skipping the full array print to save execution time<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ! the printed data file is normally sent to gnuplot w/ splot<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i=10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (10,*) i*dx,j*dy,v(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !enddo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (10,*)&quot; &quot;<br>end do<br>close(10)<br><br><br>stop<br>end<br><br><br><br><br>subroutine create_lightning_rod(v_ground,lightning_rod_center,lightning_rod_height,dx,dy,Nx,Ny,v,boundary)<br>

IMPLICIT NONE<br>integer Nx, Ny,j,boundary(Nx,Ny)<br>integer j_limit<br>integer index_lightning_rod_center<br>real*8 v(Nx,Ny)<br>real*8 lightning_rod_center,lightning_rod_height<br>real*8 dx, dy, v_ground<br><br>index_lightning_rod_center = lightning_rod_center/dx<br>

j_limit = lightning_rod_height/dy<br>do j=1,j_limit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v(index_lightning_rod_center,j) = v_ground<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(index_lightning_rod_center,j) = 1<br>end do<br><br>print *,&quot;Created a lightning rod of height &quot;,lightning_rod_height<br>

print *,&quot;\ty_index &quot;,j_limit<br>print *,&quot;\tx-position &quot;,lightning_rod_center<br>print *,&quot;\tx_index &quot;,index_lightning_rod_center<br><br><br>end subroutine<br><br><br><br><br><br><br><br>subroutine create_house(v_ground,house_center,house_height,house_width,dx,dy,Nx,Ny,v,boundary)<br>

IMPLICIT NONE<br>integer Nx, Ny, boundary(Nx,Ny)<br>real*8 v(Nx,Ny)<br>real*8 v_ground, dx, dy<br>integer i,j,i_limit,j_limit, index_house_center<br>real*8 house_center,house_height,house_width<br><br>index_house_center = house_center/dx<br>

i_limit = 0.5d0*house_width/dx <br>j_limit = house_height/dy<br>do j=1,j_limit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=(index_house_center-i_limit),(index_house_center+i_limit)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v(i,j) = v_ground<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boundary(i,j) = 1<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>end do<br><br>print *,&quot;Created a house of height &quot;,house_height<br>print *,&quot;\ty_index &quot;,j_limit<br>print *,&quot;\twidth &quot;,house_width<br>print *,&quot;\thouse bounds: &quot;,index_house_center-i_limit,index_house_center+i_limit<br>

<br>end subroutine<br><font color="#888888"><br>-- <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - - <br>Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - -<br>


</font></div><br><br clear="all"><br>-- <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - - <br>Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - -<br>

<br />-- 
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.