When responding to a recent post regarding the VSL stream-to-file facilities (see "vslloadstreamf and vslsavestreamf" by user may_ka ), I encountered a rather bizarre error.
I copied the example file vslstream2file.f from the mkl/examples/vslf/source directory (from the most recent Parallel Studio 2020 Update 2 distribution) to a working directory, and modified the code to match the user's problem description. Upon building and running the adapted program, I found that it ran normally. I wondered if the user was using an older version of MKL/Parallel Studio, which could be the reason for the errors that the user reported.
To check, I opened a PS2016 command window (on Windows 10), changed to the same working directory, and rebuilt the EXE. Without being aware of it, I was using the PS2020 example files and compiling them with PS2016. When run, the program gave the error message:
Error: skipahead advanced initializationis unsupported (code 0).
I then repeated the same operations on the unmodified example file vslstream2file.f from the PS2020 distribution, and obtained the same error message when using PS2016.
After failing to understand this message, I traced the cause to a line in the include file errcheck.inc from the same directory as the source fle:
if ( num == VSL_RNG_ERROR_SKIPAHEADEX_UNSUPPORTED ) then print 34, "Error: skipahead advanced initialization", & & "is unsupported (code ",num,")."
The symbol VSL_RNG_ERROR_SKIPAHEADEX_UNSUPPORTED is not defined in the file mkl_vsl.f90 of PS2016, and is declared as a PARAMETER with value -1004 in the mkl_vsl.f90 of PS2020. Even when the CheckVslError() subroutine is called with argument num = 0, the test succeeds!
Here is the explanation: num is an integer with value 0. In the older mkl_vsl.f90, the symbolic constant VSL_RNG_ERROR_SKIPAHEADEX_UNSUPPORTED is not declared or defined. According to the implicit typing rules of Fortran, it is a real variable; since it is a local uninitialized real variable, its initial value may be 0.0 or something else. The comparison may succeed when the integer 0 is converted to real and compared with 0.0 using XMM instructions.
The solution is quite simple. Add IMPLICIT NONE or IF (NUM == 0) RETURN at the beginning of errcheck.inc. This change might save some of your users from having to puzzle over strange error messages even when the VSL routine has returned an error code of zero.