Anyone know me some FORTRAN 95???

I’m currently learning FORTRAN 95 with Sun Studio (as a hobby) and I’m trying to learn the basics from online tutorials before I buy any books.

Anyone here with any decent knowledge of F95 to help me with a little programming?

I can’t get this to work:

program age implicit none integer :: a print*,'Please type in your age ' read (*,*) a print*,'Your age is ', a if (a.lt.0) then print*,'Your age cannot be negative!' end if end program age

It’s really basic I know, I only just started yesterday and I managed to get a few small programs up and running. But I don’t know what I did wrong here, and the debugger doesn’t seem to give me any clues on this :frowning:

who needs this?
better learn Malbolge

I’m doing this out of interest, it’s a hobby not my job.

FORTRAN is still heavily used in the scientific community and for super computers.

I got this to work:

program xtest implicit none integer::i,j,k integer::x print*,'Enter three integers ' read(*,*)i,j,k x=i*j*k print*, i, 'times ', j , 'times ', k, 'is ', x if(x.LT.0)then print*,'The result is negative.' end if end program xtest

Comparing the two I can’t find any syntax errors.

do spaces matter?

https://en.wikipedia.org/wiki/Brainfuck

Nope

I know 4chan, never heard of 4tran…

FORTRAN

BTW, nice avatar :stuck_out_tongue:

Good luck mate, I feel your pain. I managed to convince my supervisor everything would be much better if we used MATLAB.

Ok, lets see if I remember correctly:

FORTRAN assigns variables in a predefined way, meaning:

Implicitely I,J,K,L,M,N (I just killed Lemmings …) are INT, the rest is REAL, as a standard.

So if you use the “implicit” type instruction you can redefine these standards, but as the code says “implicit none” he keeps using the standart assign-structure. Meaning “integer :: a” confuses him, because he has it also as real. Try changing “a” to I,J,K,L,M,N ,
or change the “implicit none” to “implicit INT (a)”.

Hope it works, been a long time (that was the way it worked on FORT 77)

I’ll try later (I’m using Sun Studio on OpenSolaris within VMware), but I don’t think it’ll work. If you don’t use implicit none then it’ll indeed assume that any variable beginning with the letter I through N is an integer, but using implicit none and declare your variable an integer than it shouldn’t have a problem.

Implicit none means that it isn’t implied that variables I-N are integer and thus you’re forced to declare each variable.

I’ll definitely try this later, I’ll let you know if it works.

:fffuuu: Yeah, you are right “implicit none” deactivates the implicitness.

WAIT a sec. “.LT.” was a command from Fort 77, are you sure it is not “>”, “<” on 90/95? Other than that : no idea.

Good luck with this one, but being able to master one of the 3GLs always looks good on a resumee.

No because I successfully used the .lt. in the other program without problems. I’ll try some things out, see if I can get it working. Thanks for the help so far :stuck_out_tongue:

I’ve found a good book but it’s a bit expensive but I guess I really need it.

EDIT: Just ordered this book:
Fortran 95/2003 for Scientists and Engineers
It’s got good reviews and I’ve always liked the McGraw-Hill books, so hopefully this’ll help me on my way :slight_smile:

The code you posted compiles and runs just fine for me.

The first one too? Because the second one compiles fine for me. I just put it up for comparison.

This is the code that doesn’t work for me:

program age implicit none integer :: a print*,'Please type in your age ' read (*,*) a print*,'Your age is ', a if (a.lt.0) then print*,'Your age cannot be negative!' end if end program age

If it does work for you, which compiler are you using? And with what extension?

I’m compiling with gfortran.

And the first program (called age) works?

Well it’s possible, not every compiler implements everything the same. But I don’t know what I did wrong here, syntax-wise I haven’t used anything I didn’t use in the first program that did work.

Yes, the first code you posted compiles and runs fine. I just copied and pasted your code into an ‘age.f95’, compiled it with no special flags or anything, and it worked with no hitches.

Strange, I must use this gfortran compiler under NetBeans someday.

EDIT: I got it to work :slight_smile:

Founded in 2004, Leakfree.org became one of the first online communities dedicated to Valve’s Source engine development. It is more famously known for the formation of Black Mesa: Source under the 'Leakfree Modification Team' handle in September 2004.