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

Moving to iFort from gFortran

Brooks_Van_Horn
New Contributor I
3,545 Views

From a command line, I had a couple of scripts which did the following:

To compile:

          gFortran -c %1.f95

Then to put each object and MOD into a static library:

          ar r MyLib.a %1.o %1,mod

And finally to compile the main program, link it, and create an EXE

gfortran -o Test Test.f90 MyLib.a

I would like to do the same with iFort, xilink, etc. How do I accomplish this ? PS, I hate make so please don't suggest it.

Thanks,

Brooks Van Horn

0 Kudos
1 Solution
mecej4
Honored Contributor III
3,545 Views

Re LIB: Yes. Please read the LIB documentation before first use. In particular, the /out: option is needed to build a library from scratch. Once the library exists you can add .OBJ files to it.

Your configuration seems to have problems. I do not know why you are seeing all those messages from IPO. Until you get things going, I suggest the /Od option, which disables optimizations. You may have a number of options specified in IFORT.CFG.

s:\>cd lang

s:\lang>ifort /c ranf.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.4.221 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.


s:\lang>

Did you see the line regarding the missing MSPDB110.dll?

View solution in original post

0 Kudos
10 Replies
FortranFan
Honored Contributor III
3,545 Views

Did you mean to post your topic on the Linux forum instead?  https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x

"I hate make " - are you open to the idea of using an integrated development environment (IDE) instead?  If yes, have you looked into Code::Blocks with Fortran plug-in (http://darmar.vgtu.lt/index.php) or Photran with Eclipse (http://www.eclipse.org/photran/)?

If you're moving to Windows OS, then consider Visual Studio from Microsoft.

0 Kudos
Brooks_Van_Horn
New Contributor I
3,545 Views

The info I left and example were from a CMD window. I really like my UltraEd text editor and do not really like the VS editor unless I'm doing a GUI application. Microsoft would be wise to buy Ian's editor. I have been on Windows since version 3.11 but when I worked it was on a Unix system. By the time Microsoft reached Win 2K they took the lead over Unix and Win 7 is fae superior so no my poist was in the right forum. My only problem is with my lack of knowledge with the Intel Fortran Compiler and it's environment. I moved from GNU to Intel because gFortran had too many flaws -- like for instance EXIT in a do loop which correctly took me out of a do loop but also exited me the next time I tried to enter the loop. I've programmed in IBM Assembly, VB, VBS, C, C++ and Fortran over the years and I like Fortran the best.

So, please help me with using Intel tools that come with the Intel Fortran.

 

Thanks much,

Brooks Van Horn

0 Kudos
mecej4
Honored Contributor III
3,545 Views

The ar utility allows you to put anything into the mylib.a file, even the kitchen sink if you ask. The MS utility, lib.exe, on the other hand, will accept only  .OBJ and .LIB files. MS command line syntax is a bit different from Unix shell syntax and the way to specify command line arguments is a bit different. The Intel Fortran documentation shows the Linux and Windows versions of options together, so you can do the translation easily.

For your example, you put commands such as the following into a .BAT file, and then invoke the batch file by just typing its name:

     ifort /c %1.f90

     lib mylib.lib %1.obj

     ...

     ifort /Fetest test.obj mylib.lib

Note that you do not need to call the linker LINK.EXE directly unless you need to do some intricate things. The driver "ifort" calls LINK on your behalf, supplying the names of the Fortran runtime libraries needed automatically.

0 Kudos
Brooks_Van_Horn
New Contributor I
3,545 Views

Hi mecej4,

Your approach looked promising but it has 2 problems: (1) lib doesn't create the file MyLib.lib and (2)  iFort doesn't know what /c means. [See full transaction below]. The file ranf.f90 is a module with start and end looking like:

Module Random
Implicit None


Private

Integer(4),save:: a1(10) = (/ 36553, 54585, 26689, 23897,  3469, &
                              17497, 42849, 36333, 42433, 55809 /)
Integer(4),save:: a2(10) = (/ 10879, 27609, 17188, 43901, 18415, &
                              14220, 26925, 27616,  7319, 32133 /)
Integer(4),save:: a3(10) = (/ 46769, 65083, 27721, 12890, 50638, &
                              62024, 32833, 27512, 58086, 17276 /)
Integer(4),save:: rvals(3,10,100)
Character(len=200),save:: filename = 'RanF.bin'
Logical(4):: NoPass = .True.

Public:: RanFGet, RanFPut, RanF

Integer(4),save:: nsum(10,100)

Contains

......

    bot = Dble( Ior( Ishft(a2(n),16), a1(n)) ) ! neg 16 ==> shift right pos ==> shift left
    top = scale * Dble(a3(n))
    x = top + bot
    x = (x * normalize) + normalize
    RanF = x
    Return
End Function RanF

End Module Random


>>>>>>>>>>>>>  Your attempt follows......

C:\Users\TCS\Desktop\Pearson>iFort /c ranf.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Inte
l(R) 64, Version 15.0.4.221 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

fortcom: Severe: No such file or directory

... file is '/c'
compilation aborted for /c (code 1)

    Report from: Interprocedural optimizations [ipo]

INLINING OPTION VALUES:
  -Qinline-factor: 100
  -Qinline-min-size: 30
  -Qinline-max-size: 230
  -Qinline-max-total-size: 2000
  -Qinline-max-per-routine: 10000
  -Qinline-max-per-compile: 500000


Begin optimization report for: RANDOM.

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (RANDOM.) [1] C:\Users\TCS\Desktop\Pearson\ranf.f90(1,8)

warning #31001: The dll for reading and writing the pdb (for example, mspdb110.d
ll) could  not be found on your path. This is usually a configuration error. Com
pilation will continue using /Z7 instead of /Zi, but expect a similar error when
 you link your program.
