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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

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