source code from Dr. Yuan of latest DOS-TEM