Step 1 — Invoke with an explicit contract
/CLEAR,START
*USE,08_macro_debug.mac,0.10,-1000,0.05,1*USE loads the macro and assigns ARG1…ARG4. The driver translates those arguments into named parameters and rejects invalid values before building anything:
beam_h=ARG1
tip_force=ARG2
mesh_h=ARG3
case_id=ARG4
*IF,beam_h,LE,0,THEN
/COM,ERROR: ARG1 beam_h must be positive
/STATUS,PARM
/EOF
*ENDIFDo not run /CLEAR inside the driver. It would clear the database and macro stack. Clean the session before calling *USE.
Step 2 — Separate construction, solution, and extraction
/INPUT,08_build,mac,,,,1
/INPUT,08_solve,mac,,,,1
/INPUT,08_extract,mac,,,,1Each phase assumes and checks preconditions. 08_build.mac creates geometry, mesh, and components; 08_solve.mac applies D/F and solves; 08_extract.mac activates the set, validates against theory, and writes the CSV.
Mesh divisions are calculated with NINT(dim/mesh_h). Thus mesh_h is a real contract argument, not a hardcoded value in the monolith. Construction sets KEYOPT(2)=3 on SOLID185: with KEYOPT(2)=0, bending stress is artificially low (~22%) on this mesh.