Object-Oriented Prediction System - Data Assimilation

2y ago
21 Views
3 Downloads
606.04 KB
73 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Azalea Piercy
Transcription

Object-Oriented Prediction SystemYannick TrémoletECMWFNovember 2013Y. TrémoletOOPSNovember 2013

Why OOPS?The IFS is a very good global weather forecasting system. However,continuous improvements are necessary to stay at the forefront.There is uncertainty in scientific methods that will be used in the future, forexample in the data assimilation and dynamical core areas.Scalability has become a major concern in view of new computerarchitectures: addressing it will require significant algorithmic changes.IIThe code can be optimized routine by routine to increase scalability only up toa certain point.Significant leaps in the level of available parallelism can only be achievedthrough scientific progress in the formulation of the algorithms.A very flexible code is needed to test such developments and ideas.The code must also be reliable, efficient and readable.Y. TrémoletOOPSNovember 20131 / 12

FlexibleIt should be easy to modify the system (new science, new functionality,better scalability.)Different concepts should be treated in different parts of the code.A requirement is that a change to one aspect should not imply changes allover the place.IIINo code duplication: same modification in many places but also difficult tofind and leads to bugs.No global variables: a modification might have unforeseen consequencesanywhere.Think of it in terms of locality in the source code (as opposed to discontinouscode that jumps all over the place).Y. TrémoletOOPSNovember 20132 / 12

ReliableThe code must run without crashing.Additional aspects of reliablity are application dependent.Y. TrémoletOOPSNovember 20133 / 12

ReliableThe code must run without crashing.Additional aspects of reliablity are application dependent.For a system like the IFS, the code must do what the user thinks it does:IIMany experiments are wasted because it is not always the case.The code must run with the user supplied value (namelist, xml) or abort.Y. TrémoletOOPSNovember 20133 / 12

ReliableThe code must run without crashing.Additional aspects of reliablity are application dependent.For a system like the IFS, the code must do what the user thinks it does:IIMany experiments are wasted because it is not always the case.The code must run with the user supplied value (namelist, xml) or abort.No, a print in a many-Mb-long logfile is not enough!No, you are not the only one using that variable!A controlled abort with a clear error message is not a crash: it savescomputer and user time (our time).Y. TrémoletOOPSNovember 20133 / 12

ReliableThe code must run without crashing.Additional aspects of reliablity are application dependent.For a system like the IFS, the code must do what the user thinks it does:IIMany experiments are wasted because it is not always the case.The code must run with the user supplied value (namelist, xml) or abort.No, a print in a many-Mb-long logfile is not enough!No, you are not the only one using that variable!A controlled abort with a clear error message is not a crash: it savescomputer and user time (our time).Lots of testing:IIIInternal consistency and correctness of results (not scientific evaluation),Mecanism to run all the tests easily,Tests run automatically on push to source repository (ECMWF).Y. TrémoletOOPSNovember 20133 / 12

Efficient vs. ReadableThe IFS is one of the most computationaly efficient and scalable weatherforecasting systems.The maintenance cost has become very high and new releases take longerand longer to create and debug.It is more and more difficult for newcomers to learn the system and it takeslonger to be productive.Readable code is not less efficient.Readability is staff efficiency: it is as important as computational efficiency(it’s just more difficult to measure).Y. TrémoletOOPSNovember 20134 / 12

Object-OrientedFlexible, reliable, readable, efficient.This is not specific to the IFS: all developers want codes that are modular,reliable, flexible and efficient.Since the IFS was designed, in the late 1980’s, the software industry hasprogressed tremendously to make this possible.The techniques that have emerged to answer these needs are called genericand object-oriented programming.We have started to re-design our system using this technology in theObject-Oriented Prediction System (OOPS).Y. TrémoletOOPSNovember 20135 / 12

