An algorithm of evaluating effective fields and effective interactions in the cluster variation method