Porting a Fortran EMP Simulation for Henry Newton

Sometime around 2016, a guy named Henry Newton started showing up to our local meetup in New Orleans. He had a pretty interesting career and some cool stories. The reason he came out, I think other than just talking with some like minded people, was he wanted to revive an old project he worked on. The way he told it, he had some Fortran code from the 70s for simulating EMP attacks. He was interested in porting it to a modern language and studying how it could impact the electrical grid.

I found this kind of interesting, but it sounded like a big task at the time. And he said he needed help, but had a team working on it already. It felt like it was too much to help with and sounded like other people were helping anyway. So I forgot about it.

At some point he stopped coming around and we unfortunately learned in 2023 he died. I was thinking the other day about this as I was reading about the bun port. He had plenty of knowledge but just needed to find some willing Fortan, or at least Fortran-curious, developers (not easy to do). I feel if he was alive today he’d probably be excited to just drive a coding agent and build this out himself.

Agents are particularly good at porting code. So I decided why not give it a shot for him. Luckily it seems he posted the code online already.

The workflow behind the prompt I made was:

  1. Get this code to compile and output reasonable data
  2. Use this as an oracle to port the code to typescript
  3. Create a simple webpage allowing me to manipulate the parameters and simulate an attack

I ran this and went to bed. Claude Code was able to get this running pretty easily. Here is the site it made and here is the code.

I honestly didn’t scrutinize this much or iterate on it. It seemed to follow the instructions correctly and the output seems reasonable. Just thought it was an interesting experiment, but don’t go making national security policy based on this.

Regrets

I realized actually, from looking at the Fortran code, it was surprisingly small and elegant and I probably could have figured this out back then on my own. Look at this subroutine for runge-kutta integration:

      SUBROUTINE RNGKUT (E1,E,R,H,SIGMA,COMPTJ)                         RNKT1010
C                                                                       RNKT1020
C         E(I+1) IS CALCULATED FROM E(I)                                RNKT1030
C         USING THE RUNGE-KUTTA METHOD                                  RNKT1040
C                                                                       RKKT1050
      DATA C/3.0E8/,RMUO/12.56637E-7/                                   RNKT1060
      EFUN(R,E)=-(1./R+C*RMUO*SIGMA/2.)*E-COMPTJ*C*RMUO/2.              RNKT1070
      RK1=H*EFUN(R,E)                                                   RNKT1080
      RK2=H*EFUN(R+H/2.,E+RK1/2.)                                       RNKT1090
      RK3=H*EFUN(R+H/2.,E+RK2/2.)                                       RNKT1100
      RK4=H*EFUN(R+H,E+RK3)                                             RNKT1110
      E1=E+(RK1+2.*(RK2+RK3)+RK4)/6.                                    RNKT1120
      RETURN                                                            RNKT1130
      END

I really regret not volunteering to at least look at his code, but this a lesson learned I suppose.