Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gfortran undefined reference error

Status
Not open for further replies.

zmth

Technical User
Aug 5, 2015
57
PH
integer:: ls1(2,4),mlis(2,4)
lenrec=1
nps=4

write(1,*)"ls1(1,1)",ls1(1,1)
write(1,*)"ls1(1,:)",ls1(1,:)
i=1
do while(ls1(1,i)==lsl(2,i).and.i<nps+1)
i=i+1
enddo
end


First of all it ignores the write statements if omit the do while...
As it is it gives 'undefined reference error to ls1'. Is this a bug in gfortran or what ?
Is there any way to make it work ?
 
It depends on what port 1 is - normally it is the input port. Try changing 1 to *. Either
Code:
write(*,*)"ls1(1,1)",ls1(1,1)
or
Code:
print "ls1(1,1)",ls1(1,1)
 
Ok now i recall the logical comparison can only use a redefined scalar so the following
gives no error.

integer:: ls1(2,4),mlis(2,4)
lenrec=1
nps=4
write(1,*)"ls1(1,1)",ls1(1,1)
write(1,*)"ls1(1,:)",ls1(1,:)
write(1,*)"ls1",ls1,"nps",nps
i1=ls1(1,1) ; i2=ls1(2,1)
i=1
do while(i1==i2.and.i<nps) ; i=i+1 ; i1=ls1(1,i) ; i2=ls1(2,i)
enddo
write(1,*)"i",i
end

BUT why in every write(1,*).... does it refuse to write to the console ?
I find this sometimes also in other programs but then sometimes it DOES write
to the screen. Seems to be no rhyme nor reason. I know can write it to a file
and usually does write the output but NOT always necessarily even in that case.
 
Thanks for the tip. The form

write(*,*)"ls1(1,1)",ls1(1,1)

DID work . Funny though because the write(1,*).... form did in fact write to the screen in most instances of other programs.

The
print "ls1(1,1)",ls1(1,1)
form did not and in fact gave error
Error: Missing leading left parenthesis in format string
 
Sorry - should have been
Code:
print *,"ls1(1,1)", ls1(1,1)
Not sure about using port 1. I haven't used specific port numbers for console I/O since I first used a F77 compiler in 1979.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top