So there we are. Any suggestions?
If I understand correctly, nested functions *are* what you want and there is code to do exactly what you want in the implementation of OpenMP.
However, I am not into that code enough to give you any further hint. Paolo