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

Compiling a Fortran code by linking C object in command prompt

Umer_T_
Beginner
3,010 Views

Hi,

I have been handed a code to execute on Windows environment, where the same code ran without any problem on LINUX.

Here is an outline of the code execution plan:

  1. Compile a C code (hapsug.c) to create an object (hapsug.obj) file.
  2. Compile a Fortran(findhap4_c.f90) code which uses the C object to run.

Command to run a C Code:

C:\Gitlabstuff\FindhapScript1>icl -c hapsug.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

hapsug.c

Command to run a Fortran Code:

#Once the above compilation has produced a hapsug.obj then run:
ifort -debug -O0 kinds.f90 findhap4_c.f90 nhash.f90 hapsug.obj -o findhap4 -static -openmp -C -ftrapuv -fpe1 -traceback -warn -reentrancy -D _MYMKL=.TRUE. -L$MKLPATH -verbose #-heap-arrays

Error:

findhap4_c.f90(337): error #8110: The module file for compiler-generated interface was generated for a different platform or by an incompatible compiler or compiler release. It cannot be read. Use -gen-interfaces option.   [NHASH__GENMOD]

  nn = nhash(0,-1,ids,maxped2,maxn)

^

findhap4_c.f90(337): error #7977: The type of the function reference does not match the type of the function definition.   [NHASH]

  nn = nhash(0,-1,ids,maxped2,maxn)

^

findhap4_c.f90(337): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.

  nn = nhash(0,-1,ids,maxped2,maxn)

^

[ Aborting due to internal error. ]

compilation aborted for findhap4_c.f90 (code 1)

 

Specs:

Compiling all in Intel Parallel Studio XE 2017 > Compiler and Performance Libraries > Command Prompt > IA-32 Visual Studio 2015 environment

 

0 Kudos
1 Solution
mecej4
Honored Contributor III
2,935 Views

Under Windows, the Intel Fortran compiler convention requires that external routine names be uppercase by default. Therefore, change hapsug_c_ to HAPSUG_C in your C source file.

Similarly, some of the compiler options are named differently in Linux and Windows. For example, /Qopenmp instead of -openmp. Most compilers and linkers expect the -o prefix to be used to name the output object or executable file, so -openmp risks being taken to mean "the output file name is 'penmp'".

You should not expect compatibility between object files built with GCC and object files built with Intel Fortran under Windows.

With the two modifications that I mentioned, and using Intel C instead of GCC, I was able to build and run your program. It seemed to run correctly, ending with the two lines

         325  records written to genotypes.imputed
 Program findhap.f90 completed normally

Details of the compiler options for Linux and Windows are listed in the compiler documentation.

View solution in original post

0 Kudos
32 Replies
mecej4
Honored Contributor III
586 Views

Do not use any of those shortcuts under "Visual Studio Tools". Instead, look "Intel Parallel Studio...-- Compiler and Performance Libraries" in the Start menu, and chose the Command Prompt for Intel 64".

0 Kudos
Umer_T_
Beginner
586 Views

Thanks mecej4, I ran the command prompt before from Intel Parallel Studio, as shown below:

CommandPromptStarter2.jpg

 

Everything compiles ok, as suggested in your comment # 6. Details:

Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
Intel(R) Compiler 17.0 Update 1 (package 143)


C:\Program Files (x86)\IntelSWTools>icl
Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 17.
0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

icl: command line error: no files specified; for help type "icl /help"

C:\Program Files (x86)\IntelSWTools>ifort
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on IA-32,
Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

ifort: command line error: no files specified; for help type "ifort /help"

C:\Program Files (x86)\IntelSWTools>cd C:\Gitlabstuff\FindhapScript1

C:\Gitlabstuff\FindhapScript1>icl /c hapsug.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 17.
0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

hapsug.c

C:\Gitlabstuff\FindhapScript1>ifort /debug /Od hapsug.obj /exe:findhap4 /static
/Qopenmp /check /Qtrapuv /fpe:1 /traceback /reentrancy /D _MYMKL=.TRUE. kinds.f9
0 findhap4_c.f90 nhash.f90 hapsug.obj
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on IA-32,
Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:findhap4.exe
-debug
-pdb:kinds.pdb
-subsystem:console
-incremental:no
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
hapsug.obj
kinds.obj
findhap4_c.obj
nhash.obj



Executing a compiled exe (findhap4.exe) file:

