The problem is that B$ has already been defined (explicitly or implicitly) before your line 4240.
Per the documentation, https://www.sol20.org/manuals/basic5.pdf, DM error means:
Dimension error. Attempt to dimension (DIM) array more than once in program