Skip to content

Commit 160ee7f

Browse files
authored
FEAT: check unsorted layer depths (#95)
1 parent 04a1702 commit 160ee7f

File tree

1 file changed

+6
-1
lines changed
  • pygrt/C_extension/src/common

1 file changed

+6
-1
lines changed

pygrt/C_extension/src/common/model.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,12 @@ GRT_MODEL1D * grt_read_mod1d_from_file(const char *command, const char *modelpat
295295
// 如果读取了深度,转为厚度
296296
if(mod1d->io_depth){
297297
for(int i=1; i<nlay; ++i){
298-
modarr[i-1][0] = modarr[i][0] - modarr[i-1][0];
298+
// 检查,若为负数,则表示输入的层顶深度非递增
299+
double tmp = modarr[i][0] - modarr[i-1][0];
300+
if(tmp < 0.0){
301+
GRTRaiseError("[%s] In model file, negative thickness found in layer %d.\n", command, i);
302+
}
303+
modarr[i-1][0] = tmp;
299304
}
300305
}
301306

0 commit comments

Comments
 (0)