Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27118 Discussions

Trying to rebuild application with .bat files

Jonas231
Beginner
1,279 Views

Hi,

I am trying to recompile a legacy code "http://ecalculations.com/".

 

The recompile and the link are done with simple .BAT files.

How can I do this with Visual Studio and Intel One APi? Or should I use the Command Line environment?

Which commands to use?

 

There are various .bat-files:

 

MAKE.bat:

-------------------------------

CD\WINOPT
DEL ODP.EXE
DEL PRG.EXE
CALL AM
link @automake.lnk

 

AM.bat

--------------------------------

@Echo OFF
AUTOMAKE type=%1 %2 %3 %4 %5 %6 %7 %8 %9
@IF ERRORLEVEL 1 GOTO delete
call AMTEMP
:delete
DEL AMTEMP.BAT

 

MAKEKDP_IVF.bat

---------------------------------

CALL IFORTVARS
CD\WINOPT_IVF
del kdp2.exe
call am
link @automake.lnk
DEL *.F90

 

ifortvars.bat

-----------------------------------

@Echo off
Rem Intel(R) Visual Fortran Compiler Build Environment for 32-bit applications

echo.
echo Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications
echo Copyright (C) 1985-2006 Intel Corporation. All rights reserved.
echo.

@call "C:\Program Files\Microsoft Visual Studio 8\VC\Bin\Vcvars32.bat"
title Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications

echo.

SET IFORT_COMPILER91=C:\Program Files\Intel\Compiler\Fortran\9.1

SET INTEL_SHARED=C:\Program Files\Common Files\Intel\Shared Files

SET INTEL_LICENSE_FILE=C:\Program Files\Common Files\Intel\Licenses

SET PATH=%IFORT_COMPILER91%\Ia32\Bin;%INTEL_SHARED%\Ia32\Bin;%PATH%

SET LIB=C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\lib;%IFORT_COMPILER91%\Ia32\Lib;%LIB%

SET INCLUDE=%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%

if exist "C:\Program Files\Intel\Compiler\Fortran\9.1\ia32\Bin\imsl.bat" call "C:\Program Files\Intel\Compiler\Fortran\9.1\ia32\Bin\imsl.bat"

 

Does anyone have a clue what is done here? Where can I read about compiling and building

with .bat-files?

 

Kind regards,

Jonas

 

 

 

 

 

0 Kudos
25 Replies
Arjen_Markus
Valued Contributor III
1,139 Views

From your question I guess that you are unfamiliar with the process of building programs. You might want to read this minibook/tutorial: https://fortran-lang.org/learn/building_programs.

Building a program using a set of batch files is not magically different than building it with a series of commands or using Visual Studio.

Roughly what is happening via these batch files is:

  • Set up the environment, so that the compiler and linker can be found (that is what the SET xxx=yyy statements are all about)
  • Construct a temporary batch file that does the dirty work. That is what seems to be happening in the AUTOMAKE command/program
  • Execute that batch file (and then throw it away again). The result is a set of object files or even libraries, that is not really important
  • Link the various pieces into an executable program. The file "automake.lnk" contains the names of the various bits and pieces that are needed.

That said, probably all that is needed is:

  • Start the oneAPI environment
  • Use the MAKE.BAT file as that assumes the correct environment has been set up
  • This should work because the name of the (classic) compiler under Intel oneAPI is the same as under older versions

If this does not work, then you should post the commands you use and the output. Then we can try to help you with more specific advice.

Jonas231
Beginner
1,100 Views

Thank you for this answer.

I opened the oneAPI command promt. I navigated to the right location: cd C:\WINOPT_IVF and used MAKE.

There are several issues:

1. For almost any .for file I get this warning:

ifort: command line warning #10434: option '/compile_only' use with underscore is deprecated; use '/compile-only' instead
ifort: command line remark #10148: option '/unroll' not supported

 

2. Winteracter - GUI

