You are looking for a license management system. open-license-manager/licensecc: Software licensing, copy protection in C++. It has few dependencies ... says it is for C++, but it has a C API so you can call it from Fortran.
I've used the Polyhedron Licensing System before. The original developer has retired, but I believe it is still available.
It uses a simple text license file, and all the calls are pure Fortran.
I knew about the Polyhedron system, but did not see it offered at polyhedron.com. I should have done a search for it - it shows at Polyhedron Licensing System - Alfasoft (adeptscience.co.uk), but links to buy it are dead.
This in my world this depends if the software is high value low volume or visa versa. For the first case I prefer a hardware (dongle) based system of which there are many choices.
That is why I said for high value low volume software. A dongle with a data facility and encryption engine can give very high levels of protection. There are many systems without ongoing fees. But cost is an issue if the software value is relatively low.
You first have to ask yourself what you are trying to accomplish, how much effort are you willing to put into it, and how much hassle should your customers put up with? If occasional theft doesn't worry you, then don't spend a lot of time trying to make the system difficult to crack. You want to make it hard enough to deter casual theft, but no so hard that legitimate users will complain (you can find many instances of that in this forum - Intel did a particularly craptastic job of license management for its developer tools, so I am sure that the support team is relieved that the oneAPI tools have no license management at all.)
Do you care if someone copies the serial number, license file, or whatever? If so, then you need some method of tying the license to a specific system. Is someone allowed to run more than one copy? Then you can't tie to a system.
DVF/CVF had a simple serial number system - the serial number had a checksum and there was a Windows registry key that recorded the info. We had lots of theft, but we didn't care that much as it didn't affect overall sales. We used to joke that we sold only one copy to Russia and Vietnam... When a particular SN became widely copied, I added detection of that to patch updates - caught a few people that way.