Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmor should stop if coordinates table is not present #429

Closed
doutriaux1 opened this issue Jan 8, 2019 · 4 comments · Fixed by #487 or #524
Closed

cmor should stop if coordinates table is not present #429

doutriaux1 opened this issue Jan 8, 2019 · 4 comments · Fixed by #487 or #524
Assignees
Projects

Comments

@doutriaux1
Copy link
Collaborator

I forgot to copy CMIP6_coordinates.json to my local dir and when i ran my script i got a zillions line of error masking the actual error:


! In function: cmor_load_table_internal
! 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Error: Could not find file: ./CMIP6_coordinate.json
!
!!!!!!!!!!!!!!!!!!!!!!!!!


C Traceback:
In function: 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Warning: Can't open/read JSON table ./CMIP6_coordinate.json
!
!!!!!!!!!!!!!!!!!!!!!!!!!


C Traceback:
! In function: cmor_set_var_def_att
! called from: cmor_set_variable_entry
! called from: cmor_load_table_internal
! 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Error: Reading table Amon: axis name: 'time' for variable: 'ccb' is not defined in table. Table defines dimensions: 'longitude latitude time' for this variable
!
!!!!!!!!!!!!!!!!!!!!!!!!!


C Traceback:
! In function: cmor_set_var_def_att
! called from: cmor_set_variable_entry
! called from: cmor_load_table_internal
! 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Error: Reading table Amon: axis name: 'time' for variable: 'cct' is not defined in table. Table defines dimensions: 'longitude latitude time' for this variable
!
!!!!!!!!!!!!!!!!!!!!!!!!!


C Traceback:
! In function: cmor_set_var_def_att
! called from: cmor_set_variable_entry
! called from: cmor_load_table_internal
! 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Error: Reading table Amon: axis name: 'time' for variable: 'cfc113global' is not defined in table. Table defines dimensions: 'time' for this variable
!
!!!!!!!!!!!!!!!!!!!!!!!!!
[... more ...]

It probably stop with a critical error when the coordinates table is not found, or just issue the first 3 or 4 errors follwoing and then stop issuing essentially the same error.

Maybe a summary of errors at the end? Like 1 "table not found" error and "433445425243 dimension not defined in table errors"

@taylor13
Copy link
Collaborator

l agree that not finding a table that is needed should be a critical error.

@mauzey1 mauzey1 added this to To Do in 3.5 Mar 19, 2019
@mauzey1 mauzey1 moved this from To Do to In Progress in 3.5 May 8, 2019
@mauzey1 mauzey1 self-assigned this May 8, 2019
@mauzey1
Copy link
Collaborator

mauzey1 commented May 16, 2019

@doutriaux1
I tried setting the error levels from CMOR_WARNING to CMOR_CRITICAL in this section below that is trying to find the tables

cmor/Src/cmor_tables.c

Lines 609 to 644 in e066e2b

if (rc == TABLE_NOTFOUND) {
cmor_ntables += 1;
cmor_init_table(&cmor_tables[cmor_ntables], cmor_ntables);
*table_id = cmor_ntables;
strcpy(cmor_tables[cmor_ntables].path, szTable);
cmor_set_cur_dataset_attribute_internal(CV_INPUTFILENAME,
szControlFilenameJSON, 1);
rc = cmor_load_table_internal(szAxisEntryFilenameJSON, table_id);
if (rc != TABLE_SUCCESS) {
snprintf(msg, CMOR_MAX_STRING, "Can't open/read JSON table %s",
szAxisEntryFilenameJSON);
cmor_handle_error(msg, CMOR_WARNING);
}
rc = cmor_load_table_internal(szTable, table_id);
if (rc != TABLE_SUCCESS) {
snprintf(msg, CMOR_MAX_STRING, "Can't open/read JSON table %s",
szTable);
cmor_handle_error(msg, CMOR_WARNING);
}
rc = cmor_load_table_internal(szFormulaVarFilenameJSON, table_id);
if (rc != TABLE_SUCCESS) {
snprintf(msg, CMOR_MAX_STRING, "Can't open/read JSON table %s",
szFormulaVarFilenameJSON);
cmor_handle_error(msg, CMOR_WARNING);
}
rc = cmor_load_table_internal(szControlFilenameJSON, table_id);
if (rc != TABLE_SUCCESS) {
snprintf(msg, CMOR_MAX_STRING, "Can't open/read JSON table %s",
szControlFilenameJSON);
cmor_handle_error(msg, CMOR_WARNING);
}
} else if (rc == TABLE_FOUND) {
rc = TABLE_SUCCESS;
}

However, it doesn't stop the program when it reached those errors.

Here is the section of cmor_handle_error that handles critical errors, and exiting the program when it encounters a warning.

cmor/Src/cmor.c

Lines 641 to 645 in e066e2b

if ((CMOR_MODE == CMOR_EXIT_ON_WARNING) || (level == CMOR_CRITICAL)) {
fflush(stdout);
fflush(output_logfile);
kill(getpid(), SIGTERM);
}

Should we add an exit(1) to that section?

@mauzey1
Copy link
Collaborator

mauzey1 commented May 16, 2019

I tried adding exit(1) to that section of cmor_handle_error I posted, but it caused some of the Python tests to fail.

@mauzey1
Copy link
Collaborator

mauzey1 commented Jul 29, 2019

Coming back to this issue, I discovered that PrePARE wasn't stopping at the error where it didn't find CMIP6_coordinate.json but kept going with a list of errors as @doutriaux1 described. I will create a pull request to fix this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
3.5
  
Done
3 participants