C:\Gitlabstuff\FindhapScript1>.\findhap4.exe
 Output from findhap.f90 version 4

     90     40      3      4   1000     10      2  0.07000  0.01000
 maxlen,minlen, steps, iters,maxhap,overlap,estfreq,lowdense,errate

     30      2      1      2      1      0      0
    XChrom,genin,genout,ancout,listout,chip2,useprev

 Maximum number of processors set to              4
 Or set threads by command line argument: findhap4 8

 Number of processors available =                 4
 Can be controlled using:  export OMP_NUM_THREADS=8

Read depth codes =   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G  H  I  J
 K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
Read depth       =   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Binary hex decode=  48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 71 72 73 74
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

        5000  loci on           30  chromosomes read from chromosome.data

         325  records in pedigree.file (maxped)
      animal       sire         dam
     10001        -2        -1
     10002        -1        -2
     10003        -2        -1
     10004        -1        -2
     10005        -2        -1

 Max loci / segment (maxloc) =          90

  chromosome      length     markers    segments
           1    99222781         191           3
           2    99474791         173           2
           3    98473141         138           2
           4    99765001         151           2
           5    99433401         166           2
           6    99437731         176           2
           7    97589371         141           2
           8    98863551         172           2
           9    99215331         166           2
          10    95446321         175           2
          11    99505301         182           3
          12    97501321         162           2
          13    97007951         150           2
          14    99063101         157           2
          15    99836591         156           2
          16    98240221         147           2
          17    99337581         170           2
          18    99384491         174           2
          19    97894301         172           2
          20    98604561         164           2
          21    97583261         164           2
          22    99238241         162           2
          23    98848261         179           2
          24    99176321         169           2
          25    97627691         191           3
          26    98555811         164           2
          27    99389891         172           2
          28    98457171         189           3
          29    99363731         180           2
          30    97234671         147           2

          64  total segments across chromosomes
         191  maximum loci on individual chromosome
              99836591  physical length of longest chromosome
            2958771890  total length of genome processed

 Input and estimated frequencies
  1 0.50000 0.64532
  2 0.50000 0.44204
  3 0.50000 0.59326
  4 0.50000 0.34608
  5 0.50000 0.49510
  6 0.50000 0.65223
  7 0.50000 0.24139
  8 0.50000 0.48251
  9 0.50000 0.64866
 10 0.50000 0.77817


The program crashes midway:

findhapexeError.jpg

 

0 Kudos
mecej4
Honored Contributor III
586 Views

Sorry, you will have to debug the program yourself. I do not know anything about the application area.

I normally debug a program by running it single-threaded first.  You, on the other hand, are using Openmp and checking options at the same time.

0 Kudos
Umer_T_
Beginner
586 Views

I was wondering if this is something to do with the missing  #-heap-arrays as the error shown in comment # 14

Is there a way I can compile the Fortran code using this heap-arrays option (no idea why this is used originally in the LINUX command).

0 Kudos
IanH
Honored Contributor II
586 Views

The # before -heap-arrays in the linux command line would have started a comment - so that option was not part of the command line.

The equivalent option for the Windows variant of the compiler is /heap-arrays.

(Typically you would also include a zero cutoff size for arrays with compile-time known size - i.e. specify /heap-arrays:0 )

This option can help if your program has large temporary arrays.

Note that some of the other posters on this thread have had success compiling and running your program as a 64 bit application.  But based on the screen shot of your Windows Start menu, you don't have the 64 bit target compiler installed.
 

0 Kudos
Umer_T_
Beginner
586 Views

ianh wrote:

Note that some of the other posters on this thread have had success compiling and running your program as a 64 bit application.  But based on the screen shot of your Windows Start menu, you don't have the 64 bit target compiler installed.

I thought mine is 64 bit as it says in the compiler: 

"

Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 17.
03 0.1.143 Build 20161005
04 Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

 

Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on IA-32,
14 Version 17.0.1.143 Build 20161005
15 Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

"

