[Fortran] Problem with subroutine

  • Context: Fortran 
  • Thread starter Thread starter selmayda
  • Start date Start date
  • Tags Tags
    Fortran Subroutine
Click For Summary

Discussion Overview

The discussion revolves around an error encountered in a Fortran program involving subroutines. Participants are trying to diagnose an "undefined reference" error related to the subroutine `readin`, which is used to read constants from an input file for calculations in another subroutine, `getg0`. The scope includes technical troubleshooting and code examination.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports an "undefined reference" error related to the `readin` subroutine when running the program, suggesting a potential issue with linking.
  • Another participant requests to see the code in `getg0.f` to further investigate the problem.
  • A third participant inquires whether the error occurs at link time or run time and suggests checking for possible spelling errors in the subroutine name.
  • A participant mentions that the error does not occur when inputs are manually entered, implying that the issue may be related to how `readin` processes the input file.
  • Another participant reiterates that the error message points to an undefined reference in `getg0.f`, suggesting that the issue likely lies there.

Areas of Agreement / Disagreement

Participants generally agree that the error is related to the `getg0.f` file, but there is no consensus on the specific cause of the issue. Some believe it may be a linking problem, while others suggest it could be related to the input handling in `readin`.

Contextual Notes

There are unresolved aspects regarding the exact nature of the error, including whether it is a linking issue or related to the input file format. The discussion does not clarify the content of `getg0.f`, which may be critical for diagnosing the problem.

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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 54 ·
2
Replies
54
Views
5K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K