Instructions for Compiling FAST

Hi, Jean Marc.

Thanks for reporting this issue. I took a look at it in the gnu debugger (gdb) and it seems similar to the issue preventing us from running models with HydroDyn when compiling with gfortran. It looks like some memory related to the TMD mesh is getting overwritten somehow, and it’s crashing on a call to MeshCopy. I don’t have a solution right now (other than to use Intel Fortran), but I’ll keep looking as I find time.

Jean Marc,

I was able to track down the issue with Test18 with TMD in gfortran, and have it running on my version of the code. I’ll get this fix in the next FAST release, but meanwhile, I’ve put new source files for ServoDyn and TMD that you can use here.

Thank you so much Bonnie!

I will test these routines right now. Do you have the 2.07 registry so I could test my own modules as well?

Here are some links to archives of the latest version of the Registry:

Thank you very much, it works.

Here are some tricks to build a version of FAST for linux and/or osx using gfortran or ifort:

Firstly, we need to patch the SysGnuLinux.f90 file (NWTC Library) using:

@@ -92,7 +92,11 @@
 
 !=======================================================================
    FUNCTION FileSize( Unit )
-
+   
+#ifndef __GFORTRAN__
+    USE IFPORT
+#else
+#endif
 
       ! This function calls the portability routine, FSTAT, to obtain the file size
       ! in bytes corresponding to a file unit number or returns -1 on error.
@@ -149,7 +153,10 @@
 !bjj note: this subroutine is not tested for this compiler
    SUBROUTINE Get_CWD ( DirName, Status )
 
-
+#ifndef __GFORTRAN__
+    USE IFPORT
+#else
+#endif
       ! This routine retrieves the path of the current working directory.
 
 
@@ -433,6 +440,11 @@
 
 !   WRITE (CU,'(1X,A)',ADVANCE='NO')  Str
    WRITE (CU,'(A)',ADVANCE='NO')  Str
+   
+#ifndef __GFORTRAN__
+      FLUSH(CU)
+#else
+#endif
 
 
    RETURN
@@ -465,10 +477,21 @@
       WRITE (Fmt(5:7),'(I3)')  NChars
 
       WRITE (CU,Fmt,ADVANCE='NO')  CR, Str
+   
+#ifndef __GFORTRAN__
+      FLUSH(CU)
+#else
+#endif
 
    ELSE
       ! bjj: note that this will almost certainly write more than MaxWrScrLen characters on a line
       WRITE (CU,'(A)',ADVANCE='NO')  CR, Str
+   
+#ifndef __GFORTRAN__
+      FLUSH(CU)
+#else
+#endif
+
    END IF
 
 
@@ -524,11 +547,11 @@
    INTEGER(C_INT), PARAMETER :: RTLD_LOCAL=0           ! "This is the converse of RTLD_GLOBAL, and the default if neither flag is specified. Symbols defined in this library are not made available to resolve references in subsequently loaded libraries."
 
 
-   ErrStat = ErrID_Fatal
-   ErrMsg = ' LoadDynamicLib: Not implemented for '//TRIM(OS_Desc)
-   
-   
-#if 0           
+!   ErrStat = ErrID_Fatal
+!   ErrMsg = ' LoadDynamicLib: Not implemented for '//TRIM(OS_Desc)
+   
+   
+!#if 0           
 !bjj: note that this is not tested:
    INTERFACE !linux API routines
       !bjj see http://linux.die.net/man/3/dlopen
@@ -582,7 +605,7 @@
       RETURN
    END IF
 
-#endif
+!#endif
    
    RETURN
 END SUBROUTINE LoadDynamicLib
@@ -602,11 +625,11 @@
    INTEGER(C_INT), PARAMETER                 :: TRUE  = 0
 
 
-   ErrStat = ErrID_Fatal
-   ErrMsg = ' FreeDynamicLib: Not implemented for '//TRIM(OS_Desc)
-   
-   
-#if 0   
+!   ErrStat = ErrID_Fatal
+!   ErrMsg = ' FreeDynamicLib: Not implemented for '//TRIM(OS_Desc)
+   
+   
+!#if 0   
 !bjj: note that this is not tested.
    INTERFACE !linux API routine
       !bjj see http://linux.die.net/man/3/dlopen
@@ -635,7 +658,7 @@
       ErrStat = ErrID_None
       ErrMsg = ''
    END IF
-#endif
+!#endif
    
    RETURN
 END SUBROUTINE FreeDynamicLib

This allows the loading of dlls, and it resolves some portability issues between gfortran and ifort.

Next, here are the compilers options I used to build the code.

  • Using gfortran

[code]
FC = gfortran

F90_FLAGS = -x f95-cpp-input -ffree-line-length-none -O2 -m64 -finit-local-zero -fno-automatic
F77_FLAGS = -x f77-cpp-input -O2 -m64 -finit-local-zero -fno-automatic
LD_FLAGS = -O2 -m64 -ldl -finit-local-zero -fno-automatic[/code]

  • Using Intel Fortran for Linux
FC              =       ifort

F90_FLAGS       =       -fpp -threads -O2 -mkl:sequential -finline-functions -xhost
F77_FLAGS       =       -fpp -threads -O2 -mkl:sequential -finline-functions -xhost
LD_FLAGS         =       -fpp -threads -O2 -I$(MKLROOT)/include -mkl:sequential -finline-functions -xhost

Hope this helps someone.

