You need to write some code for parsing arithmetic expressions, or find some code that someone else has written. Try Googling for something like
parsing arithmetic expressions fortran
arithmetic parser fortran
etc.
With an interpreted language like Perl, it's often possible to read an arithmetic expression as a string and simply evaluate it. With compiled languages like Fortran, you generally can't do this.
