SQUARE-CIRCLE SURFACE GENERATION Question

curvewall code.gh (17.6 KB) curve wall.3dm (97.2 KB)

Hi everyone!
I have a wall with modules that are square on both sides like this:


But I want to have each of the modules be like a dome at the end. in a way that each of them is a square at the bottom and turns into a circle as they come up. like this image:

with different variation in hole size like this:

Does anyone have any idea how I can do this?

Thank you!

Sarah