From 7d7480308af6123a3c4e71355ca04e10fbf5088e Mon Sep 17 00:00:00 2001 From: "hailey.johnson" Date: Wed, 26 Apr 2017 09:54:21 -0400 Subject: [PATCH] fix index in FindBeachCells and bug on initialization --- cem/cem.c | 8 +++----- cem/conditions.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cem/cem.c b/cem/cem.c index 428c6d2..5bb39bd 100644 --- a/cem/cem.c +++ b/cem/cem.c @@ -574,17 +574,15 @@ void FindBeachCells(int YStart) if (debug1) printf("FirstX: %3d FirstY: %3d z: 0 \n", X[0], Y[0]); z = 0; - X[z - 1] = X[z]; - Y[z - 1] = Y[z] - 1; while ((Y[z] < 2 * Y_MAX - 1) && (z < MaxBeachLength - 1)) { - z++; NextX = -2; NextY = -2; BehindX = -2; BehindY = -2; - FindNextCell(X[z - 1], Y[z - 1], z - 1); + FindNextCell(X[z], Y[z], z); + z++; X[z] = NextX; Y[z] = NextY; XBehind[z] = BehindX; @@ -733,7 +731,7 @@ void FindNextCell(int x, int y, int z) { return; } - if ((X[z - 1] == X[z]) && (Y[z - 1] == Y[z] - 1)) + if (z == 0 ||(X[z - 1] == X[z]) && (Y[z - 1] == Y[z] - 1)) /* came from left */ { if ((PercentFullSand[x + 1][y] + PercentFullRock[x + 1][y]) > 0.0) { diff --git a/cem/conditions.c b/cem/conditions.c index bce637d..7dd54bd 100644 --- a/cem/conditions.c +++ b/cem/conditions.c @@ -126,7 +126,7 @@ void InitBeach(double **percent_full_sand, double **percent_full_rock, char **al int ocean_start = INIT_BEACH + 1; /* Fill in first row of ocean */ - percent_full_rock[beach_start][col] = 0.0; + percent_full_rock[ocean_start][col] = 0.0; percent_full_sand[ocean_start][col] = 0.0; all_rock[ocean_start][col] = 'n'; all_beach[ocean_start][col] = 'n';