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

numerical recipe rlft3 variable problem

anishtain4
Beginner
1,236 Views
I'm trying to use the numerical recipe of fft for three-dimensional. My subroutine is from F77 and all of my friends are using it with other versions of FORTRAN but when I try to use the example mentioned inside the book I recieve a problem:
"The type of the actual argument differs from the type of the dummy argument"
according to the example of page 524 of numerical recipies in fortran 77 I should define the variables inside the main budy as:
[bash]INTEGER,PARAMETER::N=4
REAL ::DATA(N,N)
COMPLEX ::SPEC(N/2,N),SPEQ(N)
EQUIVALENCE(DATA,SPEC)
.....
call rlft3(DATA,SPEQ,N,N,1,1)


SUBROUTINE rlft3(data,speq,nn1,nn2,nn3,isign)
INTEGER isign,nn1,nn2,nn3
COMPLEX data(nn1/2,nn2,nn3),speq(nn2,nn3)[/bash]
but when I try to compile it it gives me the error I mentioned. I really don't know what to do? when I change the data to complex, returened data don't make any sence.
Can you please help me on this?
I would be glad if I can use a more straighforward FFT subroutine that be free to use for students btw.
0 Kudos
8 Replies
mecej4
Honored Contributor III
1,236 Views
You are using a book that is more than a decade old, which assumes that the Fortran compiler does not check arguments. Your choices are

(i) use compiler switches to ignore mismatched arguments

(ii) use an older F77 compiler

(iii) fix the Numerical Recipes code to make it conform with the Fortran 77 standard.

Gratuitously changing variable types without considering the implications is something to avoid.
0 Kudos
anishtain4
Beginner
1,236 Views
Do you know another free library which has multi-dimensional FFT?
0 Kudos
Steven_L_Intel1
Employee
1,236 Views
The Intel Math Kernel Library, included with the compiler, has FFT routines.
0 Kudos
anishtain4
Beginner
1,236 Views
Somehow I found the solution, when data type of a argument that you want to enter is different with the actual you should use equivalence command. but you should be carefull with that how it manages to share the memory between them.
I have now another question, when I want to use a derived type in an EQUIVALENCE statement i get this error:

Syntax error, found ',' when expecting one of: ( )

code is like:

[bash]TYPE ND     !INFORMATION OF A NODE
  SEQUENCE
        .....
	REAL(8)::U,V       !FLUID VARIABLES
	.....
END TYPE

COMPLEX             ::SPEC(IM/2,JM,3)
TYPE(ND)            ::GN0(IM,JM)

EQUIVALENCE(SPEC(:,:,1),GN0%U)[/bash]

and I don`t understand what is wronge? I used EQUIVALENCE between for a real and a complex variable and that was right. I'm sure the problem is with the derived type but how? I don't know?
0 Kudos
mecej4
Honored Contributor III
1,236 Views
"..when data type of a argument that you want to enter is different with the actual you should use equivalence command"

-- bad decision. You may find that this approach silences the compiler for now, but your future life will become 'more interesting', as they say. Minor comment: EQUIVALENCE is not even an executable statement, let alone a 'command'.

EQUIVALENCE is deprecated and has several restrictions placed on it. In particular, objects being declared equivalent must be variables, array elements or substrings: this restriction excludes array sections and structuree components.

This modification of your code will be acceptable to the compiler. Whether it follows your intentions or not is for you to decide.

[fortran]module bad
INTEGER,PARAMETER :: IM=12,JM=4
TYPE ND
SEQUENCE
REAL(8)::U,V !FLUID VARIABLES
END TYPE
COMPLEX ::SPEC(IM/2,JM,3)
TYPE(ND) ::GN0(IM,JM)
EQUIVALENCE(SPEC(1,1,2),GN0(1,1))
end module bad
[/fortran]
0 Kudos
anishtain4
Beginner
1,236 Views
I can totally understand what you are saying, can you just explain me how is the fft of MKL? should I pay for it or no? and where can I see the data structure of it?
or best of all is that if I know it gives the output like matlab or not?
0 Kudos
anishtain4
Beginner
1,236 Views
I'm trying to use the MKL but I have some problems. I have added the path and library(thought they are there but in case I added them again) when I try to compile I receive an error that the file MKL_DFTI cannot be opened.
BTW when I tried to see how fft of MKL should be used I found this:

https://wiki.hpcc.msu.edu/display/faq/Compiling+and+running+Fortran+MKL+FFT+example

where you still see EQUIVALENCE, is that an old example? or a wronge implementation?
0 Kudos
mecej4
Honored Contributor III
1,236 Views
The source code for building the modules mkldft_type and mkl_dfti is in the .../mkl/include/mkl_dfti.f90 file. Just compile that file and put the resulting modules where the compiler will find them.

As to fourth-party sources of information: you should contact them with your comments and questions about content that they provide.
0 Kudos
Reply