+/**
+ * @brief Prepares the current process for termination.
+ */
+void smpi_process_finalize(void)
+{
+ // wait for all pending asynchronous comms to finish
+ while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
+ SIMIX_req_process_sleep(1);
+ }
+}
+
+int smpi_process_argc(void) {
+ smpi_process_data_t data = smpi_process_data();
+
+ return data->argc ? *(data->argc) - 1 : 0;
+}
+
+int smpi_process_getarg(integer* index, char* dst, ftnlen len) {
+ smpi_process_data_t data = smpi_process_data();
+ char* arg;
+ ftnlen i;
+
+ if(!data->argc || !data->argv
+ || *index < 1 || *index >= *(data->argc)) {
+ return -1;
+ }
+ arg = (*data->argv)[*index];
+ for(i = 0; i < len && arg[i] != '\0'; i++) {
+ dst[i] = arg[i];
+ }
+ for(; i < len; i++) {
+ dst[i] = ' ';
+ }
+ return 0;
+}
+
+int smpi_global_size(void) {
+ char* value = getenv("SMPI_GLOBAL_SIZE");
+
+ if(!value) {
+ fprintf(stderr, "Please set env var SMPI_GLOBAL_SIZE to expected number of processes.\n");
+ abort();
+ }
+ return atoi(value);
+}
+
+smpi_process_data_t smpi_process_data(void)
+{
+ return SIMIX_process_self_get_data(SIMIX_process_self());
+}
+
+smpi_process_data_t smpi_process_remote_data(int index)
+{