1 /*
2 * Copyright (c) 1998 Sandia Corporation. Under the terms of Contract
3 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
4 * retains certain rights in this software.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of Sandia Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
35 /*****************************************************************************/
36 /*****************************************************************************/
37 /* Function(s) contained in this file:
38 * ex_get_init_info()
39 *****************************************************************************
40 * This function reads information about the processors for which the
41 * decomposition was performed.
42 *****************************************************************************
43 * Variable Index:
44 * exoid - The NetCDF ID of an already open NemesisI file.
45 * num_proc - The number of processors in the decomposition.
46 * num_proc_in_f - The number of processors the file contains
47 * information for.
48 */
49 /*****************************************************************************/
50 /*****************************************************************************/
51 /*****************************************************************************/
52
53 #include <stdio.h>
54
55 #include <netcdf.h>
56
57 #include <exodusII.h>
58 #include <exodusII_int.h>
59
ex_get_init_info(int exoid,int * num_proc,int * num_proc_in_f,char * ftype)60 int ex_get_init_info(int exoid,
61 int *num_proc,
62 int *num_proc_in_f,
63 char *ftype
64 )
65 {
66 const char *func_name="ex_get_init_info";
67
68 int dimid, status;
69 size_t ltempsv;
70
71 char errmsg[MAX_ERR_LENGTH];
72 /*-----------------------------Execution begins-----------------------------*/
73
74 exerrval = 0; /* clear error code */
75
76 /* Get the file type */
77 if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
78 exerrval = EX_MSG;
79 sprintf(errmsg,
80 "Error: failed to get file type for file ID %d",
81 exoid);
82 ex_err(func_name, errmsg, exerrval);
83
84 return (EX_FATAL);
85 }
86
87 if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS, &dimid)) != NC_NOERR) {
88 exerrval = status;
89 sprintf(errmsg,
90 "Error: failed to find dimension ID for \"%s\" in file ID %d",
91 DIM_NUM_PROCS, exoid);
92 ex_err(func_name, errmsg, exerrval);
93
94 return (EX_FATAL);
95 }
96
97 /* Get the value of the number of processors */
98 if ((status = nc_inq_dimlen(exoid, dimid, <empsv)) != NC_NOERR) {
99 exerrval = status;
100 sprintf(errmsg,
101 "Error: failed to find length of dimension \"%s\" in file ID %d",
102 DIM_NUM_PROCS, exoid);
103 ex_err(func_name, errmsg, exerrval);
104
105 return (EX_FATAL);
106 }
107 *num_proc = ltempsv;
108
109 /* Get the dimension ID of processors that have info in this file */
110 if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid)) != NC_NOERR) {
111 exerrval = status;
112 sprintf(errmsg,
113 "Error: failed to find dimension ID for \"%s\" in file ID %d",
114 DIM_NUM_PROCS_F, exoid);
115 ex_err(func_name, errmsg, exerrval);
116
117 return (EX_FATAL);
118 }
119
120 /* Get the value of the number of processors that have info in this file */
121 if ((status = nc_inq_dimlen(exoid, dimid, <empsv)) != NC_NOERR) {
122 exerrval = status;
123 sprintf(errmsg,
124 "Error: failed to find length of dimension \"%s\" in file ID %d",
125 DIM_NUM_PROCS_F, exoid);
126 ex_err(func_name, errmsg, exerrval);
127
128 return (EX_FATAL);
129 }
130 *num_proc_in_f = ltempsv;
131
132 return (EX_NOERR);
133 }
134