masto.es es uno de los varios servidores independientes de Mastodon que puedes usar para participar en el fediverso.
Bienvenidos a masto.es, el mayor servidor de Mastodon para hispanohablantes de temática general.

Administrado por:

Estadísticas del servidor:

1,9 K
usuarios activos

#fortran

3 publicaciones3 participantes0 publicaciones hoy

My first experience with #chatgpt5.

I queried how to write some #python code to write out unformatted, binary files so my #fortran code could read it.

Proceeds to give me a load of #NumPy code. Completely neglects to mention the #SciPy FortranFile class that can trivially read and write, and appears on the first page of a search.

This is going to be a bumpy ride!

#FORTRAN doesn't have fork() or exec() natively. Creating a new process in FORTRAN requires either using system() function (portable but limited) or calling #C functions via ISO_C_BINDING (allowing full control). Modern FORTRAN (2003 and later) allows calling C functions directly
Via @unix-byte.bsky.social

Attention Fortran lawyers!

A colleague posed an interesting one to me (assuming b is a 2D real array containing values):
OK:
real, dimension(:), allocatable :: a
a = b(1, :)

Error:
real, dimension(:), allocatable :: a
a = sum(b(2:,:), dim=1)
! (can fixed by allocating a)

Is there a rule about automatic allocation requiring no temporaries? Or compiler bug (in either case?)

New #Fortran post: "Errors and error handling - Part 7 - Fatal errors" matthiasnoback.nl/2025/07/fort

Almost everywhere in our code should we allow errors to bubble up to higher abstraction levels, until we get to the point that we'd really like to terminate the program. How to do that properly? We need to consider the process' exit code, printing the error to stderr, and adding a stack trace.

Matthias Noback · Fortran - Errors and error handling - Part 7 - Fatal errorsStop with error code, error message, and stack trace

New #Fortran post: "Errors and error handling part 6: Guarantees" matthiasnoback.nl/2025/07/fort

If we want guarantees that data in a derived type is correct, we have to use a custom constructor. But such a constructor then needs another Either return type so it can return a validated instance or an error.

Matthias Noback · Fortran - Errors and error handling - Part 6 - GuaranteesThe Evidence Pattern

Inspired by some folks who have been exploring #FORTRAN 77 programming on FreeDOS, I wanted to share these programming gems:

Arithmetic If
Computed Goto
Assigned Goto

both.org/?p=11217

They are excellent ways to add subtle bugs to your programs. 🤓😂🪳

Try them out using Open Watcom FORTRAN on FreeDOS.

Both.org3 ways to write bugs with FORTRAN 77 - Both.orgExplore old-style FORTRAN programming with Arithmetic IF, Computed GOTO, and Assigned GOTO.

New #Fortran post: "Errors and error handling - Part 4 - Using an Either type" matthiasnoback.nl/2025/07/fort

We consider a problem that involves parsing and find a solution to deal with parse errors: a parse function that returns an "Either" type, containing either an error, or the expected result of parsing.

Matthias Noback · Fortran - Errors and error handling - Part 4 - Using an Either typeDealing with parse errors

Fortran: Hey, I can do object-orientation too! Just use 🐰 type :: foo <stuff> end type🐰

Me: Cool! And I can put that in a module, right?

Fortran: Absolutely! Indeed, that's best practice.

Me: And I can put particular instances of foo in a module as well, so they are accessible by multiple routines, just like I can with basic types?

Fortran, Hahaha, LOL no. Why would you want to do that?

New #Fortran post: "Errors & Error Handling Part 2 - Optional Results matthiasnoback.nl/2025/07/fort

Instead of returning a success flag and use an intent(out) argument to return the actual function result, we implement an optional return value using an abstract derived type and two concrete subtypes.

Matthias Noback · Fortran - Errors and error handling - Part 2Optional results

For some reason, raising a real number to some power gives a less accurate result in Fortran than does manually typing out each multiplication individually.

By which I mean T*T*T*T*... (until you have typed n Ts) is more accurate than T**n (that's T^n).

The wonders of computers.