Greetings,
I am in the process of setting up openFAST on a Linux based cluster, and I am facing some problems in trying to compile the DISCON.F90 file using gfortran for Linux. I am using gcc version 4.9.3.
In the terminal, I navigate to the location of the DISCON.F90 source file, and then I type -
gfortran DISCON.F90 -o DISCON.dll , but I get the following error :
DISCON.F90:18:0: warning: \u2018dllexport\u2019 attribute directive ignored [-Wattributes]
SUBROUTINE DISCON ( avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG ) BIND (C, NAME=‘DISCON’)
^
/lib/…/lib64/crt1.o: In function _start': (.text+0x20): undefined reference to
main’
collect2: error: ld returned 1 exit status
Apologies if this has already been asked before, I was not able to find it.
I would be very grateful for help in this matter. Thanks in advance.
Best regards,
Vishal
You need to tell it to build a shared library, otherwise it thinks it is a standalone executable that needs a main() routine. Try
gfortran DISCON.F90 -shared -DIMPLICIT_DLLEXPORT -o DISCON.dll
(Or maybe you want a different file extension for linux?)
Alternatively, the DLLs can be built using cmake. See github.com/openfast/r-test#note … line-cases
1 Like
Dear Bonnie,
Thank you, that fixed the problem!
Best regards,
Vishal
Dear NREL team,
I use OpenFAST in linux environment and compile the DISCON.f90 using the CMakeLists.txt & “cmake” (from the build directory) without any problem.
For a project, we needed to make changes / extentions in DISCON.f90 , therefore we have some additional files containing some new subroutines, which are called from within the DISCON.f90. E.g. read.f90 contains SUBROUTINE Read_input( …) to avoid hard-coding the control parameters, but to read from file.
In order to compile them together and create the DISCON.dll, I assume I need to make changes in the CMakeLists.txt.
Do you have any tips how to fix that ? Thanks in advance.
Hi @Salur.Basbug,
You do need to add the new file to the corresponding CMakeLists. Assuming you used the DISCON project from the r-test repository, you should add your new file at line 64 of that CMake Lists. However, I would change that section from:
set(SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/DISCON.F90")
file(TO_CMAKE_PATH ${SOURCE_PATH} SOURCE_PATH)
to this more common form:
set(SOURCE_PATH
"${CMAKE_CURRENT_LIST_DIR}/DISCON.F90"
"${CMAKE_CURRENT_LIST_DIR}/your_file.F90"
)
Also, you may want to check out ROSCO. They’ve expanded on the DISCON controller in the OpenFAST r-test repo and added functionality to provide parameters through an input file.
1 Like
Thanks a lot Rafael,
It worked for me with the way they did in ROSCO. it means that I set the source code path like:
set(SOURCES
src/discon_10.f90
src/Read_DISCON_input.f
…
)
1 Like
Perfect - well done and thanks for sharing.
1 Like