Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26753 Discussions

Compiling Calculix with Visual Studio and ifort

habermann__richard
207 Views

Hello,

I am trying to build Calculix (for example here: https://github.com/prool/ccx_prool/tree/master/CalculiX/ccx_2.15/src) in Visual Studio 2015 with Intel Fortran. Normally it is built with gcc and gfortran. It mixes C and Fortran, and I am having troubles now with arrays dynamically allocated in C because in Fortran ifort expects a dimension.

subroutine calinput(kon)
implicit none 
integer(C_LONG_LONG) kon(*) 

But this is working:

      subroutine calinput_c(kon, kons) bind(C)
      USE, INTRINSIC :: ISO_C_BINDING
!
      implicit none
!
      integer(C_LONG_LONG) kons
      integer(C_LONG_LONG), DIMENSION(kons) ::kon

      kon(1) = kon(1)
      return
      end

Is there a way to get the first variant to compile with ifort?

There was some work done previously to compile calculix, can I get the files?

https://software.intel.com/en-us/forums/intel-c-compiler/topic/536919

Thank you in advance!

0 Kudos
3 Replies
Steve_Lionel
Black Belt Retired Employee
207 Views

You don't say what isn't working in the first case. I am going to assume that your original code included "USE, INTRINSIC :: ISO_C_BINDING" as otherwise C_LONG_LONG would not be declared.

I will guess that one problem is that the C code assumes that the Fortran routine is named "callinput" in lowercase. Intel Fortran on Windows uses upper case for routine names, but gfortran does not. The addition of BIND(C) causes Intel Fortran to use lower case.

If neither of these are the problem, please provide more details, as the use of an assumed size array should work. The second code of course is also fine.

habermann__richard
207 Views

Oh, ok. This does work!

I think I mixed up the binding, thank you!

Marine__James
Beginner
207 Views

Hi Rechard, i am also working to compile CCX using Visual Studio and ifort, if you don't mind, may i ask whether you could share the VS projects with me? my email: tjumsl@outlook.com

Reply