My Modern Fortran book is now published

You can set custom lower bound also on an assumed-size array:

character(kind=c_char,len=1), intent(out) :: buf(0:*) 

In Fortran arrays are abstract and have bounds, whereas in C, char *buf is just an address. However the interoperability assumes that a Fortran fixed- or deferred-length character is interoperable with an array of characters. In addition, C uses the convention that a string (i.e. an array of characters) is terminated by the null character.

1 Like

I’d say that lumping together assumed-size arrays and assumed-length character scalars (both entities declared with an asterisk *) is not a good idea. The former entity bears no information about the true size of the actual argument while the latter - on the contrary, thus being more like assumed-shape array. I may not get all the linguistical nuances here but for me, a non-native English speaker, coining assumed term to all of those entities is quite unfortunate. If real :: tab(*) is to be called assumed-size, then real :: tab(:) or character(len=*) :: str might be called passed-shape/length?

BTW. I’m not sure whether the assumed-length is by any means official name of a dummy declared character(len=*) :: str - the F2018 Draft and Interpretation documents do mention assumed length and assumed-length in a few places but never in a defining context, rather as a reference to something obvious to the reader.

1 Like

Hello @milancurcic and congratulations for the book, I am happily getting back to fortran thanks to it :slight_smile: .
I would like to ask, are there any news about this future edition you were talking about? Are there concrete plans or is it still in the realm of ideas?

@msz95 said “I’d say that lumping together assumed-size arrays and assumed-length character scalars (both entities declared with an asterisk *) is not a good idea.”

Like many things in Fortran the reason for it is historical. Using * for both purposes dates back to Fortran 77, when assumed-shape arrays had not yet been invented. The syntax is kept unchanged so that few old programs won’t run with new compilers. Sometimes a new syntax is allowed as well as the old one, e.g. < as well as .lt.
The number of different uses of * in Fortran keeps rising: 19 in F95, 29 in F2018 unless I have missed some.

1 Like

I’m a bit late to this thread, but I just got my copy of this book today. Just scanning the contents make me very enthusiastic to dig into it a bit deeper.

The topics and exercises all look extremely well thought out. I’m especially looking forward to the C-Fortran integration, and using Fortran in web applications.

I think this is a perfect complement to the update book Modern Fortran Explained, which I also have, and value highly.

3 Likes

Great to hear, thank you for reading it. Since you mention the C-Fortran interop. That chapter has a problem related to the libdill library that it uses. It broke with later versions of GCC at the time (IIRC gcc-8 was fine but gcc-9 broke it; compiler-specific stuff). This was fixed eventually on the GitHub but regrettably the book points to the tarball from the website rather than GitHub. When you get to Chapter 11 let’s revisit this and establish a working solution, we can open a separate topic for it here on Discourse.

2 Likes

On the page 20 Best Fortran Books of All Time, Modern Fortran - Building efficient parallel applications is #1 and Modern Fortran Explained Incorporating Fortran 2018 is #2.

Curiously, despite the title of the page, there are more than 87 Fortran books listed…

About the site (and its link with Amazon): https://bookauthority.org/about

While I do have #1 and #2 and find these books really great, the rest of the list is somewhat strange, with two editions of Chapman’s Fortran for Scientists (I have this one too) and Engineers, two books on FORTRAN 77 and a book on Numerical Methods and Fortran Programming published in … 1964. The second ten is opened by a real dinosaur - Fortran IV :slight_smile:
Equally tricky is #3 - AI-generated custom-tailored book on Fortran. Anybody tried that?

2 Likes

I totally agree! Many books of the 2010’s should be in the top of the list.
Maybe an AI generated page?

You can discover books that seem interesting such as Computational Physics: With Worked Out Examples in FORTRAN® and MATLAB® (2023 edition).
But it seems there are also self-edited books sold on Amazon, for example FORTRAN : MODERN STANDARD: A Project-Based Approach by ByteBazzar Publications. The author would be a Dr. Emily, although I wonder if she is a real person or if the book is an AI generated text (O brave new world… :roll_eyes:).

1 Like

Though I do appreciate the #1 spot, it does seem like an AI spam page.

1 Like

Yes, sorry I felt in the trap.

The web is deteriorating. Not only I must regularly prove to machines that “I am human” (a very strange evolution, did Asimov predict that?), but I must myself try to evaluate if a page has been written by humans or algorithms. And even books can’t be trusted anymore.

5 Likes

I see I didn’t update on sales in more than 3 years.

4006 copies sold as of Q1 2025, holding steady ~250/year on average since 2021.

This excludes the translation to Simplified Chinese about a year ago, which I have no insight into the sales of.

14 Likes