| 1 |
\page large_model Large model modifications to the Exodus library |
| 2 |
\section large_model_ Large model modifications to the Exodus library |
| 3 |
|
| 4 |
\note The changes documented below are now the default method for |
| 5 |
storing an Exodus database. There is no reason to write a "non-large" |
| 6 |
model database. |
| 7 |
|
| 8 |
The changes are to support the storage of larger models. There are two |
| 9 |
pieces of this. The first is the setting of the type of netCDF file |
| 10 |
that will be created; either one with 32-bit offsets or one with |
| 11 |
64-bit offsets. (Note that this is *not* related to storing 64-bit |
| 12 |
integers). This can be specified in a couple ways: |
| 13 |
|
| 14 |
1. Pass the `EX_LARGE_MODEL` flag in the mode argument to ex_create. |
| 15 |
2. Set the environment variable `EXODUS_LARGE_MODEL`. |
| 16 |
|
| 17 |
If either of these are set, then the library will pass the |
| 18 |
`NC_64BIT_OFFSET` flag to the netCDF library. See the commit log for |
| 19 |
netCDF library for more details. |
| 20 |
|
| 21 |
The other change is to reduce the size of some of the datasets in an |
| 22 |
Exodus library. Even with the netCDF changes, the maximum dataset |
| 23 |
size is still 2 GiB. To reduce the size of the datasets, the nodal |
| 24 |
coordinates and the nodal variables have been split to store by |
| 25 |
component. The old behavior stored all x, y, and z coordinates in a |
| 26 |
single dataset; in the new behavior, each component is stored |
| 27 |
separately -- there is a coordx, coordy, and coordz dataset. |
| 28 |
|
| 29 |
The nodal variables used to be stored in a single blob of dimension |
| 30 |
`(#times,#nodes,#variables)`. This has now been split into `#variable` |
| 31 |
datasets of size `(#times,#nodes)`. |
| 32 |
|
| 33 |
These two changes should increase the maximum model sizes |
| 34 |
significantly. Prior to the change, the maximum number of nodes that |
| 35 |
could be stored in the coordinate dataset was about 90 Million nodes; |
| 36 |
the new storage permits 270 Million nodes in double precision. The old |
| 37 |
model was more restrictive if there were multiple nodal variables, but |
| 38 |
the new storage should not depend on the number of nodal variables. |
| 39 |
|
| 40 |
These changes were made such that the new library would create |
| 41 |
old-style files by default and would read either old or new style |
| 42 |
files. The version has been changed to 3.01 for the file version and |
| 43 |
4.01 for the API version. |
| 44 |
|
| 45 |
An additional attribute is now written to the file. It is called |
| 46 |
"file_size" or `ATT_FILESIZE`. If it is 0 or not present, then the old |
| 47 |
format is assumed; if it is 1, then the new format is assumed. |
| 48 |
|
| 49 |
There is also a new internal function called `ex_large_model(int exoid)` |
| 50 |
which will return 1 if new version; 0 if old version. |
| 51 |
|
| 52 |
If the function is passed a negative exoid, then it will check the |
| 53 |
environment variable `EXODUS_LARGE_MODEL` and return 1 if it is |
| 54 |
defined. It also currently prints a warning message saying that the |
| 55 |
large model size was selected via the environment variable. |
| 56 |
|
| 57 |
If you are using the Exodus api, then the only change to the client |
| 58 |
application is the passing of the `EX_LARGE_MODEL` flag to `ex_create` or |
| 59 |
the setting of the `EXODUS_LARGE_MODEL` environment variable. If your |
| 60 |
client application is reading the database, no changes are needed. |
| 61 |
|
| 62 |
======================================================================== |
| 63 |
If your client application bypasses some or all of the Exodus API |
| 64 |
and makes direct netCDF calls, you will need to modify the calls. The |
| 65 |
changes that were made are shown below along with the name of the |
| 66 |
Exodus API function in which the changes were made. |
| 67 |
|
| 68 |
Alternatively, you can look at the changes that were made to the API at |
| 69 |
http://github.com/sandialabs/seacas/packages/seacas/libraries/exodus/src. |
| 70 |
The files that were changed are: |
| 71 |
|
| 72 |
\note The filenames have been changed since this was written. |
| 73 |
* exgnvt.c |
| 74 |
* expcor.c |
| 75 |
* expini.c |
| 76 |
* expnv.c |
| 77 |
* expvp.c |
| 78 |
* expvpc.c |
| 79 |
* ex_utils.c |
| 80 |
* excopy.c |
| 81 |
* excre.c |
| 82 |
* exgcor.c |
| 83 |
* exgnv.c |
| 84 |
|
| 85 |
\section ex_create ex_create(): |
| 86 |
-- Check whether the `EX_LARGE_MODEL` mode was set. If so, then the |
| 87 |
mode passed to nccreate must have the `NC_64BIT_OFFSET` bit set. For |
| 88 |
example, `mode |= NC_64BIT_OFFSET;` |
| 89 |
|
| 90 |
NOTE: `NC_64BIT_OFFSET` is defined in the Sandia's netCDF version |
| 91 |
"3.4-snl10X". It should also be in netCDF-3.6.0 once it is released. |
| 92 |
|
| 93 |
-- Write the exodus file size `ATT_FILESIZE` attribute (1=large, 0=normal): |
| 94 |
|
| 95 |
``` |
| 96 |
filesiz = (nclong)(((cmode & EX_LARGE_MODEL) != 0) || (ex_large_model(-1) == 1)); |
| 97 |
if (ncattput (exoid, NC_GLOBAL, ATT_FILESIZE, NC_LONG, 1, &filesiz) == -1) |
| 98 |
... handle errors... |
| 99 |
``` |
| 100 |
|
| 101 |
\section ex_put_init ex_put_init(): |
| 102 |
-- If writing a "large model" capable database, then the coordinates |
| 103 |
are defined as components instead of an array. The variables are |
| 104 |
`VAR_COORD_X`, `VAR_COORD_Y` (if 2D or 3D), `VAR_COORD_Z` (if 3D). If not, |
| 105 |
define the `VAR_COORD` variable as is currently done. |
| 106 |
|
| 107 |
``` |
| 108 |
if (ex_large_model(exoid) == 1) { |
| 109 |
/* node coordinate arrays -- separate storage... */ |
| 110 |
dim[0] = numnoddim; |
| 111 |
if (ncvardef (exoid, VAR_COORD_X, nc_flt_code(exoid), 1, dim) == -1) |
| 112 |
{ ... handle error } |
| 113 |
|
| 114 |
if (num_dim > 1) { |
| 115 |
if (ncvardef (exoid, VAR_COORD_Y, nc_flt_code(exoid), 1, dim) == -1) |
| 116 |
{ ... handle error } |
| 117 |
} |
| 118 |
|
| 119 |
if (num_dim > 2) { |
| 120 |
if (ncvardef (exoid, VAR_COORD_Z, nc_flt_code(exoid), 1, dim) == -1) |
| 121 |
{ ... handle error } |
| 122 |
} |
| 123 |
} else { |
| 124 |
/* node coordinate arrays: -- all stored together (old method) */ |
| 125 |
.... define the old way... |
| 126 |
} |
| 127 |
``` |
| 128 |
|
| 129 |
\section ex_put_coord ex_put_coord(): |
| 130 |
-- If writing a "large model" capable database, then the coordinates |
| 131 |
are written a component at a time, otherwise write the old way as a single blob. |
| 132 |
|
| 133 |
``` |
| 134 |
if (ex_large_model(exoid) == 0) { |
| 135 |
... write coordinates old way... |
| 136 |
} else { |
| 137 |
if ((coordidx = ncvarid (exoid, VAR_COORD_X)) == -1) |
| 138 |
{ ... handle error } |
| 139 |
|
| 140 |
if (num_dim > 1) { |
| 141 |
if ((coordidy = ncvarid (exoid, VAR_COORD_Y)) == -1) |
| 142 |
{ ... handle error } |
| 143 |
} else { |
| 144 |
coordidy = 0; |
| 145 |
} |
| 146 |
if (num_dim > 2) { |
| 147 |
if ((coordidz = ncvarid (exoid, VAR_COORD_Z)) == -1) |
| 148 |
{ ... handle error } |
| 149 |
} else { |
| 150 |
coordidz = 0; |
| 151 |
} |
| 152 |
/* write out the coordinates */ |
| 153 |
for (i=0; i<= num_vars; i++) { |
| 154 |
dims[0] = time_dim; |
| 155 |
dims[1] = num_nod_dim; |
| 156 |
if ((ncvardef (exoid, VAR_NOD_VAR_NEW(i), |
| 157 |
nc_flt_code(exoid), 2, dims)) == -1) |
| 158 |
{ ... handle error ... } |
| 159 |
} |
| 160 |
} |
| 161 |
``` |
| 162 |
|
| 163 |
\section ex_put_nodal_var ex_put_nodal_var(): |
| 164 |
-- If the large model method, write the nodal variable data to the correct variable; |
| 165 |
if the old method, determine the location within the blob |
| 166 |
|
| 167 |
``` |
| 168 |
if (ex_large_model(exoid) == 0) { |
| 169 |
/* write values of the nodal variable */ |
| 170 |
if ((varid = ncvarid (exoid, VAR_NOD_VAR)) == -1) { |
| 171 |
... handle error... |
| 172 |
} |
| 173 |
start[0] = --time_step; |
| 174 |
start[1] = --nodal_var_index; |
| 175 |
start[2] = 0; |
| 176 |
|
| 177 |
count[0] = 1; |
| 178 |
count[1] = 1; |
| 179 |
count[2] = num_nodes; |
| 180 |
} else { |
| 181 |
/* nodal variables stored separately, find variable for this variable |
| 182 |
index */ |
| 183 |
if ((varid = ncvarid (exoid, VAR_NOD_VAR_NEW(nodal_var_index))) == -1) { |
| 184 |
... handle error ... |
| 185 |
} |
| 186 |
|
| 187 |
start[0] = --time_step; |
| 188 |
start[1] = 0; |
| 189 |
|
| 190 |
count[0] = 1; |
| 191 |
count[1] = num_nodes; |
| 192 |
} |
| 193 |
|
| 194 |
if (ncvarput (exoid, varid, start, count, |
| 195 |
ex_conv_array(exoid,WRITE_CONVERT,nodal_var_vals,num_nodes)) == -1) { |
| 196 |
...handle error ... |
| 197 |
} |
| 198 |
``` |
| 199 |
|
| 200 |
There are similar modifications to the reading of the nodal coordinates |
| 201 |
and the reading of nodal variables. If interested in those functions, see the viewcvs URL |
| 202 |
listed above. |
| 203 |
|
| 204 |
If there are any questions, contact: |
| 205 |
Greg Sjaardema |
| 206 |
[email protected] |