Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

Dependency analysis of mild insanity in Fortran

$
0
0

For those who want to have a bit of a giggle...

A while back, as a bit of a F2003 learning exercise I started writing a little Fortran parser in Fortran that lets you do dependency analysis - "tell me what order I should compile my files".  If you are working in Visual Studio this sort of thing is done automagically for you, but if you ever have to drop back to the command line then this sort of utility actually can come in handy.  And sometimes it even gives the right output.

Because it was a learning exercise crossed with delusions of grandeur and a good dash of a tasty cabernet/merlot blend it has been put together from "first principles" - some script kiddy could probably achieve the same in a dozen lines of the scripting language of the day using a few regexes and a hash thingamajig, but honestly people - where is the fun in that?  Plus it does F2008 syntax And Nothing More (it was supposed to be a F2003 learning exercise, but I learn real slow).  And you need fairly recent ifort, because writing this has, at times over the years, felt rather like a ifort compiler testing exercise.

So, if you compile the attached (you need /standard-semantics) , you can do things like the following from the cmd prompt (with extensions enabled):

>>set files= & (for /f "usebackq" %f in (`dir *.f90 /b ^| FF08Depends -`) do @(echo %f & ifort /c /nologo /standard-semantics %f & set files=!files! %~nf.obj)) & ifort /nologo /FeFF08Depends.exe !files!

	CharUtils.f90

	Strings.f90

	ErrorLocations.f90

	ErrorLevels.f90

	Errors.f90

	CompilerKinds.f90

	Sources.f90

	SourceLocations.f90

	Tokens.f90

	MatchUtils.f90

	UseStmtsUtils.f90

	UnitUtilities.f90

	SyntaxParts.f90

	SubmoduleStmtsUtils.f90

	StmtFunctionStmtsUtils.f90

	Statements.f90

	StatementData.f90

	SourceFiles.f90

	ErrorCodes.f90

	CharacterTypes.f90

	Scanner.f90

	ScanFreeForm.f90

	ScanFixedForm.f90

	ProgramStmtsUtils.f90

	ModuleStmtsUtils.f90

	IntegerLists.f90

	IncludeLines.f90

	FileUtilities.f90

	Debug.f90

	CompilerHosts.f90

	Classifier.f90

	FileDependencyPass.f90

	DependencyUtils.f90

	DefaultHosts.f90

	DependsImplementation.f90

	CmdLine.f90

	FF08Depends.f90

(which shows you how to compile and link the tool that you need to compile and link the tool that shows you how to compile and link the tool - and to think Fortran previously couldn't handle recursion...) 

Then combine it with the graphviz/dot tool, and you can also generate lots of wacky diagrams:

Now, for some inexplicable reason I think I might go and have spaghetti for dinner.


Viewing all articles
Browse latest Browse all 3108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>