modified p49_magnet1.c