APODGUI.FOR
\WINOPT_IVF\SRC\APODGUI.FOR(2): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [WINTERACTER]
USE WINTERACTER

--> How do I do this? ( I have a 30 day test version of winteracter installed, which works with an example provided by winteracter).

 

3. The process stops with this error (because plotcad2.obj was not created!, perhabs because of winteracter...):

LINK : fatal error LNK1181: cannot open input file '\WINOPT_IVF\SRC\PLOTCAD2.obj'

 

I attached a .txt-file with oneAPI Tools messages. Can anyone help me with how to fix these warnings?

Arjen_Markus
Valued Contributor III
1,097 Views

The warnings you get about /compile_only are siply warnings: you should use /compile-only instead (note the minus sign instead of the underscore), but as they are warnings they do not hinder progress. The real problem is the path to the module for Winteracter. Such a path can be set with the option /I: ifort ... /I<dir-containing-mod-files>

You can do so by setting the INCLUDE variable in the batch file you presented:

set INCLUDE=<dir-containing-mod-files>;%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%

Just fill in the right directory of course.

 

Jonas231
Beginner
1,086 Views

Thanks.

Okay lets say the mod files and winteracter.lib are in this directory: C:\WintEval\lib.i64

I wrote: SET INCLUDE=C:\WintEval\lib.i64;%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%

in the ifortvars.bat file.

 

The error remains:

 

\WINOPT_IVF\SRC\APODGUI.FOR(2): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [WINTERACTER]
USE WINTERACTER
------------^
\WINOPT_IVF\SRC\APODGUI.FOR(11): error #6457: This derived type name has not been declared. [WIN_MESSAGE]
TYPE(WIN_MESSAGE) :: MESSAGE

What should I do?

 

Should I write?:

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\bin\intel64_ia32

instead of "SET IFORT_COMPILER91=C:\Program Files\Intel\Compiler\Fortran\9.1"?

Arjen_Markus
Valued Contributor III
1,077 Views

Hm, I just tried whether the INCLUDE environment variable works and that is the case.

The mod files are specific to the compiler and also, unless I am mistaken, to the platform (such as 32 or 64 bits).

What happens if you use a simple Fortran source like:

program justatest
    use WINTERACTER
    write(*,*) 'Okay'
end program justatest

and compile it like:

ifort -c justatest.f90 -Ic:\WintEval\lib.i64

on the command-line in a command window opened for your compiler?

That way you can check - without all the infrastructure that apparently needed - if things are indeed correct.

Jonas231
Beginner
1,081 Views

Your example works! A corresponding .obj file is created

Arjen_Markus
Valued Contributor III
1,074 Views

Okay, and what happens if instead of -I you specify the directory via the INCLUDE environment variable? Make sure you are using the same compiler/set up as in your original attempts.

Jonas231
Beginner
1,048 Views

I wrote now this MAKE.bat, where I only commented "SET INTEL_LICENSE_FILE=C:\Program Files\Common Files\Intel\Licenses" and there are no errors:

rem @Echo off
Rem Intel(R) Visual Fortran Compiler Build Environment for 32-bit applications

echo.
echo Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications
echo Copyright (C) 1985-2006 Intel Corporation. All rights reserved.
echo.

@call "C:\Program Files\Microsoft Visual Studio 8\VC\Bin\Vcvars32.bat"
title Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications

echo.

SET IFORT_COMPILER91=C:\Program Files\Intel\Compiler\Fortran\9.1

SET INTEL_SHARED=C:\Program Files\Common Files\Intel\Shared Files

rem SET INTEL_LICENSE_FILE=C:\Program Files\Common Files\Intel\Licenses

SET PATH=%IFORT_COMPILER91%\Ia32\Bin;%INTEL_SHARED%\Ia32\Bin;%PATH%

SET LIB=C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\lib;%IFORT_COMPILER91%\Ia32\Lib;%LIB%

SET INCLUDE=%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%

SET INCLUDE=C:\WintEval\lib.if64;%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%
rem SET WINTER=C:\WintEval
SET WINTER=C:\WintEval