Hi, Bonnie,
Thank you very much for your answers.
I found FAST V8.10 can “ add an additional FAST_SFunc input from Simulink, just change the third S-Function parameter in the S-Function block in Simulink and then modify FAST_Library.f90 to handle the new input value” , I think this could help me to add an flap control signal input from simulink.But I met another problem.I modify some FAST source code list as below:
(1) FAST_Library.f90
subroutine FAST_SetExternalInputs(NumInputs_c, InputAry, m_FAST)
……
! add some variable
REAL(ReKi) , DIMENSION(1:3) :: FlapCom_STU ! Flap commands from Simulink/Labview [rad/s]
REAL :: COM1_STU,COM2_STU,COM3_STU ! Deliver the flap commands parameter to AeroSubs.f90 file.
COMMON COM1_STU,COM2_STU,COM3_STU
……
IF ( NumInputs_c > NumFixedInputs ) THEN ! NumFixedInputs is the fixed number of inputs
IF ( NumInputs_c == NumFixedInputs + 3 ) &
m_FAST%ExternInput%FlapCom_STU = InputAry(9:11) ! use the input port InputAry(9:11) to pass the flap commands
!m_FAST%ExternInput%LidarFocus = InputAry(9:11)
END IF
COM1_STU = FlapCom_STU(1)
COM2_STU = FlapCom_STU(2)
COM3_STU = FlapCom_STU(3)
end subroutine FAST_SetExternalInputs
(2)AeroSubs.f90
SUBROUTINE AD_GetInput(InitInp, P, x, xd, z, O, y, ErrStat, ErrMess )
……
! add some variable
CHARACTER (1024) :: FlapNm(100)
INTEGER :: L
INTEGER :: FlapCom
REAL :: COM11_STU,COM12_STU,COM13_STU
COMMON COM11_STU,COM12_STU,COM13_STU
……
!read the flap airfoil file name(s)
CALL ReadAryLines( UnIn, InitInp%ADFileName, FlapNm, 10, AryName=‘FlapNm’, AryDescr=‘Flap file names’, ErrStat=ErrStat, ErrMsg=ErrMess )
IF (ErrStat >= AbortErrLev) THEN
CLOSE(UnIn)
RETURN
END IF
! flap airfoil data file name(s) pass to FlapNm(L)
DO L=1,10
IF ( PathIsRelative( FlapNm(L) ) ) FlapNm(L) = TRIM(FilePath)//TRIM( FlapNm(L) )
END DO
FlapCom = INT( COM11_STU ) !Use the COM11_STU as an flap command single
! use the new flap airfoil data file to replace the old airfoil data file according to the flap command single
SELECT CASE (FlapCom)
CASE(1)
P%AirFoil%FoilNm(10)=FlapNm(1)
CASE(2)
P%AirFoil%FoilNm(10)=FlapNm(2)
CASE(3)
P%AirFoil%FoilNm(10)=FlapNm(3)
CASE(4)
P%AirFoil%FoilNm(10)=FlapNm(4)
CASE(5)
P%AirFoil%FoilNm(10)=FlapNm(5)
CASE(6)
P%AirFoil%FoilNm(10)=FlapNm(6)
CASE(7)
P%AirFoil%FoilNm(10)=FlapNm(7)
CASE(8)
P%AirFoil%FoilNm(10)=FlapNm(8)
CASE(9)
P%AirFoil%FoilNm(10)=FlapNm(9)
CASE(10)
P%AirFoil%FoilNm(10)=FlapNm(10)
CASE DEFAULT
WRITE(,)“ERROR”
STOP
END SELECT
……
Then run the …\Simulink\VisualStudio\FAST_Library.vfproj, It could create the FAST_Library_debug_Win32.dll. And then use the new FAST_Library_debug_Win32.dll replace the old FAST_Library _Win32.dll, and run the Run_OpenLoop.m file, An error occur , the prompt message are as below:


This segmentation violation occurred while executing the 
S-function 'FAST_SFunc' in block 'O'.
A common cause of this segmentation violation is an incorrect
input port direct feedthrough setting. Each input port of the
S-function that is read (accessed) in mdlOutputs and/or
mdlGetTimeOfNextVarHit must specify that it needs its input
signal in these routines by setting direct feedthrough for
these input ports.
1) To debug your C-MEX S-function, you can enable diagnostics
   by compiling the S-function source with the -g flag, e.g.,
      mex -g sfunction_name.c
2) You can ask Simulink to try assuming your S-function has
   direct feedthrough using:
      set_param('modelname','TryForcingSFcnDF','on')
   If Simulink can find a valid sorting mode that does not
   result in algebraic loops involving your S-function, your
   model will execute (assuming that the cause of this
   segmentation violation is an incorrect direct feedthrough
   setting on an input port).
See matlabroot/simulink/src/sfuntmpl_directfeed.txt
-------------------------------------------------------------

Error using Run_OpenLoop (line 30)
Error while obtaining sizes from MEX S-function ‘FAST_SFunc’ in ‘OpenLoop/FAST Nonlinear Wind
Turbine/S-Function’.
Caused by:
Error using Run_OpenLoop (line 30)
FatalException

  There are something wrong happen in the interface of the FAST_SFunc and Matlab\Simulink, I don’t know how to solve it. Can anybody help me?  

Best regards,
keshan

Dear JeanMarc,

I am trying to compile FAST in Ubuntu 14.04, I have to admit this is my first compiling experience so I am a bit lost…

First I’ve checked if I have gfortran and gcc installed and they are and their versions are 4.8.2 both of them.
I made some changes in the makefile indicating some paths and changing the compiler instructions to the ones you indicated for gfortran. I save and copy the file into …/Source folder.
In addition I patched SysGnuLinux.f90 as indicated in your post.

Now, I open a terminal, go to …/FAST_v8.10.00a-bjj/Source folder and execute the command “make” and I get the following message.

[code]borja@borja-HP:~/FAST/FAST_v8.10.00a-bjj/Source$ make
gfortran -I Obj_lin64 -c /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90 -o Obj_lin64/SysGnuLinux.obj -J Obj_lin64 -B Obj_lin64
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:399: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:413: Illegal preprocessor directive
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:95.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:96.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:97.1:

+#ifndef GFORTRAN
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:98.1:

  • USE IFPORT
    1
    Error: Invalid character in name at (1)
    /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:99.1:

+#else
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:100.1:

+#endif
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:157.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:158.1:

+#ifndef GFORTRAN
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:159.1:

  • USE IFPORT
    1
    Error: Invalid character in name at (1)
    /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:160.1:

+#else
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:161.1:

+#endif
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:445.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:446.1:

+#ifndef GFORTRAN
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:447.1:

  •  FLUSH(CU)
    

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:448.1:

+#else
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:449.1:

+#endif
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:481.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:482.1:

+#ifndef GFORTRAN
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:483.1:

  •  FLUSH(CU)
    

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:484.1:

+#else
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:485.1:

+#endif
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:490.1:

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:491.1:

+#ifndef GFORTRAN
1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:492.1:

  •  FLUSH(CU)
    

1
Error: Invalid character in name at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:493.1:

+#else
1
Error: Invalid character in name at (1)
Fatal Error: Error count reached limit of 25.
make: *** [SysGnuLinux.obj] Error 1[/code]

At this point I don’t know if I am doing the right thing or not, but seems like my gfortran does not like some expressions in the patched SysGnuLinux.f90 file.

If I try to run the same command without patching it I get also bad results.

[code]borja@borja-HP:~/FAST/FAST_v8.10.00a-bjj/Source$ make
gfortran -I Obj_lin64 -c /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90 -o Obj_lin64/SysGnuLinux.obj -J Obj_lin64 -B Obj_lin64
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:390: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:404: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:531: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:585: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:609: Illegal preprocessor directive
Warning: /home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:638: Illegal preprocessor directive
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:533.32:

INTERFACE !linux API routines
1
Error: Unexpected INTERFACE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:537.6:

  FUNCTION dlOpen(filename,mode) BIND(C,NAME="dlopen")
  1

Error: Unclassifiable statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:539.26:

     USE ISO_C_BINDING
                      1

Error: Unexpected USE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:540.22:

     IMPLICIT NONE
                  1

Error: Unexpected IMPLICIT NONE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:541.48:

     TYPE(C_PTR)                   :: dlOpen
                                            1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:542.53:

     CHARACTER(C_CHAR), INTENT(IN) :: filename(*)
                                                 1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:543.46:

     INTEGER(C_INT), VALUE         :: mode
                                          1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:544.9:

  END FUNCTION
     1