Object-Oriented and Weather ForecastingThe weather forecasting problem can be broken into manageable pieces:IIIData assimilation (or ensemble prediction) can be described without knowingthe specifics of a model or observations.Minimisation algorithms can be written without knowing the details of thematrices and vectors involved.Development of a dynamical core on a new model grid should not requireknowledge of the data assimilation algorithm.All aspects exist but scientists focus on one aspect at a time: the codeshould reflect this.Object-oriented programming does not solve scientific problems in itself: itprovides a more powerful way to tell the computer what to do.OOPS currently stops at the level of the calls to the forecast model andobservation operators but the same principle could be applied at any level.Y. TrémoletOOPSNovember 20136 / 12

What is OOPS?ApplicationsBuilding BlocksForecast4D-Var EDA EPS EnKF. StatesObservations Covariances Increments. ModelsLorenz 95QG IFS NEMO Surface. OOPSThe high levels Applications use abstract building blocks.The Models implement the building blocks.OOPS is independent of the Model being driven.Y. TrémoletOOPSNovember 20137 / 12

OOPS ImplementationWe have defined a small set of abstract classes that encompasses mostentities required for data assimilation.IBiases (model and observations) will also be needed.For practical implementation, a few more classes will be useful.Utility classes:IConfig, DateTime, Duration, Logger.Auxiliary classes:IGeometry, ModelConfiguration, TLM (Trajectory), Locations,ModelAtLocations (GOM)Y. TrémoletOOPSNovember 20138 / 12

OOPS ClassesOOPS requires a consistent set of classes that work together with predefinedinterfaces:IIn model gurationLinearModel (Trajectory)11. Locations12. ModelAtLocationsICovariance matrices (if generic onesare not used):13. Model space (B and Q)14. Observation space (R)15. Localization (4D-Ens-Var)In observation space:6.7.8.9.10.To make the ectorObsOperatorTrajectory;Approximately 100 methods to be implemented (in Fortran or not).Observation and model errors (biases) will be added.Y. TrémoletOOPSNovember 20139 / 12

Model Trait DefinitionActual implementation struct QgTraits {typedef qg :: QgGeometrytypedef qg :: QgStatetypedef qg :: QgModeltypedef qg :: QgIncrementtypedef qg :: QgTLMtypedef oops :: NullModelAuxtypedef oops :: NullModelAuxtypedeftypedeftypedeftypedeftypedefqg :: QgObservationqg :: ObsTrajQGoops :: NullObsAuxoops :: NullObsAuxqg :: ObsVecQGName used in OOPS Geometry ;State ;ModelConfiguration ;Increment ;LinearModel ;Mo d el Au xC o nt ro l ;ModelAuxIncrement ;ObsOperator ;ObsOperatorLinearizationTrajectory ;ObsAuxControl ;O b sA ux In c re me n t ;ObsVector ;typedef qg :: LocQGtypedef qg :: GomQGLocations ;M o d e l A t L o c a t i o ns ;typedef qg :: L o c a l i z a t i o n M a t r i x Q GLocalizationMatrix ;};The trait is used as a template argument MODEL : compile time polymorphism.Y. TrémoletOOPSNovember 201310 / 12

Model Trait DefinitionActual implementation struct IfsTraits {typedef ifs :: GeometryIFStypedef ifs :: StateIFStypedef ifs :: ModelIFStypedef ifs :: IncrementIFStypedef ifs :: LinearModelIFStypedef oops :: NullModelAuxtypedef oops :: NullModelAuxtypedeftypedeftypedeftypedeftypedefifs :: AllObsifs :: AllObsTrajoops :: NullObsAuxoops :: NullObsAuxifs :: ObsVectorName used in OOPS Geometry ;State ;ModelConfiguration ;Increment ;LinearModel ;Mo d el Au xC o nt ro l ;ModelAuxIncrement ;ObsOperator ;ObsOperatorLinearizationTrajectory ;ObsAuxControl ;O b sA ux In c re me n t ;ObsVector ;typedef ifs :: LocationsIFStypedef ifs :: GomsIFSLocations ;ModelAtLocations ;typedef ifs :: L o c a l i z a t i o n M a t r i x I F SLocalizationMatrix ;};The trait is used as a template argument MODEL : compile time polymorphism.Y. TrémoletOOPSNovember 201310 / 12

