added subroutine outfilemainname to pick a core name for the output files. Output filenames will be truncated if longer than 25 characters.