For Programmers: Free Programming Magazines  


Home > Archive > Fortran > February 2007 > simple compilation batch file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author simple compilation batch file
Beliavsky

2007-02-16, 7:06 pm

I compile code from the command line with all warnings turned on, but
a single error in the code can lead to multiple error and warning
messages, so if a compilation fails, I want to compile only until the
first error occurs. The following batch file does this for g95 using
the Windows cmd.exe language. Changing it for other compilers or
translating it to a Unix shell language would not be difficult. I have
found the script convenient

@ echo off
:: compile a source file with a .f90 suffix with g95 with all warnings
on
:: if compilation fails, compile again, until the first error occurs
:: usage: g95co foo.f90 or g95co foo
setlocal
set cmnd=g95 -c -Wall -Wextra
set src=%1.f90
set obj=%~n1.o
if exist %obj% del %obj%
if not exist %src% (set src=%1)
if not exist %src% (echo %src% does not exist && goto :eof)
if exist %src% call %cmnd% %src%
if not exist %obj% (
echo.
echo ****************************************
****************
echo COMPILING WITH FONE-ERROR:
g95 -c -fone-error %src%)
:eof

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com