You installed gcc9 successfully; the failure was in rebuilding hdf5-18, which was found to be broken by rev-upgrade (which runs automatically after each installation and checks all installed ports). hdf5-18 has been replaced by hdf5, so hdf5 was built with the same variants that hdf5-18 was previously installed with, but the gcc49 variant no longer works with your new Xcode version.
You can fix this by simply uninstalling hdf5-18 and installing hdf5 with some newer gcc variant. However it seems like hdf5 shouldn't offer the variant in the first place when it won't work.