Traditional design and implementation of large atmospheric models is a difficult, tedious and error prone task. With the CTADEL project we investigate a new method of code generation, where the designer describes the model in an abstract high-level specification language which is translated into highly optimized Fortran code. This is applied to a convection scheme as used in a numerical weather prediction model (NWP). We address problems like how to generate efficient code for conditional expressions by using polymorphic templates. Finally, we compare the generated code for the convection scheme with the hand-written reference code. Categories and Subject Descriptors D.3.4 [Programming Languages]: Processors—Code generation; G.1 [Numerical Analysis]: General—Parallel algorithms; I.6.3 [Simulation and Modeling]: Applications