Run time vs. Compile time polymorphismThe model is chosen at compile time via template instantiation.# include " mains / RunQg . h "# include " model / QgTraits . h "# include " oops / runs / Forecast . h "int main ( int argc , char ** argv ) {qg :: RunQg oops :: Forecast qg :: QgTraits run ( argc , argv );int info run . execute ();return info ;};ifs :: RunIfs oops :: Forecast ifs :: IfsTraits run ( argc , argv );The covariance matrices are chosen at run time because some are generic(Ensemble or hybrid B, diagonal R).The classes in the trait definition might be abstract base classes (seeQgObservation).Y. TrémoletOOPSNovember 201311 / 12

Encapsulating Fortran Code in C ClassesC Interface (ISO)Fortranmodule mytype modClass MyClass {public:MyClass() {create data(&data );} Myclass() {delete data(&data );}doSomething() {do work(&data );}private:Fdata * data ;}type mytype! some contents here.end type mytypesubroutine do work(c self)use iso c bindingsuse mytype modtype(c ptr) :: c selftype(mytype), pointer :: selfcall c f pointer(c self, self)call do it(self)end subroutine do workcontainssubroutine create(self)type(mytype) :: self! allocate and setup.end subroutine createsubroutine delete(self)type(mytype) :: self! deallocate.end subroutine deletesubroutine do it(self)type(mytype) :: self! do the work.end subroutine do it// Give a class to pointerClass Fdata {};end module mytype modY. TrémoletOOPSNovember 201312 / 12

Encapsulating Fortran Code in C ClassesC Interface (ISO)Fortranmodule mytype modClass MyClass {public:MyClass() {create data(&data );} Myclass() {delete data(&data );}doSomething() {do work(&data );}private:Fdata * data ;}type mytype! some contents here.end type mytypesubroutine create data(c self)use iso c bindingsuse mytype modtype(c ptr) :: c selftype(mytype), pointer :: selfallocate(self)call create(self)c self c loc(self)end subroutine create datacontainssubroutine create(self)type(mytype) :: self! allocate and setup.end subroutine createsubroutine delete(self)type(mytype) :: self! deallocate.end subroutine deletesubroutine do it(self)type(mytype) :: self! do the work.end subroutine do it// Give a class to pointerClass Fdata {};end module mytype modNo static variable of type mytype is declared in the module!Y. TrémoletOOPSNovember 201312 / 12

Encapsulating Fortran Code in C ClassesC Interface (ISO)Fortranmodule mytype modClass MyClass {public:MyClass() {create data(&data );} Myclass() {delete data(&data );}doSomething() {do work(&data );}private:Fdata * data ;}type mytype! some contents here.end type mytypesubroutine do work(c self)use iso c bindingsuse mytype modtype(c ptr) :: c selftype(mytype), pointer :: selfcall c f pointer(c self, self)call do it(self)end subroutine do workcontainssubroutine create(self)type(mytype) :: self! allocate and setup.end subroutine createsubroutine delete(self)type(mytype) :: self! deallocate.end subroutine deletesubroutine do it(self)type(mytype) :: self! do the work.end subroutine do it// Give a class to pointerClass Fdata {};end module mytype modNo static variable of type mytype is declared in the module!The Fortran module does not know about C : it is fully usable in the restof the Fortran code.Y. TrémoletOOPSNovember 201312 / 12

Object-Oriented Prediction SystemYannick TrémoletECMWFNovember 2013Y. TrémoletOOPS DesignNovember 2013

