add a physics scheme into wrf model

36
Add a Physics Scheme into WRF Model Shu-hua Chen UC Davis/AFWA Physics implementation features Adding a physics scheme

Upload: jeslyn

Post on 05-Feb-2016

59 views

Category:

Documents


2 download

DESCRIPTION

Add a Physics Scheme into WRF Model. Shu-hua Chen UC Davis/AFWA. Physics implementation features Adding a physics scheme. Three Sets of Dimensions. Domain size: ids, ide, jds, jde, kds, kde Memory size: ims, ime, jms, jme, kms, kme Tile size: its, ite, jts, jte, kts, kte. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Add a Physics Scheme  into WRF Model

Add a Physics Scheme

into WRF Model

Shu-hua ChenUC Davis/AFWA

Physics implementation features

Adding a physics scheme

Page 2: Add a Physics Scheme  into WRF Model

Domain size: ids, ide, jds, jde, kds, kde

Memory size: ims, ime, jms, jme, kms, kme

Tile size: its, ite, jts, jte, kts, kte

Three Sets of Dimensions

Page 3: Add a Physics Scheme  into WRF Model

Rules for WRF Physics

Naming rules

Page 4: Add a Physics Scheme  into WRF Model

xxx = individual scheme

ex, module_cu_kf.F

Naming Rules

module_yy_xxx.F (module)

yy = ra is for radiation bl is for PBL cu is for cumulus mp is for microphysics.

Page 5: Add a Physics Scheme  into WRF Model

YY = ra is for radiation bl is for PBL cu is for cumulus

Naming Rules

RXXYYTEN (tendencies)

XX = variable (th, u, v, qv, qc, … )

ex, RTHBLTEN

Page 6: Add a Physics Scheme  into WRF Model

Coding rules (later)

Rules for WRF Physics

Naming rules

One scheme one module

Page 7: Add a Physics Scheme  into WRF Model

WRF Physics Features

REAL , PARAMETER :: r_d = 287. REAL , PARAMETER :: r_v = 461.6 REAL , PARAMETER :: cp = 7.*r_d/2. REAL , PARAMETER :: cv = cp-r_d . .

• Unified global constatnts

(module_model_constants.F)

Page 8: Add a Physics Scheme  into WRF Model

• Unified global constatnts

(module_model_constants.F)

• Vertical index

(kms is at the bottom)

• Unified common calculations

(saturation mixing ratio)

WRF Physics Features

Page 9: Add a Physics Scheme  into WRF Model

WRF Language

• 4D Moisture field, moist(i,k,j,?)

? = P_QV (water vapor) P_QC (cloud water)

P_QI (cloud ice)

P_QR (rain)

P_QS (snow)

P_QG (graupel)

(module_state_description.F)

Page 10: Add a Physics Scheme  into WRF Model

WRF Language

• 4D Moisture field, moist(i,k,j,?)

• PARAM_FIRST_SCALAR

IF ( P_QI .ge. PARAM_FIRST_SCALAR ) (the memory of cloud ice is allocated) . . .

Page 11: Add a Physics Scheme  into WRF Model

Prepare your code

Create a new module

Declare new variables and a new package in Registry

Modify solve_em.F (solve_eh.F)

Implement a new physics scheme

Do initialization

Modify namelist

Modify phy_prep (module_em.F)

Page 12: Add a Physics Scheme  into WRF Model

Modify physics_drive.int

Modify cumulus_driver.F

Modify Makefile

Compile and test

Modify calculate_phy_ten (module_em.F)

Implement a new physics scheme

Modify phy_cu_ten (module_physics_addtendc.F)

Page 13: Add a Physics Scheme  into WRF Model

a) Replace continuation characters in the 6th column with f90 continuation `&‘ at end of previous line

1.F90

Prepare your code

Subroutine kessler(QV, T,& its,ite,jts,jte,kts,kte,& ims,ime,jms,jme,kms,kme,& ids,ide,jds,jde,kds,kde)

F77

Subroutine kessler(QV, T, . . . & its,ite,jts,jte,kts,kte,& ims,ime,jms,jme,kms,kme,& ids,ide,jds,jde,kds,kde )

F90

Page 14: Add a Physics Scheme  into WRF Model

a) Replace continuation characters in the 6th column with f90 continuation `&‘ at end of previous line

