A "friendly" reviewer purposely disclosed his identity to me (the author) during a previous round of reviews of a paper that was not published back then. However, he helped me to make the article better. If I publish the paper now, should I thank him by name or as an anonymous reviewer?
You can thank him by name for making helpful suggestions for improvement. You don't need to say that the comments were during a formal review.
Alternatively, he should be thanked as an anonymous reviewer.
I would, personally, prefer the first alternative. The publisher might also prefer it if you are using the name.
Email him first and thank him that way before disclosing him in the article. He may have inadvertently revealed himself or there was an administrative error that revealed him? Good to check just in case.
Most people would prefer a personal email anyway rather than a mention in an article. Though both is great too.
Echoing Wolfgang Bangerth's comment:
Anytime you plan on thanking someone in the acknowledgements to a paper, it is not a bad idea to contact them first to let them know what you plan to say. This gives them a heads up and a chance to object in case for some reason they don't want to be thanked, as well as a double-check that you have written their name correctly and so forth. (It's not just a matter of spelling - for instance, some people sign their emails with one variant of their name, and their papers with another.)
So I would do that in this case:
Dear Professor Schmoe,
I wanted to write to thank you for your helpful comments on my paper "On the reticulation of splines". I really appreciate you taking the time to review the paper so carefully.
I am planning to write in the acknowledgements: "I thank Joseph Schmoe for suggestions regarding the material in Section 5." Is that how you prefer your name to be written? I can also list you as "an anonymous reviewer" if you would prefer that.
If he agrees, then I see no problem with mentioning his name.
I think strictly speaking the right answer here is to thank them anonymously. If you thank them by name, you are revealing more than they themselves disclosed - they may, in principle, by willing to disclose their identity towards the authors but not towards the general public.
That said, I find the general practice of thanking anonymous reviewers to be a bit silly - every peer reviewed paper has had (usually anonymous) reviewers, and people tend to thank them whether they have actually made good comments or not. I think nothing is lost to anybody if we just stopped this custom entirely (and, ideally, start implementing some actual benefits for peer reviewing).
Yes. (Asking permission is good, too.)
I agree with this answer, but responding to OP's comment, "He won't have any problem with being associated with my findings, my doubt was about the ethics of naming him when I am not supposed to know who he is.":
I should think the most ethical perspective is to make sure to name him. Otherwise, it might seem like you are hiding the relationship. I personally think disclosing all potential conflicts of interest (if that's the ethical dilemma, here) is the best way to avoid both deception and the appearance of deception.
Apart from the fact that reviewers should not disclose their identities to authors, ... I'd think that you should not play into the situation by publicizing the fact that the reviewer did so.
The potential problem is that if we have many precedents for this, then some people might start expecting reviewers to disclose their identities, possibly with the purpose of getting a co-authorship (otherwise deserved or not), and so on.
If the reviewer went above and beyond the call of duty, I think a thanks by name is entirely appropriate. I know of at least one example of exactly that situation where the referee is thanked by name.