===========================================================================

Begin optimization report for: RANDOM::RANFGET

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (RANDOM::RANFGET) [2] C:\Users\TCS\Desktop\Pearson\ranf.f90(57,12
)

===========================================================================

Begin optimization report for: RANDOM::RANFPUT

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (RANDOM::RANFPUT) [3] C:\Users\TCS\Desktop\Pearson\ranf.f90(79,12
)

===========================================================================

Begin optimization report for: RANDOM::RANF

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (RANDOM::RANF) [4] C:\Users\TCS\Desktop\Pearson\ranf.f90(112,23)

===========================================================================

C:\Users\TCS\Desktop\Pearson>lib MyLib.lib ranf.obj
Microsoft (R) Library Manager Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1104: cannot open file 'MyLib.lib'

0 Kudos
TimP
Honored Contributor III
3,545 Views

In principle, you have multiple choices available which resemble what you requested. As you used gfortran -O0, you should  be happy with -Qipo- so that your .obj files will work even if renamed to .o.  you may be able to use Microsoft mingw or cygwin static library tools.  However, ifort Windows requires cl libraries, not gcc ones. It's difficult to see what might be easier when avoiding the beaten path with fort.

0 Kudos
TimP
Honored Contributor III
3,545 Views

I can only guess that omitting Qipo- (or -Od) has stopped ifort /c from working as you wish.  If you like gfortran with.optimization disabled, you shouldn't be jumping to ipo.

0 Kudos
mecej4
Honored Contributor III
3,546 Views

Re LIB: Yes. Please read the LIB documentation before first use. In particular, the /out: option is needed to build a library from scratch. Once the library exists you can add .OBJ files to it.

Your configuration seems to have problems. I do not know why you are seeing all those messages from IPO. Until you get things going, I suggest the /Od option, which disables optimizations. You may have a number of options specified in IFORT.CFG.

s:\>cd lang

s:\lang>ifort /c ranf.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.4.221 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.


s:\lang>

Did you see the line regarding the missing MSPDB110.dll?

0 Kudos
Brooks_Van_Horn
New Contributor I
3,545 Views

Hey Mercej4,

My first batch file contains:

del %1.mod %1.o
iFort /c %1.f90
lib MyLib.lib %1.obj

and the second one:

iFort /Test Test.obj MyLib.lib
test

When I did this under gFortran I had no errors and everything worked as expected.

MyLib.a had some 20 routines in it which were for two other main programs. I use it also as in this case to debug routines like RanF. ar with a prameter of ar creates an archive but I've not been able to find the parameter of lib used to create a library. That parameter for Lib is what started this whole question.

Brooks Van Horn

0 Kudos
Brooks_Van_Horn
New Contributor I
3,545 Views

My bad.

ar cr libname

creates a library and

ar r libname objname

updates/adds objname to the library.

0 Kudos
Brooks_Van_Horn
New Contributor I
3,545 Views

Hey All,

 

Got my problem solved!!!

Thanks to all!

Brooks

 

To create a library:

        lib /def /out:MyLib.lib
       lib /remove:MyLib.dll MyLib.lib

To list entries:

        lib /list MyLib.Lib

To remove an obj file

        lib /remove:some.obj MyLib.Lib

To add some coeff object to the library

        lib MyLib.lib some.obj

Now a batch file to compile and add to MyLib.lib

      iFort -O3 /c %1.f90
      lib MyLib.lib %1.obj

Then to link and run a batch file would have

      ifort -o %1 MyLib.lib

 

 

0 Kudos
Reply