DAVID POGUE: Of all our planet’s upheavals, earthquakes are among the most terrifying. We can’t predict them, and we sure can’t stop them. But, increasingly, engineers are learning how to protect against their awesome power.

That’s good news, because one of my favorite cities is also one of our most vulnerable: San Francisco. I’d always thought these skyscrapers would be the hardest hit in a big quake, but, in fact, the taller the building, the more flexible it is. Skyscrapers can sway without falling over.

What we need to worry about are thousands of buildings that went up before the 1970s. They’re called “soft story” buildings, because their ground floor is an open space, usually a garage, with large doorways.

In an earthquake, that structurally soft story can’t support the motion of the upper floors and it collapses.

In 1989, a magnitude 6.9 earthquake damaged hundreds of these structures in the Bay Area, and left thousands homeless. Today, throughout California’s seismic zones, some 2-, to 300,000 people still live in these death traps. They’re sitting ducks. The risk is so high that cities across the state are writing laws requiring that these structures be retrofitted. But how can engineers figure out exactly what will work?

Well, for starters, a five-university team built a replica of a soft story building from the 1920s. But they couldn’t just sit around and wait for the earth to move. They staged their own earthquake. Then they followed that with a devastating aftershock that brought this building to its knees.

But we’re getting ahead of ourselves, because before they flattened it, engineers spent a month testing ways to keep the structure standing.

It’s built on the largest outdoor shake table in the world, at the University of California, San Diego. Powered by massive hydraulic pistons, this 172-ton brute can simulate the most devastating earthquakes ever recorded. It can also make a mean milkshake.

Seriously, for team leader John van de Lindt this is the project of a lifetime.

JOHN VAN DE LINDT: This is the first time a building this size, that represents a true soft-story building, has been tested.

DAVID POGUE: His team will test four engineering solutions that performed well in computer models.

JOHN VAN DE LINDT: We’re looking at design and retrofit methods to try and make these structures safer for the many, many families around the United States that live in them.

DAVID POGUE: The first retrofit involves panels of a new building material called “cross laminated timber,” or C.L.T. C.L.T. is made of lumber, stacked at right angles and glued together, which makes for panels that are very strong and stiff.

Two sets of panels are placed on the garage floor and anchored to the ceiling. During an earthquake, they should rock in place and help absorb energy from the motion of the upper stories. But the C.L.T. panels aren’t bearing the burden alone. They’re attached to steel rods that run straight down into the foundation.

JOHN VAN DE LINDT: The steel rods, they have to transfer forces from the cross-laminated timber, while it rocks, and this will dissipate the energy from the earthquake.

DAVID POGUE: Before the test, they fully wire the place: 30 cameras and 300 sensors to measure the movement and behavior of each part of the building.

Now it’s time to rock and roll.

DAN RADULESCU: Loma Prieta, in 10, 9…

DAVID POGUE: This will be a simulation of the 1989 earthquake that took 63 lives and destroyed countless structures. But with its retrofit in place, this building’s ready to rumble.

DAN RADULESCU: Three, two, one, running.

DAVID POGUE: Can just a few wooden panels really prevent collapse? The original earthquake lasted about 15 seconds. That may not sound like a long time, but if you happen to be inside a building that’s about to collapse, it must feel like an eternity.

Cameras reveal the C.L.T. panels rocking in place. At last the test is over. They head inside and look for damage.

It’s clear that the panels saved the day, but the rocking motion put so much stress on the steel rods that they actually stretched.

JOHN VAN DE LINDT: All in all, this test was absolutely perfect, I’d say phenomenal. If this wasn’t here, the building would have collapsed.

DAVID POGUE: The researchers document every crack and break. Some repairs would be needed, but the building would still be livable.

C.L.T. panels are the simplest of the retrofits they’ll test. Steel frames strengthened the openings on the ground floor and performed even better than the C.L.T. panels, allowing minimal damage to the building. When engineers added plywood reinforcement on the upper floors, the steel frames kept the structure virtually intact.

Same goes for the fourth retrofit: high-tech dampers that acted like shock absorbers on the bottom floor and kept the building standing.

All in all, four for four.