Thank you very much for the references. Just for the future reference, I would like to emphasize the following points:

1. According to Stanton Glantz's book (Chapter 10), "When there are tied ranks, and we use the normal distribution to compute the
P value, sigma_w needs to be reduced by a factor that depends on the number of ties". You have used this formula in your function.

2. The correction for continuity has been implemented based on the second reference mentioned above (http://faculty.vassar.edu/lowry/ch12a.html)

Please correct any false statement mentioned above.

So, do you mean that "0.5" in Line 123 (zW=(abs(W)-0.5)/sW) is the correction for continuity; however the real mean of the distribution of W is 0?

I read a little about the concept of "continuity correction"; however, it seems that those methods including Yates' Correction have not been designed for the normal distribution. I really appreciate if you send me your reference on this particular case (i.e. for the normal distribution)

According to Chapter 10 of the book by Stanton A. Glantz (Primer of Biostatistics) and as you mentioned above, mu_w=0 (mu_w is the mean of the distribution of W). My question is why line 123 of your code shows that mean = 0.5 :
zW=(abs(W)-0.5)/sW;