19 #include "order/order_internal.h"
56 if ((intLoad (stream, &versval) +
57 intLoad (stream, &cblknbr) +
58 intLoad (stream, &vertnbr) != 3) ||
59 ((versval != 0) && (versval != 1)) ||
60 (cblknbr > vertnbr)) {
61 pastix_print_error(
"orderLoad: bad input (1)" );
70 for (cblknum = 0, i = 1; (i == 1) && (cblknum <= cblknbr); cblknum ++)
71 i = intLoad (stream, &ordeptr->
rangtab[cblknum]);
74 for (vertnum = 0; (i == 1) && (vertnum < vertnbr); vertnum ++)
75 i = intLoad (stream, &ordeptr->
permtab[vertnum]);
79 for (cblknum = 0, i = 1; (i == 1) && (cblknum < cblknbr); cblknum ++)
80 i = intLoad (stream, &ordeptr->
treetab[cblknum]);
88 pastix_print_error(
"pastixOrderLoad: bad input (2)" );
96 for (vertnum = ordeptr->
rangtab[0], vertnnd = vertnum + vertnbr;
97 vertnum < vertnnd; vertnum ++)
98 peritax[permtax[vertnum]] = vertnum;
136 char *filename = NULL;
141 if ( ordemesh == NULL ) {
148 filename = pastix_getenv(
"PASTIX_FILE_ORDER" );
153 if ( filename == NULL ) {
154 filename =
"ordername";
163 pastix_print_error(
"test: cannot load order" );
169 pastix_cleanenv( filename );
207 if (ordeptr->
permtab == NULL) {
208 pastix_print_error(
"pastixOrderSave: cannot save ordering without direct permutation data" );
211 if (ordeptr->
rangtab == NULL) {
212 pastix_print_error(
"pastixOrderSave: cannot save ordering without rangtab array" );
215 if (ordeptr->
treetab == NULL) {
216 pastix_print_error(
"pastixOrderSave: cannot save ordering without treetab array" );
223 assert( vertnbr == ordeptr->
vertnbr );
226 if (fprintf (stream,
"1\n%ld\t%ld\n",
228 (
long) vertnbr) == EOF) {
229 pastix_print_error(
"pastixOrderSave: bad output (1)" );
234 for (cblknum = 0, o = 1; (o == 1) && (cblknum < ordeptr->cblknbr); cblknum ++) {
235 o = intSave (stream, ordeptr->
rangtab[cblknum]);
236 putc (((cblknum & 7) == 7) ?
'\n' :
'\t', stream);
238 o = intSave (stream, ordeptr->
rangtab[cblknum]);
242 for (vertnum = 0; (o == 1) && (vertnum < (vertnbr - 1)); vertnum ++) {
243 o = intSave (stream, ordeptr->
permtab[vertnum]);
244 putc (((vertnum & 7) == 7) ?
'\n' :
'\t', stream);
246 o = intSave (stream, ordeptr->
permtab[vertnum]);
250 for (cblknum = 0; (o == 1) && (cblknum < ordeptr->cblknbr - 1); cblknum ++) {
251 o = intSave (stream, ordeptr->
treetab[cblknum]);
252 putc (((cblknum & 7) == 7) ?
'\n' :
'\t', stream);
254 o = intSave (stream, ordeptr->
treetab[cblknum]);
258 pastix_print_error(
"pastixOrderSave: bad output (2)" );
299 char *filename = NULL;
302 if ( ordemesh == NULL ) {
309 filename = pastix_getenv(
"PASTIX_FILE_ORDER" );
314 if ( filename == NULL ) {
315 filename =
"ordergen";
320 if ( pastix_data->
procnbr == 0 ) {
325 pastix_print_error(
"cannot save order" );
330 pastix_cleanenv( filename );
BEGIN_C_DECLS typedef int pastix_int_t
static int ordering_load(pastix_order_t *ordeptr, FILE *stream)
Load an ordering from a file.
static int ordering_save(const pastix_order_t *ordeptr, FILE *stream)
Save an ordering to a file.
FILE * pastix_fopenw(const char *dirname, const char *filename, const char *mode)
Open a file in the unique directory of the pastix instance.
FILE * pastix_fopen(const char *filename)
Open a file in the current directory in read only mode.
void pastix_gendirectories(pastix_data_t *pastix_data)
Generate a unique temporary directory to store output files.
@ PASTIX_ERR_BADPARAMETER
int pastixOrderAlloc(pastix_order_t *ordeptr, pastix_int_t vertnbr, pastix_int_t cblknbr)
Allocate the order structure.
int pastixOrderSave(pastix_data_t *pastix_data, const pastix_order_t *ordeptr)
Save an ordering to a file.
void pastixOrderExit(pastix_order_t *ordeptr)
Free the arrays initialized in the order structure.
int pastixOrderLoad(const pastix_data_t *pastix_data, pastix_order_t *ordeptr)
Load an ordering from a file.
Main PaStiX data structure.