1.F90

b)Replace the 1st column `C` for comment with `!`

Prepare your code

c This is a test

F77

! This is a test

F90

Page 15: Add a Physics Scheme  into WRF Model

1.F90

2.No common block

common/var1/T,q,p, …

F77

Subroutine sub(T,q,p, ….) real,intent(out), & dimension(ims:ime,kms:kme,jms:jme):: T,q,p

F90

Prepare your code

Page 16: Add a Physics Scheme  into WRF Model

1.F90

2.No common block

3.Use “ implicit none ”

4.Use “ intent ”

Prepare your code

Subroutine sub(T,q,p, ….) real,intent(out), & dimension(ims:ime,kms:kme,jms:jme):: T

real,intent( in), & dimension(ims:ime,kms:kme,jms:jme):: q real,intent(inout), & dimension(ims:ime,kms:kme,jms:jme):: p

Page 17: Add a Physics Scheme  into WRF Model

1.F90

2.No common block

3.Use “ implicit none ”

4.Use “ intent ”

5.Variable dimensions

Prepare your code

Subroutine sub(glo,….) real,intent(out), & dimension(ims:ime,kms:kme,jms:jme):: glo

real,dimension(its:ite,kts:kte,jts:jte):: loc

Page 18: Add a Physics Scheme  into WRF Model

1.F90

2.No common block

3.Use “ implicit none ”

4.Use “ intent ”

5.Variable dimensions

6.Do loops

do j = jts, jte do k = kts, kte do i = its, ite ... enddo enddo enddo

Prepare your code

Page 19: Add a Physics Scheme  into WRF Model

Implement a new physics scheme

Create a new module

ex, module_cu_chen.F (put all your codes in)

Go Registry and declare a new package (and new variables) (WRFV1/Registry)

package chenscheme cu_physics==3 - -

package kfscheme cu_physics==1 - -

package bmjscheme cu_physics==2 - -

Page 20: Add a Physics Scheme  into WRF Model

Implement a new physics scheme

Cloud microphysics

package kesslerscheme mp_physics==1 - moist:qv,qc,qr

package linscheme mp_physics==2 - moist:qv,qc,qr,qi,qs,qg

package ncepcloud3 mp_physics==3 - moist:qv,qc,qr

package ncepcloud5 mp_physics==4 - moist:qv,qc,

Create a new module

ex, module_cu_chen.F (put all your codes in)

Go Registry and declare a new package (and new variables) (WRFV1/Registry)

Page 21: Add a Physics Scheme  into WRF Model

Implement a new physics scheme

Modify namelist.input and assign

cu_physics = 3

Create a new module

ex, module_cu_chen.F (put all your codes in)

Go Registry and declare a new package (and new variables) (WRFV1/Registry)

Page 22: Add a Physics Scheme  into WRF Model

INIT

WRF ……. solve_em

phy_initstart_domain_em cu_init

(dyn_em)(start_em.F)

*

*

(phys)(module_physics_init.F)

(dyn_em)

Page 23: Add a Physics Scheme  into WRF Model

phys/module_physics_init.F

Pass new variables down to cu_init

Page 24: Add a Physics Scheme  into WRF Model

INIT

WRF ……. solve_em

phy_initstart_domain_em cu_init

(dyn_em)(start_em.F)

*

*

(phys)(module_physics_init.F)

(dyn_em)

Page 25: Add a Physics Scheme  into WRF Model

phys/module_physics_init.F

Go subroutine cu_init Include the new module and create a new SELECT case

Pass new variables down to cu_init

Page 26: Add a Physics Scheme  into WRF Model

cps_select: SELECT CASE(config_flags%cu_physics) CASE (KFSCHEME) CALL kfinit(...) CASE (BMJSCHEME)