ifort -c justatest.FOR

 

Now when I comment the same line out in the ifortvars.bat of the legacy code:

The winteracter related error is gone:

ifort: command line remark #10148: option '/unroll' not supported
APODGUI.FOR

 

There are additional errors, though:

 

PLOTCAD2.FOR
\WINOPT_IVF\SRC\PLOTCAD2.FOR(4922): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...
STOPPOINT(1:4,1:3,0:I)=0.0D0

and later:

LINK : fatal error LNK1181: cannot open input file '\WINOPT_IVF\SRC\PLOTCAD2.obj'

 

How would you debug this file with e.g. Visual Studio 2019 to find the cause of the error?

It is somewhere around these lines:

DEALLOCATE (PRO,STARTPOINT,STOPPOINT,STAT=ALLOERR)
ALLOCATE (STARTPOINT(1:4,1:3,0:INT(SYSTEM(20))),STAT=ALLOERR)
ALLOCATE (STOPPOINT(1:4,1:3,0:INT(SYSTEM(20))),STAT=ALLOERR)
LNTYPE=0
I=INT(SYSTEM(20))
STARTPOINT(1:4,1:3,0:I)=0.0D0
STOPPOINT(1:4,1:3,0:I)=0.0D0

 

 

 

 

 

 

andrew_4619
Honored Contributor I
1,030 Views

The include files are needed to compile that. I can't see what is wrong with STARTPOINT(1:4,1:3,0:I)=0.0D0 that seems strange but why not write 

STARTPOINT=0.0D0 it is less messy.

Jonas231
Beginner
993 Views

Well, STOPPOINT is an array just as STARTPOINT. It is initialized with zeros. I cannot define it as simple integer.

 

INTEGER STARTPOINT,STOPPOINT
DIMENSION STARTPOINT(:,:,:),STOPPOINT(:,:,:)
ALLOCATABLE :: STARTPOINT,STOPPOINT

Why is the error showing up with STOPPOINT and not with STARTPOINT?

 

DEALLOCATE (PRO,STARTPOINT,STOPPOINT,STAT=ALLOERR)
ALLOCATE (STARTPOINT(1:4,1:3,0:INT(SYSTEM(20))),STAT=ALLOERR)
ALLOCATE (STOPPOINT(1:4,1:3,0:INT(SYSTEM(20))),STAT=ALLOERR)
LNTYPE=0
I=INT(SYSTEM(20))
STARTPOINT(1:4,1:3,0:I)=0.0D0   --> no error?!  = double-precision zero
STOPPOINT(1:4,1:3,0:I)=0.0D0      --> error!

Jonas231
Beginner
991 Views

See this test file. ifort -c justatest3.FOR

When I comment out the STOPPOINT lines (line 18) no error appears.

With line 18 I get this:

 

C:\WINOPT>ifort -c justatest3.FOR
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.

justatest3.FOR(18): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...
STOPPOINT(1:4,1:3,0:I)=0.0D0
-----------------------------^
justatest3.FOR(18): error #6911: The syntax of this substring is invalid. [POINT]
STOPPOINT(1:4,1:3,0:I)=0.0D0
-----------^
compilation aborted for justatest3.FOR (code 1)

 

 

Jonas231
Beginner
987 Views

Okay I replaced all "STOPPOINT" with "SP" and it works. No clue why...

cean
New Contributor I
770 Views

STOP should not at the front of a variable for fixed form. See here Re: Is StopPoint a reserved keyword? - Intel Community

 

You'd better try to build with Winteracter first. Under D:\winopt_ivf\EDITOR folder, there is a EDFILE.WPJ file. I think you can let Winteracter to open it and build a D:\winopt_ivf\edfile.exe. 

Then you can try to build D:\winopt_ivf\SRC\kde.wpj. This makes sure your current intel fortran can build the kde source.

Then try to build kde with  intel fortran only. You need to write your own subs to replace calls to Winteracter's.

