Skip to content

Commit

Permalink
BUG: fix scanning of timesteps when LGR present
Browse files Browse the repository at this point in the history
The scanning for SEQNUM/INTEHEAD pairs was failing when
LGR's are present, as LGR's also have INTEHEAD. Hence we
now look for first INTEHEAD when SEQNUM is found.
  • Loading branch information
jcrivenaes committed May 25, 2022
1 parent 6911594 commit 500d5e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/clib/xtg/grd3d_ecl_tsteps.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
* cf. XTGeo LICENSE
***************************************************************************************
*/

#include "libxtg.h"
#include "libxtg_.h"
#include "logger.h"
#include <stdbool.h>

/* since windows is missing strsep() */
char *
Expand Down Expand Up @@ -80,7 +80,10 @@ grd3d_ecl_tsteps(FILE *fc, int *seqnums, int *day, int *mon, int *year, int nmax
tofree = keywords;
ic = 0;
nc = 0;
// while ((token = strsep(&keywords, "|")) != NULL) {

// with LGR's, multiple INTEHEAD may occurs; need here to ensure first
// INTEHEAD after SEQNUM
bool look_for_intehead = false;
while ((token = _mystrsep(&keywords, "|")) != NULL) {

if (strcmp(token, "SEQNUM ") == 0) {
Expand All @@ -94,9 +97,10 @@ grd3d_ecl_tsteps(FILE *fc, int *seqnums, int *day, int *mon, int *year, int nmax
seqnums[nc] = intrecord[0];

free(intrecord);
look_for_intehead = true;
}

if (strcmp(token, "INTEHEAD") == 0) {
if (strcmp(token, "INTEHEAD") == 0 && look_for_intehead == true) {
keytype = 1;
rlen = reclengths[ic];
rstart = recstarts[ic];
Expand All @@ -121,6 +125,7 @@ grd3d_ecl_tsteps(FILE *fc, int *seqnums, int *day, int *mon, int *year, int nmax
throw_exception("Fail in dimensions in: grd3d_ecl_tsteps, nc >= nmax");
return EXIT_FAILURE;
}
look_for_intehead = false;
}

ic++;
Expand Down

0 comments on commit 500d5e3

Please sign in to comment.