Pmetrics icon indicating copy to clipboard operation
Pmetrics copied to clipboard

MAXGRD, MAXACT may need to be bigger than (2*ndim+1)*nsub

Open CRquantum opened this issue 3 years ago • 0 comments

Just post here before I forgot.

In NPAG, the number of max grid points (MAXGRD and MAXACT in npagdriv.f) are 2129, 5003, 10007, ..., until 960252. Those numbers seems are mostly depend on the dimension (ndim) of the problem, not the number of subjects(nsub).

However, I suggest that we may have one more additional check, that is MAXGRD and MAXACT needs to be equal or bigger than (2*ndim+1)*nsub which is about the number of total expanded grid points.

Without this protection, when MAXGRD and MAXACT is smaller than (2*ndim+1)*nsub, some parts of the code may access elements in array CORDEN(and other arrays) which are actually outside the array's boundary(access violation). This will cause unpredictable behavior of the program, such as giving incorrect results and/or terminating unexpectedly.

This protection could be added in R I guess; if not, we can implement it in Fortran.

CRquantum avatar Nov 11 '22 07:11 CRquantum