Steve_Lionel
Black Belt Retired Employee
763 Views

@cean wrote:

STOP should not at the front of a variable for fixed form.


Not true - you can name variables anything you like, even in fixed form. This is simply a compiler bug.

Jonas231
Beginner
983 Views

Now I can compile PLOTCAD2.for. However, I get some link errors which did not show up earlier:

First of all it is expected that "winter.lib" of winteracter is located in a path "C:\Wint\lib.if8" if this path does not exist there is a linking error. Where would you expect that this winter.lib is needed (because it was not necessary during compliation)? I used these lines in the ifortvars.bat:

SET INCLUDE=C:\WintEval\lib.i64;%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%
SET WINTER=C:\WintEval
rem SET LIB=C:\WintEval\lib.i64\winter.lib;

When I copy C:\WintEval\lib.if8\winter.lib in a folder C:\Wint\lib.if8 no linking error appears anymore but this is no satisfactory solution.

 

Another linking error related to Visual Studio appears:

 

C:\WINOPT_IVF>MAKE

C:\WINOPT_IVF>rem CD \WINOPT

C:\WINOPT_IVF>rem DEL ODP.EXE

C:\WINOPT_IVF>rem DEL PRG.EXE

C:\WINOPT_IVF>CALL AM
AUTOMAKE - Version 6.50Dc
Copyright (C) Polyhedron Software Ltd. (1987-2002) - All rights reserved

Configuration data read from automake.fig
Reading dependency file AUTOMAKE.DEP
AUTOMAKE finished normally

LINK : fatal error LNK1181: cannot open input file '\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib'

 

This comes at no suprise since I am using VisualStudio 2019. Do you know what I should change? Just the attached ifortvars.bat or something else? Also I know that the program I recompile was  a 32 bit application and not 64 bit. What would you do about that?

 

ifortvars.bat:

 

@Echo off
Rem Intel(R) Visual Fortran Compiler Build Environment for 32-bit applications

echo.
echo Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications
echo Copyright (C) 1985-2006 Intel Corporation. All rights reserved.
echo.

@call "C:\Program Files\Microsoft Visual Studio 8\VC\Bin\Vcvars32.bat"
title Intel(R) Visual Fortran Compiler 9.1.024 Build Environment for 32-bit applications

echo.

SET IFORT_COMPILER91=C:\Program Files\Intel\Compiler\Fortran\9.1

SET INTEL_SHARED=C:\Program Files\Common Files\Intel\Shared Files

rem SET INTEL_LICENSE_FILE=C:\Program Files\Common Files\Intel\Licenses

SET PATH=%IFORT_COMPILER91%\Ia32\Bin;%INTEL_SHARED%\Ia32\Bin;%PATH%

SET LIB=C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\lib;%IFORT_COMPILER91%\Ia32\Lib;%LIB%

SET INCLUDE=%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%

SET INCLUDE=C:\WintEval\lib.i64;%IFORT_COMPILER91%\Ia32\Include;%INCLUDE%
SET WINTER=C:\WintEval
rem SET LIB=C:\WintEval\lib.i64\winter.lib;

if exist "C:\Program Files\Intel\Compiler\Fortran\9.1\ia32\Bin\imsl.bat" call "C:\Program Files\Intel\Compiler\Fortran\9.1\ia32\Bin\imsl.bat"

 

 

mecej4
Black Belt
968 Views

Jonas: 

Reading your posts in this thread, I feel that you are trying to accomplish something for which you do not have the necessary background knowledge and desirable experience (programming language, compiling and linking a multi-file project). The software package that you are attempting to recompile contains over 150 Fortran source files, was set up to be built using tools available in 2007, and needs a third-party library (Winteracter).

Given the difficult nature of the task and the handicaps that you have, why do you not simply use the prebuilt KDP2.EXE that the author has provided? It started fine under Windows-10, as far as I could see. On some future date, when you are better equipped to handle the task, you could come back to this project and build a 64-bit exe with modern versions of the compiler, etc.

