Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

ddot function returning single precision result

jpharvey1981
Beginner
335 Views

Hi everyone,

I have the following function in a Fortran project (built in the Visual studio 2010 environment + Intel Compiler XE) that uses one of the MKL library functions (the ddot function that computes a vector-vector dot product):

*******************************************************************************************************************************************************

 function Calculate_Potential_Energy_From_Clusters(nb_clusters,Tetra_Mol_Array,Cluster_Pot_energy_Array)
 use Mod
 integer nb_clusters,n
 double precision Calculate_Potential_Energy_From_Clusters,Tetra_Mol_Array(nb_clusters),Cluster_Pot_energy_Array(nb_clusters)
         
  Calculate_Potential_Energy_From_Clusters=ddot(nb_clusters,Tetra_Mol_Array,1,Cluster_Pot_energy_Array,1)
  ...    
 end

*******************************************************************************************************************************************************

The project is compiled without any error or warning...

However, if I do not specify explicitly the type of the ddot function result, the MKL library return a single precision number (even if I specify the use of ddot, not sdot).

I solved the problem by defining explicitly the type of ddot in my function:

*******************************************************************************************************************************************************

 function Calculate_Potential_Energy_From_Clusters(nb_clusters,Tetra_Mol_Array,Cluster_Pot_energy_Array)
 use Mod
 integer nb_clusters,n
 double precision ddot, Calculate_Potential_Energy_From_Clusters,Tetra_Mol_Array(nb_clusters),Cluster_Pot_energy_Array(nb_clusters)
         
  Calculate_Potential_Energy_From_Clusters=ddot(nb_clusters,Tetra_Mol_Array,1,Cluster_Pot_energy_Array,1)
  ...   
 end

*******************************************************************************************************************************************************

Is it normal that the intel XE compiler assumes that the result of the ddot function is of single precision when ddot function is not explicitly defined as a double precision number (ddot is supposed to return a double precision result)?

 

If so, what should I do to avoid this problem?

 

Thank you very much for your help!

0 Kudos
1 Reply
mecej4
Honored Contributor III
335 Views

JPHarvey wrote:
Is it normal that the intel XE compiler assumes that the result of the ddot function is of single precision when ddot function is not explicitly defined as a double precision number

This behavior is what the Fortran language rules prescribe, and is not specific to the Intel compiler.

Any function that is not an intrinsic function has a type that is given by implicit typing rules. If you had declared IMPLICIT NONE in the subprogram where you invoked DDOT, the compiler would have complained that the variable/function did not have a declared type. In the absence of a type declaration, DDOT is a name beginning with a letter other than I, J, K, L, M, N and, therefore, of type real if IMPLICIT NONE has not been specified.

0 Kudos
Reply