From 20b300ab74b069f9847d18c5e410e94914ed8cdd Mon Sep 17 00:00:00 2001
From: Grzegorz Kowal <grzegorz@gkowal.info>
Date: Fri, 27 Jul 2012 16:02:07 -0300
Subject: [PATCH] Use variables from COORDINATES in module MESH.

Remove dependency on module CONFIG.
---
 src/makefile |  4 ++--
 src/mesh.F90 | 32 ++++++++++++++------------------
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/makefile b/src/makefile
index 76d7843..3d04e05 100644
--- a/src/makefile
+++ b/src/makefile
@@ -221,8 +221,8 @@ integrals.o     : integrals.F90 blocks.o config.o coordinates.o evolution.o    \
 interpolation.o : interpolation.F90 blocks.o config.o variables.o
 io.o            : io.F90 blocks.o coordinates.o error.o evolution.o mpitools.o \
                   random.o scheme.o variables.o
-mesh.o          : mesh.F90 blocks.o config.o coordinates.o error.o             \
-                  interpolation.o mpitools.o problem.o variables.o
+mesh.o          : mesh.F90 blocks.o coordinates.o error.o interpolation.o      \
+                  mpitools.o problem.o variables.o
 mpitools.o      : mpitools.F90 timers.o
 parameters.o    : parameters.F90 mpitools.o
 problem.o       : problem.F90 blocks.o constants.o coordinates.o mpitools.o    \
diff --git a/src/mesh.F90 b/src/mesh.F90
index 0879089..8fc5be4 100644
--- a/src/mesh.F90
+++ b/src/mesh.F90
@@ -52,8 +52,8 @@ module mesh
   subroutine initialize_mesh(flag)
 
     use blocks     , only : datablock_set_dims
-    use config     , only : toplev, in, jn, kn, im, jm, km, ncells, rdims, ng
     use coordinates, only : xmin, xmax, ymin, ymax, zmin, zmax
+    use coordinates, only : toplev, im, jm, km
     use mpitools   , only : master, nprocs
     use variables  , only : nqt, nvr
 
@@ -153,8 +153,7 @@ module mesh
     use blocks  , only : refine_block, deallocate_datablock
     use blocks  , only : nchild, nsides, nfaces
     use blocks  , only : get_mblocks, get_nleafs
-    use config  , only : minlev, maxlev, rdims
-    use coordinates, only : res
+    use coordinates, only : minlev, maxlev, res
     use error   , only : print_info, print_error
     use mpitools, only : master, nproc, nprocs
     use problem , only : init_domain, init_problem, check_ref
@@ -430,8 +429,7 @@ module mesh
                         , refine_block, derefine_block, append_datablock       &
                         , associate_blocks, deallocate_datablock
     use blocks   , only : get_nleafs
-    use config   , only : minlev, maxlev, toplev, im, jm, km
-    use coordinates, only : res
+    use coordinates, only : minlev, maxlev, toplev, im, jm, km, res
     use error    , only : print_info, print_error
 #ifdef MPI
     use mpitools , only : reduce_sum_integer_array
@@ -909,7 +907,7 @@ module mesh
     use blocks   , only : block_meta, block_data, list_meta, list_data
     use blocks   , only : get_nleafs, append_datablock, deallocate_datablock   &
                         , associate_blocks
-    use config   , only : im, jm, km
+    use coordinates, only : im, jm, km
     use mpitools , only : send_real_array, receive_real_array
     use mpitools , only : nprocs, nproc
     use variables, only : nqt
@@ -1042,8 +1040,8 @@ module mesh
   subroutine prolong_block(pblock)
 
     use blocks       , only : block_meta, block_data, nchild
-    use config       , only : ng, nh, in, jn, kn, im, jm, km
-    use config       , only : ib, ie, jb, je, kb, ke
+    use coordinates  , only : ng, nh, in, jn, kn, im, jm, km
+    use coordinates  , only : ib, ie, jb, je, kb, ke
     use interpolation, only : minmod
     use variables    , only : nqt
 
@@ -1214,14 +1212,14 @@ module mesh
 !
   subroutine restrict_block(pblock)
 
-    use blocks       , only : block_meta, block_data, nchild
-    use config       , only : ng, in, ih, im, ib, ie, nh, jn, jh, jm, jb, je   &
-                                , kn, kh, km, kb, ke
-    use variables    , only : nfl
+    use blocks     , only : block_meta, block_data, nchild
+    use coordinates, only : ng, nh, in, jn, kn, im, jm, km
+    use coordinates, only : ih, jh, kh, ib, jb, kb, ie, je, ke
+    use variables  , only : nfl
 #ifdef MHD
-    use variables    , only : ibx, iby, ibz
+    use variables  , only : ibx, iby, ibz
 #ifdef GLM
-    use variables    , only : iph
+    use variables  , only : iph
 #endif /* GLM */
 #endif /* MHD */
 
@@ -1403,8 +1401,7 @@ module mesh
 
     use blocks  , only : block_meta, list_meta
     use blocks  , only : get_mblocks, get_nleafs
-    use config  , only : ncells, nghost, toplev
-    use coordinates, only : effres
+    use coordinates, only : ng, im, jm, km, toplev, effres
     use mpitools, only : master, nprocs
 
     implicit none
@@ -1450,8 +1447,7 @@ module mesh
 ! calculate the coverage
 !
       cov = (1.0 * nl) / tblocks
-      eff = (1.0 * nl * (ncells + 2 * nghost)**NDIMS)                          &
-                                       / product(effres(1:NDIMS) + 2 * nghost)
+      eff = 1.0 * nl * (im * jm * km) / product(effres(1:NDIMS) + 2 * ng)
 
 ! get the block level distribution
 !