The errors that you reported on 9 June, "...justatest3.FOR(18): error #6911: The syntax of this substring is invalid. [POINT]" is probably a result of attempting to compile a fixed form Fortran source file as if it were a free format file. Visual Studio permits you to make such mistakes, if you insist.

Even the twenty-line source file justatest3.f90 shows many signs that you are asking for trouble:

  • You used Fortran-77 style declarations, with attributes scattered over several declarations, instead of in one place.
  • You attempt to deallocate an array that has not been allocated, which is a programmer error, but you stifle the error message that would have normally followed at run time by specifying a STAT= clause, and then you ignore the status value that was set. That's tantamount to "aiding, abetting and aggravating". These habits guarantee many happy hours of perplexing debugging.
  • What is the point of writing statements such as I = INT(20) instead of I = 20?
  • What is the point of the "D0" in STARTPOINT(1:4,1:3,0:I)=0.0D0, given that STARTPOINT was declared to be of type INTEGER?

One of the first rules of programming is "Don't make a mess!". Therefore, one should not respond to compiler messages by making arbitrary changes to a complex body of source code without understanding the implications of such changes.

andrew_4619
Honored Contributor I
977 Views

Winding back to my previous comment. Stoppoint=0 is an assignment to the whole array. It seems strange that you are assigning a DP real to an integer array.  However I wonder if the Fortran compiler parser is getting confused because "STOP" is a Fortran keyword. 

cean
New Contributor I
914 Views

kdp2/PLOTCAD2.FOR at main · ceanwang/kdp2 · GitHub

This Line #4922:

 

 

STOPPOINT(1:4,1:3,0:I)=0.0D0

 

 

has an error message:

 

 

 

SRC\PLOTCAD2.FOR(4922): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...

 

 

 

 

But the compiler doesn't complain about line #4921 which nearly the same. The next same error is at Line # 5630 which is:

 

 

STOPPOINT(1,1,I)=P1ARAY(1,1,1)

 

Stoppoint is defined at Line #4895

 

      INTEGER STARTPOINT,STOPPOINT
      DIMENSION STARTPOINT(:,:,:),STOPPOINT(:,:,:)
      ALLOCATABLE :: STARTPOINT,STOPPOINT

 

mecej4
Black Belt
895 Views

You reported some errors but did not provide enough detail regarding how you attempted to compile, which version of the compiler you used, what compiler options were in effect, etc. Please follow the guidelines for reporting compiler problems.

For what it is worth, I downloaded the files DATLEN.INC, DATMAI.INC, DATHGR.INC, DATSPD.INC, DATMAC.INC, globals.for and PLOTCAD2.FOR from the Github that you linked to. Compilation was completed with no errors.

R:\lang>ifort /Od /c /w globals.for PLOTCAD2.FOR
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 2021.1.3.311 Beta Build 20201010_000000
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.


R:\lang>

It is highly probable that you did not use the compiler properly, which illustrates why it is important to provide sufficient detail for someone else to reproduce and examine the problem.

cean
New Contributor I
883 Views

Cool.

I just created a VS2017 project for Win32 + Debug. It shows in the Output window of VS: "Compiling with Intel® Fortran Compiler Classic 2021.1.1 [IA-32]..."

But I don't know what options were in effect. Default options? How do I add the switches like " /Od /c /w"?

 

Edit: 

 

Tried compile PLOTCAD2.FOR in command line, same errors.

D:\kdp2Win32\SRC>ifort /Od /c /w globals.for PLOTCAD2.FOR
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on IA-32, Version 2021.1 Build 20201112_000000
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

PLOTCAD2.FOR(4922): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...
        STOPPOINT(1:4,1:3,0:I)=0.0D0
------------------------------^
PLOTCAD2.FOR(5630): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...
        STOPPOINT(1,1,I)=P1ARAY(1,1,1)

 

 

 

Reply