⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp_parse_command_line.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 5 页
字号:
		    smpd_process.timeout = -1;		}		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "hide_console") == 0)	    {#ifdef HAVE_WINDOWS_H		FreeConsole();#endif	    }	    else if (strcmp(&(*argvp)[1][1], "quiet_abort") == 0)	    {		smpd_process.verbose_abort_output = SMPD_FALSE;	    }	    else if ((strcmp(&(*argvp)[1][1], "rsh") == 0) || (strcmp(&(*argvp)[1][1], "ssh") == 0))	    {		smpd_process.rsh_mpiexec = SMPD_TRUE;		if (smpd_process.mpiexec_inorder_launch == SMPD_FALSE)		{		    smpd_launch_node_t *temp_node, *ordered_list = NULL;		    /* sort any existing reverse order nodes to be in order */		    while (smpd_process.launch_list)		    {			temp_node = smpd_process.launch_list->next;			smpd_process.launch_list->next = ordered_list;			ordered_list = smpd_process.launch_list;			smpd_process.launch_list = temp_node;		    }		    smpd_process.launch_list = ordered_list;		}		smpd_process.mpiexec_inorder_launch = SMPD_TRUE;	    }	    else if ((strcmp(&(*argvp)[1][1], "nosmpd") == 0) || (strcmp(&(*argvp)[1][1], "no_smpd") == 0) || (strcmp(&(*argvp)[1][1], "nopm") == 0))	    {		smpd_process.use_pmi_server = SMPD_FALSE;	    }	    else if (strcmp(&(*argvp)[1][1], "plaintext") == 0)	    {		smpd_process.plaintext = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "channel") == 0)	    {		if (argc < 3)		{		    printf("Error: no name specified after -channel option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(channel, (*argvp)[2], SMPD_MAX_NAME_LENGTH);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "log") == 0)	    {		/* -log is a shortcut to create log files using the mpe wrapper dll */		env_node = (smpd_env_node_t*)MPIU_Malloc(sizeof(smpd_env_node_t));		if (env_node == NULL)		{		    printf("Error: malloc failed to allocate structure to hold an environment variable.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(env_node->name, "MPI_WRAP_DLL_NAME", SMPD_MAX_NAME_LENGTH);		strncpy(env_node->value, "mpe", SMPD_MAX_VALUE_LENGTH);		env_node->next = env_list;		env_list = env_node;	    }#ifdef HAVE_WINDOWS_H	    else if (strcmp(&(*argvp)[1][1], "user") == 0)	    {		if (argc < 3)		{		    printf("Error: no index specified after -user option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		smpd_process.user_index = atoi((*argvp)[2]);		if (smpd_process.user_index < 0)		    smpd_process.user_index = 0;		num_args_to_strip = 2;		smpd_delete_cached_password();	    }#endif	    else if (strcmp(&(*argvp)[1][1], "l") == 0)	    {		smpd_process.prefix_output = SMPD_TRUE;	    }	    else	    {		printf("Unknown option: %s\n", (*argvp)[1]);	    }	    strip_args(argcp, argvp, num_args_to_strip);	}	/* check to see if a timeout is specified by the environment variable only if	 * a timeout has not been specified on the command line	 */	if (smpd_process.timeout == -1)	{	    char *p = getenv("MPIEXEC_TIMEOUT");	    if (p)	    {		smpd_process.timeout = atoi(p);		if (smpd_process.timeout < 1)		{		    smpd_process.timeout = -1;		}	    }	    else	    {		/* If a timeout is specified in the smpd settings but not in an env variable and not on the command line then use it. */		if (smpd_setting_timeout != SMPD_INVALID_SETTING)		{		    smpd_process.timeout = smpd_setting_timeout;		}	    }	}	/* Check to see if the environment wants all processes to run locally.	 * This is useful for test scripts.	 */	env_str = getenv("MPIEXEC_LOCALONLY");	if (env_str == NULL && smpd_setting_localonly == SMPD_TRUE)	{	    smpd_setting_tmp_buffer[0] = '1';	    smpd_setting_tmp_buffer[1] = '\0';	    env_str = smpd_setting_tmp_buffer;	}	if (env_str != NULL)	{	    if (smpd_is_affirmative(env_str) || strcmp(env_str, "1") == 0)	    {#if 1		/* This block creates a host list of one host to implement -localonly */		if (host_list == NULL)		{		    /* Use localroot to implement localonly */		    smpd_process.local_root = SMPD_TRUE;		    /* create a host list of one and set nproc to -1 to be replaced by 		       nproc after parsing the block */		    host_list = (smpd_host_node_t*)MPIU_Malloc(sizeof(smpd_host_node_t));		    if (host_list == NULL)		    {			printf("failed to allocate memory for a host node.\n");			smpd_exit_fn(FCNAME);			return SMPD_FAIL;		    }		    host_list->next = NULL;		    host_list->left = NULL;		    host_list->right = NULL;		    host_list->connected = SMPD_FALSE;		    host_list->connect_cmd_tag = -1;		    host_list->nproc = -1;		    host_list->alt_host[0] = '\0';		    smpd_get_hostname(host_list->host, SMPD_MAX_HOST_LENGTH);		}		else		{		    smpd_dbg_printf("host_list not null, not using localonly\n");		}#else		/* This block uses the rsh code to implement -localonly */		smpd_process.mpiexec_run_local = SMPD_TRUE;		smpd_process.rsh_mpiexec = SMPD_TRUE;		if (smpd_process.mpiexec_inorder_launch == SMPD_FALSE)		{		    smpd_launch_node_t *temp_node, *ordered_list = NULL;		    /* sort any existing reverse order nodes to be in order */		    while (smpd_process.launch_list)		    {			temp_node = smpd_process.launch_list->next;			smpd_process.launch_list->next = ordered_list;			ordered_list = smpd_process.launch_list;			smpd_process.launch_list = temp_node;		    }		    smpd_process.launch_list = ordered_list;		}		smpd_process.mpiexec_inorder_launch = SMPD_TRUE;#endif	    }	    else	    {		smpd_dbg_printf("MPIEXEC_LOCALONLY env is not affirmative: '%s'\n", env_str);	    }	}	/* remaining args are the executable and it's args */	if (argc < 2)	{	    printf("Error: no executable specified\n");	    smpd_exit_fn(FCNAME);	    return SMPD_FAIL;	}	exe_iter = exe;	exe_len_remaining = SMPD_MAX_EXE_LENGTH;	if (!((*argvp)[1][0] == '\\' && (*argvp)[1][1] == '\\') && (*argvp)[1][0] != '/' &&	    !(strlen((*argvp)[1]) > 3 && (*argvp)[1][1] == ':' && (*argvp)[1][2] == '\\') )	{	    /* an absolute path was not specified so find the executable an save the path */	    if (smpd_get_full_path_name((*argvp)[1], SMPD_MAX_EXE_LENGTH, exe_path, &namepart))	    {		if (path[0] != '\0')		{		    if (strlen(path) < SMPD_MAX_PATH_LENGTH)		    {			strcat(path, ";");			strncat(path, exe_path, SMPD_MAX_PATH_LENGTH - strlen(path));			path[SMPD_MAX_PATH_LENGTH-1] = '\0';		    }		}		else		{		    strncpy(path, exe_path, SMPD_MAX_PATH_LENGTH);		}		result = MPIU_Str_add_string(&exe_iter, &exe_len_remaining, namepart);		if (result != MPIU_STR_SUCCESS)		{		    printf("Error: insufficient buffer space for the command line.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}	    }	    else	    {		result = MPIU_Str_add_string(&exe_iter, &exe_len_remaining, (*argvp)[1]);		if (result != MPIU_STR_SUCCESS)		{		    printf("Error: insufficient buffer space for the command line.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}	    }	}	else	{	    /* an absolute path was specified */#ifdef HAVE_WINDOWS_H	    char *pTemp = (char*)malloc(SMPD_MAX_EXE_LENGTH);	    if (pTemp == NULL)	    {		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }	    strncpy(pTemp, (*argvp)[1], SMPD_MAX_EXE_LENGTH);	    pTemp[SMPD_MAX_EXE_LENGTH-1] = '\0';	    ExeToUnc(pTemp, SMPD_MAX_EXE_LENGTH);	    result = MPIU_Str_add_string(&exe_iter, &exe_len_remaining, pTemp);	    free(pTemp);	    if (result != MPIU_STR_SUCCESS)	    {		printf("Error: insufficient buffer space for the command line.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }#else	    result = MPIU_Str_add_string(&exe_iter, &exe_len_remaining, (*argvp)[1]);	    if (result != MPIU_STR_SUCCESS)	    {		printf("Error: insufficient buffer space for the command line.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }#endif	}	for (i=2; i<argc; i++)	{	    result = MPIU_Str_add_string(&exe_iter, &exe_len_remaining, (*argvp)[i]);	}	/* remove the trailing space */	exe[strlen(exe)-1] = '\0';	smpd_dbg_printf("handling executable:\n%s\n", exe);	if (nproc == 0){    /* By default assume "mpiexec foo" => "mpiexec -n 1 foo" */        nproc = 1;	}	if (ghost_list != NULL && host_list == NULL && use_machine_file != SMPD_TRUE)	{	    host_list = (smpd_host_node_t*)MPIU_Malloc(sizeof(smpd_host_node_t));	    if (host_list == NULL)	    {		printf("failed to allocate memory for a host node.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }	    host_list->next = NULL;	    host_list->left = NULL;	    host_list->right = NULL;	    host_list->connected = SMPD_FALSE;	    host_list->connect_cmd_tag = -1;	    host_list->nproc = -1;	    host_list->alt_host[0] = '\0';	    strncpy(host_list->host, ghost_list->host, SMPD_MAX_HOST_LENGTH);	}	if (host_list != NULL && host_list->nproc == -1)	{	    /* -host specified, replace nproc field */	    host_list->nproc = nproc;	}	/* add environment variables */	env_data[0] = '\0';	env_str = env_data;	maxlen = SMPD_MAX_ENV_LENGTH;	/* add and destroy the local environment variable list */	while (env_list)	{	    MPIU_Str_add_string_arg(&env_str, &maxlen, env_list->name, env_list->value);	    /*	    env_str += snprintf(env_str,		SMPD_MAX_ENV_LENGTH - (env_str - env_data),		"%s=%s", env_list->name, env_list->value);	    if (env_list->next)	    {		env_str += snprintf(env_str, SMPD_MAX_ENV_LENGTH - (env_str - env_data), ";");	    }	    */	    env_node = env_list;	    env_list = env_list->next;	    MPIU_Free(env_node);	}	/* add the global environment variable list */	env_node = genv_list;	while (env_node)	{	    MPIU_Str_add_string_arg(&env_str, &maxlen, env_node->name, env_node->value);	    env_node = env_node->next;	}	if (env_str > env_data)	{	    /* trim the trailing white space */	    env_str--;	    *env_str = '\0';	}	/* merge global drive mappings with the local drive mappings */	gmap_node = gdrive_map_list;	while (gmap_node)	{	    map_node = drive_map_list;	    while (map_node)	    {		if (map_node->drive == gmap_node->drive)		{		    /* local option trumps the global option */		    break;		}		if (map_node->next == NULL)		{		    /* add a copy of the global node to the end of the list */		    map_node->next = (smpd_map_drive_node_t*)MPIU_Malloc(sizeof(smpd_map_drive_node_t));		    if (map_node->next == NULL)		    {			printf("Error: malloc failed to allocate map structure.\n");			smpd_exit_fn(FCNAME);			return SMPD_FAIL;		    }		    map_node = map_node->next;		    map_node->ref_count = 0;		    map_node->drive = gmap_node->drive;		    strncpy(map_node->share, gmap_node->share, SMPD_MAX_EXE_LENGTH);		    map_node->next = NULL;		    break;		}		map_node = map_node->next;	    }	    if (drive_map_list == NULL)	    {		map_node = (smpd_map_drive_node_t*)MPIU_Malloc(sizeof(smpd_map_drive_node_t));		if (map_node == NULL)		{		    printf("Error: malloc failed to allocate map structure.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		map_node->ref_count = 0;		map_node->drive = gmap_node->drive;		strncpy(map_node->share, gmap_node->share, SMPD_MAX_EXE_LENGTH);		map_node->next = NULL;		drive_map_list = map_node;	    }	    gmap_node = gmap_node->next;	}	for (i=0; i<nproc; i++)	{	    /* create a launch_node */	    launch_node = (smpd_launch_node_t*)MPIU_Malloc(sizeof(smpd_launch_node_t));	    if (launch_node == NULL)	    {		smpd_err_printf("unable to allocate a launch node structure.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;	    }	    launch_node->clique[0] = '\0';	    smpd_get_next_host(&host_list, launch_node);	    launch_node->iproc = cur_rank++;	    launch_node->appnum = appnum;	    launch_node->priority_class = n_priority_class;	    launch_node->priority_thread = n_priority;	    launch_node->env = launch_node->env_data;	    strcpy(launch_node->env_data, env_data);	    if (launch_node->alt_hostname[0] != '\0')	    {		if (smpd_append_env_option(launch_node->env_data, SMPD_MAX_ENV_LENGTH, "MPICH_INTERFACE_HOSTNAME", launch_node->alt_hostname) != SMPD_SUCCESS)		{		    smpd_err_printf("unable to add the MPICH_INTERFACE_HOSTNAME environment variable to the launch command.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}	    }	    if (wdir[0] != '\0')	    {		strcpy(launch_node->dir, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -