M3tools writing to existing file

I have a slightly awkward problem I’m trying to solve using m3tools. I’m currently trying to create an MSOILOUT file using an existing BSOILOUT file and a METCRO2D file. The MSOILOUT file needs all of the variables from BSOILOUT, but also needs to add three variables from METCRO2D. Two of these variables must be separated into a new variable for each hour of a day, so that they appear in MSOILOUT as SW00,SW01…SW24 and T2M00,…,T2M24. The third variable LAI must also be copied from METCRO2D to MSOILOUT.

I haven’t found an elegant way to script this without having intermediate netcdf files. The problem I’m running into is that there seems to be no way to use the m3tools to add a variable to an existing file, as this results in warnings in CHKFIL3 for an inconsistent variable list when trying to write the new variables. Here is the script I’ve made that results in this error.

Can I do this with only m3tools (not hard-coding reads and writes in Fortran) and without creating intermediate netcdf files? There’s no real problem with doing so, but it may be slightly more time-consuming and less elegant.

M3Tools does not engage in metadata perjury, claiming that time stepped, time dependent data is time independent.