I have a program consisting of a number of hundreds of subroutines residing in the same folder. How do I write the ifort command to compile and link these subroutines? I guess a batchfile will be needed if all subroutines have to be listed. If so, can I retrieve the subroutines names from VS, which I have used until now?
How many files are there? The number of subroutines is not relevant.
You can get a list of the files in a directory using command line tools such as dir.
dir *.f90 /b > some_file.txt
You can then edit and change the order of the file names in that file. Changing the order might be necessary if your source code contains modules.
You can then pass this list of files to ifort:
Add appropriate compiler command line options to suit. The option that enables parallel compilation ('/MP', if memory serves me correctly) mzy be of interest if you have lots of files.
Note you can invoke the build system used by Visual Studio from the command line too.
For routine development of a program using a command line you would normally use some sort of build tool, of which there are many.
Normally a programmer would us a make file (NMAKE under Windows) for this.
If you are not using modules, the second link may be of interest.
I like to setup a makefile if there are several source files, instead of a batch file, to avoid rebuilding the entire project when there are changes to just a few source files. In addition to the links Jim provided, there is an example of a Windows makefile to run using "nmake" in this previous forum article:
Thanks for you quick reply, which gives a simple but easy way to compile and link my program! Will I get in trouble if the text file contains more subroutine names than needed to produce an exe module. This situation appears when you are trouble-shooting and take away some subroutine call in the code.
Hi Greg and Jim,
Thanks for your advice! I have been using VS up till now, when MPI came into the picture requiring command line (CL) work. At the moment I use both VS and CL. Is it so that makefile requires less work to implement as I am already using VS? In any case, makefile or nmake is the next step if I go for the CL alternative in the future.
The text file contains a list of file names, not subroutine names. Each file will contain Fortran code, possibly many subroutines and functions. It is not a problem to include subroutines that are never called in the program, but of course all subroutines that are called must be present.
In this context, it is good to be aware of a number of utilities that can be used to scan a set of Fortran sources from which an EXE or DLL is to be built, and generate a makefile that takes into account the module dependencies and builds the objects in the proper order. Follow the "makefile builders" links on the page http://www.fortran.com/the-fortran-company-homepage/fortran-tools-libraries-and-application-software/ , and Polyhedron Software's AutoMake, https://www.polyhedron.com/Automake7 .