INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

gfortran undefined reference error

gfortran undefined reference error

(OP)
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 ?

RE: gfortran undefined reference error

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) 

RE: gfortran undefined reference error

(OP)
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.

RE: gfortran undefined reference error

(OP)
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

RE: gfortran undefined reference error

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close