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

Compiling Calculix with Visual Studio and ifort

habermann__richard
1,030 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
Honored Contributor III
1,030 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.

0 Kudos
habermann__richard
1,030 Views

Oh, ok. This does work!

I think I mixed up the binding, thank you!

0 Kudos
Marine__James
Beginner
1,030 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

0 Kudos
Reply