I've slightly updated the code to ensure that the all the sent bytes are getting read on both sides of the socket; i.e. I've implemented a receive all function in both Python and Fortran with error checking. This makes the codes slightly more robust. The change is probably unnecessary at the size of messages being sent but this could potentially be an issue if one started to send a lot of data this way.