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

Type mismatch

Alessandro
Beginner
751 Views
Hi,
I have a program that can work in single or double precision, depending on the value of the variable kvar which may be sgl or dbl (4 or 8). I have some routines that accept only a specific kind though, and I tried the following:

complex(kind=kvar) G_fft
...
if (kvar.eq.dbl) then
! do nothing
elseif (kvar.eq.sgl) then
call transfer_c(G_fft,dv_Gfft,.true.)
endif

When I try to compile it with kvar set to dbl it gives me the following error:

Error 1 error #6633: The type of the actual argument differs from the type of the dummy argument. [G_FFT] E:\Codice\IterSolver_v14x1\MGM.F90 902

Is there anything I can do?

Alessandro

0 Kudos
4 Replies
Andrew_Smith
Valued Contributor I
751 Views
Quoting - Alessandro
Hi,
I have a program that can work in single or double precision, depending on the value of the variable kvar which may be sgl or dbl (4 or 8). I have some routines that accept only a specific kind though, and I tried the following:

complex(kind=kvar) G_fft
...
if (kvar.eq.dbl) then
! do nothing
elseif (kvar.eq.sgl) then
call transfer_c(G_fft,dv_Gfft,.true.)
endif

When I try to compile it with kvar set to dbl it gives me the following error:

Error 1 error #6633: The type of the actual argument differs from the type of the dummy argument. [G_FFT] E:CodiceIterSolver_v14x1MGM.F90 902

Is there anything I can do?

Alessandro

I dont know what transfer_c does but if it similar to the Fortran transfer function then it would not be suitable. Why not try: dv_Gfft = G_fft
0 Kudos
Alessandro
Beginner
751 Views
Quoting - Andrew Smith
I dont know what transfer_c does but if it similar to the Fortran transfer function then it would not be suitable. Why not try: dv_Gfft = G_fft

It's a wrapper for CUDA, dv_Gfft is more like a struct, and transfer_c deals with the transfer of the data into the variable of the device.
0 Kudos
TimP
Honored Contributor III
751 Views
Quoting - Alessandro

It's a wrapper for CUDA, dv_Gfft is more like a struct, and transfer_c deals with the transfer of the data into the variable of the device.
Then it seems you should make your own function to copy from your version of the struct with non-compliant types to the one required by CUDA. If you were using C, you could depend on prototypes to make implicit conversions of simple variables, but not for a struct.
0 Kudos
tom_p
Beginner
751 Views
If I understand you correctly, the code compiles if kvar ist set to sgl. As the value of kvar has to be known at compile time anyway, the simplest solution seems to be to use conditional compilation:

#ifdef SGLPREC
call transfer_c(G_fft,dv_Gfft,.true.)
#endif

You could define your parameter kvar like this:

#ifdef SGLPREC
integer, parameter :: kvar = sgl
#else
integer, parameter :: kvar = dbl
#endif

To compile the program with single precision:
ifort -fpp -DSGLPREC [...]
and with double precision:
ifort -fpp [...]

0 Kudos
Reply