Nature Language: findRank:Finds the MPI ranks which will take part in the pingping or pingpong benchmarks based on the numbers read from the input file.
  
CPP: int findRank(int rankIn){\n    int CalcRank;\n\n    if (rankIn < 0){\n        CalcRank = numMPIprocs + rankIn;\n    } else{\n        CalcRank = rankIn;\n    }\n\n    if (CalcRank > (numMPIprocs-1)){\n        printf(\"Warning: Rank input greater than total process count.\\n\");\n        printf(\"Using Rank = %d\\n\", numMPIprocs-1);\n        CalcRank = numMPIprocs - 1;\n    } else if(CalcRank < 0){\n        printf(\"Warning: MPI process offset greater than total process count.\\n\");\n        printf(\"Using Rank = 0\\n\");\n        CalcRank = 0;\n    }\n\n    return CalcRank;\n}",
  
Fortran: SUBROUTINE findNeighbourRanks()\n integer :: dims(1) !dims array for MPI_Dims_Create\n logical, parameter :: PERIODS(1) = (/.true./), REORDER = .false.\n\n !find a good process distribution\n dims = 0 !zero so that dims_create tries to rearrange\n CALL MPI_Dims_Create(numMPIProcs,1,dims,ierr)\n\n !Create the cartesian topology\n CALL MPI_Cart_Create(comm,1,dims,PERIODS,REORDER, &\n commCart, ierr)\n\n !Find the ranks of left and right neighbour\n CALL MPI_Cart_Shift(commCart, 0, 1, leftNeighbour, &\n rightNeighbour, ierr)\n \n END SUBROUTINE findNeighbourRanks
  