Fortran Undefined Reference Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more
Fortran Undefined Reference To Main
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users gfortran collect2: error: ld returned 1 exit status Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping undefined reference to fortran 77 each other. Join them; it only takes a minute: Sign up Fortran compilation error - undefined reference up vote 3 down vote favorite 2 I am trying to compile a fortran program which uses a bunch of modules.
Fortran Undefined Reference To Mod
I obtain an error when I compile it, and it's driving me crazy. The error is originated by the addition of one subroutine and takes place when I try to recompile the program: Main program contains these two lines: -- call read_step(nStepOne,molOne) call read_step(nStep,mol) -- This is calling one of the subroutines in a file "fileio.f90": -- subroutine read_step(n,tape) implicit none integer, intent(in) :: tape integer, intent(out) :: n character(len=6) :: dum rewind(tape) read (tape,*) read (tape,*)
Fortran Use Module
dum, n rewind(tape) return ! end subroutine read_step -- When I try to compile it, the following error arises: ifort -o SpIdMD.x *.o -static-intel -openmp SpIdMD.o: In function `MAIN__': SpIdMD.f90:(.text+0x3b2): undefined reference to `read_step_' SpIdMD.f90:(.text+0x3c5): undefined reference to `read_step_' make: *** [SpIdMD.x] Error 1 Other calls to subroutines in the same module did not give any error, and I just don't see any difference between the calls to the "old subroutines" and the one I just created. An example of one of these "old subroutines", which does not give any complaint, is: In the main program: call get_dim(n_atom,nSnap,mol) In the fileio.f90: subroutine get_dim(n,n_snap,tape) implicit none integer,intent(in) :: tape integer,intent(out) :: n, n_snap integer :: m rewind(tape) read (tape,*,err=1,end=2) n rewind(tape) m = 0 do while (.true.) read (tape,*,err=1,end=3) m = m +1 end do 3 n_snap = m/(n + 2) if (m.ne.(n_snap*(n + 2))) stop 'unexpected end of input file' rewind(tape) return ! 1 stop 'error in input file' 2 stop 'unexpected end of input file' end subroutine get_dim I have absolutely no idea why this behavior. I'd be grateful if anybody could help me solve this nightmare. Thanks! fortran share|improve this question asked Apr 18 '13 at 16:53 user2296052 18113 1 Have you run make clean and then tried make again ? –High Performance Mark Apr 18 '13 at 18:28 Yep, but doesn't solve any
here for a quick overview of the site Help Center Detailed answers to any questions you might have fortran use statement Meta Discuss the workings and policies of this site About Us
Compile Fortran
Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with fortran interface us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just http://stackoverflow.com/questions/16088892/fortran-compilation-error-undefined-reference like you, helping each other. Join them; it only takes a minute: Sign up Linking fortran module: “undefined reference” up vote 2 down vote favorite 1 I'm trying to write some functions/subroutines in a module that call another function in the same module and running into linker errors. A toy example displaying the same behavior: !in http://stackoverflow.com/questions/11512897/linking-fortran-module-undefined-reference test.f module m1 implicit none contains real function mult(a, b) real :: a real :: b mult = a * b return end function mult real function sq(a) real :: a, mult sq = mult(a, a) return end function sq end module m1 program main use m1 write(*,*) sq(2.0) end program When I try to compile this, I run into trouble: [christopher@archlinux metropolis]$ gfortran -ffree-form test.f /tmp/ccpzdTLE.o: In function `__m1_MOD_sq': test.f:(.text+0x20): undefined reference to `mult_' collect2: error: ld returned 1 exit status On the other hand, compiling only (gfortran -c -ffree-form test.f -Wall) runs with no complaint. Now this looks for all the world like a compiler error---in the module it comes up with a reference to mult_ when it really ought to com up with __m1_MOD_sq---but I have a very hard time believing that this is a compiler bug rather than me doing something stupid. DDG didn't turn up anything useful. Most of the similar problems ocurred in splitting the module off from one main f
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC https://ubuntuforums.org/showthread.php?t=2107170 Support AskUbuntu Official Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Can't link compiled fortran files together Having an Issue With Posting ? Do you want to help us undefined reference debug the posting issues ? < is the place to report it, thanks ! Page 1 of 3 123 Last Jump to page: Results 1 to 10 of 25 Thread: Can't link compiled fortran files together Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode January 21st, 2013 #1 msgeo View Profile View Forum Posts Private fortran undefined reference Message Spilled the Beans Join Date Jan 2013 Beans 13 Can't link compiled fortran files together hi! I'm new to Ubuntu and working on a Fortran based program! got some errors and I'm sure I'll find my answer here... so...here is the problem: I have some .f files that needed to be compiled and then linked together and create a single file. I installed gfortran on my Ubuntu and compiled .f files using Code: gfortran -c filename.f files compiled successfully with some warnings that aren't important! now I need to link them together using Code: gfortran -o file1.o file2.o file3.o -o outputfilename but I get this error: Code: lateralf.o: In function `MAIN__': lateralf.f:(.text+0x6733b): undefined reference to `time_' lateralf.f:(.text+0x72abb): undefined reference to `time_' collect2: error: ld returned 1 exit status what should i do? thanks.... Adv Reply January 21st, 2013 #2 bouncingwilf View Profile View Forum Posts Private Message Frothy Coffee! Join Date May 2010 Location SE England Beans 210 Re: Can't link compiled fortran files together Not sure where time is defined or if it is an intrinsic but it looks as though you may need to add the appropriate library to the linker line i.e. append -llibrary_