CALL bmjinit(...)

CASE DEFAULT END SELECT cps_select

Match the package name in Registry

Subroutine cu_init(…) . USE module_cu_kf USE module_cu_bmj

.

CASE (CHENSCHEME) CALL cheninit(...)

phys/module_physics_init.F

USE module_cu_chen

Put intomodule_cu_chen.F

Page 27: Add a Physics Scheme  into WRF Model

WRF … solve_em

DYNAMICS

phy_init…

INIT

.

.

phy_prep

moist_physics_prep

Page 28: Add a Physics Scheme  into WRF Model

phy_prep/moist_physics_prep

• Calculate required variables

• Convert variables from C grid

to A grid

Page 29: Add a Physics Scheme  into WRF Model

WRF … solve_em

DYNAMICS

phy_init…

INIT

.

.

microphysics_driver

radiation_driver

cumulus_driver

pbl_driver

phy_prep

moist_physics_prep

chencps

Page 30: Add a Physics Scheme  into WRF Model

Three-level structure

solve_em

Physics_driverSELECT CASE (CHOICE) CASE ( NOPHY ) CASE ( SCHEME1 ) CALL XXX CASE ( SCHEME2 ) CALL YYY CASE DEFAULTEND SELECT

Individual physics scheme ( XXX )

Page 31: Add a Physics Scheme  into WRF Model

Go physics driver (cumulus_driver.F) Include the new module and create a new SELECT CASE in driver

Check available variables in drivers (variables are explained inside drivers)

cumulus_driver.F

Page 32: Add a Physics Scheme  into WRF Model

Subroutine cumulus_driver . USE module_cu_kf USE module_bmj_kf

.

cumulus_driver.F

USE module_cu_chen cps_select: SELECT CASE(config_flags%cu_physics) CASE (KFSCHEME) CALL KFCPS(...) CASE (BMJSCHEME) CALL BMJCPS(...)

CASE DEFAULTEND SELECT cps_select

Match the package name in Registry

Put inmodule_cu_chen.F

CASE (CHENSCHEME) CALL CHENCPS(...)

Page 33: Add a Physics Scheme  into WRF Model

SUBROUTINE cumulus_driver(arg1, arg2, … & newvar1, newvar2,… & its,ite,jts,jte,kts,kte, & ims,ime,jms,jme,kms,kme, & ids,ide,jds,jde,kds,kde )

INTEGER, INTENT(IN) :: its,ite,jts,jte,kts,kte, & ims,ime,jms,jme,kms,kme, & ids,ide,jds,jde,kds,kde REAL, INTENT(IN) :: arg1, arg2

REAL, INTENT(OUT), DIMENSION(kms:kme) :: & newvar1,newvar2,….

Physics_drive.int

Page 34: Add a Physics Scheme  into WRF Model

solve_em

cumulus_driver chencps

phy_prep

DYNAMICS

.

calculate_phy_tend

update_phy_ten phy_cu_ten

Might need to call MPP

Page 35: Add a Physics Scheme  into WRF Model

. CASE(BMJSCHEME) . CASE (CHENSCHEME) CALL add_a2a (rt_tendf, RTHCUTEN,… ) CALL add_a2c_u(ru_tendf,RUBLTEN,… ) CALL add_a2c_v(rv_tendf,RVBLTEN,… ) if (P_QS .ge. PARAM_FIRST_SCALAR) & CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN, .. & ids,ide, jds, jde, kds, kde, & ims, ime, jms, jme, kms, kme, & its, ite, jts, jte, kts, kte ) .

phys/module_physics_addtendc.F

Subroutine phy_cu_ten (… )

Page 36: Add a Physics Scheme  into WRF Model

MODULE_CU_CHEN

CONTRAINS!--------------------------------------------------------------------------SUBROUTINE cheninit (arg1, arg2, … ).ENDSUBROUTINE cheninit

SUBROUTINE chencps (arg3, arg4, … ).END SUBROUTINE chencps .

END MODULE_CU_CHEN

module_cu_chen.F