Fortran [Fortran] Problem with subroutine

AI Thread Summary
The discussion revolves around an error encountered while running a program that includes multiple subroutines. The specific error message indicates an "undefined reference" to the subroutine `readin_` in the file `getg0.f`. The subroutine `readin` is responsible for reading constants from an input file, which are then used in calculations within `getg0.f`. The user notes that when inputs are manually entered, the program runs without issues, suggesting that the problem arises specifically when reading from the input file. Despite checking for spelling errors, the user remains uncertain about the source of the issue. Other participants in the discussion emphasize the importance of examining the `getg0.f` file for potential problems and suggest verifying the linking process, as the error may stem from how the subroutine is referenced or compiled.
selmayda
Messages
9
Reaction score
0
Hello everyone ;

I have tried to run a program which has many subrotines so I control each of them.But, when I run one of them, the below error message is seen;

/tmp/ccMqKR9L.o: In function `MAIN__':
getg0.f:(.text+0x73c): undefined reference to `readin_'
collect2: ld returned 1 exit status

subroutine readin is used to read some constant from an infile (5,*) . the other subroutine getg0.f use some constants from infile to calculate g.For example;
in getg0:
do 346 id = 1,Nd

mi(id) = 1.d0 / ( dexp ( ( Ed(id) / 2.d0 ) / T ) + 1.d0 )

346 continue

and Ed(id) values are readin from infile via readin.f.

readin.f
read(5,*) UU(1), UU(2), UU(3), UU(4), UU(5)
read(5,*) Ed(1), Ed(2), Ed(3), Ed(4), Ed(5)

infile
1.d0, 2.d0, 3.d0, 4.d0, 1d0
-7.24068, -5.32445, -6.63223, -6.40883, -7.66001

readin following
UU(1), UU(2), UU(3), UU(4), UU(5)
Ed(1), Ed(2), Ed(3), Ed(4), Ed(5)

can everyone help me about this error?

Thanks a lot
 
Last edited:
Technology news on Phys.org
The error you show indicates that there's a problem in getg0.f, so show us the code in that file.
 
Does the undefined reference error occur at link time or at load / run time (dynamic linking)? Any chance you misspelled readin (with an I) as readln (with an L) (or vice versa)?
 
actually, when I write inputs by hand, there is no problem.However, when readin is read inputs from infile, the error message is seen so I think it is not related to getg0.

I control spelling and there is no problem.
 
selmayda said:
/tmp/ccMqKR9L.o: In function `MAIN__':
getg0.f:(.text+0x73c): undefined reference to `readin_'
collect2: ld returned 1 exit status
The error message says that you have an undefined reference in getg0.f, so it seems reasonable to look there for a problem.

Please show us the code you have in getg0.f.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
4
Views
2K
Replies
59
Views
11K
Replies
8
Views
4K
Replies
5
Views
8K
Replies
2
Views
2K
Replies
4
Views
2K
Replies
54
Views
5K
Replies
7
Views
2K
Replies
20
Views
2K
Replies
6
Views
3K
Back
Top