Model Integration with SWAT -...

23
Model Integration with SWAT A publish-subscribe type system June 24, 2013 André Dozier and Olaf David

Transcript of Model Integration with SWAT -...

Page 1: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Model Integration with SWAT

A publish-subscribe type system

June 24, 2013

André Dozier and Olaf David

Page 2: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Detailed Assessment Model – daily and 1-5km resolution

SWAT Read Inputs

MODFLOW Solver

MODFLOW Read Inputs

MODFLOW Close

RT3D Read Inputs

RT3D Solver

RT3D Close

SWAT HRU calcs

SWAT Routing

SWAT Output

SWAT Close

Daily Loop

Optimization – yearly (or 2-5 year) and 30-50km resolution

WALL Solver

WALL Solver

Minimize Vulnerability and Cost

CGE Solver

SWAT Solver

IUWM BMPs

Few Iterations

Ensure Economic Demand = Cons. Use

Supply to WALL Demand to SWAT

Manually add model

detail

Pareto optimal curve of

management solutions

DayCent

Page 3: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Linkages

• Need to add two linking components

SWAT Model

Other Model

Page 4: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Linkages

• Need to add two linking components

SWAT Model

OMS Simulation

Other Model

Page 5: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

My OMS Component

My Wrapper

Linkages

• Need to add two linking components

SWAT Model

OMS Simulation

Other Model

Page 6: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

My OMS Component

My Wrapper

Linkages

• Need to add two linking components

SWAT Model

event

OMS Simulation

SWAT run

direction Other Model

run component

finished

Page 7: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

My OMS Component

My Wrapper Special OMS Component - Event names - Event inputs - Event outputs - Communication via MPI

(use blocking sends)

Linkages

• Need to add two linking components

OMS Simulation

Other Model

Page 8: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

My OMS Component Normal (or special if desired) OMS component - Inputs - Outputs - Execution subroutine

My Wrapper Special OMS Component - Event names - Event inputs - Event outputs - Communication via MPI

(use blocking sends)

Linkages

• Need to add two linking components

OMS Simulation

Page 9: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

OMS Simulation

My OMS Component Normal (or special if desired) OMS component - Inputs - Outputs - Execution subroutine

My Wrapper Special OMS Component - Event names - Event inputs - Event outputs - Communication via MPI

(use blocking sends)

Linkages

• Need to add two linking components

Simulation specifications - location(s) or NULL - Native or managed?

Page 10: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop End End End

Page 11: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End End

Page 12: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End End

Array of function pointers

Page 13: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End End

mysub

othersub

Array of function pointers

To “subscribe”

subroutine mysub()

print *,“my sub”

end subroutine

subroutine othersub()

print *,“other sub”

end subroutine

Page 14: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End End

mysub

othersub

Array of function pointers

To “subscribe”

subroutine mysub()

print *,“my sub”

end subroutine

subroutine othersub()

print *,“other sub”

end subroutine

program subscriber()

use parm

implicit none

integer :: event_i

interface

subroutine mysub()

end subroutine

end interface

interface

subroutine othersub()

end subroutine

end interface

event_i = TopOfDailyLoop%subscribe(mysub)

event_i = TopOfDailyLoop%subscribe(othersub)

call swat_main()

end program

Page 15: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

“Events” in SWAT SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End End

mysub

othersub

Array of function pointers

subroutine mysub()

print *,“my sub”

end subroutine

subroutine othersub()

print *,“other sub”

end subroutine

Page 16: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Special OMS-SWAT Component SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End call EndOfYear%fire() End

mpi_input

mpi_output

subroutine mpi_input()

use parm

! Variable initialization

! MPI inputs

call MPI_RECEIVE(buf, …)

! Variable dereferencing

end subroutine

subroutine mpi_output()

use parm

! Variable initialization

! MPI outputs

call MPI_SEND(buf, …)

! MPI wait until finished

call MPI_RECEIVE(buf, …)

! Variable dereferencing

end subroutine

Page 17: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Special OMS-SWAT Component SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End call EndOfYear%fire() End

mpi_input

mpi_output

Waits until inputs are available from another OMS component

Sends output from SWAT to OMS with the option of waiting until the component has finished running

Page 18: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

My OMS Component

My Wrapper

Linkages

• Need to add two linking components

SWAT Model

event

OMS Simulation

SWAT run

direction Other Model

run component

finished

Page 19: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

One Possible Orientation SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End call EndOfYear%fire() End

mpi_input

mpi_output

OMS Simulation

OMS Component(s)

OMS Component(s)

Page 20: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Another Possible Orientation SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End call EndOfYear%fire() End

mpi_output

mpi_input

OMS Simulation

OMS Component(s)

Allows parallel implementation

Page 21: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Yet Another Possible Orientation SWAT Start Read Inputs Year Loop Month Loop Daily Loop call TopOfDailyLoop%fire() End End call EndOfYear%fire() End

mpi_output

mpi_input

OMS Simulation

OMS Component(s)

mpi_input

mpi_output

Page 22: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

Detailed Assessment Model – daily and 1-5km resolution

SWAT Read Inputs

MODFLOW Solver

MODFLOW Read Inputs

MODFLOW Close

RT3D Read Inputs

RT3D Solver

RT3D Close

SWAT HRU calcs

SWAT Routing

SWAT Output

SWAT Close

Daily Loop

Optimization – yearly (or 2-5 year) and 30-50km resolution

WALL Solver

WALL Solver

Minimize Vulnerability and Cost

CGE Solver

SWAT Solver

IUWM BMPs

Few Iterations

Ensure Economic Demand = Cons. Use

Supply to WALL Demand to SWAT

Manually add model

detail

Pareto optimal curve of

management solutions

DayCent

Page 23: Model Integration with SWAT - erams.comerams.com/.../wp-content/uploads/Model-Integration-with-SWAT-1.pdf · MODFLOW RT3D Close RT3D Read Inputs RT3D Solver SWAT HRU calcs SWAT Routing

First test case