Compiling options for DISCON.dll

Hello everybody,

I am currently trying to compile a DISCON.dll file for my wind turbine model. I had some problems with my file, so I first tried compiling the DISCON.f90 file that is delivered with the NREL 5MW model. The compilation works without errors, but the resulting DLL file is only 9KB instead of the 24KB of the original DLL, and a FAST simulation fails with a popup message: "This application has failed to start because MSVCR80.dll was not found" and a FAST error message "The DLL DISCON.dll could nod be loaded.".
I found several copies of this MSVCR80.dll on my computer from different programs, so I took one, and copied it to my work directory. Now I got a popup error: "Runtime Error! Program: [path to my working folder] R6034 An application has made an attempt to load the C runtime library incorreclty. Please contact [...]"
I use Intel Visual Fortran 11.1 and I tried these command lines for compiling:

ifort /dll DISCON.f90 ifort /c /automatic /O1 /architecture:pn4 /Ob2 /MD /Gm /real_size:32 /assume:byterecl /Qdiag-disable:5268 /dll DISCON.f90
I always get the same result. Could you tell me, how you compile your DISOCN.dll files?

Thank you,
Luiz da Rocha

Hello, I have met similar problem as you. I has Intel fortran compiler 9.1 with Microsoft VC++ 2008 express. I guess when we compile dll (dynamic-link-library), it just refers to serveral standard libraries and functions in the system but not save the functions in the DLL itself. My IT friend suggest me to compile with options:
ifort/dll /winapp /libs:static DISCON.f90

So that the necessary functions will be stored in the dll, it turns to be static-link-library. This method works for me, and at last, the generated dll file is over 370Kb.

I wish you good luck!

By the way, if you can find an old Compaq visual fotran compiler, it works with simple option df/dll DISCON.f90, and it generates 24Kb DISCON.dll

Thanks for your reply!

I tried that, but it still does not work. At first some more information on my build environment. I tried two PCs. Nr. 1 uses Win XP SP3 32bit with Visual Studio 2005 and the Intel Fortran 11.1 compiler. The second one is A Windows 7 64 bit with Visual Studio 2008 and the Intel Fortran 11.1 compiler. On both machines, I am able to compile A2AD and FAST without problems.

Now back to my problem with the DISCON.dll. I tried to compile it with ifort /dll /winapp /libs:static DISCON.f90 and got the result ifort: warning #10153: option '/Qvc8' or higher used with '/ML[d]' is not supported [...] LINK : fatal error LNK1104: cannot open file 'LIBC.lib'
The first is a warning, not too important i guess, even though i specified none of these options. the second is fatal and causes termination.

I did some research and found that this seems to be a common problem with VS2005 (and higher?), and a solution would be to tell the fortran compiler that it does not require the LIBC.dll: ifort /dll /libs:static /winapp DISCON.f90 /link /NODEFAULTLIB:libc

If I try this however, I get loads of errors:[...] libifcore.lib(cvtas_a_to_s.obj) : error LNK2001: unresolved external symbol __fltused libifcore.lib(cvtas_nan_t.obj) : error LNK2001: unresolved external symbol __fltused DISCON.obj : error LNK2001: unresolved external symbol __fltused libifcore.lib(cvt_cvtas_t.obj) : error LNK2001: unresolved external symbol __fltused libifcore.lib(cvt_cvtas_s.obj) : error LNK2001: unresolved external symbol __fltused libifcore.lib(cvtas_t_to_a.obj) : error LNK2001: unresolved external symbol __fltused LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12 libifcore.lib(for_f90str.obj) : error LNK2019: unresolved external symbol _memmove ref [...] LINK : error LNK2001: unresolved external symbol __load_config_used DISCON.dll : fatal error LNK1120: 118 unresolved externals so I guess, that this library is indeed required.

