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

Lahey95 to IVF conversion

polarbear00
Beginner
778 Views
Hi,
I am investigating possibility of converting our Lahey95 source codes to IVF 11.1 and am going through some examples. If I can do an example conversion quick and correct I probabaly can persuade my manager for conversion. Is there any automated way that accelerates such conversion? also (an immediate question!) how can I replace "includes" in LH file for example:
Include 'file.inc'
when I leave it as is I receive below error:
error #5102: Cannot open include file 'file.inc'
I am new in IVF so please take that into account in your answer.

Thanks in advance.
0 Kudos
13 Replies
Steven_L_Intel1
Employee
778 Views
I would not expect any "conversion" to be needed, unless you were using some Lahey extensions not supported in Intel Fortran. I suggest you try the compiles and see what errors you get. If you tell us what they are, we can help.

The error you got simply indicates that 'file.inc' does not exist in the folder containing the source file, nor in any of the folders listed under "Additional INCLUDE directories". If you find that file and put it in the right place, it should work.

Let us know if you have further questions.
0 Kudos
lklawrie
Beginner
778 Views
I have a rather large Fortran application that I've compiled (essentially same source) in IVF, Lahey V7.1 (95?), CVF, g95 and gfortran.

As I remember, IsNan is not available in Lahey (it's an extension to standard in the others) and I had to supply it in a special module but that doesn't apply if you are coming from Lahey.

Linda

0 Kudos
Robert_van_Amerongen
New Contributor III
778 Views
Recently I moved from Lahey to Intel. As most (but not all!) of my code was conform the standard I did not encounter any problem. The Intelcompiler produce more speedy code (sometimes spectacular.) The only conversion that must be done is regarding the use of window functions and the use of opengl. But that's all!

Robert
0 Kudos
polarbear00
Beginner
778 Views
Thanks Steve,
I also have some calls to borland C dlls withing my Lahey fortran code; like below lines:

dll_import BCDLLSample
a=BCDLLSample(Carg(x1),Carg(x2))

somewhere in the source code there is BCDLLSample.dll and BCDLLSample.lib files.

1) How can I call such DLL in IVF?
2) Do I need to have the .lib files for all DLL's
3) Having the Borland C source codes for the .dll's will help? can I for example directly integrate it into VS2010 and call them.


Thanks
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
778 Views
Hi, let me try to address your questions:

1) How can I call such DLL in IVF?
The Intel Visual Fortran command would be: !DEC$ ATTRIBUTES DLLIMPORT

2) Do I need to have the .lib files for all DLL's
Yes, you can add them to your Microsoft Visual Studio project.

3) Having the Borland C source codes for the .dll's will help? can I for example directly integrate it into VS2010 and call them.
Yes you could recompile your dlls (the documentation gives help in how to do this), but I don't think it is necessary. Note you need to take into account mixed language subroutine calls (also documented).


I would suggest looking though the documentation on how to call DLLs in IVF (installed by default on your system at:

C:\Program Files (x86)\Intel\ComposerXE-2011\Documentation\en_US\compiler_f\cl\index.htm

Look under the section: Creating and Using DLLs

In addition we have some sample code showing how to call DLLs in

C:\Program Files (x86)\Intel\ComposerXE-2011\Samples\en_US\Fortran\DLL

Here is the excerpted section from the documentation:

  1. Within your Fortran application, import each DLL subprogram. Add !EC$ ATTRIBUTES DLLIMPORT to declare that a function, subroutine, or data is being imported from outside the current image. For example:

    INTERFACE
    SUBROUTINE ARRAYTEST (rarray)
    !DEC$ ATTRIBUTES DLLIMPORT :: ARRAYTEST
    REAL(4) rarray(3, 7)
    END SUBROUTINE ARRAYTEST
    END INTERFACE 
    CALL ARRAYTEST (rarray)

    Or, not using an INTERFACE block:

    PROGRAM TESTA
    !DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST
    REAL(4) rarray (3,7)
    CALL ARRAYTEST(rarray)
    END PROGRAM TESTA

    The DLLEXPORT and DLLIMPORT options (for the cDEC$ ATTRIBUTES directive) define a DLL's interface.

    The DLLEXPORT property declares that functions or data are being exported to other images or DLLs, usually eliminating the need for a Linker module definition (.DEF) file to export symbols for the functions or subroutines declared with DLLEXPORT. When you declare a function, subroutine, or data with the DLLEXPORT property, it must be defined in the same module of the same program.

    A program that uses symbols defined in another image (such as a DLL) must import them. The DLL user needs to link with the import LIB file from the other image and use the DLLIMPORT property inside the application that imports the symbol. The DLLIMPORT option is used in a declaration, not a definition, because you do not define the symbol you are importing.

    If you have more specific questions please post them to the thread.

    ------

    Wendy

    Attaching or including files in a post

0 Kudos
polarbear00
Beginner
778 Views
Thanks Wendy,
can you please explain in detail where/how I should add the .lib files associated with the .dll files in VS2010?
when i right click on the Fortran file and click properties I have below options:
General
optimization
Debugging
..
..
.
Command line
Thanks
0 Kudos
Steven_L_Intel1
Employee
778 Views
Just add them as if they were source files using Project > Add to project > Files.
0 Kudos
polarbear00
Beginner
778 Views
Hi,
in my migration test from LH95 to IVF Iran into a C++ produced .dll called by LH95, I have also a .lib file for that .dll that made by LH95 with some way. It seems that I can't use same .lib file for IVF. Does anybody have suggestion how to make required .lib file from an existing C++ .dll file so that I can call it from Fortran?

Thanks
0 Kudos
Steven_L_Intel1
Employee
778 Views
Why do you think you "can't use" the .lib? Attach the .lib here and let me look at it.
0 Kudos
polarbear00
Beginner
778 Views
I attached the whole solution that has the .dll and .lib file in it. There are calling lines, according to Lahey convension, in the solution that are marked. I need to be able to call it from IVF. also I don't know what is the equivalent to "carg" used in Lahey.
0 Kudos
Steven_L_Intel1
Employee
778 Views
There are several ways to get what I think Lahey does with carg - in this case it passes a character variable by address only, no length. If it weren't that the routines in the DLL have non-standard name decoration, you could use BIND(C) to get the name case right and proper declaration of the arguments, but instead you can do it this way:

[fortran]program Temp03
implicit none
character(len=200) c_sect, c_ident, c_value, c_file
logical xexist

interface
  logical function write_pps (c_sect, c_ident, c_value, c_arg) 
  !DEC$ ATTRIBUTES DLLIMPORT, ALIAS:"write_pps" :: write_pps
  character(*) :: c_sect, c_ident, c_value, c_arg
  !DEC$ ATTRIBUTES REFERENCE :: c_sect, c_ident, c_value, c_arg
  end function write_pps
end interface

!Original Calling convension in Lahey95
!dll_import write_pps
!xexist = write_pps(carg(c_sect),carg(c_ident),carg(c_value),carg(c_file))
xexist = write_pps (c_sect, c_ident, c_value, c_file)

end program Temp03[/fortran]

I know you had "read_cla" as the alias, but I didn't think you really meant that. The key here is the interface declaring the character arguments with the REFERENCE attribute. It might also work to use %REF(arg) where Lahey had carg(arg). There's nothing wrong with the .lib - it is a normal DLL export library.
0 Kudos
polarbear00
Beginner
778 Views
Thanks, It worked!
0 Kudos
Steven_L_Intel1
Employee
778 Views
Glad to hear it.
0 Kudos
Reply