Community
cancel
Showing results for 
Search instead for 
Did you mean: 
utab
Beginner
106 Views

mixing fortran77 and fortran95 interfaces

Jump to solution

Dear all,

I programmed my code with the fortran 77 interfaces. However I was wondering if that is possible to mix fortran77 and fortran95 routines. For instance, looking at the sparse blas level 2 routine, mkl_dcsrmv, it is not explicitly stated that it has a fortran77 and fortran95 interface. It is only mentioned that it has a Fortran interface.

If this is possible how can I do this? Which modules should be used without conflicting?

Best regards,

Umut

0 Kudos
1 Solution
mecej4
Black Belt
106 Views

Then what I understood from above there should be some equivalent 77 versions as well, am I correct?

No. Consider, for example, the file mkl_lapack.fi. Inspection of the source file, which is in the mkl/include directory, shows that it is in fixed format. Therefore, one can create a fixed format source file, say, "lapacki.f", containing the following:

C source code for building module
      module lapack
      include 'mkl_lapack.fi'
      end module

After compiling this file, one can say "USE LAPACK" in free format source code as well as fixed format source code.

View solution in original post

3 Replies
mecej4
Black Belt
106 Views

What you call "F77 interfaces" and "F95 interfaces" differ only in that the former use fixed source format. Both produce, after compilation, identical module files, which can be USEd in either free or fixed source code. It is even possible to switch between fixed and free format in a single source file using directives, but that is non-portable and is not recommended. 

Instead of using interface declarations by including *.fi files, it is better to use the compiler to build the *.mod files from these include files, and USE the modules in your source code. Doing so makes it unnecessary to recompile the voluminous source code in the *.fi files in every project where they are needed.

utab
Beginner
106 Views

mecej4 wrote:

Instead of using interface declarations by including *.fi files, it is better to use the compiler to build the *.mod files from these include files, and USE the modules in your source code. Doing so makes it unnecessary to recompile the voluminous source code in the *.fi files in every project where they are needed.

Ok, then if I am using the fortran95 inteface with USEs, for instance,

use mkl_service
use mkl95_precision
use mkl95_blas

Then what I understood from above there should be some equivalent 77 versions as well, am I correct?

if yes, where can I find them? To use the 77 versions, I was always including the 'mkl.fi' files, however, now I understood from the above explanation that compiling into mod files is also possible. I am learning fortran recently with a fast pace coming from a programming experience in C/C++.

 

mecej4
Black Belt
107 Views

Then what I understood from above there should be some equivalent 77 versions as well, am I correct?

No. Consider, for example, the file mkl_lapack.fi. Inspection of the source file, which is in the mkl/include directory, shows that it is in fixed format. Therefore, one can create a fixed format source file, say, "lapacki.f", containing the following:

C source code for building module
      module lapack
      include 'mkl_lapack.fi'
      end module

After compiling this file, one can say "USE LAPACK" in free format source code as well as fixed format source code.

View solution in original post

Reply