[Carpet] cctk_{origin, delta}_space not set properly in singlemap mode

Jonathan Thornburg jthorn at aei.mpg.de
Mon Jul 3 19:16:22 CEST 2006


Hi, Erik,

You may recall that in late May (in a thread starting at
  http://lists.carpetcode.org/archives/developers/2006-May/001647.html
and with your message
  http://lists.carpetcode.org/archives/developers/2006-May/001659.html
being the eventual solution), we discussed a problem I had where
CCTK_ORIGIN_SPACE() and CCTK_DELTA_SPACE() were returning wrong
values in a multipatch simulation.

I now have a new variant of this problem. :(

I am (now) using a fresh darcs checkout from a few hours ago, and
current-CVS Cactus flesh and all thorns.  I schedule the following
code in level mode:

// this function is called in LEVEL mode by the Cactus scheduler
extern "C"
  void TestCarpetGridInfo_test(CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
cGH* GH = cctkGH;

assert(Carpet::is_level_mode());

        for (int map_number = 0 ; map_number < N_maps ; ++map_number)
        {
        // switch Carpet to this map
        Carpet::enter_singlemap_mode(GH, map_number);

        do_singlemap_stuff(GH, map_number);

        Carpet::leave_singlemap_mode(GH);
        }
}

//******************************************************************************

// this function is called in SINGLEMAP mode for each patch (= Carpet map)
namespace {
void do_singlemap_stuff(cGH* GH, const int map_number)
{
assert(Carpet::is_singlemap_mode());

cGH* cctkGH = GH;               // magic variable name for CCTK_*() macros
DECLARE_CCTK_ARGUMENTS;         // set up for CCTK_*() macros

printf("in singlemap mode, map_number=%d\n", map_number);
printf("   cctk_origin_space[]=(%g,%g,%g)\n",
       double(GH->cctk_origin_space[0]), double(GH->cctk_origin_space[1]),
                                         double(GH->cctk_origin_space[2]));
printf("   cctk_delta_space[]=(%g,%g,%g)\n",
       double(GH->cctk_delta_space[0]), double(GH->cctk_delta_space[1]),
                                        double(GH->cctk_delta_space[2]));
printf("   CCTK_ORIGIN_SPACE()=(%g,%g,%g)\n",
       double(CCTK_ORIGIN_SPACE(0)), double(CCTK_ORIGIN_SPACE(1)),
                                     double(CCTK_ORIGIN_SPACE(2)));
printf("   CCTK_DELTA_SPACE()=(%g,%g,%g)\n",
       double(CCTK_DELTA_SPACE(0)), double(CCTK_DELTA_SPACE(1)),
                                    double(CCTK_DELTA_SPACE(2)));
}
          }

Everything is fine for map_number=0, but the values are all wrong
for the other 5 Carpet maps:

in singlemap mode, map_number=0
   cctk_origin_space[]=(-0.934998,-0.934998,0.04)
   cctk_delta_space[]=(0.0747998,0.0747998,0.04)
   CCTK_ORIGIN_SPACE()=(-0.934998,-0.934998,0.04)
   CCTK_DELTA_SPACE()=(0.0747998,0.0747998,0.04)
in singlemap mode, map_number=1
   cctk_origin_space[]=(-1.99335,1.07369e-268,1.29566e-268)
   cctk_delta_space[]=(1.15389e-269,1.74191e+63,5.83549e-314)
   CCTK_ORIGIN_SPACE()=(-1.99335,1.07369e-268,1.29566e-268)
   CCTK_DELTA_SPACE()=(1.15389e-269,1.74191e+63,5.83549e-314)
in singlemap mode, map_number=2
   cctk_origin_space[]=(-1.99335,1.07369e-268,1.29566e-268)
   cctk_delta_space[]=(1.15389e-269,1.74191e+63,5.83549e-314)
   CCTK_ORIGIN_SPACE()=(-1.99335,1.07369e-268,1.29566e-268)
   CCTK_DELTA_SPACE()=(1.15389e-269,1.74191e+63,5.83549e-314)
in singlemap mode, map_number=3
   cctk_origin_space[]=(-1.99335,1.07369e-268,1.29566e-268)
   cctk_delta_space[]=(1.15389e-269,1.74191e+63,5.83549e-314)
   CCTK_ORIGIN_SPACE()=(-1.99335,1.07369e-268,1.29566e-268)
   CCTK_DELTA_SPACE()=(1.15389e-269,1.74191e+63,5.83549e-314)
in singlemap mode, map_number=4
   cctk_origin_space[]=(-1.99335,1.07369e-268,1.29566e-268)
   cctk_delta_space[]=(1.15389e-269,1.74191e+63,5.83549e-314)
   CCTK_ORIGIN_SPACE()=(-1.99335,1.07369e-268,1.29566e-268)
   CCTK_DELTA_SPACE()=(1.15389e-269,1.74191e+63,5.83549e-314)
in singlemap mode, map_number=5
   cctk_origin_space[]=(-1.99335,1.07369e-268,1.29566e-268)
   cctk_delta_space[]=(1.15389e-269,1.74191e+63,5.83549e-314)
   CCTK_ORIGIN_SPACE()=(-1.99335,1.07369e-268,1.29566e-268)
   CCTK_DELTA_SPACE()=(1.15389e-269,1.74191e+63,5.83549e-314)

This is running on an AEI xeon, compiled with Intel 8 compilers.
(I get similar results on my laptop with gcc, though the wrong
values are different, suggesting that the problem may again be
the accessing of uninitialized memory.)

I can understand how  cctk_origin_space[]  and  CCTK_ORIGIN_SPACE()
might not be meaningful in singlemap mode -- they may vary from one
component to another.  But as I understand it,  cctk_delta_space[]
and CCTK_DELTA_SPACE() are necessarily identical from one component
to another (in the same map, at the same refinement level), so it
should be valid to access them in singlemap mode.


Attached are the offending source file (for easy reading), and a
tarball of the full test thorn (which has just this one test file
and minimal .ccl files) including the par files to produce the above
output.

I think this problem may be a fallout from the last months changes
to cctk_delta_space in global mode, but I'm not sure where the fix
should lie.  Suggestions?

thanks, ciao,

-- 
-- Jonathan Thornburg <jthorn at aei.mpg.de>      
   Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut),
   Golm, Germany, "Old Europe"     http://www.aei.mpg.de/~jthorn/home.html      
   "Washing one's hands of the conflict between the powerful and the
    powerless means to side with the powerful, not to be neutral."
                                      -- quote by Freire / poster by Oxfam