Error: Expecting END SUBROUTINE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:546.6:

  FUNCTION dlSym(handle,name) BIND(C,NAME="dlsym")
  1

Error: Unclassifiable statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:548.26:

     USE ISO_C_BINDING
                      1

Error: Unexpected USE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:549.22:

     IMPLICIT NONE
                  1

Error: Unexpected IMPLICIT NONE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:550.68:

     TYPE(C_FUNPTR)                :: dlSym ! A function pointer
                                                                1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:551.48:

     TYPE(C_PTR), VALUE            :: handle
                                            1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:552.49:

     CHARACTER(C_CHAR), INTENT(IN) :: name(*)
                                             1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:553.9:

  END FUNCTION
     1

Error: Expecting END SUBROUTINE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:555.6:

END INTERFACE
1
Error: Expecting END SUBROUTINE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:611.31:

INTERFACE !linux API routine
1
Error: Unexpected INTERFACE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:614.6:

  FUNCTION dlClose(handle) BIND(C,NAME="dlclose")
  1

Error: Unclassifiable statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:616.26:

     USE ISO_C_BINDING
                      1

Error: Unexpected USE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:617.22:

     IMPLICIT NONE
                  1

Error: Unexpected IMPLICIT NONE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:618.40:

     INTEGER(C_INT)       :: dlClose
                                    1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:619.39:

     TYPE(C_PTR), VALUE   :: handle
                                   1

Error: Unexpected data declaration statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:620.9:

  END FUNCTION
     1

Error: Expecting END SUBROUTINE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:622.6:

END INTERFACE
1
Error: Expecting END SUBROUTINE statement at (1)
/home/borja/FAST/FAST_v8.10.00a-bjj/Source/dependencies/NWTC_Library/SysGnuLinux.f90:628.13:

Success = dlClose( DLL%FileAddrX ) !The function dlclose() returns 0 on succ
1
Error: Function ‘dlclose’ at (1) has no IMPLICIT type
Fatal Error: Error count reached limit of 25.
make: *** [SysGnuLinux.obj] Error 1[/code]

Analysing the message I see that expressions like #ifndef are not recognised… :open_mouth: :open_mouth:

I would really appreciate any help on this.

Best regards,

Borja

Just a thought, but if you are not trying to compile both intel fortran and gfortran using the same SysGnuLinux.f90 file, I don’t think you need most of the patches to that file. SysGnuLinux.f90 should compile with gfortran as is.

Keshan,

I don’t have a lot of time now to help with more involved questions, but one thing that concerns me is that you seem to be using S-Function inputs to set parameters. Parameters don’t change over the course of the simulation, and the inputs are not even defined before calling FAST_Sizes() where your code seems to be used. I’d suggest using S-function parameters (initialization inputs) instead of inputs to the S-Function for what you’re doing at initialization. The “NumAdditionalInputs” parameter can actually be input as an array; elements 2-n can be accessed through the InitInpAry array in FAST_Sizes(). So if you set NumAdditionalInputs to [3, COM11_STU], InitInpAry(1) = COM11_STU. Be careful, though, because when NumAdditionalInputs is 3, the code expects InitInpAry to contain two values to initialize a lidar module.

If you really do want to change parameters during the simulation, that will involve a lot more effort.

Borja,

As mentioned by Bonnie, the patch allows to compile FAST on Linux with Ifort (and Gfortran as well, but only a few lines need to be modified for Gfortran). But, I think that first errors come from the fact you didn’t apply the patch correctly, the “+” and “-” symbols should not appear in the code, they are needed by the patch program to know which line to remove or to insert when applying the patch.

Here is the patched SysGnuLinux file that you should obtain:

!**********************************************************************************************************************************
! LICENSING
! Copyright (C) 2013  National Renewable Energy Laboratory
!
!    This file is part of the NWTC Subroutine Library.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
!     http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
!**********************************************************************************************************************************
! File last committed: $Date: 2015-02-12 09:16:39 -0700 (Thu, 12 Feb 2015) $
! (File) Revision #: $Rev: 289 $
! URL: $HeadURL: https://windsvn.nrel.gov/NWTC_Library/trunk/source/SysGnuLinux.f90 $
!**********************************************************************************************************************************
MODULE SysSubs


   ! This module contains routines with system-specific logic and references, including all references to the console unit, CU.
   ! It also contains standard (but not system-specific) routines it uses.

   ! SysGnuLinux.f90 is specifically for the GNU Fortran (gfortran) compiler on Linux. This should also work for gfortran on MAC.


   ! It contains the following routines:

   !     FUNCTION    FileSize( Unit )                                         ! Returns the size (in bytes) of an open file.
   !     SUBROUTINE  FlushOut ( Unit )
   !     SUBROUTINE  GET_CWD( DirName, Status )
   !     FUNCTION    Is_NaN( DblNum )                                         ! Please use IEEE_IS_NAN() instead
   !     FUNCTION    NWTC_Gamma( x )                                          ! Returns the gamma value of its argument.   
   ! per MLB, this can be removed, but only if CU is OUTPUT_UNIT:
   !     SUBROUTINE  OpenCon                                                  ! Actually, it can't be removed until we get Intel's FLUSH working. (mlb)
   !     SUBROUTINE  OpenUnfInpBEFile ( Un, InFile, RecLen, Error )
   !     SUBROUTINE  ProgExit ( StatCode )
   !     SUBROUTINE  Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )   
   !     SUBROUTINE  UsrAlarm
   !     SUBROUTINE  WrNR ( Str )
   !     SUBROUTINE  WrOver ( Str )
   !     SUBROUTINE  WriteScr ( Str, Frm )
   !     SUBROUTINE LoadDynamicLib( DLL, ErrStat, ErrMsg )
   !     SUBROUTINE FreeDynamicLib( DLL, ErrStat, ErrMsg )



   USE                             NWTC_Base

   IMPLICIT                        NONE

   INTERFACE NWTC_gamma ! Returns the gamma value of its argument
         ! note: gamma is part of the F08 standard, but may not be implemented everywhere...
      MODULE PROCEDURE NWTC_gammaR4
      MODULE PROCEDURE NWTC_gammaR8
      MODULE PROCEDURE NWTC_gammaR16
   END INTERFACE
   
   INTERFACE NWTC_ERF ! Returns the ERF value of its argument
      MODULE PROCEDURE NWTC_ERFR4
      MODULE PROCEDURE NWTC_ERFR8
      MODULE PROCEDURE NWTC_ERFR16
   END INTERFACE
   
   

