Variable-screening model for diatomic molecules