I ported the classic ASCII Donut to Fortran

Thanks for taking time to go through the code and the feedback!

I will try to rename variables and make them more readable.

Thanks, I will do that.

I will change the character declaration. I have a question, what is the exact motive of using (len=12) or (kind = 8) instead of *8. Is it better readability? Or something else?

If there’s any best practices guide in the forum, a link to that would be helpful.

1 Like

The Fortran-lang best practices guide is here.

2 Likes

That is my style too, but with the OP’s method you can declare several character variables of different lengths in one line, for example

character :: a*5, c*3

Maybe if you have several character variables of the same length you should write

character (len=3) :: a, c

but if you have a single character variable to declare, both methods are fine.

1 Like

Yeah, that’s what I do.

Like real*8,allocatable::a(:),b(:,:). I am wondering if it has any changes than code. Like if I have a single variable, is one better than another?

Well, the form “real*8” is a common extension to the language that has superseded by the kind specification. That is much more flexible and well-defined. For instance: switching from single to double precision can be achieved with:

real(kind=wp) :: a   ! Set wp to the right kind number via:  integer, parameter :: wp = kind(1.0d0) or the like

Combining variables like a(:) and b(:,:) in one statement or separating them is merely syntax.

– I fixed the formatting so that smileys do not show instead of code. Ondrej

2 Likes

Nice work Bro

1 Like