!=======================================================================


   INTEGER, PARAMETER            :: ConRecL     = 120                               ! The record length for console output.
   INTEGER, PARAMETER            :: CU          = 6                                 ! The I/O unit for the console.  Unit 6 causes ADAMS to crash.
                                                                                    ! CU = 7 works on gfortran compiler version 4.6 and possibly 4.5. Fails on version 4.7 and 4.8 (see bugzilla bug report #445 for details)
   INTEGER, PARAMETER            :: MaxWrScrLen = 98                                ! The maximum number of characters allowed to be written to a line in WrScr

   LOGICAL, PARAMETER            :: KBInputOK   = .TRUE.                            ! A flag to tell the program that keyboard input is allowed in the environment.

   CHARACTER(10), PARAMETER      :: Endian      = 'BIG_ENDIAN'                      ! The internal format of numbers.
   CHARACTER(*),  PARAMETER      :: NewLine     = ACHAR(10)                         ! The delimiter for New Lines [ Windows is CHAR(13)//CHAR(10); MAC is CHAR(13); Unix is CHAR(10) {CHAR(13)=\r is a line feed, CHAR(10)=\n is a new line}]
   CHARACTER(*),  PARAMETER      :: OS_Desc     = 'GNU Fortran for Linux'           ! Description of the language/OS
   CHARACTER( 1), PARAMETER      :: PathSep     = '/'                               ! The path separator.
   CHARACTER( 1), PARAMETER      :: SwChar      = '-'                               ! The switch character for command-line options.
   CHARACTER(11), PARAMETER      :: UnfForm     = 'UNFORMATTED'                     ! The string to specify unformatted I/O files.


CONTAINS

!=======================================================================
   FUNCTION FileSize( Unit )
   
#ifndef __GFORTRAN__
    USE IFPORT
#else
#endif

      ! This function calls the portability routine, FSTAT, to obtain the file size
      ! in bytes corresponding to a file unit number or returns -1 on error.


      ! Function declaration.

   INTEGER(B8Ki)                             :: FileSize                      ! The size of the file in bytes to be returned.


      ! Argument declarations:

   INTEGER, INTENT(IN)                       :: Unit                          ! The I/O unit number of the pre-opened file.


      ! Local declarations:

   INTEGER                                   :: StatArray(13)                 ! An array returned by FSTAT that includes the file size.
   INTEGER                                   :: Status                        ! The status returned by



   Status = FSTAT( INT( Unit, B4Ki ), StatArray )

   IF ( Status /= 0 ) THEN
      FileSize = -1
   ELSE
      FileSize = StatArray(8)
   END IF


   RETURN
   END FUNCTION FileSize ! ( Unit )
!=======================================================================
   SUBROUTINE FlushOut ( Unit )


      ! This subroutine flushes the buffer on the specified Unit.
      ! It is especially useful when printing "running..." type messages.


      ! Argument declarations:

   INTEGER, INTENT(IN)          :: Unit                                         ! The unit number of the file being flushed.



  ! CALL FLUSH ( Unit )


   RETURN
   END SUBROUTINE FlushOut ! ( Unit )
!=======================================================================
!bjj note: this subroutine is not tested for this compiler
   SUBROUTINE Get_CWD ( DirName, Status )

#ifndef __GFORTRAN__
    USE IFPORT
#else
#endif
      ! This routine retrieves the path of the current working directory.


   IMPLICIT                        NONE


      ! Passed variables.

   CHARACTER(*), INTENT(OUT)    :: DirName                                         ! A CHARACTER string containing the path of the current working directory.
   INTEGER,      INTENT(OUT)    :: Status                                          ! Status returned by the call to a portability routine.


   Status = GETCWD ( DirName )

   RETURN
   END SUBROUTINE Get_CWD
!=======================================================================
   FUNCTION Is_NaN( DblNum )


      ! This routine determines if a REAL(DbKi) variable holds a proper number.
      ! BJJ: this routine is used in CRUNCH.
      ! Note that IsNaN does not exist in earlier versions of gfortran (e.g., 4.2.1),
      ! but does exist in version 4.4. It should be replaced with the standard
      ! IEEE_IS_NAN when gfortran implements it.


      ! Argument declarations.

   REAL(DbKi), INTENT(IN)       :: DblNum


      ! Function declaration.

   LOGICAL                      :: Is_Nan



   Is_NaN = IsNaN( DblNum )


   RETURN
   END FUNCTION Is_NaN ! ( DblNum )
!=======================================================================
   FUNCTION NWTC_ERFR4( x )
   
      ! Returns the ERF value of its argument. The result has a value equal  
      ! to the error function: 2/pi * integral_from_0_to_x of e^(-t^2) dt. 

      REAL(SiKi), INTENT(IN)     :: x           ! input 
      REAL(SiKi)                 :: NWTC_ERFR4  ! result
      
      
      NWTC_ERFR4 = ERF( x )
   
   END FUNCTION NWTC_ERFR4
!=======================================================================
   FUNCTION NWTC_ERFR8( x )
   
      ! Returns the ERF value of its argument. The result has a value equal  
      ! to the error function: 2/pi * integral_from_0_to_x of e^(-t^2) dt. 

      REAL(R8Ki), INTENT(IN)     :: x             ! input 
      REAL(R8Ki)                 :: NWTC_ERFR8    ! result
      
      
      NWTC_ERFR8 = ERF( x )
   
   END FUNCTION NWTC_ERFR8
!=======================================================================
   FUNCTION NWTC_ERFR16( x )
   
      ! Returns the ERF value of its argument. The result has a value equal  
      ! to the error function: 2/pi * integral_from_0_to_x of e^(-t^2) dt. 

      REAL(QuKi), INTENT(IN)     :: x             ! input 
      REAL(QuKi)                 :: NWTC_ERFR16   ! result
      
      
      NWTC_ERFR16 = ERF( x )
   
   END FUNCTION NWTC_ERFR16
!=======================================================================
   FUNCTION NWTC_GammaR4( x )
   
      ! Returns the gamma value of its argument. The result has a value equal  
      ! to a processor-dependent approximation to the gamma function of x. 

      REAL(SiKi), INTENT(IN)     :: x             ! input 
      REAL(SiKi)                 :: NWTC_GammaR4  ! result
      
      
      NWTC_GammaR4 = gamma( x )
   
   END FUNCTION NWTC_GammaR4
!=======================================================================
   FUNCTION NWTC_GammaR8( x )
   
      ! Returns the gamma value of its argument. The result has a value equal  
      ! to a processor-dependent approximation to the gamma function of x. 

      REAL(R8Ki), INTENT(IN)     :: x             ! input 
      REAL(R8Ki)                 :: NWTC_GammaR8  ! result
      
      
      NWTC_GammaR8 = gamma( x )
   
   END FUNCTION NWTC_GammaR8
!=======================================================================
   FUNCTION NWTC_GammaR16( x )
   
      ! Returns the gamma value of its argument. The result has a value equal  
      ! to a processor-dependent approximation to the gamma function of x. 

      REAL(QuKi), INTENT(IN)     :: x             ! input 
      REAL(QuKi)                 :: NWTC_GammaR16  ! result
      
      
      NWTC_GammaR16 = gamma( x )
   
   END FUNCTION NWTC_GammaR16
!=======================================================================
   SUBROUTINE OpenCon


      ! This routine opens the console for standard output.


!bjj: removed for use with CygWin; Because CU = 6 now, this statement is not necessary
!   OPEN ( CU , FILE='/dev/stdout' , STATUS='OLD' )

   CALL FlushOut ( CU )


   RETURN
   END SUBROUTINE OpenCon
!=======================================================================
   SUBROUTINE OpenUnfInpBEFile ( Un, InFile, RecLen, Error )


      ! This routine opens a binary input file with data stored in Big Endian format (created on a UNIX machine.)
      ! Data are stored in RecLen-byte records.

   IMPLICIT                        NONE



      ! Argument declarations.

   INTEGER, INTENT(IN)          :: Un                                           ! Logical unit for the input file.

   CHARACTER(*), INTENT(IN)     :: InFile                                       ! Name of the input file.

   INTEGER, INTENT(IN)          :: RecLen                                       ! Size of records in the input file, in bytes.

   LOGICAL, INTENT(OUT)         :: Error                                        ! Flag to indicate the open failed.


      ! Local declarations.

   INTEGER                      :: IOS                                          ! I/O status of OPEN.



      ! Open input file.  Make sure it worked.

   ! The non-standard CONVERT keyword allows us to read UNIX binary files, whose bytes are in reverse order (i.e., stored in BIG ENDIAN format).

   ! NOTE: using RecLen in bytes requires using the /assume:byterecl compiler option!

   OPEN ( Un, FILE=TRIM( InFile ), STATUS='OLD', FORM='UNFORMATTED', ACCESS='DIRECT', RECL=RecLen, IOSTAT=IOS, &
                   ACTION='READ'  )                                              ! Use this for UNIX systems.
!                  ACTION='READ', CONVERT='BIG_ENDIAN' )                         ! Use this for PC systems.


   IF ( IOS /= 0 )  THEN
      Error = .TRUE.
   ELSE
      Error = .FALSE.
   END IF


   RETURN
   END SUBROUTINE OpenUnfInpBEFile
!=======================================================================
   SUBROUTINE ProgExit ( StatCode )


      ! This routine stops the program.  If the compiler supports the EXIT routine,
      ! pass the program status to it.  Otherwise, do a STOP.


      ! Argument declarations.

   INTEGER, INTENT(IN)          :: StatCode                                      ! The status code to pass to the OS.



   CALL EXIT ( StatCode )

!   IF ( StatCode == 0 ) THEN
!      STOP 0
!   ELSE
!      IF ( StatCode < 0 ) THEN
!         CALL WrScr( 'Invalid STOP code.' )
!      END IF
!
!      STOP 1
!   END IF


   END SUBROUTINE ProgExit ! ( StatCode )
!=======================================================================
   SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )   
         
      ! routine that sets the values of NaN_D, Inf_D, NaN, Inf (IEEE 
      ! values for not-a-number and infinity in sindle and double 
      ! precision) F03 has standard intrinsic routines to do this,  
      ! but Gnu has not yet implemented it. This code will fail if  
      ! the compiler checks for floating-point-error, hence the  
      ! compiler directive FPE_TRAP_ENABLED.
   
   
      REAL(DbKi), INTENT(inout)           :: Inf_D          ! IEEE value for NaN (not-a-number) in double precision
      REAL(DbKi), INTENT(inout)           :: NaN_D          ! IEEE value for Inf (infinity) in double precision

      REAL(ReKi), INTENT(inout)           :: Inf            ! IEEE value for NaN (not-a-number)
      REAL(ReKi), INTENT(inout)           :: NaN            ! IEEE value for Inf (infinity)
   
         ! local variables for getting values of NaN and Inf (not necessary when using ieee_arithmetic)
      REAL(DbKi)                          :: Neg_D          ! a negative real(DbKi) number
      REAL(ReKi)                          :: Neg            ! a negative real(ReKi) number
   
      
         ! if compiling with floating-point-exception traps, this will not work, so we've added a compiler directive.
         !  note that anything that refers to NaN or Inf will be incorrect in that case.
         
