Nature Language: testScatterGather:Verifies that the scatter and gahter benchmarks worked correctly.
  
CPP: int testScatterGather(int sizeofBuffer, int benchmarkType){\\n\n    int i, startVal;\\n\n    int testFlag, reduceFlag;\\n\n    int *testBuf;\\n\n    testFlag = TRUE;\\n\n    testBuf = (int *) malloc (sizeofBuffer * sizeof(int));\\n\n    if (benchmarkType == SCATTER){\\n\n        startVal = (myMPIRank * sizeofBuffer) + SCATTERSTARTVAL;\\n\n    } else if (benchmarkType == GATHER){\\n\n        startVal = GATHERSTARTVAL;\\n\n    }\\n\n    for (i=0; i<sizeofBuffer; i++){\\n\n        testBuf[i] = startVal + i;\\n\n    }\\n\n    for (i=0; i<sizeofBuffer; i++){\\n\n        if (finalBuf[i] != testBuf[i]){\\n\n            testFlag = FALSE;\\n\n        }\\n\n    }\\n\n    if (benchmarkType == SCATTER){\\n\n        MPI_Reduce(&testFlag, &reduceFlag, 1, MPI_INT, MPI_LAND, 0, comm);\\n\n        if (myMPIRank == 0){\\n\n            setTestOutcome(reduceFlag);\\n\n        }\\n\n    } else if (benchmarkType == GATHER){\\n\n        setTestOutcome(testFlag);\\n\n    }\\n\n    free(testBuf);\\n\n    return 0;\\n\n}",
  
Fortran: SUBROUTINE testScatterGather(sizeofBuffer, benchmarkType)\ninteger, intent(in) :: sizeofBuffer, benchmarkType\ninteger :: i\ninteger :: startVal\nlogical :: testFlag, reduceFlag\n\n!initialise testFlag to true\ntestFlag = .true.\n\n!Allocate space for testBuf\nallocate(testBuf(sizeofBuffer))\n\nIF (benchmarkType == SCATTER) THEN\n!Find the start scatter value for each MPI process\nstartVal = (myMPIRank*sizeofBuffer) + SCATTERSTARTVAL\nELSE IF (benchmarkType == GATHER) THEN\n!startVal is GATHERSTARTVAL\nstartVal = GATHERSTARTVAL\nEND IF\n\n!Fill testBuf with correct values\nDO i = 1, sizeofBuffer\ntestBuf(i) = startVal + i\nEND DO\n\n!Compare each element of finalBuf with testBuf\nDO i = 1, sizeofBuffer\nIF (finalBuf(i) /= testBuf(i)) THEN\ntestFlag = .false.\nEND IF\nEND DO\n\n!For scatter reduce testFlag into master with\n!logical AND operator\nIF (benchmarkType == SCATTER) THEN\nCALL MPI_Reduce(testFlag, reduceFlag, 1, MPI_LOGICAL, &\nMPI_LAND, 0, comm, ierr)\n!Master then sets testOutcome using reduceFlag\nIF (myMPIRank == 0) THEN\nCALL setTestOutcome(reduceFlag)\nEND IF\nELSE IF (benchmarkType == GATHER) THEN\nCALL setTestOutcome(testFlag)\nEND IF\n\ndeallocate(testBuf)\n\nEND SUBROUTINE testScatterGather
  