-------------- next part --------------
#include <cstdio>
#include <cassert>

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

#include "carpet.hh"

using std::printf;
#define then	/* empty */

// prototypes
namespace {
void do_singlemap_stuff(cGH* GH, int map_number, bool test_local_mode);
void do_local_stuff(cGH* GH, int map_number, int component_number);
	  };

//******************************************************************************

// this function is called in LEVEL mode by the Cactus scheduler
extern "C"
  void TestCarpetGridInfo_test(CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
cGH* GH = cctkGH;

assert(Carpet::is_level_mode());

	for (int map_number = 0 ; map_number < N_maps ; ++map_number)
	{
	// switch Carpet to this map
	Carpet::enter_singlemap_mode(GH, map_number);

	do_singlemap_stuff(GH, map_number, (test_local_mode != 0));

	Carpet::leave_singlemap_mode(GH);
	}
}

//******************************************************************************

// this function is called in SINGLEMAP mode for each patch (= Carpet map)
namespace {
void do_singlemap_stuff(cGH* GH, const int map_number, bool test_local_mode)
{
assert(Carpet::is_singlemap_mode());

cGH* cctkGH = GH;		// magic variable name for CCTK_*() macros
DECLARE_CCTK_ARGUMENTS;		// set up for CCTK_*() macros

printf("in singlemap mode, map_number=%d\n", map_number);
printf("   cctk_origin_space[]=(%g,%g,%g)\n",
       double(GH->cctk_origin_space[0]), double(GH->cctk_origin_space[1]),
					 double(GH->cctk_origin_space[2]));
printf("   cctk_delta_space[]=(%g,%g,%g)\n",
       double(GH->cctk_delta_space[0]), double(GH->cctk_delta_space[1]),
					double(GH->cctk_delta_space[2]));
printf("   CCTK_ORIGIN_SPACE()=(%g,%g,%g)\n",
       double(CCTK_ORIGIN_SPACE(0)), double(CCTK_ORIGIN_SPACE(1)),
				     double(CCTK_ORIGIN_SPACE(2)));
printf("   CCTK_DELTA_SPACE()=(%g,%g,%g)\n",
       double(CCTK_DELTA_SPACE(0)), double(CCTK_DELTA_SPACE(1)),
				    double(CCTK_DELTA_SPACE(2)));

if (test_local_mode)
   then {
	using namespace Carpet;		// needed for magic Carpet macros below
		BEGIN_LOCAL_COMPONENT_LOOP(GH, CCTK_GF)
		{
		assert(Carpet::is_local_mode());
		const int component_number = Carpet::component;

		do_local_stuff(GH, map_number, component_number);
		}
		END_LOCAL_COMPONENT_LOOP;
	}
}
	  }

//******************************************************************************

namespace {
void do_local_stuff(cGH* GH, int map_number, int component_number)
{
assert(Carpet::is_local_mode());

cGH* cctkGH = GH;		// magic variable name for CCTK_*() macros
DECLARE_CCTK_ARGUMENTS;		// set up for CCTK_*() macros

printf("in local mode, map_number=%d component_number=%d:\n",
       map_number, component_number);

printf("   cctk_origin_space[]=(%g,%g,%g)\n",
       double(GH->cctk_origin_space[0]), double(GH->cctk_origin_space[1]),
					 double(GH->cctk_origin_space[2]));
printf("   cctk_delta_space[]=(%g,%g,%g)\n",
       double(GH->cctk_delta_space[0]), double(GH->cctk_delta_space[1]),
					double(GH->cctk_delta_space[2]));
printf("   CCTK_ORIGIN_SPACE()=(%g,%g,%g)\n",
       double(CCTK_ORIGIN_SPACE(0)), double(CCTK_ORIGIN_SPACE(1)),
				     double(CCTK_ORIGIN_SPACE(2)));
printf("   CCTK_DELTA_SPACE()=(%g,%g,%g)\n",
       double(CCTK_DELTA_SPACE(0)), double(CCTK_DELTA_SPACE(1)),
				    double(CCTK_DELTA_SPACE(2)));
}
	  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestCarpetGridInfo.tar.gz
Type: application/x-gzip
Size: 5187 bytes
Desc: tarball of test thorn, including par files & sample output
Url : /archives/developers/attachments/20060703/d1a91edd/attachment.bin 


More information about the developers mailing list