Getting OOPSThe main point of information about OOPS is the wiki OOPS HomeThe source code is accessible from the git repository (via OPSThe IFS component are in the usual perforce repository.Y. TrémoletOOPS DesignNovember 20131 / 34

OOPS DesignWhy OOPS?IIWhat do we want to develop?Why cannot we do it in the IFS?OOPS General DesignIIIHow can we adress the problems above?What basic classes do we need (building blocks)?Run time vs. compile time polymorphismDetails of some classesIIBasic classes: State, ObservationsBuilding a DA system: CostFunction, MinimizerNot enough time to cover every class in OOPSIIEnough to understand the main structureExamples of “object-thinking”Y. TrémoletOOPS DesignNovember 20132 / 34

Outline1The IFS2OOPS Design: Abstract Level3Implementing the Abstract Design: Building Blocks4Implementing the Abstract Design: Applications5Some General CommentsY. TrémoletOOPS DesignNovember 2013

The IFS was designed for tion windowThe initial state is integrated forward and compared with the observations.The 4D-Var cost function is computednJ(x0 ) 1X1T 1[H(xi ) yi ]T R 1i [H(xi ) yi ] (x0 xb ) B (x0 xb )22i 0and minimized using an incremental approach.Y. TrémoletOOPS DesignNovember 20133 / 34

The IFS was designed for tion windowThe initial state is integrated forward and compared with the observations.The 4D-Var cost function is computednJ(x0 ) 1X1T 1[H(xi ) yi ]T R 1i [H(xi ) yi ] (x0 xb ) B (x0 xb )22i 0and minimized using an incremental approach.Y. TrémoletOOPS DesignNovember 20133 / 34

Weak Constraint 4D-VarJqJbδx0δx1xbJqδx2Jqδx3timeThe control variable is the state at several points in time.There are additional terms in the cost function.Model integrations over each sub-window are independent.Y. TrémoletOOPS DesignNovember 20134 / 34

Weak Constraint 4D-VarJqJbδx0δx1xbJqδx2Jqδx3timeThe control variable is the state at several points in time.There are additional terms in the cost function.Model integrations over each sub-window are independent.We need several states!The nature of the optimization problem is different: we need to explore dualspace (i.e. observation space) algorithms (or mixed primal/dual).Y. TrémoletOOPS DesignNovember 20134 / 34

More Scalability in 4D-Var4000Scalability estimate 12h 4D-Var (36r4)Time (sec.)300058%48 nodes (actual)96 nodes (actual)96 nodes 1 exec96 nodes 2x6hours66%Running 1 executable instead of 7would reduce I/O and start-upcosts.79%2000Incremental 4D-Var in the IFS isachieved by executing the IFSseveral times.We need states and increments atdifferent resolutions (inner andouter loops).10000Estimates from Deborah SalmondY. TrémoletOOPS DesignNovember 20135 / 34

Another concern: IFS complexity2.0140120100801.060IF statements (x 1,000)Lines of code (x 1,000,000)1.5400.5200.0 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 0It means growth of maintenance, development costs, and number of bugs.Y. TrémoletOOPS DesignNovember 20136 / 34

Current situation in the IFSMost high level routines don’t have arguments (global variables).IIAssumes that there is only one state, one set of observations, one.Algorithms not envisaged at the outset (25 years ago) are extremely difficultto implement.Setup routines are separated from the rest of the code.IAll variables have to be accessible from four places (module, namelist, setup,subroutine) instead of one.Entities are not always independent.IHT R 1 H is one piece (jumble) of code.No structure exists to manipulate vectors in observation space (or in modelspace!).IObservation space algorithms are practically impossible to implement.The nonlinear model M can only be integrated once per execution.IIAlgorithms that require several calls to M can only be written at script level.It is not possible to run 4D-Var in one executable which affects performance.In practice, only one resolution can be used per execution.Y. TrémoletOOPS DesignNovember 20137 / 34

Outline1The IFS2OOPS Design: Abstract Level3Implementing the Abstract Design: Building Blocks4Implementing the Abstract Design: Applications5Some General CommentsY. TrémoletOOPS DesignNovember 2013

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.States :Observations :Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.States properties:IIIIInput, output (raw or post-processed).Interpolate.Move forward in time (using the model).Copy, assign.Observations :Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.States properties:IIIIInput, output (raw or post-processed).Interpolate.Move forward in time (using the model).Copy, assign.Observations properties:IIIInput, output.Compute observation equivalent from a state (observation operator).Copy, assign.Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignWhat is data assimilation?Data assimilation is finding the best estimate (analysis) of the state of theatmosphere (or system of interest) given a previous estimate of the state(background) and recent observations of the system.States properties:IIIIInput, output (raw or post-processed).Interpolate.Move forward in time (using the model).Copy, assign.Observations properties:IIIInput, output.Compute observation equivalent from a state (observation operator).Copy, assign.We don’t need to know how these operations are performed, how the statesare represented or how the observations are stored.Y. TrémoletOOPS DesignNovember 20138 / 34

OOPS Analysis and DesignnJ(x) 11X(x0 xb )T B 1 (x0 xb ) [H(xi ) yi ]T R 1i [H(xi ) yi ]22i 0Increments:IIIBasic linear algebra operators,Evolve forward in time linearly and backwards with adjoint.Compute as difference between states, add to state.Y. TrémoletOOPS DesignNovember 20139 / 34

OOPS Analysis and DesignnJ(x) 11X(x0 xb )T B 1 (x0 xb ) [H(xi ) yi ]T R 1i [H(xi ) yi ]22i 0Increments:IIIBasic linear algebra operators,Evolve forward in time linearly and backwards with adjoint.Compute as difference between states, add to state.Departures:IIIIBasic linear algebra operators,Compute as difference between observations, add to observations,Compute as linear variation in observation equivalent as a result of a variationof the state (linearized observation operator).Output (for diagnostics).Y. TrémoletOOPS DesignNovember 20139 / 34

OOPS Analysis and DesignnJ(x) 11X(x0 xb )T B 1 (x0 xb ) [H(xi ) yi ]T R 1i [H(xi ) yi ]22i 0Increments:IIIBasic linear algebra operators,Evolve forward in time linearly and backwards with adjoint.Compute as difference between states, add to state.Departures:IIIIBasic linear algebra operators,Compute as difference between observations, add to observations,Compute as l

Why OOPS? The IFS is a very good global weather forecasting system. However, continuous improvements are necessary to stay at the forefront. There is uncertainty in scienti c methods that will be used in the future, for example in the data assimilation and dynamical core areas. Scala

Related Documents:

Object Class: Independent Protection Layer Object: Safety Instrumented Function SIF-101 Compressor S/D Object: SIF-129 Tower feed S/D Event Data Diagnostics Bypasses Failures Incidences Activations Object Oriented - Functional Safety Object: PSV-134 Tower Object: LT-101 Object Class: Device Object: XS-145 Object: XV-137 Object: PSV-134 Object .

2 Database System Concepts 8.3 Silberschatz, Korth and Sudarshan Object-Oriented Data Model! Loosely speaking, an object corresponds to an entity in the E- R model.! The object-oriented paradigm is based on encapsulating code and data related to an object into single unit.! The object-oriented data model is a logical data model (like

method dispatch in different object-oriented programming languages. We also include an appendix on object-oriented programming languages, in which we consider the distinction between object-based and object-oriented programming languages and the evolution and notation and process of object-oriented analysis and design, start with Chapters 5 and 6;

Object oriented design methods emerged in the 1980s, and object oriented analysis methods emerged during the 1990s. In the early stage, object orientation was largely . and extensible system. Whole object oriented modeling is covered by using three kinds of models for a system description. These models are: object model,

Reusability, CK Metric, Object - Oriented. 1. INTRODUCTION Object oriented systems continue to share a major portion of software development and customer base for these systems is on the rise. This is because there are many advantages in taking the object oriented concept. The weakness though is that most object oriented systems tend to be .

object-oriented programming language is based on a kind of old object-oriented programming language. For example, though C language is an object-oriented programming language, it still retains the pointer which is complex but has strong function. But C# improved this problem. C# is a kind of pure object-oriented language.

Object built-in type, 9 Object constructor, 32 Object.create() method, 70 Object.defineProperties() method, 43–44 Object.defineProperty() method, 39–41, 52 Object.freeze() method, 47, 61 Object.getOwnPropertyDescriptor() method, 44 Object.getPrototypeOf() method, 55 Object.isExtensible() method, 45, 46 Object.isFrozen() method, 47 Object.isSealed() method, 46

as object–oriented design. Object–oriented development approaches are best suited to projects that will imply systems using emerging object technologies to construct, manage, and assemble those objects into useful computer applications. Object oriented design is the continuation of object-oriented analysis,