The code is quite bugged.
the arrays you access in LEV_SHAD_Initialise haven't been correctly initialized.
You create ter for example with [1,1] instead of the size you read out.
If you put a ter = new float[LMapSize,LMapSize] and Lmap = new float[LMapSize,LMapSize] after the function head it should work.
btw: Since when do () work for array index? They should be []
the arrays you access in LEV_SHAD_Initialise haven't been correctly initialized.
You create ter for example with [1,1] instead of the size you read out.
If you put a ter = new float[LMapSize,LMapSize] and Lmap = new float[LMapSize,LMapSize] after the function head it should work.
btw: Since when do () work for array index? They should be []