Nature Language: initParallelEnv:Initialises the MPI and OpenMP environments. Finds the total number of MPI processes and OpenMP threads. Also finds the ID of each MPI process and OpenMP thread.
  
CPP: int initParallelEnv() { \n    MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &threadSupport); \n    comm = MPI_COMM_WORLD; \n    MPI_Comm_size(comm, &numMPIprocs); \n    MPI_Comm_rank(comm, &myMPIRank); \n    sizeInteger = sizeof(int); \n    MPI_Get_processor_name(myProcName, &procNameLen); \n\n    // * across node boundaries. \n    setupCommunicators(); \n\n    #pragma omp parallel default(none) \\ \n    shared(numThreads,globalIDarray,myMPIRank) \n    { \n        numThreads = omp_get_num_threads(); \n        myThreadID = omp_get_thread_num(); \n\n        #pragma omp single \n        { \n            globalIDarray = (int *)malloc(numThreads * sizeof(int)); \n        } \n\n        globalIDarray[myThreadID] = (myMPIRank * numThreads) + myThreadID; \n    } \n\n    setParallelInfo(numMPIprocs,threadSupport,numThreads); \n\n    return 0; \n}",
  
Fortran: SUBROUTINE initParallelEnv()\n\n !setup MPI programming environment \n CALL MPI_Init_thread(MPI_THREAD_MULTIPLE,threadSupport,ierr)\n\n comm = MPI_COMM_WORLD\n CALL MPI_Comm_size(comm, numMPIprocs, ierr)\n CALL MPI_Comm_rank(comm, myMPIRank, ierr)\n\n !Find the number of bytes for an int (numMPIprocs)\n CALL MPI_Type_size(MPI_INTEGER, sizeInteger, ierr)\n\n !Find the processor name of each MPI process.\n CALL MPI_Get_processor_name(myProcName, procNameLen, ierr)\n\n !Use processor name to create a communicator across \n !node boundaries.\n CALL setupCommunicators()\n\n !setup OpenMP programming environment\n!$OMP PARALLEL DEFAULT(NONE), &\n!$OMP SHARED(numThreads,globalIDarray,myMPIRank)\n\n numThreads = omp_get_num_threads()\n myThreadID = omp_get_thread_num() + 1 !threadID from 1 to totalThreads\n\n !Allocate space for globalIDarray\n!$OMP SINGLE\n allocate(globalIDarray(numThreads))\n!$OMP END SINGLE\n\n !Calculate the globalID for each thread\n globalIDarray(myThreadID) = (myMPIRank * numThreads) + myThreadID\n\n!$OMP END PARALLEL\n \n END SUBROUTINE initParallelEnv
  