Automatic Module compilation

Hi!

I have a dream!

Instead of:

pgf90 libxmath.f90 libutil.f90 libgrid.f90 libdate.f90
libcoordinate.f90 libmeteo.f90 libcontract.f90 libwindfunction.f90
bmp_io.c libbmp.f90 test.f90 -o test.exe

I would like to do something like:

pgf90 -fautomodules test.f90 -o test.exe

Many of my programs start with a list of USE statements like:

USE LibXMath
USE LibUtil
USE LibGrid
USE LibDate
USE LibCoordinate
USE LibMeteo
USE LibContract
USE LibWindFunction
USE LibBMP

The modules are generally stored in separate .f90-files with names like:

LibXMath.f90
LibUtil.f90
LibGrid.f90
LibDate.f90
LibCoordinate.f90
LibMeteo.f90
LibContract.f90
LibWindFunction.f90
LibBMP.f90

When I compile my main program, I would very much like to have a compile-switch that takes care after all the modules by (re-)compiling them in the correct order (if necessary) and linking them automatically. I have already taken the effort of listing the names of all necessary modules in the sources of the main program and of the sources of the modules themselves. To me it seems a bit odd that I have to tell the compiler again which modules to compile. In particular, the order in which I have to tell the compiler to process the sources matters. Every time again this is a nuisance/“challenge”. An unnecessary nuisance/“challenge”.

Is there a way to do the above trick?
If not: can I invite you to consider implementing it?

Regards,


Arjan

Hi Arjan,

With PVF(PGI Visual Fortran), it will look for dependencies and compile/re-compile. Unfortunately we don’t have such thing for Linux.

Hongyon

Hi!

I just wrote a utility named “checkdeps” that recursively generates the filelist of all dependencies in correct order. A convention for using filenames that correspond with the modulenames must be followed. The call:

“checkdeps test.f90”

gives as output the following string:

“libxmath.f90 libutil.f90 libgrid.f90 libdate.f90
libcoordinate.f90 libmeteo.f90 libcontract.f90 libwindfunction.f90
libbmp.f90 test.f90”

This is done such that all sources for USED modules always preceed the name of the USING sourcefiles.

–> Remains 1 challenge: how to call this script in one integrated compile-statement with pgf90? In the past I called:

pgf90 -Mfreeform libxmath.f90 libutil.f90 libgrid.f90 libdate.f90
libcoordinate.f90 libmeteo.f90 libcontract.f90 libwindfunction.f90
bmp_io.c libbmp.f90 test.f90 -lnag -o test.exe

With the new utility I seek a method to make a smart compile statement like:

pgf90 -Mfreeform bmp_io.c -lnag -o test.exe

Probably something with a pipe |, but my unix skills are too poor to handle this. Can I please ask you to help sort this out? If you want, you can have the sources of the script (which itself is written in f90), also for integration with your pgf90 distribution.

Regards,


Arjan

Hi Arjan,

On linux, cat command should work in this case, make sure double quotes are removed from checkdeps file.

Example: pgf90 bmp_io.c cat checkdeps

Hongyon

Thanks!
The double quotes were just inserted in this forum message to distinguish from the running text, they don’t appear in the script output.
The first occasion that I can try this will be next monday. But then this will be my first action!

I’ll let you know what happens.

Regards,


Arjan

Hi!

Sorry for the delay! The command:

pgf90 getdeps test.f90 -o test.exe

does the trick! Funny how much difference two `-symbols can make!
The two anti-primes (what are they called?) and the utility-call replace the specification of all MODULES. Anyone who wants to have (the sources of) utility getdeps is free to ask.

Regards,


Arjan