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

📄 mp_parse_command_line.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 5 页
字号:
	    {		if (user_index_str[0] == 'a' && user_index_str[1] == 'l' && user_index_str[2] == 'l' && user_index_str[3] == '\0')		{		    user_index = -1;		}		else		{		    user_index = atoi(user_index_str);		    if (user_index < 0)		    {			user_index = 0;		    }		}	    }	    if (smpd_delete_current_password_registry_entry(user_index))	    {		smpd_delete_cached_password();		printf("Account and password removed from the Registry.\n");	    }	    else	    {		printf("ERROR: Unable to remove the encrypted password.\n");	    }	    fflush(stdout);	    smpd_exit(0);	}	if (strcmp((*argvp)[1], "-validate") == 0)	{	    user_index = 0;	    smpd_get_opt_int(argcp, argvp, "-user", &user_index);	    if (user_index < 0)	    {		user_index = 0;	    }	    if (smpd_read_password_from_registry(user_index, smpd_process.UserAccount, smpd_process.UserPassword))	    {		if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))		{		    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);		}		smpd_get_opt_int(argcp, argvp, "-port", &smpd_process.port);		smpd_get_opt_string(argcp, argvp, "-phrase", smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH);		smpd_process.builtin_cmd = SMPD_CMD_VALIDATE;		smpd_do_console();	    }	    else	    {		printf("FAIL: Unable to read the credentials from the registry.\n");fflush(stdout);	    }	    fflush(stdout);	    smpd_exit(0);	}	if (strcmp((*argvp)[1], "-whoami") == 0)	{	    char username[100] = "";	    ULONG len = 100;	    if (GetUserNameEx(NameSamCompatible, username, &len))	    {		printf("%s\n", username);	    }	    else if (GetUserName(username, &len))	    {		printf("%s\n", username);	    }	    else	    {		printf("ERROR: Unable to determine the current username.\n");	    }	    fflush(stdout);	    smpd_exit(0);	}	if (strcmp((*argvp)[1], "-add_job") == 0)	{	    if (smpd_get_opt(argcp, argvp, "-verbose"))	    {		smpd_process.verbose = SMPD_TRUE;		smpd_process.dbg_state |= SMPD_DBG_STATE_ERROUT | SMPD_DBG_STATE_STDOUT | SMPD_DBG_STATE_TRACE;	    }	    if (smpd_get_opt_two_strings(argcp, argvp, "-add_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH, smpd_process.job_key_account, SMPD_MAX_ACCOUNT_LENGTH))	    {		if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))		{		    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);		}		smpd_get_opt_int(argcp, argvp, "-port", &smpd_process.port);		smpd_get_opt_string(argcp, argvp, "-phrase", smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH);		if (smpd_get_opt_string(argcp, argvp, "-password", smpd_process.job_key_password, SMPD_MAX_PASSWORD_LENGTH))		{		    smpd_process.builtin_cmd = SMPD_CMD_ADD_JOB_AND_PASSWORD;		}		else		{		    smpd_process.builtin_cmd = SMPD_CMD_ADD_JOB;		}		smpd_do_console();		fflush(stdout);		smpd_exit(0);	    }	    printf("Invalid number of arguments passed to -add_job <job_key> <user_account>\n");	    fflush(stdout);	    smpd_exit(-1);	}	if (strcmp((*argvp)[1], "-remove_job") == 0)	{	    if (smpd_get_opt(argcp, argvp, "-verbose"))	    {		smpd_process.verbose = SMPD_TRUE;		smpd_process.dbg_state |= SMPD_DBG_STATE_ERROUT | SMPD_DBG_STATE_STDOUT | SMPD_DBG_STATE_TRACE;	    }	    if (smpd_get_opt_string(argcp, argvp, "-remove_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH))	    {		if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))		{		    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);		}		smpd_get_opt_int(argcp, argvp, "-port", &smpd_process.port);		smpd_get_opt_string(argcp, argvp, "-phrase", smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH);		smpd_process.builtin_cmd = SMPD_CMD_REMOVE_JOB;		smpd_do_console();		fflush(stdout);		smpd_exit(0);	    }	    printf("Invalid number of arguments passed to -remove_job <job_key>\n");	    fflush(stdout);	    smpd_exit(-1);	}	if (strcmp((*argvp)[1], "-associate_job") == 0)	{	    if (smpd_get_opt(argcp, argvp, "-verbose"))	    {		smpd_process.verbose = SMPD_TRUE;		smpd_process.dbg_state |= SMPD_DBG_STATE_ERROUT | SMPD_DBG_STATE_STDOUT | SMPD_DBG_STATE_TRACE;	    }	    if (smpd_get_opt_string(argcp, argvp, "-associate_job", smpd_process.job_key, SMPD_MAX_NAME_LENGTH))	    {		if (!smpd_get_opt_string(argcp, argvp, "-host", smpd_process.console_host, SMPD_MAX_HOST_LENGTH))		{		    smpd_get_hostname(smpd_process.console_host, SMPD_MAX_HOST_LENGTH);		}		smpd_get_opt_int(argcp, argvp, "-port", &smpd_process.port);		smpd_get_opt_string(argcp, argvp, "-phrase", smpd_process.passphrase, SMPD_PASSPHRASE_MAX_LENGTH);		smpd_process.builtin_cmd = SMPD_CMD_ASSOCIATE_JOB;		smpd_do_console();		fflush(stdout);		smpd_exit(0);	    }	    printf("Invalid number of arguments passed to -associate_job <job_key>\n");	    fflush(stdout);	    smpd_exit(-1);	}    }#endif    if ((*argcp == 2) &&	((strcmp((*argvp)[1], "-pmiserver") == 0) || (strcmp((*argvp)[1], "-pmi_server") == 0)))    {	smpd_err_printf("Error: No number of processes specified after the %s option\n", (*argvp)[1]);	return SMPD_FAIL;    }    if (*argcp >= 3)    {	if ((strcmp((*argvp)[1], "-pmiserver") == 0) || (strcmp((*argvp)[1], "-pmi_server") == 0))	{	    char host[100];	    int id;	    if (smpd_get_opt(argcp, argvp, "-verbose"))	    {		smpd_process.verbose = SMPD_TRUE;		smpd_process.dbg_state |= SMPD_DBG_STATE_ERROUT | SMPD_DBG_STATE_STDOUT | SMPD_DBG_STATE_TRACE;	    }	    smpd_process.nproc = atoi((*argvp)[2]);	    if (smpd_process.nproc < 1)	    {		smpd_err_printf("invalid number of processes: %s\n", (*argvp)[2]);		return SMPD_FAIL;	    }	    /* set up the host list to connect to only the local host */	    smpd_get_hostname(host, 100);	    result = smpd_get_host_id(host, &id);	    if (result != SMPD_SUCCESS)	    {		smpd_err_printf("unable to get a id for host %s\n", host);		return SMPD_FAIL;	    }        if (*argcp == 5){    	    smpd_process.singleton_client_port = atoi((*argvp)[4]);            if(smpd_process.singleton_client_port < 1){                smpd_err_printf("Invalid singleton client port = %d\n",                                    smpd_process.singleton_client_port);                return SMPD_FAIL;            }        }	    /* Return without creating any launch_nodes.  This will result in an mpiexec connected to the local smpd	     * and no processes launched.	     */	    return SMPD_SUCCESS;	}    }    /* Get settings saved in smpd */    /* These settings have the lowest priority.     * First are settings on the command line,     * second are settings from environment variables and     * these are last.     */    result = smpd_get_smpd_data("channel", smpd_setting_channel, 20);    result = smpd_get_smpd_data("internode_channel", smpd_setting_internode_channel, 20);    smpd_setting_tmp_buffer[0] = '\0';    result = smpd_get_smpd_data("timeout", smpd_setting_tmp_buffer, 20);    if (result == SMPD_SUCCESS)    {	smpd_setting_timeout = atoi(smpd_setting_tmp_buffer);	if (smpd_setting_timeout < 1)	{	    smpd_setting_timeout = SMPD_INVALID_SETTING;	}    }    smpd_process.output_exit_codes = smpd_option_on("exitcodes");    if (smpd_option_on("noprompt") == SMPD_TRUE)    {	smpd_process.noprompt = SMPD_TRUE;	smpd_process.credentials_prompt = SMPD_FALSE;    }    env_str = getenv("MPIEXEC_NOPROMPT");    if (env_str)    {	smpd_process.noprompt = SMPD_TRUE;	smpd_process.credentials_prompt = SMPD_FALSE;    }    smpd_setting_tmp_buffer[0] = '\0';    result = smpd_get_smpd_data("priority", smpd_setting_tmp_buffer, 20);    if (result == SMPD_SUCCESS)    {	if (smpd_isnumbers_with_colon(smpd_setting_tmp_buffer))	{	    char *str;	    smpd_setting_priority_class = atoi(smpd_setting_tmp_buffer); /* This assumes atoi will stop at the colon and return a number */	    str = strchr(smpd_setting_tmp_buffer, ':');	    if (str)	    {		str++;		smpd_setting_priority = atoi(str);	    }	    else	    {		smpd_setting_priority = SMPD_DEFAULT_PRIORITY;	    }	    if (smpd_setting_priority_class < 0 || smpd_setting_priority_class > 4 || smpd_setting_priority < 0 || smpd_setting_priority > 5)	    {		/* ignore invalid priority settings */		smpd_setting_priority_class = SMPD_INVALID_SETTING;		smpd_setting_priority = SMPD_INVALID_SETTING;	    }	}    }    result = smpd_get_smpd_data("app_path", smpd_setting_path, SMPD_MAX_PATH_LENGTH);    smpd_process.plaintext = smpd_option_on("plaintext");    smpd_setting_localonly = smpd_option_on("localonly");    result = smpd_get_smpd_data("port", smpd_setting_tmp_buffer, 20);    if (result == SMPD_SUCCESS)    {	if (smpd_isnumber(smpd_setting_tmp_buffer))	{	    result = atoi(smpd_setting_tmp_buffer);	    if (result != 0)		smpd_process.port = result;	}    }    env_str = getenv("MPIEXEC_SMPD_PORT");    if (env_str)    {	if (smpd_isnumber(env_str))	{	    result = atoi(env_str);	    if (result != 0)		smpd_process.port = result;	}    }    /* check for mpi options */    /*     * Required:     * -n <maxprocs>     * -host <hostname>     * -soft <Fortran90 triple> - represents allowed number of processes up to maxprocs     *        a or a:b or a:b:c where     *        1) a = a     *        2) a:b = a, a+1, a+2, ..., b     *        3) a:b:c = a, a+c, a+2c, a+3c, ..., a+kc     *           where a+kc <= b if c>0     *                 a+kc >= b if c<0     * -wdir <working directory>     * -path <search path for executable>     * -arch <architecture> - sun, linux, rs6000, ...     * -configfile <filename> - each line contains a complete set of mpiexec options, #commented     *     * Extensions:     * -env <variable=value>     * -env <variable=value;variable2=value2;...>     * -hosts <n host1 host2 ... hostn>     * -hosts <n host1 m1 host2 m2 ... hostn mn>     * -machinefile <filename> - one host per line, #commented     * -localonly <numprocs>     * -nompi - don't require processes to be MPI processes (don't have to call MPI_Init or PMI_Init)     * -exitcodes - print the exit codes of processes as they exit     * -verbose - same as setting environment variable to SMPD_DBG_OUTPUT=stdout     * -quiet_abort - minimize the output when a job is aborted     * -file - mpich1 job configuration file     *      * Windows extensions:     * -map <drive:\\host\share>     * -pwdfile <filename> - account on the first line and password on the second     * -nomapping - don't copy the current directory mapping on the remote nodes     * -dbg - debug     * -noprompt - don't prompt for user credentials, fail with an error message     * -logon - force the prompt for user credentials     * -priority <class[:level]> - set the process startup priority class and optionally level.     *            class = 0,1,2,3,4   = idle, below, normal, above, high     *            level = 0,1,2,3,4,5 = idle, lowest, below, normal, above, highest     * -localroot - launch the root process without smpd if the host is local.     *              (This allows the root process to create windows and be debugged.)     *     * Backwards compatibility     * -np <numprocs>     * -dir <working directory>     */    /* Get a list of hosts from a file or the registry to be used with the -n,-np options */    smpd_get_default_hosts();     cur_rank = 0;    gdrive_map_list = NULL;    genv_list = NULL;    gwdir[0] = '\0';    gpath[0] = '\0';    ghost_list = NULL;    next_argc = *argcp;    next_argv = *argvp + 1;    exe_ptr = **argvp;    do    {	/* calculate the current argc and find the next argv */	argc = 1;	while ( (*next_argv) != NULL && (**next_argv) != ':')	{	    argc++;	    next_argc--;	    next_argv++;	}	if ( (*next_argv) != NULL && (**next_argv) == ':')	{	    (*next_argv) = NULL;	    next_argv++;	}	argcp = &argc;	/* reset block global variables */	use_configfile = SMPD_FALSE;	delete_configfile = SMPD_FALSE;configfile_loop:	nproc = 0;	drive_map_list = NULL;	env_list = NULL;	wdir[0] = '\0';	use_debug_flag = SMPD_FALSE;	use_pwd_file = SMPD_FALSE;	host_list = NULL;	no_drive_mapping = SMPD_FALSE;	n_priority_class = (smpd_setting_priority_class == SMPD_INVALID_SETTING) ? SMPD_DEFAULT_PRIORITY_CLASS : smpd_setting_priority_class;	n_priority = (smpd_setting_priority == SMPD_INVALID_SETTING) ? SMPD_DEFAULT_PRIORITY : smpd_setting_priority;	use_machine_file = SMPD_FALSE;	if (smpd_setting_path[0] != '\0')	{	    strncpy(path, smpd_setting_path, SMPD_MAX_PATH_LENGTH);	}	else	{	    path[0] = '\0';	}	/* Check for the -configfile option.  It must be the first and only option in a group. */	if ((*argvp)[1] && (*argvp)[1][0] == '-')	{	    if ((*argvp)[1][1] == '-')	    {		/* double -- option provided, trim it to a single - */		index = 2;		while ((*argvp)[1][index] != '\0')		{		    (*argvp)[1][index-1] = (*argvp)[1][index];		    index++;		}		(*argvp)[1][index-1] = '\0';	    }	    if (strcmp(&(*argvp)[1][1], "configfile") == 0)	    {		if (use_configfile)		{		    printf("Error: -configfile option is not valid from within a configuration file.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (argc < 3)		{

⌨️ 快捷键说明

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