Scenario_mpiDebug.cpp 1.26 KB
Newer Older
1
#include "common/Scenarios.h"
2
3
4
#ifdef DISTRIBUTED
	#include <mpi.h>
#endif
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

SceneControls& Scenario_mpiDebug::provideSceneControls()
{
	//does 3 iterations (but w/o agents)
	SceneControls::Constants myConstants;
	myConstants.stopTime = myConstants.initTime + 3*myConstants.incrTime;

	class mySceneControl: public SceneControls
	{
	public:
		mySceneControl(Constants& c): SceneControls(c) {}

		void updateControls(const float currTime) override
		{
			//execute the following own code after every iteration

			if (currTime == 0.1f)
			{
				DEBUG_REPORT("empty example one-time adjustment...");
			}
		}
	};

	mySceneControl* ctrl = new mySceneControl(myConstants);
	return *ctrl;
}


void Scenario_mpiDebug::initializeScene()
{
	DEBUG_REPORT("disabling wait for key");
	params.disableWaitForUserPrompt();
}


void Scenario_mpiDebug::initializeAgents(FrontOfficer*,int p,int P)
{
42
	DEBUG_REPORT("FOs slice=" << p << "/" << P);
43
44
45

#ifdef DISTRIBUTED
	//code that gets compiled only in MPI (DISTRIBUTED) version
46
47
48
49
50
51
52
53
54
55
56

	int len;
	int rank, size;
	char node[MPI_MAX_PROCESSOR_NAME];

	MPI_Comm_rank(MPI_COMM_WORLD,&rank);
	MPI_Comm_size(MPI_COMM_WORLD,&size);
	MPI_Get_processor_name(node,&len);

	REPORT("Hello world! from MPI true rank " << rank << " of " << size
	    << " on host " << node);
57
58
#endif
}