I called the DNEQNF non-linear solver by IMSL but keep getting this exception after a few iterations. An mkl_dfti module is used during as part of the function needs to be solved during DNEQNF.
"Exception thrown at 0x3D3E5144 (imslmkl_dll.dll) in *.exe: 0xC0000005: Acess violation writing location 0xCCCCCCCC.
If there is a handler for this exception, the program may be safely continued."
The error is forrtl: severe (157): Program Exception - access violation
In Debug build (depending on other factors), the runtime image initializes uninitialized data to 0xCCCCCCCC.
I agree with Steve, the address of an output (or workspace) has not been initialized. Note, this can also occur if you declare an incorrect interface or lack thereof, use something like EXTERN someFunction where the function requires an interface.
Please show the source code, or at least the subroutine in which the nonlinear equations are defined, the call to DNEQNF, and the declarations of the variables in the CALL statement.
Access errors can occur if you are using ALLOCATE for some temporary array (possibly needed for the FFT calls inside your FCN subroutine) and use the array without checking the allocation status. Your program may run out of heap space if you do not deallocate such variables after they are no longer needed.
Are you USE-ing the provided module interfaces .OR. did you provide your own?
Speaking of allocatables. Should you have realloc_lhs enabled (default now)
arrayOut = ArrayOrArrayExpression
can resize arrayOut. Should this arrayOut be a workspace array or output array of MKL or other library, these library calls will use the (then) provided array. IOW they will not re-re-size the array to what is necessary. It is your responsibility to assure proper arguments to the routine called.
xi, shun wrote:
I figured out the problem is because I used a pre-assigned fnorm variable for the non-linear solver.
I find that puzzling. Since FNORM is an output variable for NEQNF, it should not matter whether or not a value is assigned to it before the call. However, if a literal constant were used as the actual argument, then an attempt to overwrite it could cause an access violation.
Please clarify what exactly happened, because the answer could help others later with similar problems.