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

📄 ne_pcmpc.c

📁 一个用来实现偏微分方程中网格的计算库
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* Define variables for the nodal IDS and processor vectors */    if ((status = nc_def_var(neid, VAR_N_COMM_NIDS, NC_INT, 1, n_dimid, &varid)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_N_COMM_NIDS, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }    if ((status = nc_def_var(neid, VAR_N_COMM_PROC, NC_INT, 1, n_dimid, &varid)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_N_COMM_PROC, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }  } /* End "if (num_n_comm_maps > 0)" */    /*     * Add dimensions for the size of the number of elemental     * communication maps.     */  if (num_e_comm_maps > 0) {    /* add the communications data index variable */    if ((status = nc_def_var(neid, VAR_E_COMM_DATA_IDX, NC_INT, 1,			     e_dimid, &e_varid_idx)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_E_COMM_DATA_IDX, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }    /* now add up all of the nodal communications maps */    ecnt_cmap = 0;    for(iproc=0; iproc < num_procs_in_file; iproc++) {      num_icm = e_var_idx[iproc+1] - e_var_idx[iproc];      for(icm=0; icm < num_icm; icm++)	ecnt_cmap += elem_cmap_elem_cnts[elem_proc_ptrs[iproc]+icm];    }    /* Add dimensions for elemental communications maps */    if ((status = nc_def_dim(neid, DIM_ECNT_CMAP, ecnt_cmap, &e_dimid[0])) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add dimension for \"%s\" in file ID %d",	      DIM_ECNT_CMAP, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }    /* Define variables for the nodal IDS and processor vectors */    if ((status = nc_def_var(neid, VAR_E_COMM_EIDS, NC_INT, 1, e_dimid, &varid)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_E_COMM_EIDS, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }    if ((status = nc_def_var(neid, VAR_E_COMM_PROC, NC_INT, 1, e_dimid, &varid)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_E_COMM_PROC, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }    if ((status = nc_def_var(neid, VAR_E_COMM_SIDS, NC_INT, 1, e_dimid, &varid)) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to add variable \"%s\" in file ID %d",	      VAR_E_COMM_SIDS, neid);      ex_err(func_name, errmsg, exerrval);      /* Leave define mode before returning */      ne_leavedef(neid, func_name);      return (EX_FATAL);    }  } /* End "if (num_e_comm_maps > 0)" */    /* Exit define mode */  ne_leavedef(neid, func_name);  /* Set the status of the nodal communication maps */  if (num_n_comm_maps > 0) {    /* need to get the two "n_comm_*" variable ids */    if ((status = nc_inq_varid(neid, VAR_N_COMM_STAT, &n_varid[0])) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to find variable ID for \"%s\" in file ID %d",	      VAR_N_COMM_STAT, neid);      ex_err(func_name, errmsg, exerrval);      return (EX_FATAL);    }    /* Get the variable ID for the comm map IDs vector */    if ((status = nc_inq_varid(neid, VAR_N_COMM_IDS, &n_varid[1])) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to find variable ID for \"%s\" in file ID %d",	      VAR_N_COMM_IDS, neid);      ex_err(func_name, errmsg, exerrval);      return (EX_FATAL);    }    /* reset the index variable */    nl_ncnt_cmap = 0;    for(iproc=0; iproc < num_procs_in_file; iproc++) {      num_icm = n_var_idx[iproc+1] - n_var_idx[iproc];      for(icm=0; icm < num_icm; icm++) {	start[0] = n_var_idx[iproc] + icm;	if (node_cmap_node_cnts[node_proc_ptrs[iproc]+icm] > 0)	  nmstat = 1;	else	  nmstat = 0;	if ((status = nc_put_var1_int(neid, n_varid[0], start, &nmstat)) != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: unable to output variable in file ID %d", neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}	/* increment to the next starting position */	nl_ncnt_cmap += node_cmap_node_cnts[node_proc_ptrs[iproc]+icm];	/* fill the data index variable */	if ((status = nc_put_var1_int(neid, n_varid_idx, start, &nl_ncnt_cmap)) != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: failed to output int elem map index in file ID %d",		  neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}      } /* End "for(icm=0; icm < num_icm; icm++)" */      if (num_icm > 0) {	/* Output the nodal comm map IDs */	start[0] = n_var_idx[iproc];	count[0] =  num_icm;	status = nc_put_vara_int(neid, n_varid[1], start, count,			 &node_cmap_ids[node_proc_ptrs[iproc]]);	if (status != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: failed to output variable in file ID %d", neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}      }    } /* End "for(iproc=0; iproc < num_procs_in_file; iproc++)" */      /* free up memory for index */    free(n_var_idx);  } /* End "if (num_n_comm_maps > 0)" */    /* Set the status of the elemental communication maps */  if (num_e_comm_maps > 0) {    /* need to get the two "e_comm_*" variables" */    /* Get variable ID for elemental status vector */    if ((status = nc_inq_varid(neid, VAR_E_COMM_STAT, &e_varid[0])) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to find variable ID for \"%s\" in file ID %d",	      VAR_E_COMM_STAT, neid);      ex_err(func_name, errmsg, exerrval);      return (EX_FATAL);    }    /* Get the variable ID for the elemental comm map IDs vector */    if ((status = nc_inq_varid(neid, VAR_E_COMM_IDS, &e_varid[1])) != NC_NOERR) {      exerrval = status;      sprintf(errmsg,	      "Error: failed to find variable ID for \"%s\" in file ID %d",	      VAR_E_COMM_IDS, neid);      ex_err(func_name, errmsg, exerrval);      return (EX_FATAL);    }    /* reset the index variable */    nl_ecnt_cmap = 0;    for(iproc=0; iproc < num_procs_in_file; iproc++) {      num_icm = e_var_idx[iproc+1] - e_var_idx[iproc];      for(icm=0; icm < num_icm; icm++) {	start[0] = e_var_idx[iproc] + icm;	if (elem_cmap_elem_cnts[elem_proc_ptrs[iproc]+icm] > 0)	  nmstat = 1;	else	  nmstat = 0;	if ((status = nc_put_var1_int(neid, e_varid[0], start, &nmstat)) != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: unable to output variable in file ID %d", neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}	/* increment to the next starting position */	nl_ecnt_cmap += elem_cmap_elem_cnts[elem_proc_ptrs[iproc]+icm];	/* fill the data index variable */	if ((status = nc_put_var1_int(neid, e_varid_idx, start, &nl_ecnt_cmap)) != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: failed to output int elem map index in file ID %d",		  neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}      } /* End "for(icm=0; icm < num_icm; icm++)" */      if (num_icm > 0) {	/* Output the elemental comm map IDs */	start[0] = e_var_idx[iproc];	count[0] = num_icm;	status = nc_put_vara_int(neid, e_varid[1], start, count,			 &elem_cmap_ids[elem_proc_ptrs[iproc]]);	if (status != NC_NOERR) {	  exerrval = status;	  sprintf(errmsg,		  "Error: failed to output variable in file ID %d", neid);	  ex_err(func_name, errmsg, exerrval);	  return (EX_FATAL);	}      }    } /* End "for(iproc=0; iproc < num_procs_in_file; iproc++)" */    free(e_var_idx);  } /* End "if (num_e_comm_maps > 0)" */  return (EX_NOERR);}

⌨️ 快捷键说明

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