diff --git a/src/Infrastructure/Mesh/src/ESMCI_ESMFMesh_Util.C b/src/Infrastructure/Mesh/src/ESMCI_ESMFMesh_Util.C index 727e07711f..d1426915a8 100644 --- a/src/Infrastructure/Mesh/src/ESMCI_ESMFMesh_Util.C +++ b/src/Infrastructure/Mesh/src/ESMCI_ESMFMesh_Util.C @@ -635,20 +635,20 @@ void get_elemConn_info_from_ESMFMesh_file(int pioSystemDesc, int pioFileDesc, ch // Declare some useful vars int dimid; - int varid; + int elementConn_id; int localrc; int piorc; - + // Figure out dimension of elementConn array int dimElementConn=2; // Get elementConn varid - piorc = PIOc_inq_varid(pioFileDesc, "elementConn", &varid); + piorc = PIOc_inq_varid(pioFileDesc, "elementConn", &elementConn_id); if (!CHECKPIOERROR(piorc, std::string("Error elementConn variable not in file ") + filename, ESMF_RC_FILE_OPEN, localrc)) throw localrc;; // Get elementConn number of dims - piorc = PIOc_inq_varndims(pioFileDesc, varid, &dimElementConn); + piorc = PIOc_inq_varndims(pioFileDesc, elementConn_id, &dimElementConn); if (!CHECKPIOERROR(piorc, std::string("Error getting number of dims for elementConn variable in file ") + filename, ESMF_RC_FILE_OPEN, localrc)) throw localrc;; @@ -669,29 +669,37 @@ void get_elemConn_info_from_ESMFMesh_file(int pioSystemDesc, int pioFileDesc, ch //// Handle start_index attribute - -#if 0 - // Get start_index attribute, otherwise default to 0. - int start_index=0; // Set to default - int att_start_index=0; + // Get start_index attribute, otherwise default to 1. + int start_index=1; // Set to default for ESMFMesh + int att_start_index=1; // Set to default ESMFMesh piorc = PIOc_get_att_int(pioFileDesc, elementConn_id, "start_index", &att_start_index); + + // If there's a start_index then record it and modify elementConn accordingly + // NOTE: the default start_index of 1, doesn't require the elementConn to be changed if (piorc == PIO_NOERR) { + + // Get start_index value start_index=att_start_index; + + // Given start_index switch base of connections to be 1-based (what's expected by mesh create code) + for (int i=0; i