I got these results on both machines, with the 64bit machine set to 32bit build environment variables. With 64bit settings on the Win7 machine, I get another error (ifort: error #10037: could not find ‘link’) but that is not of interest for me, because I want a 32bit dll file.

I will see If I can find it, thanks!

Could anyone of you, who successfully compiled the NREL 5MW onshore DISCON.f90 tell me about their system specification, and build command?

Thanks a lot,

Luiz da Rocha

I found Compaq Fortran 6.6 lying around and it really works with that, thanks a lot! For me the topic is resolved now, for others it might sill be interesting to see some successful build options and system specs.

Thanks a lot!

Luiz da Rocha

Good morning, dear Luiz da Rocha

I am the person who compiled FAST, A2AD and DISCON.f90. It looks strange for your question, I doubt about the system enviornment settings for your intel fotran compiler, here is my PATH variable value:
Path=C:\Programme\Intel\Compiler\Fortran\9.1\Ia32\Bin;C:\Programme\Gemeinsame Dateien\Intel\Shared Files\Ia32\Bin;C:\Programme\Microsoft Platform SDK for Windows Server 2003 R2\Bin;C:\Programme\Microsoft Platform SDK for Windows Server 2003 R2\Bin\WinNT;C:\Programme\Microsoft Visual Studio 8\Common7\IDE;C:\Programme\Microsoft Visual Studio 8\VC\BIN;C:\Programme\Microsoft Visual Studio 8\Common7\Tools;C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Programme\Microsoft Visual Studio 8\VC\VCPackages;C:\PROGRA~1\MKSTOO~1\bin;C:\PROGRA~1\MKSTOO~1\bin\X11;C:\PROGRA~1\MKSTOO~1\mksnt;C:\Programme\Intel\MKL\9.1.027\ia32\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\Intel\Compiler\Fortran\9.1\IA32\Bin;C:\Programme\Intel\Compiler\Fortran\9.1\EM64T\Bin;C:\Programme\Intel\IDB\9.1\IA32\Script;C:\Programme\Microsoft Visual Studio 8\Common7\IDE;

LIBC.lib is in C:\Programme\Intel\Compiler\Fortran\9.1\IA32\Lib. If setting up the enviornment variable does not work, why not copy this file to your current directory?

here I post a screen shot of my compiling window. The compiler complains but works.

Hi again!

Thank you for pointing me to the correct direction! The problem was really caused by some incorrect environment variables. By calling C:\Program Files\Intel\Compiler\11.1\048\bin\ia32\ifortvars_ia32.bat or C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\Bin\ifortvars.bat before the compile command, I can now use the IVF 9.1 (size of DISCON.dll: 372 KB) as well as the IVF 11.1 (size of DISCON.dll: 424 KB) compilers to successfully compile it (with /libs:static). With the DF 6.6 compiler, it works without any additions.

Thanks and best regards,

Luiz da Rocha

Hi all!

I have come accross similar “challenges” while compiling the discon.f90 to discon.dll. On my computer (WinXp32bit) I have installed MVS (Microsoft Visual Studio 2008) and IVF( Intel Visual Fortran) 11.1.054. Running FAST with the recompiled discon.dll works with many different compiler options so I personally don’t have any problems with the controller.

BUT funny things start happening (or actually nothing happens) when copying the entire simulation folder (contain all FAST model files, FAST.exe and discon.dll) to a new computer WITHOUT IVF preinstalled. This triggers the popular error message “DISCON.DLL could not be loaded”. This is a systematic pattern, I tested it with 10 collegue computers (XP32 and Win7_64-bit all with no IVF preinstalled). It seems that when IVF compiles the discon.f90 (using default compiler settings) it needs some library files from the IVF installation folder when a FAST simulation is started. And if they are missing, discon.dll cannot be loaded.

So changing the compiler settings solved the problem :smiley: If you are using MVS2008: Tools → Options → Intel(R) Visual Fortran → Compilers → Default options: /Qvc9 /Qlocation,link,“$(VCInstallDir)bin” /libs:dll OR /Qvc9 /Qlocation,link,“$(VCInstallDir)bin” /libs:static (underlining the added options). With these IVF settings, the recompiled discon.dll worked on my collegues computer that did not have IVF installed. These additional settings increased the discon.dll size to over 1000 kb, indicating it has “integrated” something into it :smiley:

Hope this helps!

Just because I’m slow and don’t use MVS very often, here are the instructions for MVS 2010. (For some reason it took me ages to figure out. DOH!)

Click on the DISCON.f90 in the solution explorer, then Tools > Options > Intel Composer XE > Visual Fortran > Compilers > Default options.

My settings were:
/Qvc10 /Qlocation,link,“$(VCInstallDir)\bin”
Updated to:
/Qvc10 /Qlocation,link,“$(VCInstallDir)\bin” /libs:static

and the DISCON.dll went from 23kb to 852kb.

Thanks, Alec.

I wanted to point out a couple of things:

  • The FAST archive contains a batch script that will compile DISCON.f90. Look for Compiling/Compile_DISCON_DLL.bat. You can change the CompOpts variable so that it contains /libs:static instead of /libs:dll. This script works a lot like the one described in the FAST compiling instructions.
  • You can change the configuration options (i.e., options specific to the Release or Debug configurations) instead of the default options, too. Just open your Project → Properties window to Configuration Properties → Fortran → Libraries. The options “Multithreaded DLL” and “Debug Multithreaded DLL” are /libs:dll; the others are /libs:static.
1 Like

Hi all,

My name is Dimitrios Bilionis and I am a PhD student at the National Technical University of Athens, Greece. I am analyzing offshore wind turbines for my dissertation using FAST v8 in a 64-bit machine with windows 7. I am actually focused on the 5 MW NREL wind turbine and using the sample files for this turbine that are contained in the FAST v8 archive.

I have though encounter some problems with the DISCON.dll, similar to those mentioned in previous posts by other users. My major problem is that FAST aborts when I am trying to incorporate the blade controls by using ServoDyn. Specifically, I get the following error:

“Message from SrvD_Init:
The dynamic library .\ServoData\DISCON_win32.dll could not be loaded. Check that the file exists in the specified location and that is compiled for 32-bit systems”.

Since, I have double-checked that DISCON_win32.dll exists in the correct location, I assume that probably that .dll is not compatible with 64-bit systems. So, my question is: Is there any similar “.dll” for 64-bit systems available (e.g. DISCON_win64.dll)?

I am mainly asking for that, because I am not familiar with IVF or Microsoft Visual Studio (neither I have them installed in my PC), so it would be really difficult for me to compile the 32-bit .dll file. Furthermore, I am not going to use any custom controls but only those default controls that are associated with the DISCON.dll for the sample turbine.

Thank you in advance,
Dimitrios

Dear Dimitrios,

Thinking you need to run 64-bit software on a 64-bit computer is a very common misconception. All 64-bit, x86-based computers can run 32-bit software. If you look at the folders on drive C:, you will see “Program Files” and “Program Files (x86)”. The first holds 64-bit programs and the latter holds 32-bit programs.

The only reason for compiling a program for 64 bits is if you are going to be using very large arrays. I have needed to do that for hour-long, high resolution wind files, but that is not common. If you are using the distributed, 32-bit version of FAST8, you need to use the 32-bit DLL on your 64-bit system. I don’t believe Bonnie distributes 64-bit versions of FAST8, so FAST and DISCON.dll should be compatible.

It appears that FAST cannot find DISCON_win32.dll, so my guess is that your statement that it “exists in the correct location” is not actually true. I have found that putting it in the current working directory that is active when you run FAST is the correct location.

Marshall

Hi, Dimitrios.

Unless you’ve recompiled it using at 64-bit compiler, FAST v8 is a 32-bit application. A 32-bit application will look for 32-bit DLLs, even if it is running on a 64-bit system.

I don’t think this is the problem (at least not yet, because you would get a different error later in the simulation), but the FAST v8.3 archive on the web contains DLLs that expect you to have the Intel libraries on the computer you are using. You can download DLLs without those dependencies here: wind.nrel.gov/public/bjonkman/De … SCON_dlls/
I use these DLLs on my own 64-bit Windows 7 machine all the time, with no problem.

You might try to use the new DLLs and see if that helps fix the problem (maybe the DLL you are using got corrupted?). Otherwise, triple check that you’ve got the path to the DLL specified correctly. Then if you’re still having trouble, perhaps you could post a screen shot of exactly what you typed to run the program and what the error says.

Marshall and Bonnie,

First of all thank you for your responses.
Following your comments I downloaded the DISCON_win32.dll from the link that Bonnie posted and I have no problem with running ServoDyn now. So, my problem is fixed, at least for now.

Once again, I appreciate your immediate help.

Dimitrios

Dear sir
I have a question about compile DISCON.dll why I leave other file such as DISCON.lib,DISCON.exp?
I think I don’t compile my DISCON.dll completely whether I forget to rewrite some code?
Thanks for your help.

Jason. Lai

[code]@ECHO OFF

REM ----------------------------------------------------------------------------
REM set compiler internal variables
REM ----------------------------------------------------------------------------
REM You can run this bat file from the IVF compiler’s command prompt (and not
REM do anything in this section). If you choose not to run from the IVF command
REM prompt, you must call the compiler’s script to set internal variables.
REM TIP: Right click on the IVF Compiler’s Command Prompt shortcut, click
REM properties, and copy the target (without cmd.exe and/or its switches) here:

ECHO.

IF “%INCLUDE%”==“” (

IF /I “%1”==“64” ( ECHO //// Using intel64 compiler \\
CALL “C:\Program Files (x86)\Intel\Composer XE 2011 SP1\bin\ipsxe-comp-vars.bat” intel64 vs2010
) ELSE ( ECHO //// Using ia32 compiler \\
CALL “C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\ia32\ifortvars.bat” ia32 vs2008
)

) ELSE ( ECHO //// Using existing compiler settings \\
)

REM ----------------------------------------------------------------------------
REM set compiler and linker options
REM ----------------------------------------------------------------------------

REM Use /libs:static if the DLL will be used on other PCs. (will result in a
REM larger dll)

rem SET CompOpts= /nologo /O2 /inline /traceback /libs:static /threads
SET CompOpts= /nologo /O2 /inline /traceback /libs:static /threads
rem SET LinkOpts=/link

SET FileName=DISCON

REM ----------------------------------------------------------------------------
REM compile DLL
REM ----------------------------------------------------------------------------

ECHO.
ECHO Creating %FileName%.dll:

CALL IFORT /dll %CompOpts% %FileName%.f90 /exe:%FileName%.dll

ECHO.

REM ----------------------------------------------------------------------------
REM clear variables
REM ----------------------------------------------------------------------------

DEL %FileName%.obj

SET CompOpts=
SET LinkOpts=
SET FileName=

[/code]

The .lib and .exp files have uses depending on what you are going to do with the DLL that was generated. But, for the Bladed-style controller used in FAST, we don’t need them.

This is because we dynamically (explicitly) load the DLL. This allows us to state explicitly which DLL we want to use in a simulation–both it’s name and location–and to use different controller DLLs without having to copy and rename them every time we want to run FAST.

This is in contrast to DLLs like MAP_Win32.dll. When we link the FAST v8 executable, we link it with the MAP_Win32.lib file; this tells us what subroutines we can access in MAP_Win32.dll. It also means that Windows must be able to find and load MAP_Win32.dll before FAST will run, even if you are not using MAP for that particular simulation.

Dear sir
I have a question about how to compile FAST_RT_DLL.dll.
I meet an error: “LINK: fatal error LNK1104: cannot open file ‘LIBC.lib’.”
Could you tell me how to resolve it?

[code]@ECHO OFF

REM The calling syntax for this script is
REM Compile_FASTforLabview
REM

REM ----------------------------------------------------------------------------
REM set compiler internal variables
REM ----------------------------------------------------------------------------
REM You can run this bat file from the IVF compiler’s command prompt (and not
REM do anything in this section). If you choose not to run from the IVF command
REM prompt, you must call the compiler’s script to set internal variables.
REM TIP: Right click on the IVF Compiler’s Command Prompt shortcut, click
REM properties, and copy the target (without cmd.exe and/or its switches) here:

REM: PLEASE NOTE: newer versions of the IVF compiler are not yet supported.

IF “%INTEL_SHARED%”==“” CALL “C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\ifortvars.bat” ia32 vs2008

REM ----------------------------------------------------------------------------
REM -------------------- LOCAL VARIABLES ---------------------------------------
REM ----------------------------------------------------------------------------

SET ROOT_NAME=…\FAST_RT_DLL

REM bjj: DO NOT USE /threads. It causes a memory leak when the DLL runs in LabVIEW.
SET CompOpts= /O2 /inline:speed /Qzero /Qsave /real_size:32 /assume:byterecl /libs:static /nothreads /vms /check:none /NODEFAULTLIB:libc
rem /nologo /Qopenmp_report:0 /Qpar_report:0 /Qvec_report:0 /warn:none /libdir:nouser /c

rem SET LINKOPTS=/link /stack:64000000
SET LinkOpts=/DELAYLOAD:“imagehlp.dll” /DLL delayimp.lib

rem /INCREMENTAL /NOLOGO /ASSEMBLYDEBUG:DISABLE /OPT:NOREF

REM ----------------------------------------------------------------------------
REM ------------------------- LOCAL PATHS --------------------------------------
REM ----------------------------------------------------------------------------
REM – USERS WILL NEED TO EDIT THESE PATHS TO POINT TO FOLDERS ON THEIR LOCAL –
REM – MACHINES. NOTE: do not use quotation marks around the path names!!! —
REM ----------------------------------------------------------------------------
REM NWTC_Lib_Loc is the location of the NWTC subroutine library files
REM AeroDyn_Loc is the location of the AeroDyn source files
REM Wind_Loc is the location of the AeroDyn wind inflow source files
REM FAST_LOC is the location of the FAST source files
REM ----------------------------------------------------------------------------

rem SET NWTC_Lib_Loc=C:\Users\bjonkman\Data\DesignCodes\NWTC Library\source
rem SET AeroDyn_Loc=C:\Users\bjonkman\Data\DesignCodes\AeroDyn\Source
rem SET Wind_Loc=C:\Users\bjonkman\Data\DesignCodes\AeroDyn\Source\InflowWind\Source
rem SET FAST_Loc=C:\Users\bjonkman\Data\DesignCodes\FAST\Source

SET NWTC_Lib_Loc=C:\Users\jason2\Desktop\FAST_LAVIEW compile\Source_NWTC_Lib2
SET AeroDyn_Loc=C:\Users\jason2\Desktop\FAST_LAVIEW compile\Source_AeroDyn2
SET Wind_Loc=C:\Users\jason2\Desktop\FAST_LAVIEW compile\Source_InflowWind2
SET FAST_Loc=C:\Users\jason2\Desktop\FAST_LAVIEW compile\Source_FAST2
SET Labview_Loc=C:\Users\jason2\Desktop\FAST_LAVIEW compile\Source_Labview_Lib2

REM ----------------------------------------------------------------------------
REM -------------------- LIST OF ALL SOURCE FILES ------------------------------
REM ----------------------------------------------------------------------------

SET NWTC_Files=
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\SingPrec.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\SysIVF_Labview.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\NWTC_IO.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\NWTC_Num.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\NWTC_Aero.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\ModMesh.f90”
SET NWTC_Files=%NWTC_Files% “%NWTC_Lib_Loc%\NWTC_Library.f90”

SET Wind_Files=
SET Wind_Files=%Wind_Files% “%Wind_Loc%\SharedInflowDefs.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\HHWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\FFWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\HAWCWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\FDWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\CTWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\UserWind.f90”
SET Wind_Files=%Wind_Files% “%Wind_Loc%\InflowWindMod.f90”

SET AeroDyn_Files=
SET AeroDyn_Files=%AeroDyn_Files% “%AeroDyn_Loc%\SharedTypes.f90”
SET AeroDyn_Files=%AeroDyn_Files% “%AeroDyn_Loc%\AeroMods.f90”
SET AeroDyn_Files=%AeroDyn_Files% “%AeroDyn_Loc%\GenSubs.f90”
SET AeroDyn_Files=%AeroDyn_Files% “%AeroDyn_Loc%\AeroSubs.f90”
SET AeroDyn_Files=%AeroDyn_Files% “%AeroDyn_Loc%\AeroDyn.f90”

SET FAST_Files=
SET FAST_Files=%FAST_Files% “%FAST_LOC%\fftpack.f”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FFTMod.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\HydroCalc.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FAST_Mods.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\Noise.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FAST_IO.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FAST.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FAST_Lin.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\FAST2ADAMS.f90”

SET FAST_Files=%FAST_Files% “%FAST_LOC%\PitchCntrl_ACH.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\UserSubs.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\UserVSCont_KP.f90”

SET FAST_Files=%FAST_Files% “%FAST_LOC%\AeroCalc.f90”
SET FAST_Files=%FAST_Files% “%FAST_LOC%\SetVersion.f90”

SET FAST_Files=%FAST_Files% “%Labview_Loc%\FAST_RT_DLL.f90”

:ivf
REM ----------------------------------------------------------------------------
REM ---------------- COMPILE WITH INTEL VISUAL FORTRAN -------------------------
REM ----------------------------------------------------------------------------

REM compile

ECHO.
ECHO Compiling FAST, AeroDyn, InflowWind, and NWTC_Library routines to create %ROOT_NAME%.dll:

ifort /dll %CompOpts% /exe:%ROOT_NAME%.dll %NWTC_Files% %Wind_Files% %AeroDyn_Files% %FAST_Files% /link %LinkOpts%

:end
REM ----------------------------------------------------------------------------
REM ------------------------- CLEAR MEMORY -------------------------------------
REM ------------- and delete all .mod and .obj files ---------------------------
REM ----------------------------------------------------------------------------
ECHO a

DEL *.mod
DEL *.obj

SET ROOT_NAME=

SET NWTC_Files=
SET Wind_Files=
SET AeroDyn_Files=
SET FAST_Files=
SET A2AD_Files=
SET Fixed_Files=

SET NWTC_Lib_Loc=
SET Wind_Loc=
SET AeroDyn_Loc=
SET A2AD_Loc=
SET FAST_Loc=
SET Labview_Loc=

SET COMPOPTS=
SET LINKOPTS=
[/code]
Thanks for your help.

Jason. Lai

Dear Jason,

Compiling instructions for FAST RT are in a pdf document contained in the Labview directory of the FAST v7 archive (UsingFAST4Labview.pdf).

Best regards,