diff options
author | Bill Wendling <wendling@ncsa.uiuc.edu> | 2003-11-12 23:02:00 (GMT) |
---|---|---|
committer | Bill Wendling <wendling@ncsa.uiuc.edu> | 2003-11-12 23:02:00 (GMT) |
commit | 680262645fc936e17571ac43e905b678bc799bb6 (patch) | |
tree | f6eaa5077ddf4722757f599c8c1a9ae70d8d887c /src | |
parent | 2668d2e5a3c34631918ff6ea1945c514e2df083b (diff) | |
download | hdf5-680262645fc936e17571ac43e905b678bc799bb6.zip hdf5-680262645fc936e17571ac43e905b678bc799bb6.tar.gz hdf5-680262645fc936e17571ac43e905b678bc799bb6.tar.bz2 |
[svn-r7838] Purpose:
Bug fix and File Addition
Description:
- Fixed when reading from the file with FPHDF5. It wasn't recording
how many bytes it read.
- Added Arithmetic Transformation modules. These haven't been
included into the HDF5 build. I just added them here for future
porposes...
Solution:
Added a call to "MPI_Get_count" to get the number of bytes read.
Platforms tested:
Linux (w/ FPHDF5)
AIX (w/ and w/o FPHDF5)
FPHDF5-specific fixes...No need for H5committest
Misc. update:
Diffstat (limited to 'src')
-rw-r--r-- | src/H5DZ.c | 82 | ||||
-rw-r--r-- | src/H5DZtrans.c | 707 | ||||
-rw-r--r-- | src/H5FDfphdf5.c | 45 | ||||
-rw-r--r-- | src/H5FPserver.c | 16 |
4 files changed, 822 insertions, 28 deletions
diff --git a/src/H5DZ.c b/src/H5DZ.c new file mode 100644 index 0000000..7affb47 --- /dev/null +++ b/src/H5DZ.c @@ -0,0 +1,82 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu> + * 25. August 2003 + * + * Dataset Filters + * + * This is a filter, similar to the H5Z* filters. However, these + * transformations are applied to the data before a write or after a + * read. + * + * - If applied before a write, a permanent change of the data + * may take place. + * - If applied after a read, the data is only changed + * in memory. + * + * The transformations are transitory (not saved with the dataset). + * The transformations aren't automatically reversible, since this + * isn't possible in all cases and not possible if the original + * transformation was lost (it being transitory). + */ + +/* + * Pablo information + * (Put before include files to avoid problems with inline functions) + */ +#define PABLO_MASK H5DZ_mask + +#include "H5private.h" /* Generic Functions */ + + +/*------------------------------------------------------------------------- + * Function: H5DZ_init_interface + * Purpose: Initializes the data filters layer. + * Return: Non-negative on success/Negative on failure + * Programmer: Bill Wendling + * 25. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5DZ_init_interface(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOINIT(H5DZ_init_interface) + + FUNC_LEAVE_NOAPI(ret_value) +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_term_interface + * Purpose: Terminate the H5DZ layer. + * Return: 0 + * Programmer: Bill Wendling + * 25. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5DZ_term_interface(void) +{ + if (interface_initialize_g) + interface_initialize_g = 0; + + return 0; +} diff --git a/src/H5DZtrans.c b/src/H5DZtrans.c new file mode 100644 index 0000000..5e54621 --- /dev/null +++ b/src/H5DZtrans.c @@ -0,0 +1,707 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu> + * 25. August 2003 + */ + +/* + * This is the context-free grammar for our expressions: + * + * expr := term | term '+ term | term '-' term + * term := factor | factor '*' factor | factor '/' factor + * factor := number | + * symbol | + * '-' factor | // unary minus + * '+' factor | // unary plus + * '(' expr ')' + * symbol := [a-zA-Z][a-zA-Z0-9]* + * number := INTEGER | FLOAT + * // INTEGER is a C long int + * // FLOAT is a C double + */ + +#define H5DZ_DEBUG + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +/* Token types */ +typedef enum { + ERROR, + INTEGER, + FLOAT, + SYMBOL, + PLUS, + MINUS, + MULT, + DIVIDE, + LPAREN, + RPAREN, + END +} token_type; + +/* The token */ +typedef struct { + const char *tok_expr; /* Holds the original expression */ + + /* Current token values */ + token_type tok_type; /* The type of the current token */ + const char *tok_begin; /* The beginning of the current token */ + const char *tok_end; /* The end of the current token */ + + /* Previous token values */ + token_type tok_last_type; /* The type of the last token */ + const char *tok_last_begin; /* The beginning of the last token */ + const char *tok_last_end; /* The end of the last token */ +} token; + +typedef union { + char *sym_val; + long int_val; + double float_val; +} num_val; + +typedef struct node { + struct node *lchild; + struct node *rchild; + token_type type; + num_val value; +} node; + +/* local functions */ +static void H5DZ_destroy_parse_tree(node *tree); +static token *H5DZ_get_token(token *current); +static node *H5DZ_parse_expression(token *current); +static node *H5DZ_parse_term(token *current); +static node *H5DZ_parse_factor(token *current); +static node *H5DZ_new_node(token_type type); + +#ifdef H5DZ_DEBUG +static void H5DZ_debug(node *tree); +static void H5DZ_print(node *tree, FILE *stream); +#endif /* H5DZ_DEBUG */ + +/*------------------------------------------------------------------------- + * Function: H5DZ_unget_token + * Purpose: Rollback the token to the previous token retrieved. There + * should only need to be one level of rollback necessary + * for our grammar. + * Return: Always succeeds. + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +H5DZ_unget_token(token *current) +{ + /* check args */ + assert(current); + + current->tok_type = current->tok_last_type; + current->tok_begin = current->tok_last_begin; + current->tok_end = current->tok_last_end; +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_get_token + * Purpose: Determine what the next valid token is in the expression + * string. The current position within the token string is + * kept internal to the token and handled by this and the + * unget_token function. + * Return: Succeess: The passed in token with a valid tok_type + * field. + * Failure: The passed in token but with the tok_type + * field set to ERROR. + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static token * +H5DZ_get_token(token *current) +{ + /* check args */ + assert(current); + + /* Save the last position for possible ungets */ + current->tok_last_type = current->tok_type; + current->tok_last_begin = current->tok_begin; + current->tok_last_end = current->tok_end; + + current->tok_begin = current->tok_end; + + while (current->tok_begin[0] != '\0') { + if (isspace(current->tok_begin[0])) { + /* ignore whitespace */ + } else if (isdigit(current->tok_begin[0]) || + current->tok_begin[0] == '.') { + current->tok_end = current->tok_begin; + + /* + * integer := digit-sequence + * digit-sequence := digit | digit digit-sequence + * digit := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 + */ + if (current->tok_end[0] != '.') { + /* is number */ + current->tok_type = INTEGER; + + while (isdigit(current->tok_end[0])) + ++current->tok_end; + } + + /* + * float := digit-sequence exponent | + * dotted-digits exponent? + * dotted-digits := digit-sequence '.' digit-sequence? | + * '.' digit-sequence + * exponent := [Ee] [-+]? digit-sequence + */ + if (current->tok_end[0] == '.' || + current->tok_end[0] == 'e' || + current->tok_end[0] == 'E') { + current->tok_type = FLOAT; + + if (current->tok_end[0] == '.') + do { + ++current->tok_end; + } while (isdigit(current->tok_end[0])); + + if (current->tok_end[0] == 'e' || + current->tok_end[0] == 'E') { + ++current->tok_end; + + if (current->tok_end[0] == '-' || + current->tok_end[0] == '+') + ++current->tok_end; + + if (!isdigit(current->tok_end[0])) { + current->tok_type = ERROR; + fprintf(stderr, "Invalidly formatted floating point number\n"); + } + + while (isdigit(current->tok_end[0])) + ++current->tok_end; + } + + /* Check that this is a properly formatted numerical value */ + if (isalpha(current->tok_end[0]) || current->tok_end[0] == '.') { + current->tok_type = ERROR; + fprintf(stderr, "Invalidly formatted floating point number\n"); + } + } + + break; + } else if (isalpha(current->tok_begin[0])) { + /* is symbol */ + current->tok_type = SYMBOL; + current->tok_end = current->tok_begin; + + while (isalnum(current->tok_end[0])) + ++current->tok_end; + + break; + } else { + /* should be +, -, *, /, (, or ) */ + switch (current->tok_begin[0]) { + case '+': current->tok_type = PLUS; break; + case '-': current->tok_type = MINUS; break; + case '*': current->tok_type = MULT; break; + case '/': current->tok_type = DIVIDE; break; + case '(': current->tok_type = LPAREN; break; + case ')': current->tok_type = RPAREN; break; + default: + current->tok_type = ERROR; + fprintf(stderr, "Unknown token: %c\n", current->tok_begin[0]); + return current; + } + + current->tok_end = current->tok_begin + 1; + break; + } + + ++current->tok_begin; + } + + if (current->tok_begin[0] == '\0') + current->tok_type = END; + + return current; +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_destroy_parse_tree + * Purpose: Recursively destroys the expression tree. + * Return: Nothing + * Programmer: Bill Wendling + * 25. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +H5DZ_destroy_parse_tree(node *tree) +{ + if (!tree) + return; + + if (tree->type == SYMBOL) + free(tree->value.sym_val); + + H5DZ_destroy_parse_tree(tree->lchild); + H5DZ_destroy_parse_tree(tree->rchild); + free(tree); +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_parse + * Purpose: Entry function for parsing the expression string. + * Return: Success: Valid NODE ptr to an expression tree. + * Failure: NULL + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static node * +H5DZ_parse(const char *expression) +{ + token tok; + + if (!expression) + return NULL; + + /* Set up the initial token for parsing */ + tok.tok_expr = tok.tok_begin = tok.tok_end = expression; + return H5DZ_parse_expression(&tok); +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_parse_expression + * Purpose: Beginning of the recursive descent parser to parse the + * expression. An expression is: + * + * expr := term | term '+' term | term '-' term + * + * Return: Success: Valid NODE ptr to expression tree + * Failure: NULL + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static node * +H5DZ_parse_expression(token *current) +{ + node *expr = H5DZ_parse_term(current); + + for (;;) { + node *new_node; + + current = H5DZ_get_token(current); + + switch (current->tok_type) { + case PLUS: + new_node = H5DZ_new_node(PLUS); + + if (!new_node) { + H5DZ_destroy_parse_tree(expr); + expr = NULL; + goto done; + } + + new_node->lchild = expr; + new_node->rchild = H5DZ_parse_term(current); + + if (!new_node->rchild) { + H5DZ_destroy_parse_tree(new_node); + fprintf(stderr, "Parsing error occurred\n"); + expr = NULL; + goto done; + } + + expr = new_node; + break; + case MINUS: + new_node = H5DZ_new_node(MINUS); + + if (!new_node) { + H5DZ_destroy_parse_tree(expr); + expr = NULL; + goto done; + } + + new_node->lchild = expr; + new_node->rchild = H5DZ_parse_term(current); + + if (!new_node->rchild) { + H5DZ_destroy_parse_tree(new_node); + fprintf(stderr, "Parsing error occurred\n"); + expr = NULL; + goto done; + } + + expr = new_node; + break; + case RPAREN: + H5DZ_unget_token(current); + goto done; + case END: + goto done; + default: + H5DZ_destroy_parse_tree(expr); + expr = NULL; + fprintf(stderr, "Parsing error around %c\n", current->tok_begin[0]); + goto done; + } + } + +done: + return expr; +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_parse_term + * Purpose: Parses a term in our expression language. A term is: + * + * term := factor | factor '*' factor | factor '/' factor + * + * Return: Success: Valid NODE ptr to expression tree + * Failure: NULL + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static node * +H5DZ_parse_term(token *current) +{ + node *term = H5DZ_parse_factor(current); + + for (;;) { + node *new_node; + + current = H5DZ_get_token(current); + + switch (current->tok_type) { + case MULT: + new_node = H5DZ_new_node(MULT); + + if (!new_node) { + H5DZ_destroy_parse_tree(term); + term = NULL; + goto done; + } + + new_node->lchild = term; + new_node->rchild = H5DZ_parse_factor(current); + + if (!new_node->rchild) { + H5DZ_destroy_parse_tree(term); + fprintf(stderr, "Parsing error occurred\n"); + term = NULL; + goto done; + } + + term = new_node; + break; + case DIVIDE: + new_node = H5DZ_new_node(DIVIDE); + + if (!new_node) { + H5DZ_destroy_parse_tree(term); + term = NULL; + goto done; + } + + new_node->lchild = term; + new_node->rchild = H5DZ_parse_factor(current); + term = new_node; + + if (!new_node->rchild) { + H5DZ_destroy_parse_tree(term); + fprintf(stderr, "Parsing error occurred\n"); + term = NULL; + goto done; + } + + break; + case RPAREN: + H5DZ_unget_token(current); + goto done; + case END: + goto done; + default: + H5DZ_unget_token(current); + goto done; + } + } + +done: + return term; +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_parse_factor + * Purpose: Parses a factor in our expression language. A factor is: + * + * factor := number | // C long or double + * symbol | // C identifier + * '-' factor | // unary minus + * '+' factor | // unary plus + * '(' expr ')' + * + * Return: Success: Valid NODE ptr to expression tree + * Failure: NULL + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static node * +H5DZ_parse_factor(token *current) +{ + node *factor, *new_node; + + current = H5DZ_get_token(current); + + switch (current->tok_type) { + case INTEGER: + factor = H5DZ_new_node(INTEGER); + + if (!factor) + goto done; + + sscanf(current->tok_begin, "%ld", &factor->value.int_val); + break; + case FLOAT: + factor = H5DZ_new_node(FLOAT); + + if (!factor) + goto done; + + sscanf(current->tok_begin, "%lf", &factor->value.float_val); + break; + case SYMBOL: + factor = H5DZ_new_node(SYMBOL); + + if (!factor) + goto done; + + factor->value.sym_val = calloc(current->tok_end - current->tok_begin + 1, 1); + strncpy(factor->value.sym_val, current->tok_begin, + current->tok_end - current->tok_begin); + break; + case LPAREN: + factor = H5DZ_parse_expression(current); + + if (!factor) + goto done; + + current = H5DZ_get_token(current); + + if (current->tok_type != RPAREN) { + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Syntax error around %c\n", current->tok_begin[0]); + factor = NULL; + goto done; + } + + break; + case RPAREN: + /* We shouldn't see a ) right now */ + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Syntax error: unexpected ')' \n"); + factor = NULL; + goto done; + case PLUS: + /* unary + */ + new_node = H5DZ_parse_factor(current); + + if (new_node) { + if (new_node->type != INTEGER && new_node->type != FLOAT && + new_node->type != SYMBOL) { + H5DZ_destroy_parse_tree(new_node); + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + return NULL; + } + + factor = new_node; + new_node = H5DZ_new_node(PLUS); + + if (!new_node) { + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + factor = NULL; + goto done; + } + + new_node->rchild = factor; + factor = new_node; + } else { + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + return NULL; + } + + break; + case MINUS: + /* unary - */ + new_node = H5DZ_parse_factor(current); + + if (new_node) { + if (new_node->type != INTEGER && new_node->type != FLOAT && + new_node->type != SYMBOL) { + H5DZ_destroy_parse_tree(new_node); + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + return NULL; + } + + factor = new_node; + new_node = H5DZ_new_node(MINUS); + + if (!new_node) { + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + factor = NULL; + goto done; + } + + new_node->rchild = factor; + factor = new_node; + } else { + H5DZ_destroy_parse_tree(factor); + fprintf(stderr, "Parsing error occurred\n"); + return NULL; + } + + break; + case END: + goto done; + } + +done: + return factor; +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_new_node + * Purpose: Create and initilize a new NODE structure. + * Return: Success: Valid NODE ptr + * Failure: NULL + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static node * +H5DZ_new_node(token_type type) +{ + node *new_node = calloc(1, sizeof(node)); + + if (new_node) { + new_node->type = type; + } else { + fprintf(stderr, "Out of memory\n"); + } + + return new_node; +} + +#ifdef H5DZ_DEBUG +/*------------------------------------------------------------------------- + * Function: H5DZ_debug + * Purpose: Print out the expression in a nice format which displays + * the precedences explicitly with parentheses. + * Return: Nothing + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +H5DZ_debug(node *tree) +{ + fprintf(stderr, "Expression: "); + H5DZ_print(tree, stderr); + fprintf(stderr, "\n"); +} + +/*------------------------------------------------------------------------- + * Function: H5DZ_print + * Purpose: Print out the expression in a nice format which displays + * the precedences explicitly with parentheses. + * Return: Nothing + * Programmer: Bill Wendling + * 26. August 2003 + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +H5DZ_print(node *tree, FILE *stream) +{ + /* check args */ + assert(stream); + + if (!tree) + return; + + if (tree->type == INTEGER) { + fprintf(stream, "%ld", tree->value.int_val); + } else if (tree->type == FLOAT) { + fprintf(stream, "%f", tree->value.float_val); + } else if (tree->type == SYMBOL) { + fprintf(stream, "%s", tree->value.sym_val); + } else { + fprintf(stream, "("); + H5DZ_print(tree->lchild, stream); + + switch (tree->type) { + case PLUS: fprintf(stream, "+"); break; + case MINUS: fprintf(stream, "-"); break; + case MULT: fprintf(stream, "*"); break; + case DIVIDE: fprintf(stream, "/"); break; + default: fprintf(stream, "Invalid expression tree\n"); + return; + } + + H5DZ_print(tree->rchild, stream); + fprintf(stream, ")"); + } +} +#endif /* H5DZ_DEBUG */ + +int main(int argc, char **argv) +{ + node *n; + printf("Parsing Expression: \"%s\"\n", argv[1]); + n = H5DZ_parse(argv[1]); + H5DZ_debug(n); + return 0; +} diff --git a/src/H5FDfphdf5.c b/src/H5FDfphdf5.c index b9f5b64..b47ca7a 100644 --- a/src/H5FDfphdf5.c +++ b/src/H5FDfphdf5.c @@ -1058,7 +1058,7 @@ H5FD_fphdf5_set_eoa(H5FD_t *_file, haddr_t addr) if (!H5FD_fphdf5_is_sap(_file)) /* Retrieve the EOA information */ if (H5FP_request_set_eoa(_file, addr, &req_id, &status)) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, HADDR_UNDEF, "can't retrieve eoa information") + HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "can't retrieve eoa information") file->eoa = addr; @@ -1194,13 +1194,14 @@ H5FD_fphdf5_read(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size_t to int") /* Only look for MPI views for raw data transfers */ - if(mem_type==H5FD_MEM_DRAW) { + if (mem_type == H5FD_MEM_DRAW) { H5P_genplist_t *plist; - H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ + H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ /* Obtain the data transfer properties */ if ((plist = H5I_object(dxpl_id)) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + xfer_mode = H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); /* @@ -1209,11 +1210,11 @@ H5FD_fphdf5_read(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, * allowed us to test that btype == ftype == MPI_BYTE (or even * MPI_TYPE_NULL, which could mean "use MPI_BYTE" by convention). */ - if(xfer_mode==H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { + MPI_Datatype file_type; /* Remember that views are used */ - use_view_this_time=TRUE; + use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ if (H5P_get(plist, H5FD_FPHDF5_XFER_MEM_MPI_TYPE_NAME, &buf_type) < 0) @@ -1265,8 +1266,7 @@ H5FD_fphdf5_read(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, H5FD_mpio_native, file->info)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mrc) - } /* end if */ - else { + } else { /* * This is metadata - we want to try to read it from the SAP * first. @@ -1283,7 +1283,15 @@ HDfprintf(stderr, "%s:%d: Metadata cache read failed!\n", FUNC, __LINE__); if (sap_status == H5FP_STATUS_OK) { /* WAH-HOO! We've found it! We can leave now */ - } else if (sap_status != H5FP_STATUS_MDATA_NOT_CACHED) { + } else if (sap_status == H5FP_STATUS_MDATA_NOT_CACHED) { + /* Metadata isn't cached, so grab it from the file */ + if ((mrc = MPI_File_read_at(file->f, mpi_off, buf, size_i, + MPI_BYTE, &status)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mrc) + + if ((mrc = MPI_Get_count(&status, MPI_BYTE, &bytes_read)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mrc) + } else { /* FIXME: something bad happened */ HDfprintf(stderr, "%s:%d: Metadata cache read failed!\n", FUNC, __LINE__); } @@ -1424,11 +1432,11 @@ done: */ herr_t H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, H5P_genplist_t *plist, - haddr_t addr, int size, const void *buf) + haddr_t addr, int size, const void *buf) { H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; MPI_Status status; - MPI_Datatype buf_type=MPI_BYTE; + MPI_Datatype buf_type = MPI_BYTE; MPI_Offset mpi_off; int mrc; int bytes_written; @@ -1455,7 +1463,7 @@ H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, H5P_genplist_t *plist H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ /* Obtain the data transfer properties */ - xfer_mode=(H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); + xfer_mode = (H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); /* * Set up for a fancy xfer using complex types, or single byte block. @@ -1463,11 +1471,11 @@ H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, H5P_genplist_t *plist * allowed us to test that btype == ftype == MPI_BYTE (or even * MPI_TYPE_NULL, which could mean "use MPI_BYTE" by convention). */ - if(xfer_mode==H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { + MPI_Datatype file_type; /* Remember that views are used */ - use_view_this_time=TRUE; + use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ if (H5P_get(plist, H5FD_FPHDF5_XFER_MEM_MPI_TYPE_NAME, &buf_type) < 0) @@ -1491,18 +1499,17 @@ H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, H5P_genplist_t *plist } /* end if */ /* Write the data. */ - if(use_view_this_time) { + if (use_view_this_time) { /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if ((mrc = MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size, buf_type, &status)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mrc) - } /* end if */ - else { + } else { /*OKAY: CAST DISCARDS CONST QUALIFIER*/ if ((mrc = MPI_File_write_at(file->f, mpi_off, (void*)buf, size, buf_type, &status)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mrc) - } /* end else */ + } /* Reset the file view when we used MPI derived types */ if (use_view_this_time) diff --git a/src/H5FPserver.c b/src/H5FPserver.c index f612b13..25a456b 100644 --- a/src/H5FPserver.c +++ b/src/H5FPserver.c @@ -146,11 +146,10 @@ static H5FP_file_info *H5FP_new_file_info_node(unsigned file_id); static H5FP_file_info *H5FP_find_file_info(unsigned file_id); /* local file modification structure handling functions */ -static H5FP_mdata_mod *H5FP_new_file_mod_node(unsigned rank, - H5FD_mem_t mem_type, - haddr_t addr, - unsigned md_size, - char *metadata); +static H5FP_mdata_mod *H5FP_new_file_mod_node(H5FD_mem_t mem_type, + haddr_t addr, + unsigned md_size, + char *metadata); static herr_t H5FP_free_mod_node(H5FP_mdata_mod *info); /* local request handling functions */ @@ -499,8 +498,7 @@ H5FP_free_mod_node(H5FP_mdata_mod *info) * Modifications: */ static H5FP_mdata_mod * -H5FP_new_file_mod_node(unsigned UNUSED rank, H5FD_mem_t mem_type, - haddr_t addr, unsigned md_size, char *metadata) +H5FP_new_file_mod_node(H5FD_mem_t mem_type, haddr_t addr, unsigned md_size, char *metadata) { H5FP_mdata_mod *ret_value = NULL; @@ -558,7 +556,7 @@ H5FP_add_file_mod_to_list(H5FP_file_info *info, H5FD_mem_t mem_type, HGOTO_DONE(SUCCEED); } - if ((fm = H5FP_new_file_mod_node(rank, mem_type, addr, md_size, metadata)) != NULL) { + if ((fm = H5FP_new_file_mod_node(mem_type, addr, md_size, metadata)) != NULL) { if (!H5TB_dins(info->mod_tree, (void *)fm, NULL)) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert modification into tree"); @@ -1283,7 +1281,7 @@ H5FP_sap_handle_read_request(H5FP_request_t *req) r.addr = 0; r.status = H5FP_STATUS_MDATA_NOT_CACHED; - if ((info = H5FP_find_file_info(req->file_id)) != NULL) { + if ((info = H5FP_find_file_info(req->file_id)) != NULL && info->num_mods) { H5FP_mdata_mod mod; /* Used to find the correct modification */ H5TB_NODE *node; |