Errors when getting started with simple fortran program
juanfariaso opened this issue · 7 comments
Dear LadaF,
I am trying to use the library, however I fail to compile a very simple program following the usage_Fortran.txt directions.
I am compiling using this command:
gcc -IPoisFFT/bin/gcc -LPoisFFT/lib/gcc -lpoisfft testPoisFFT.f90
But I get the error:
testPoisFFT.f90:33:9:
Solver = PoisFFT_Solver3D([nx,ny,nz],[1.0,1.0,1.0],[(PoisFFT_Periodic, i = 1,6)])
1
Error: No initializer for component ‘nxyz’ given in the structure constructor at (1)!
testPoisFFT.f90:35:32:
call Execute(Solver, Phi, srhod)
1
Error: There is no specific subroutine for the generic ‘execute’ at (1)
I have compiled the dynamic and static libraries, and the tests runs fine.
I bet I am missing something very basic, I am very new on linking libraries.
Thanks!
Hi, thanks for the quick reply.
i am bassically trying to make this to work:
PROGRAM testfftpoisson
use PoisFFT, PoisFFT_Solver3D => PoisFFT_Solver3D_DP
implicit none
character*20 :: filename
real*8 :: rho(128,128,128),PHI(128,128,128)
integer :: nx,ny,nz,d(3),i
type(PoisFFT_Solver3D) :: Solver
nx = 128
ny = 128
nz = 128
open(200,file=trim(filename),status="old",form="unformatted")
read(200) d
read(200) rho
close(200)
Solver = PoisFFT_Solver3D(d,[1.0D0,1.0D0,1.0D0],[(PoisFFT_Periodic, i = 1,6)])
call Execute(Solver, Phi, rho)
call Finalize(Solver)
END PROGRAM
what I am doing wrong?
EDIT: I updated above for the type declarations
Ok, I solved the errors. It was all about type mismatch as you suggested.
However, I am still getting this error, probably due to linking:
$ gfortran -IPoisFFT/bin/gcc -LPoisFFT/lib/gcc -lpoisfft sample.f90
/tmp/cc1yR3v1.o: In function `MAIN__':
sample.f90:(.text+0x46e): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__new'
sample.f90:(.text+0xce3): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__execute'
sample.f90:(.text+0xcef): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__finalize'
collect2: error: ld returned 1 exit status
I would appreciate if you can point me to the right way of linking this.. thanks!
Hi Vladimir,
Right, I solved that issue with the type declarations, but I am still getting the above error when all variable declarations are correct.
$ gfortran -IPoisFFT/bin/gcc -LPoisFFT/lib/gcc -lpoisfft sample.f90
/tmp/cc1yR3v1.o: In function `MAIN__':
sample.f90:(.text+0x46e): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__new'
sample.f90:(.text+0xce3): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__execute'
sample.f90:(.text+0xcef): undefined reference to `__poisfft_dp_MOD_poisfft_solver3d__finalize'
collect2: error: ld returned 1 exit status
It seems that is not linking properly, but I cant find the way to compile it correctly..
Great!, it compiles now, thank you very much. The order in the libraries was the issue.
The command that worked for me was:
gfortran -IPoisFFT/bin/gcc -LPoisFFT/lib/gcc sample.f90 -lpoisfft -lfftw3 -lfftw3f -lfftw3_omp -lfftw3f_omp
I can write the tool I need now.. thanks for the library it will be very useful!
Juan