Nature Language: findBenchmarkNumber:Finds the ID of the next benchmark which will be executed. Master MPI process reads next line from input file. It then compares it to the benchmark list to find the ID and broadcasts this to the other MPI processes. The function sets the benchmarkNumber variable and also returns the benchmarkNumber.
  
CPP: int findBenchmarkNumber(){\n\tchar benchmarkName[MAXSTRING];\n\tint rankInA, rankInB;\n\tint i;\n\n\t/* Master MPI process reads next line from file */\n\tif (myMPIRank == 0){\n\t\t/* set benchmarkNumber to ERROR before read to allow error\n\t\tcheck */\n\t\tbenchmarkNumber = ERROR;\n\n\t\t/* read next benchmark from file */\n\t\tif (fscanf(inputFile, "%s", benchmarkName) == EOF){\n\t\t\tbenchmarkNumber = FINISHED;\n\t\t}\n\t\telse {\n\t\t\t/* convert benchmarkName to lowercase characters */\n\t\t\tconvertToLowercase(benchmarkName);\n\t\t\t/* ..and check if benchmark name matches. */\n\t\t\tfor (i = 0; i< NUM_BENCHMARKS; i++){\n\t\t\t\tif (strcmp(benchmarkName,benchmarkList[i]) == 0){\n\t\t\t\t\tbenchmarkNumber = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* Check if benchmark Name does not match */\n\t\tif (benchmarkNumber == ERROR){\n\t\t   printf("ERROR: %s does not match any possible benchmarks\\n",benchmarkName);\n\t\t}\n\n\t\t/* Check if pingpong or pingping benchmark */\n\t\tif (benchmarkNumber <= LASTPPID){\n\t\t\t/* Read ranks from input file */\n\t\t\tif (fscanf(inputFile, "%d %d",&rankInA, &rankInB) != 2){\n\t\t\t\tprintf("ERROR: expecting ranks after %s\\n",benchmarkName);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPPRanks[0] = findRank(rankInA);\n\t\t\t\tPPRanks[1] = findRank(rankInB);\n\t\t\t}\n\t\t\t/* Check if PPRanks are the same */\n\t\t\tif (PPRanks[0] == PPRanks[1]){\n\t\t\t\tprintf("Warning: Ranks are the same; benchmark will not work.\\n");\n\t\t\t}\n\n\t\t}\n\t}\n\n\t/* Broadcast benchmarkNumber to other MPI processes */\n\tMPI_Bcast(&benchmarkNumber, 1, MPI_INT, 0, comm);\n\n\t/* If pingpong or pingping benchmark then broadcast ranks of participating processes */\n\tif (benchmarkNumber <= LASTPPID) {\n\t\tMPI_Bcast(PPRanks, 2, MPI_INT, 0, comm);\n\t}\n\n\treturn benchmarkNumber;\n}
  
Fortran: SUBROUTINE findBenchmarkNumber()\n\tcharacter (len = MAXSTRING) :: benchmarkName\n\tinteger :: rankInA, rankInB\n\tinteger :: i\n\n\t!Master MPI process reads next line from file\n\tIF (myMPIRank == 0) THEN\n\t\t!set benchmarkNumber to ERROR before read\n\t\t!to allow error check\n\t\tbenchmarkNumber = ERROR\n\t\t\n\t\t!Read next benchmark from file\n\t\tREAD(10,,IOSTAT=ioStatus) benchmarkName\n\t\t\n\t\t!Check if EOF is reached\n\t\tIF (ioStatus < 0) THEN\n\t\t\tbenchmarkNumber = FINISHED\n\t\tELSE\n\t\t\t!Convert benchmarkName to lowercase characters\n\t\t\tCALL ConvertTolowercase(benchmarkName)\n\t\t\t!..and check if benchmark name matches.\n\t\t\tDO i = 1,NUM_BENCHMARKS\n\t\t\t\tIF (benchmarkName == benchmarkList(i)) THEN\n\t\t\t\t\tbenchmarkNumber = i\n\t\t\t\tEND IF\n\t\t\tEND DO\n\t\tEND IF\n\n\t\t!Check if benchmark Name does not match\n\t\tIF (benchmarkNumber == ERROR) THEN\n\t\t\twrite(,) 'ERROR: ', trim(benchmarkName) , &\n\t\t\t\t'does not match any possible benchmarks'\n\t\tEND IF\n\n\t\t!Check if pingpong or pingping benchmark\n\t\tIF (benchmarkNumber <= LASTPPID) THEN\n\t\t\t!Read ranks from input file\n\t\t\tREAD(10,,IOSTAT=ioStatus) rankInA, rankInB\n\t\t\t\n\t\t\t!Check if error in read\n\t\t\tIF (ioStatus < 0) THEN\n\t\t\t\twrite(,) 'ERROR: expecting ranks after ',&\n\t\t\t\t\ttrim(benchmarkName)\n\t\t\tELSE !if no error find actual MPI ranks\n\t\t\t\tPPRanks(1) = findRank(rankInA)\n\t\t\t\tPPRanks(2) = findRank(rankInB)\n\t\t\tEND IF\n\t\t\t!Check if PPRanks are the same\n\t\t\tIF (PPRanks(1) == PPRanks(2)) THEN\n\t\t\t\twrite(,) 'Warning: Ranks are the same; benchmark will',&\n\t\t\t\t\t' not work.'\n\t\t\tEND IF\n\t\tEND IF\n\t\t\n\tEND IF\n\n\t!Broadcast benchmarkNumber to other MPI processes\n\tCALL MPI_Bcast(benchmarkNumber, 1, MPI_INTEGER, 0, &\n\t\tcomm, ierr)\n\n\t!If pingpong or pingping benchmark broadcast ranks of\n\t!participating processes.\n\tIF (benchmarkNumber <= LASTPPID) THEN\n\t\tCALL MPI_Bcast(PPRanks, 2, MPI_INTEGER, 0, comm, ierr)\n\tEND IF\n\nEND SUBROUTINE findBenchmarkNumber
  