Nature Language: compareProcNames:Compares the names of 2 processes to check if they are on the same node or not.
  
CPP: int compareProcNames(int rankA, int rankB){ \\n\n  int sameNode; \\n\n  char recvProcName[MPI_MAX_PROCESSOR_NAME]; \\n\n  if (myMPIRank == rankB){ \\n\n    MPI_Send(myProcName, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, rankA, TAG, comm); \\n\n  } \\n\n  else if (myMPIRank == rankA){ \\n\n    MPI_Recv(recvProcName, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, rankB, TAG, comm, &status); \\n\n    if (strcmp(myProcName,recvProcName) == 0){ \\n\n      sameNode = TRUE; \\n\n    } \\n\n    else{ \\n\n      sameNode = FALSE; \\n\n    } \\n\n  } \\n\n  MPI_Bcast(&sameNode, 1, MPI_INT, rankA, comm); \\n\n  return sameNode; \\n\n}",
  
Fortran: FUNCTION compareProcNames(rankA, rankB)\n integer, intent(in) :: rankA, rankB\n logical :: compareProcNames\n character (len = MPI_MAX_PROCESSOR_NAME) :: recvProcName\n\n !Rank B sends procName to Rank A\n IF (myMPIRank == rankB) THEN\n CALL MPI_Send(myProcName, MPI_MAX_PROCESSOR_NAME, &\n MPI_CHARACTER, rankA, tag, comm, ierr)\n ELSE IF (myMPIRank == rankA) THEN\n CALL MPI_Recv(recvProcName, MPI_MAX_PROCESSOR_NAME, &\n MPI_CHARACTER, rankB, tag, comm, status, ierr)\n !rankB compares the two processor names\n IF (myProcName == recvProcName) THEN\n compareProcNames = .true.\n ELSE\n compareProcNames = .false.\n END IF\n END IF\n\n !Rank A then broadcasts its compareProcNames value to \n !the other processes\n CALL MPI_Bcast(compareProcNames, 1, MPI_LOGICAL, rankA, &\n comm, ierr)\n\n END FUNCTION compareProcNames
  