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

📄 mp_parse_command_line.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 5 页
字号:
	    }	    else if ( (strcmp(&(*argvp)[1][1], "delegate") == 0) || (strcmp(&(*argvp)[1][1], "delegation") == 0) )	    {		smpd_process.use_sspi = SMPD_TRUE;		smpd_process.use_delegation = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "job") == 0)	    {		smpd_process.use_delegation = SMPD_FALSE;		smpd_process.use_sspi_job_key = SMPD_TRUE;		if (argc < 3)		{		    printf("Error: no job key specified after the -job option\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(smpd_process.job_key, (*argvp)[2], SMPD_SSPI_JOB_KEY_LENGTH);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "dbg") == 0)	    {		use_debug_flag = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "pwdfile") == 0)	    {		use_pwd_file = SMPD_TRUE;		if (argc < 3)		{		    printf("Error: no filename specified after -pwdfile option\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(pwd_file_name, (*argvp)[2], SMPD_MAX_FILENAME);		smpd_get_pwd_from_file(pwd_file_name);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "configfile") == 0)	    {		printf("Error: The -configfile option must be the first and only option specified in a block.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;		/*		if (argc < 3)		{		    printf("Error: no filename specifed after -configfile option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(configfilename, (*argvp)[2], SMPD_MAX_FILENAME);		use_configfile = SMPD_TRUE;		num_args_to_strip = 2;		*/	    }	    else if (strcmp(&(*argvp)[1][1], "file") == 0)	    {		printf("Error: The -file option must be the first and only option specified in a block.\n");		smpd_exit_fn(FCNAME);		return SMPD_FAIL;		/*		if (argc < 3)		{		    printf("Error: no filename specifed after -file option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(configfilename, (*argvp)[2], SMPD_MAX_FILENAME);		use_configfile = SMPD_TRUE;		num_args_to_strip = 2;		*/	    }	    else if (strcmp(&(*argvp)[1][1], "host") == 0)	    {		if (argc < 3)		{		    printf("Error: no host specified after -host option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (host_list != NULL)		{		    printf("Error: -host option can only be specified once and it cannot be combined with -hosts.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		/* 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';		strncpy(host_list->host, (*argvp)[2], SMPD_MAX_HOST_LENGTH);		num_args_to_strip = 2;		smpd_add_host_to_default_list((*argvp)[2]);	    }	    else if (strcmp(&(*argvp)[1][1], "ghost") == 0)	    {		if (argc < 3)		{		    printf("Error: no host specified after -ghost option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (ghost_list != NULL)		{		    printf("Error: -ghost option can only be specified once.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		/* create a host list of one and set nproc to -1 to be replaced by		   nproc after parsing the block */		ghost_list = (smpd_host_node_t*)MPIU_Malloc(sizeof(smpd_host_node_t));		if (ghost_list == NULL)		{		    printf("failed to allocate memory for a host node.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		ghost_list->next = NULL;		ghost_list->left = NULL;		ghost_list->right = NULL;		ghost_list->connected = SMPD_FALSE;		ghost_list->connect_cmd_tag = -1;		ghost_list->nproc = -1;		ghost_list->alt_host[0] = '\0';		strncpy(ghost_list->host, (*argvp)[2], SMPD_MAX_HOST_LENGTH);		num_args_to_strip = 2;		smpd_add_host_to_default_list((*argvp)[2]);	    }	    else if (strcmp(&(*argvp)[1][1], "hosts") == 0)	    {		if (nproc != 0)		{		    printf("Error: only one option is allowed to determine the number of processes.\n");		    printf("       -hosts, -n, -np and -localonly x are mutually exclusive\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (host_list != NULL)		{		    printf("Error: -hosts option can only be called once and it cannot be combined with -host.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (argc > 2)		{		    if (smpd_isnumber((*argvp)[2]))		    {			/* initially set nproc to be the number of hosts */			nproc = atoi((*argvp)[2]);			if (nproc < 1)			{			    printf("Error: You must specify a number greater than 0 after -hosts.\n");			    smpd_exit_fn(FCNAME);			    return SMPD_FAIL;			}			num_args_to_strip = 2 + nproc;			index = 3;			for (i=0; i<nproc; i++)			{			    if (index >= argc)			    {				printf("Error: missing host name after -hosts option.\n");				smpd_exit_fn(FCNAME);				return SMPD_FAIL;			    }			    host_node_ptr = (smpd_host_node_t*)MPIU_Malloc(sizeof(smpd_host_node_t));			    if (host_node_ptr == NULL)			    {				printf("failed to allocate memory for a host node.\n");				smpd_exit_fn(FCNAME);				return SMPD_FAIL;			    }			    host_node_ptr->next = NULL;			    host_node_ptr->left = NULL;			    host_node_ptr->right = NULL;			    host_node_ptr->connected = SMPD_FALSE;			    host_node_ptr->connect_cmd_tag = -1;			    host_node_ptr->nproc = 1;			    host_node_ptr->alt_host[0] = '\0';			    strncpy(host_node_ptr->host, (*argvp)[index], SMPD_MAX_HOST_LENGTH);			    smpd_add_host_to_default_list((*argvp)[index]);			    index++;			    if (argc > index)			    {				if (smpd_isnumber((*argvp)[index]))				{				    host_node_ptr->nproc = atoi((*argvp)[index]);				    index++;				    num_args_to_strip++;				}			    }			    if (host_list == NULL)			    {				host_list = host_node_ptr;			    }			    else			    {				host_node_iter = host_list;				while (host_node_iter->next)				    host_node_iter = host_node_iter->next;				host_node_iter->next = host_node_ptr;			    }			}			/* adjust nproc to be the actual number of processes */			host_node_iter = host_list;			nproc = 0;			while (host_node_iter)			{			    nproc += host_node_iter->nproc;			    host_node_iter = host_node_iter->next;			}		    }		    else		    {			printf("Error: You must specify the number of hosts after the -hosts option.\n");			smpd_exit_fn(FCNAME);			return SMPD_FAIL;		    }		}		else		{		    printf("Error: not enough arguments specified for -hosts option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}	    }	    else if (strcmp(&(*argvp)[1][1], "nocolor") == 0)	    {		smpd_process.do_multi_color_output = SMPD_FALSE;	    }	    else if (strcmp(&(*argvp)[1][1], "nompi") == 0)	    {		smpd_process.no_mpi = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "nomapping") == 0)	    {		no_drive_mapping = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "nopopup_debug") == 0)	    {#ifdef HAVE_WINDOWS_H		SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);#endif	    }	    else if (strcmp(&(*argvp)[1][1], "help") == 0 || (*argvp)[1][1] == '?')	    {		mp_print_options();		exit(0);	    }	    else if (strcmp(&(*argvp)[1][1], "help2") == 0)	    {		mp_print_extra_options();		exit(0);	    }	    else if (strcmp(&(*argvp)[1][1], "exitcodes") == 0)	    {		smpd_process.output_exit_codes = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "localroot") == 0)	    {		smpd_process.local_root = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "priority") == 0)	    {		if (argc < 3)		{		    printf("Error: you must specify a priority after the -priority option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		if (smpd_isnumbers_with_colon((*argvp)[2]))		{		    char *str;		    n_priority_class = atoi((*argvp)[2]); /* This assumes atoi will stop at the colon and return a number */		    str = strchr((*argvp)[2], ':');		    if (str)		    {			str++;			n_priority = atoi(str);		    }		    if (n_priority_class < 0 || n_priority_class > 4 || n_priority < 0 || n_priority > 5)		    {			printf("Error: priorities must be between 0-4:0-5\n");			smpd_exit_fn(FCNAME);			return SMPD_FAIL;		    }		}		else		{		    printf("Error: you must specify a priority after the -priority option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		smpd_dbg_printf("priorities = %d:%d\n", n_priority_class, n_priority);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "iproot") == 0)	    {		smpd_process.use_iproot = SMPD_TRUE;	    }	    else if (strcmp(&(*argvp)[1][1], "noiproot") == 0)	    {		smpd_process.use_iproot = SMPD_FALSE;	    }	    else if (strcmp(&(*argvp)[1][1], "verbose") == 0)	    {		smpd_process.verbose = SMPD_TRUE;		smpd_process.dbg_state |= SMPD_DBG_STATE_ERROUT | SMPD_DBG_STATE_STDOUT | SMPD_DBG_STATE_TRACE;	    }	    else if ( (strcmp(&(*argvp)[1][1], "p") == 0) || (strcmp(&(*argvp)[1][1], "port") == 0))	    {		if (argc > 2)		{		    if (smpd_isnumber((*argvp)[2]))		    {			smpd_process.port = atoi((*argvp)[2]);		    }		    else		    {			printf("Error: you must specify the port smpd is listening on after the %s option.\n", (*argvp)[1]);			smpd_exit_fn(FCNAME);			return SMPD_FAIL;		    }		}		else		{		    printf("Error: you must specify the port smpd is listening on after the %s option.\n", (*argvp)[1]);		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "path") == 0)	    {		if (argc < 3)		{		    printf("Error: no path specifed after -path option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(path, (*argvp)[2], SMPD_MAX_PATH_LENGTH);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "gpath") == 0)	    {		if (argc < 3)		{		    printf("Error: no path specifed after -gpath option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(gpath, (*argvp)[2], SMPD_MAX_PATH_LENGTH);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "noprompt") == 0)	    {		smpd_process.noprompt = SMPD_TRUE;		smpd_process.credentials_prompt = SMPD_FALSE;	    }	    else if (strcmp(&(*argvp)[1][1], "phrase") == 0)	    {		if (argc < 3)		{		    printf("Error: no passphrase specified afterh -phrase option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(smpd_process.passphrase, (*argvp)[2], SMPD_PASSPHRASE_MAX_LENGTH);		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "smpdfile") == 0)	    {		if (argc < 3)		{		    printf("Error: no file name specified after -smpdfile option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		strncpy(smpd_process.smpd_filename, (*argvp)[2], SMPD_MAX_FILENAME);		{		    struct stat s;		    if (stat(smpd_process.smpd_filename, &s) == 0)		    {			if (s.st_mode & 00077)			{			    printf("Error: .smpd file cannot be readable by anyone other than the current user.\n");			    smpd_exit_fn(FCNAME);			    return SMPD_FAIL;			}		    }		}		num_args_to_strip = 2;	    }	    else if (strcmp(&(*argvp)[1][1], "timeout") == 0)	    {		if (argc < 3)		{		    printf("Error: no timeout specified after -timeout option.\n");		    smpd_exit_fn(FCNAME);		    return SMPD_FAIL;		}		smpd_process.timeout = atoi((*argvp)[2]);		if (smpd_process.timeout < 1)		{		    printf("Warning: invalid timeout specified, ignoring timeout value of '%s'\n", (*argvp)[2]);

⌨️ 快捷键说明

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