#ifndef FPE_TRAP_ENABLED      
         ! set variables to negative numbers to calculate NaNs (compilers may complain when taking sqrt of negative constants)
      Neg_D = -1.0_DbKi
      Neg   = -1.0_ReKi

      NaN_D = SQRT ( Neg_D )
      NaN   = SQRT ( Neg )

         ! set variables to zero to calculate Infs (using division by zero)
      Neg_D = 0.0_DbKi
      Neg   = 0.0_ReKi
      
      Inf_D = 1.0_DbKi / Neg_D
      Inf   = 1.0_ReKi / Neg
#endif 
   
   END SUBROUTINE Set_IEEE_Constants  

!=======================================================================
   SUBROUTINE UsrAlarm


      ! This routine generates an alarm to warn the user that something went wrong.



   CALL WrNR ( CHAR( 7 ) )


   RETURN
   END SUBROUTINE UsrAlarm
!=======================================================================
   SUBROUTINE WrNR ( Str )


      ! This routine writes out a string to the screen without following it with a new line.


      ! Argument declarations.

   CHARACTER(*), INTENT(IN)     :: Str                                          ! The string to write to the screen.



!   WRITE (CU,'(1X,A)',ADVANCE='NO')  Str
   WRITE (CU,'(A)',ADVANCE='NO')  Str
   
#ifndef __GFORTRAN__
      FLUSH(CU)
#else
#endif


   RETURN
   END SUBROUTINE WrNR ! ( Str )
!=======================================================================
   SUBROUTINE WrOver ( Str )


      ! This routine writes out a string that overwrites the previous line.


      ! Argument declarations.

   CHARACTER(*), INTENT(IN)     :: Str                                          ! The string to write to the screen.


      ! Local declarations.
   INTEGER(IntKi)               :: NChars                                       ! Number of characters to write
   CHARACTER(1), PARAMETER      :: CR = ACHAR( 13 )                             ! The carriage return character.
   CHARACTER(25)                :: Fmt = '(2A,   (" "))'                        ! The format specifier for the output.



!   WRITE (Fmt(5:6),'(I2)')  ConRecL - LEN( Str )

   NChars = MaxWrScrLen - LEN( Str )

   IF ( NChars > 0 ) THEN

      WRITE (Fmt(5:7),'(I3)')  NChars

      WRITE (CU,Fmt,ADVANCE='NO')  CR, Str
   
#ifndef __GFORTRAN__
      FLUSH(CU)
#else
#endif

   ELSE
      ! bjj: note that this will almost certainly write more than MaxWrScrLen characters on a line
      WRITE (CU,'(A)',ADVANCE='NO')  CR, Str
   
#ifndef __GFORTRAN__
      FLUSH(CU)
