You are on page 1of 3

@echo off

REM ===========================================================================
REM Build a User Subroutine Executable - NT Version
REM ===========================================================================
REM
REM This batch file will compile a user subroutine and link it
REM with the appropriate libraries and user subroutine program.
REM
REM The Compaq Fortran works to compile subroutines for MineSight.
REM
REM Compaq Digital or Microsoft Fortran MUST be in your PATH.
REM
REM Other Assumptions: libusrdyn.lib or libusrdynb.lib (if using m612db1,
m612db2,
REM or m708db1) must be in your LOCAL or
REM medexe\user\lib\compaq\32 directory.
REM The main program object module (eg m208v1.obj)
REM MUST be in your local or medexe\user\lib\compaq\32
REM directory.
REM The user subroutine MUST be in a LOCAL file
REM with a .f or .for extension (eg, usr208.f)
REM
REM Usage: bldusr program user_sub [-out progname.exe]
REM
REM where: program is the main program object module (without
REM extension. eg m208v1)
REM user_sub is the filename (excluding the extension)
REM of the file containing the user subroutine.
REM (eg user_sub is geo208 for file geo208.for).
REM
REM By default the executable will be named program.exe (eg M208V1.EXE)
REM
REM Example: bldusr m508v1 tst508 -- makes Compaq Fortran
REM exe named m508v1.exe
REM
REM To specify another name for the resulting program
REM add "-out progname.exe" (including .exe extension)
REM
REM Example: bldusr m508v1 tst508 -out tst508.exe --
REM makes Compaq Fortran
REM exe named tst508.exe
REM
REM
REM WARNING: Make sure your libusrdyn.lib corresponds to the Compaq Fortran.
REM
REM ===========================================================================
REM
if %1! == ! goto USAGE
if %2! == ! goto USAGE

set usrlibpath=%medexe%\user\lib\compaq\32

set mfor=%2.f
if not exist %mfor% set mfor=%2.for
if not exist %mfor% goto NOSUB

set mobj=%1.obj
if not exist %mobj% set mobj=%usrlibpath%\%1.obj
if not exist %mobj% goto NOOBJ
if /I %1! == m612db1! goto USRB
if /I %1! == m612db2! goto USRB
if /I %1! == m708db1! goto USRB

set libname=libusrdyn.lib
set libu=libusrdyn.lib
if not exist %libu% set libu=%usrlibpath%\libusrdyn.lib
if not exist %libu% goto NOLIB

goto REPORT

: USRB

set libname=libusrdynb.lib
set libu=libusrdynb.lib
if not exist %libu% set libu=%usrlibpath%\libusrdynb.lib
if not exist %libu% goto NOLIB

: REPORT

echo.
echo Using User Subroutine File: %mfor%
echo Main Program Object Module: %mobj%
echo Library: %libu%

set exename=%1.exe
set mout=

if %3! == -out! goto SETOUT


if %3! == -OUT! goto SETOUT
if %3! == /out! goto SETOUT
if %3! == /OUT! goto SETOUT

goto BLD

:SETOUT
if %4! == ! goto BLD

set exename=%4
set mout=/OUT:%4

:BLD

echo Output executable name: %exename%


echo.

REM ================== Compaq Fortran ============================


if exist %exename% del %exename%

echo fl32 /MDs %mobj% %mfor% %libu% /LINK %mout% /NODEFAULTLIB:LIBC.LIB


fl32 /MDs %mobj% %mfor% %libu% /LINK %mout% /NODEFAULTLIB:LIBC.LIB

echo.
if exist %2.obj del %2.obj

goto END
REM ======================= ERROR Messages ================================

:USAGE
echo.
echo Usage: bldusr program user_sub [-out progname.exe]
echo.
echo where: program is the main program object module (without
echo extension, eg m208v1)
echo user_sub is the filename (excluding the extension)
echo of the file containing the user subroutine.
echo (eg user_sub is geo208 for file geo208.for).
echo.
echo By default executable will be named program.exe (eg m208v1.exe)
echo.
echo Example: bldusr m508v1 tst508 -- makes Compaq Fortran
echo exe named m508v1.exe
echo.
echo To specify another name for the resulting program
echo add "-out progname.exe" (including .exe extension)
echo.
echo Example: bldusr m508v1 tst508 -out tst508.exe --
echo makes Compaq Fortran
echo exe named tst508.exe
echo.
goto END

:NOSUB
echo.
echo ERROR: Couldn't find file %2.f in your local directory.
echo.
goto END

:NOOBJ
echo.
echo ERROR: Couldn't find object %1.obj in your local directory or
echo in the medexe user subrirectory: %usrlibpath%
echo.
goto END

:NOLIB
echo.
echo ERROR: Couldn't find library %libname% in your local directory or
echo in the medexe user subrirectory: %usrlibpath%.
echo.
goto END

REM ============================ End ======================================


:END

set mobj=
set mfor=
set libu=
set mout=
set exename=
set libname=
set usrlibpath=

You might also like