If I go for the Visual Studio command prompt options then I do  see the intel compiler versions same as others, but then it throws out different error.(shown in comment # 17)

I downloaded a setup file (parallel_studio_xe_2017_update1_setup.exe) from the link: https://software.intel.com/en-us/intel-parallel-studio-xe

Is there any other link from where there is an option to download 64 bit version?

0 Kudos
Kevin_D_Intel
Employee
586 Views

The first Intel(R) 64 is saying the compiler itself is a 64-bit executable; however, you are actually targeting IA-32 as the compiler sign-on says: for applications running on IA-32

Both the IA-32 and Intel 64 compilers are included in the package you downloaded. I'm confused because in your initial post you showed an icl "for applications running on Intel(R) 64" suggesting the Intel64 compiling environment was installed but I see what IanH has pointed out in the earlier screen snap.

I'm not sure why you appear to only have the shortcut for IA-32 shortcuts. Under Control Panel > Program and Features look for Intel Parallel Studio XE 2017, click it and run an Uninstall/Change and use the Repair option to see whether the shortcuts can be repaired.

If Repair does not work then repeat choose an Uninstall to remove the product and then reinstall the product again making certain during installation via the Customize option that both the IA-32 and Intel64 compilers are being installed (although you may not need/use the IA-32).

0 Kudos
Umer_T_
Beginner
586 Views

Thanks Kevin D, the Repair option couldn't find the installation files. so now I am re-installing it as per your instructions. *fingers crossed*

0 Kudos
Umer_T_
Beginner
586 Views

The fresh new installation summary:

Intel Parallel Studio XE 2017 Update 1 Cluster Edition
Destination Folder(s):
   C:\Program Files (x86)\IntelSWTools
Configuration Options:
   Add integration into Microsoft Visual Studio* 2015 software
Following components will be installed:
       Intel C++ Compiler 17.0 Update 1 for Windows* Target
          Intel C++ Compiler for IA-32
          Intel C++ Compiler for Intel® 64
       Intel Visual Fortran Compiler 17.0 Update 1 for Windows* Target
          Intel Visual Fortran Compiler for IA-32
          Intel Visual Fortran Compiler for Intel® 64
       Intel Math Kernel Library 2017 Update 1 for Windows* Target
          Intel MKL for C/C++
             Intel MKL core libraries for C/C++ for Intel® 64
             Intel® TBB threading support for Intel® 64
             Intel MKL core libraries for C/C++ for IA-32
             Intel® TBB threading support for IA-32
             Intel® Xeon Phi™ coprocessor support
             Cluster support for C/C++
          Intel MKL for Fortran
             Intel MKL core libraries for Fortran for Intel® 64
             Fortran 95 interfaces for BLAS and LAPACK for Intel® 64
             Intel® Xeon Phi™ coprocessor support
             Cluster support for Fortran
             Intel MKL core libraries for Fortran for IA-32
             Fortran 95 interfaces for BLAS and LAPACK for IA-32
       Intel Integrated Performance Primitives 2017 Update 1 for Windows* Target
          Intel IPP single-threaded libraries for Intel® 64
          Intel IPP single-threaded libraries for IA-32
       Intel Threading Building Blocks 2017 Update 2 for Windows* Target
       Intel Data Analytics Acceleration Library 2017 Update 1 for Windows* Target
          Intel DAAL core libraries for Intel® 64
          Intel DAAL core libraries for IA-32
       Intel MPI Library 2017 Update 1
          Intel MPI Library SDK
          Intel MPI Library Environment Variables
          Intel MPI Benchmarks
       Intel Debugger Extension 7.8
          GNU* GDB 7.8
       Intel Debugger for Heterogeneous Compute 2017 Update 1
          GNU* GDB 7.6 and ELFDWARF library
       Intel VTune Amplifier XE 2017 Update 1
          Command-line interface
          Graphical user interface
          Event-based sampling driver
       Intel Inspector 2017 Update 1
          Command-line interface
          Graphical user interface
       Intel Advisor 2017 Update 1
          Command-line interface
          Graphical user interface
       Intel Trace Analyzer and Collector 2017 Update 1
          Intel Trace Analyzer and Collector Common files
          Intel Trace Analyzer for Intel(R) 64 Architecture
          Intel Trace Collector for Intel(R) 64 Architecture

 

IntelParallelInstallationSummary.jpg

0 Kudos
Kevin_D_Intel
Employee
586 Views

Looks great! Hopefully when you look under the Intel Parallel Studio 2017 program group (as shown in your post #23) you see shortcuts for both IA-32 and Intel(R) 64 under the Command Prompt with Intel Compilers group. If so, choose the Intel(R) 64 flavor and then retry the compilations making certain you use the forward-slash style compiler options like my post #8 and your post #23.

0 Kudos
Umer_T_
Beginner
586 Views

Kevin D (Intel) wrote:

Looks great! Hopefully when you look under the Intel Parallel Studio 2017 program group (as shown in your post #23) you see shortcuts for both IA-32 and Intel(R) 64 under the Command Prompt with Intel Compilers group. If so, choose the Intel(R) 64 flavor and then retry the compilations making certain you use the forward-slash style compiler options like my post #8 and your post #23.

certainly do see the 64 bit version too now:

IntelParallelStudio_AfterInstallation.jpg

I am now going to compile my scripts in this new environment. 

0 Kudos
Umer_T_
Beginner
586 Views

perfect...that works now:


         325  records written to genotypes.imputed
 Program findhap.f90 completed normally

I can't say thank you enough for everyone's help in this....much obliged!

0 Kudos
Reply