#else
#endif

   END IF


   RETURN
   END SUBROUTINE WrOver ! ( Str )
!=======================================================================
   SUBROUTINE WriteScr ( Str, Frm )


      ! This routine writes out a string to the screen.


   IMPLICIT                        NONE


      ! Argument declarations.

   CHARACTER(*), INTENT(IN)     :: Str                                         ! The input string to write to the screen.
   CHARACTER(*), INTENT(IN)     :: Frm                                         ! Format specifier for the output.

   INTEGER                      :: ErrStat                                     ! Error status of write operation (so code doesn't crash)


   IF ( LEN_TRIM(Str)  < 1 ) THEN
      WRITE ( CU, '()', IOSTAT=ErrStat )
   ELSE
      WRITE ( CU,Frm, IOSTAT=ErrStat ) TRIM(Str)
   END IF

   IF ( ErrStat /= 0 ) &
      print *, ' WriteScr produced an error. Please inform the programmer.'


   END SUBROUTINE WriteScr ! ( Str )
!=======================================================================

!==================================================================================================================================
SUBROUTINE LoadDynamicLib ( DLL, ErrStat, ErrMsg )

      ! This SUBROUTINE is used to dynamically load a DLL.

      ! Passed Variables:

   TYPE (DLL_Type),           INTENT(INOUT)  :: DLL         ! The DLL to be loaded.
   INTEGER(IntKi),            INTENT(  OUT)  :: ErrStat     ! Error status of the operation
   CHARACTER(*),              INTENT(  OUT)  :: ErrMsg      ! Error message if ErrStat /= ErrID_None

!bjj: these are values I found on the web; I have no idea if they actually work...
!bjj: hopefully we can find them pre-defined in a header somewhere
   INTEGER(C_INT), PARAMETER :: RTLD_LAZY=1            ! "Perform lazy binding. Only resolve symbols as the code that references them is executed. If the symbol is never referenced, then it is never resolved. (Lazy binding is only performed for function references; references to variables are always immediately bound when the library is loaded.) "
   INTEGER(C_INT), PARAMETER :: RTLD_NOW=2             ! "If this value is specified, or the environment variable LD_BIND_NOW is set to a nonempty string, all undefined symbols in the library are resolved before dlopen() returns. If this cannot be done, an error is returned."
   INTEGER(C_INT), PARAMETER :: RTLD_GLOBAL=256        ! "The symbols defined by this library will be made available for symbol resolution of subsequently loaded libraries"
   INTEGER(C_INT), PARAMETER :: RTLD_LOCAL=0           ! "This is the converse of RTLD_GLOBAL, and the default if neither flag is specified. Symbols defined in this library are not made available to resolve references in subsequently loaded libraries."


!   ErrStat = ErrID_Fatal
!   ErrMsg = ' LoadDynamicLib: Not implemented for '//TRIM(OS_Desc)
   
   
!#if 0           
!bjj: note that this is not tested:
   INTERFACE !linux API routines
      !bjj see http://linux.die.net/man/3/dlopen
      ! also: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/dlopen.3.html

      FUNCTION dlOpen(filename,mode) BIND(C,NAME="dlopen")
      ! void *dlopen(const char *filename, int mode);
         USE ISO_C_BINDING
         IMPLICIT NONE
         TYPE(C_PTR)                   :: dlOpen
         CHARACTER(C_CHAR), INTENT(IN) :: filename(*)
         INTEGER(C_INT), VALUE         :: mode
      END FUNCTION

      FUNCTION dlSym(handle,name) BIND(C,NAME="dlsym")
      ! void *dlsym(void *handle, const char *name);
         USE ISO_C_BINDING
         IMPLICIT NONE
         TYPE(C_FUNPTR)                :: dlSym ! A function pointer
         TYPE(C_PTR), VALUE            :: handle
         CHARACTER(C_CHAR), INTENT(IN) :: name(*)
      END FUNCTION

   END INTERFACE


   ErrStat = ErrID_None
   ErrMsg = ''


      ! Load the DLL and get the file address:

   DLL%FileAddrX = dlOpen( TRIM(DLL%FileName)//C_NULL_CHAR, RTLD_LAZY )  !the "C_NULL_CHAR" converts the Fortran string to a C-type string (i.e., adds //CHAR(0) to the end)

   IF( .NOT. C_ASSOCIATED(DLL%FileAddrX) ) THEN
      ErrStat = ErrID_Fatal
      WRITE(ErrMsg,'(I2)') BITS_IN_ADDR
      ErrMsg  = 'The dynamic library '//TRIM(DLL%FileName)//' could not be loaded. Check that the file '// &
                'exists in the specified location and that it is compiled for '//TRIM(ErrMsg)//'-bit systems.'
      RETURN
   END IF


      ! Get the procedure address:

   DLL%ProcAddr = dlSym( DLL%FileAddrX, TRIM(DLL%ProcName)//C_NULL_CHAR )  !the "C_NULL_CHAR" converts the Fortran string to a C-type string (i.e., adds //CHAR(0) to the end)

   IF(.NOT. C_ASSOCIATED(DLL%ProcAddr)) THEN
      ErrStat = ErrID_Fatal
      ErrMsg  = 'The procedure '//TRIM(DLL%ProcName)//' in file '//TRIM(DLL%FileName)//' could not be loaded.'
      RETURN
   END IF

!#endif
   
   RETURN
END SUBROUTINE LoadDynamicLib
!==================================================================================================================================
SUBROUTINE FreeDynamicLib ( DLL, ErrStat, ErrMsg )

      ! This SUBROUTINE is used to free a dynamically loaded DLL (loaded in LoadDynamicLib).

      ! Passed Variables:

   TYPE (DLL_Type),           INTENT(INOUT)  :: DLL         ! The DLL to be freed.
   INTEGER(IntKi),            INTENT(  OUT)  :: ErrStat     ! Error status of the operation
   CHARACTER(*),              INTENT(  OUT)  :: ErrMsg      ! Error message if ErrStat /= ErrID_None

      ! Local variable:
   INTEGER(C_INT)                            :: Success     ! Whether or not the call to dlClose was successful
   INTEGER(C_INT), PARAMETER                 :: TRUE  = 0


!   ErrStat = ErrID_Fatal
!   ErrMsg = ' FreeDynamicLib: Not implemented for '//TRIM(OS_Desc)
   
   
!#if 0   
!bjj: note that this is not tested.
   INTERFACE !linux API routine
      !bjj see http://linux.die.net/man/3/dlopen

      FUNCTION dlClose(handle) BIND(C,NAME="dlclose")
      ! int dlclose(void *handle);
         USE ISO_C_BINDING
         IMPLICIT NONE
         INTEGER(C_INT)       :: dlClose
         TYPE(C_PTR), VALUE   :: handle
      END FUNCTION

   END INTERFACE



      ! Close the library:

   Success = dlClose( DLL%FileAddrX ) !The function dlclose() returns 0 on success, and nonzero on error.

   IF ( Success /= TRUE ) THEN !bjj: note that this is not the same as LOGICAL .TRUE.
      ErrStat = ErrID_Fatal
      ErrMsg  = 'The dynamic library could not be freed.'
      RETURN
   ELSE
      ErrStat = ErrID_None
      ErrMsg = ''
   END IF
!#endif
   
   RETURN
END SUBROUTINE FreeDynamicLib
!==================================================================================================================================


END MODULE SysSubs

Dear all,

I have been diving a while in to the makefiles of FAST v8.10.00a-bjj and MAP++ and finally I finished the compilation of FAST with MAP++ (1.10.0rc, 10-March-2015) on a Ubuntu 14.04 64bits

I had to download the MAP++ source files and compile them in order to get the MAP.so file being asked by FAST compilation.
When compiling MAP++ i got an error with “llapacke” it turned to be a lapack family library, named “liblapacke” and “liblapacke-dev” that I installed through synaptic.
After that the compilation of MAP++ ended perfectly and a file called “libmap-1.10.00.so” was created in the “src” folder within MAP++.

Then I copied that file to the MAP folder in “…/FAST/FAST_v8.10.00a-bjj/Source/dependencies/MAP” and renamed it to MAP.so
I went back to the terminal and tried to compile again FAST by executing the command “make” and it worked.

I am running the Certification Tests now, everything seems to end correctly except for the offshore ones, I understood from Bonnie Jonkman that there is a solution to it.

Could someone elaborate how to correct a given installation? Is just about recompiling with some new ServoDyn and TMD??

Thanks in advance and thank you to Bonnie Jonkman and Jean Marc for your clarifications!

Best regards.

Hi, Borja.

To clarify, I found a solution for the issue with ServoDyn/TMD in gfortran. This issue was also present in HydroDyn in gfortran; however that hasn’t yet solved all of the issues with running the offshore cases with gfortran. We’re getting closer, but not yet there. (I’m hoping to find time to look at this issue closer in September.)

Hello ,

I have been trying for long to install FAST in Linux cluster. But failed. Now I am trying to install it in my laptop in Linux environment. I have experienced almost all the errors you have mentioned in the forum and solved them accordingly. e.g lapacke installation. But it is still showing some errors.
Here is what I did,

  1. Downloaded and extracted FAST_v_8 packages in Ubuntu.
  2. Went to user\FAST_v8.10.00a-bjj\Source\dependencies\Registry => make => created registry.exe file at Source
  3. installed lapacke and libblas from synaptic as you discussed in the forum
  4. Went to user\FAST_v8.10.00a-bjj\Source\dependencies\MAP => make => still showing error. (/usr/bin/ld: can not find … type error). I did not make any change in the SysGnuLinux.f90 file

Any response will be highly appreciated .

We don’t distribute a makefile in the Source\dependencies\MAP folder, so if you added source code there, I cannot help. If you didn’t add code/makefile there, that is likely the source of the errors.

I assume you are trying to compile the MAP.so file; if so, you will have to download the code from the MAP++ web site and compile it for Linux. There should be a makefile in the MAP archive’s src folder.

Dear all,
Has anyone successfully built FAST v8 using Intel compilers in Linux?
The problem is what appears to be a GNU specific library calls, i.e., it is the build fails when trying to compile SysGnuLinux.f90 - see below.

johnston@rayleigh:~/FAST_INTEL/Compiling$ make
ifort -I Obj_lin64 -O2 -m64 -fpp -real-size 64 -mkl=sequential -c …/Source/dependencies/NWTC_Library/SysGnuLinux.f90 -o Obj_lin64/SysGnuLinux.obj -module Obj_lin64
…/Source/dependencies/NWTC_Library/SysGnuLinux.f90(118): error #6404: This name does not have a type, and must have an explicit type. [FSTAT]
Status = FSTAT( INT( Unit, B4Ki ), StatArray )
------------^
…/Source/dependencies/NWTC_Library/SysGnuLinux.f90(165): error #6404: This name does not have a type, and must have an explicit type. [GETCWD]
Status = GETCWD ( DirName )
------------^
compilation aborted for …/Source/dependencies/NWTC_Library/SysGnuLinux.f90 (code 1)
make: *** [SysGnuLinux.obj] Error 1

 Any advice would be appreciated.

Best,
Shujian

[b]Dear all,

I have some problem to discuss.
I’m currently using Intel(R) Visual Fortran Composer XE 2013 SP1 Update 2 Integration for Microsoft Visual Studio* 2013, 14.0.0086.12.
When I compile the FAST v8.10a-bjj using IVF for Windows®, I find the following 24 warnings :[/b]


Error occurred while restoring NuGet packages: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetDirectoryName(String path)
at NuGet.VisualStudio.VsUtility.GetNuGetSolutionFolder(Solution solution)
at NuGet.VsEvents.PackageRestorer.UsingOldPackageRestore(Solution solution)
at NuGet.VsEvents.PackageRestorer.BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action).
1>------ Build started: Project: FAST_Project, Configuration: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler XE 14.0.2.176 [IA-32]…
1>slasrt2.f
1>dlasrt2.f
1>qsort_c_module.f90
1>SingPrec.f90
1>RANLUX.f90
1>NWTC_Base.f90
1>NWTC_ScaLAPACK.f90
1>NWTC_LAPACK.f90
1>SysIVF.f90
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(215): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(228): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(241): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(254): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(267): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(280): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(301): warning #7410: Fortran 2003 does not allow this keyword. [CARRIAGECONTROL]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(342): warning #7410: Fortran 2003 does not allow this keyword. [CONVERT]
1>E:\01_FAST-windows\Source\dependencies\NWTC_Library\SysIVF.f90(369): warning #7416: Fortran 2003 does not allow this intrinsic procedure. [EXIT]
1>NWTC_Library_Types.f90
1>NWTC_IO.f90
1>NWTC_Num.f90
1>iceLog.F90
1>iceInput.f90
1>ModMesh_Types.f90
1>ModMesh.f90
1>ModMesh_Mapping.f90
1>NWTC_Library.f90
1>Waves2_Types.f90
1>Current_Types.f90
1>Lidar_Types.f90
1>IfW_FFWind_Types.f90
1>SubDyn_Types.f90
1>SS_Radiation_Types.f90
1>Morison_Types.f90
1>MAP_Types.f90
1>Conv_Radiation_Types.f90
1>SS_Radiation.f90
1>MAP.f90
1>Current.f90
1>TMD_Types.f90
1>WAMIT_Interp.f90
1>WAMIT2_Types.f90
1>IfW_HHWind_Types.f90
1>ElastoDyn_Types.f90
1>SD_FEM.f90
1>FEAMooring_Types.f90
1>IceDyn_Types.f90
1>Waves_Types.f90
1>TMD.f90
1>E:\01_FAST-windows\Source\dependencies\ServoDyn\TMD.f90(56): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [INITOUT]
1>NWTC_FFTPACK.f90
1>IfW_FFWind.f90
1>WAMIT2_Output.f90
1>ServoDyn_Types.f90
1>MoorDyn_Types.f90
1>IceFloe_Types.f90
1>Waves2_Output.f90
1>IceFloeBase.F90
1>Waves.f90
1>BladedInterface.f90
1>InflowWind_Types.f90
1>crushingISO.F90
1>SubDyn_Output.f90
1>randomCrushing.F90
1>IceDyn.f90
1>WAMIT_Types.f90
1>MoorDyn_IO.f90
1>crushingIEC.F90
1>Morison_Output.f90
1>ElastoDyn.f90
1>SubDyn.f90
1>FEAM.f90
1>lockInISO.F90
1>Conv_Radiation.f90
1>HydroDyn_Types.f90
1>IfW_HHWind.f90
1>MoorDyn.f90
1>E:\01_FAST-windows\Source\dependencies\MoorDyn\MoorDyn.f90(42): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD]
1>E:\01_FAST-windows\Source\dependencies\MoorDyn\MoorDyn.f90(42): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z]
1>coupledCrushing.F90
1>Morison.f90
1>DWM_Types.f90
1>intermittentCrushing.F90
1>HydroDyn_Output.f90
1>ServoDyn.f90
1>WAMIT2.f90
1>Waves2.f90
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\Waves2.f90(95): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [U]
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\Waves2.f90(95): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value.
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\Waves2.f90(95): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD]
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\Waves2.f90(95): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z]
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\Waves2.f90(95): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [OTHERSTATE]
1>IceFlexBase.F90
1>InflowWind_Subs.f90
1>WAMIT_Output.f90
1>IceFlexISO.f90
1>AeroDyn_Types.f90
1>IceFlexIEC.f90
1>HydroDyn_Input.f90
1>GenSubs.f90
1>Lidar.f90
1>WAMIT.f90
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\WAMIT.f90(1589): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT]
1>FAST_Types.f90
1>HydroDyn.f90
1>E:\01_FAST-windows\Source\dependencies\HydroDyn\HydroDyn.f90(1501): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT]
1>InflowWind.f90
1>IceFloe.f90
1>E:\01_FAST-windows\Source\dependencies\IceFloe\IceFloe.f90(80): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD]
1>E:\01_FAST-windows\Source\dependencies\IceFloe\IceFloe.f90(80): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z]
1>E:\01_FAST-windows\Source\dependencies\IceFloe\IceFloe.f90(80): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [OTHERSTATE]
1>DWM_Wake_Sub_ver2.f90
1>FAST_Mods.f90
1>AeroSubs.f90
1>DWM.f90
1>AeroDyn.f90
1>E:\01_FAST-windows\Source\dependencies\AeroDyn\AeroDyn.f90(1301): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT]
1>E:\01_FAST-windows\Source\dependencies\AeroDyn\AeroDyn.f90(1358): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z_RESIDUAL]
1>FAST_Subs.f90
1>PitchCntrl_ACH.f90
1>fftpack4.1.f
1>UserVSCont_KP.f90
1>UserSubs.f90
1>FAST_Prog.f90
1>Linking…
1>Embedding manifest…
1>
1>Build log written to “file://E:\01_FAST-windows\Compiling\VisualStudio\Debug\BuildLog.htm”
1>FAST_Project - 0 error(s), 24 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


