herr_t
ss_gfile_debug_one(size_t idx, FILE *out, const char *prefix)
{
SS_ENTER(ss_gfile_debug_one, herr_t);
int self, fldsize=16;
unsigned flags;
char intro[32], white_space[128];
ss_gfile_t *gfile=NULL;
hbool_t first_only=FALSE;
self = ss_mpi_comm_rank(SS_COMM_WORLD);
sprintf(intro, "SSlib-%d: ", self);
if (!prefix) prefix = "";
if ('\001'==*prefix) {
first_only = TRUE;
prefix++;
}
/* The gfile general info */
gfile = SS_GFILE_IDX(idx);
fprintf(out, "%s%s%-*s", intro, prefix, fldsize, "global file:");
fprintf(out, " direct(%lu) 0x%08lx ", (unsigned long)idx, (unsigned long)gfile);
if (!gfile) {
fprintf(out, "invalid\n");
goto done;
}
fprintf(out, "serial(0x%08lx)\n", (unsigned long)(gfile->serial));
/* Replace prefix with all white space if appropriate now that we displayed the first line */
if (first_only) {
assert(strlen(prefix)<sizeof white_space);
memset(white_space, ' ', strlen(prefix));
white_space[strlen(prefix)] = '\0';
prefix = white_space;
}
/* The destination file */
fprintf(out, "%s%s%-*s \"%s\"\n", intro, prefix, fldsize, "file name:", gfile->name);
fprintf(out, "%s%s%-*s", intro, prefix, fldsize, "file status:");
if (gfile->cur_open<=0) {
fprintf(out, " closed\n");
goto done;
}
fprintf(out, " open(%lu)", (unsigned long)(gfile->cur_open));
fprintf(out, " flags(");
flags = gfile->flags;
fprintf(out, "%s", (flags & H5F_ACC_RDWR) ? "RDWR" : "RDONLY");
flags &= ~H5F_ACC_RDWR;
if (flags & H5F_ACC_TRANSIENT) {
fprintf(out, "|TRANSIENT");
flags &= ~H5F_ACC_TRANSIENT;
}
if (flags & H5F_ACC_TRUNC) {
fprintf(out, "|TRUNC");
flags &= ~H5F_ACC_TRUNC;
}
if (flags & H5F_ACC_EXCL) {
fprintf(out, "|EXCL");
flags &= ~H5F_ACC_EXCL;
}
if (flags & H5F_ACC_CREAT) {
fprintf(out, "|CREAT");
flags &= ~H5F_ACC_CREAT;
}
if (flags & H5F_ACC_DEBUG) {
fprintf(out, "|DEBUG");
flags &= ~H5F_ACC_DEBUG;
}
if (flags) {
fprintf(out, "|0x%08lx", (unsigned long)flags);
}
fprintf(out, ")");
if (0==gfile->fid) fprintf(out, " hdf5(closed)\n");
else if (1==gfile->fid) fprintf(out, " hdf5(transient)\n");
else if (gfile->fid<0) fprintf(out, " hdf5(error)\n");
else fprintf(out, " hdf5(%lu)\n", (unsigned long)(gfile->fid));
done:
SS_LEAVE(0);
}