[b]I don’t know how to solve this warnings and it confuses me for a long time.
I would really appreciate any help regrding this!

Thanks a lot in advance for any suggestions.[/b]

SeongOh,

Your build succeeded, so I am not sure what your question is. There are a couple of warnings, which are normal. I have never seen the errors about NuGet packages, but that looks like an issue with Visual Studio, which occur before building the FAST project. The build should have created an executable in the FAST8\bin directory.

Shujian,

Yes, people have successfully built FAST v8 in Linux. I think the problem you are having is that you are using Intel Fortran with the Sys library built for gfortran on Linux. I’d suggest using SysIFL.f90 (Intel Fortran Linux) instead of SysGnuLinux.f90. Alternatively, you can modify SysGnuLinux and the makefile as described by JeanMarc.Cherfils here on May 5: Precone angle in WTPERF

Thanks Bonnie, we finally got things work!

Dear all,
I am using Microsoft Visual studio 2013 and Intel parallel studio 2015
When I try to compile Fast, it seems that the project cannot be build.
In particular, I recieve the following 25 Warnings and 1 Error:

Warning 1 FAST_Project: warning: TargetPath(C:\Users\Giorgos\Documents\Programmes\FAST\bin\FAST_Project.exe) does not match the Linker’s OutputFile property value (C:\Users\Giorgos\Documents\Programmes\FAST\bin\FAST_dev_Debug_Win32.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
Warning 2 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 215
Warning 3 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 228
Warning 4 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [ERF] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 241
Warning 5 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 254
Warning 6 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 267
Warning 7 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [GAMMA] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 280
Warning 8 warning #7410: Fortran 2003 does not allow this keyword. [CARRIAGECONTROL] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 301
Warning 9 warning #7410: Fortran 2003 does not allow this keyword. [CONVERT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 342
Warning 10 warning #7416: Fortran 2003 does not allow this intrinsic procedure. [EXIT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\NWTC_Library\SysIVF.f90 369
Warning 11 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [U] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\Waves2.f90 95
Warning 12 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\Waves2.f90 95
Warning 13 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\Waves2.f90 95
Warning 14 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\Waves2.f90 95
Warning 15 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [OTHERSTATE] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\Waves2.f90 95
Warning 16 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\MoorDyn\MoorDyn.f90 42
Warning 17 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\MoorDyn\MoorDyn.f90 42
Warning 18 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [INITOUT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\ServoDyn\TMD.f90 56
Warning 19 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\WAMIT.f90 1589
Warning 20 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\HydroDyn\HydroDyn.f90 1501
Warning 21 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [XD] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\IceFloe\IceFloe.f90 80
Warning 22 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\IceFloe\IceFloe.f90 80
Warning 23 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [OTHERSTATE] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\IceFloe\IceFloe.f90 80
Warning 24 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [DXDT] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\AeroDyn\AeroDyn.f90 1301
Warning 25 warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [Z_RESIDUAL] C:\Users\Giorgos\Documents\Programmes\FAST\Source\dependencies\AeroDyn\AeroDyn.f90 1358
Error 26 general error c101008d: Failed to write the updated manifest to the resource of file “C:\Users\Giorgos\Documents\Programmes\FAST\bin\FAST_Project.exe”. The system cannot find the file specified. mt.exe

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

However, an executable file C:\Users\Giorgos\Documents\Programmes\FAST\bin\FAST_dev_Debug_Win32.exe has been created
I would higly appreciate it if I could recieve some help!

Thank you in advance
Georgios Papathanasiou
Msc Student Ship and Offshore Structures
The University of Strathclyde