Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### Install and compiling the WRF-Model ###

## Installing the pre-requisites: ##

```Shell
sudo apt install csh gfortran m4 mpich libhdf5-mpich-dev libpng-dev libnetcdff-dev netcdf-bin ncl-ncarg build-essential
```

## Install Jasperlib: ##

```Shell
wget https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.29.tar.gz
tar xvf jasper-1.900.29.tar.gz
cd jasper-1.900.29/
./configure --prefix=/opt/jasper-1.900.29
make
sudo make install
```
40 changes: 40 additions & 0 deletions Registry/Registry.EM_COMMON
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,46 @@ state real itype_3 ikj misc 1 - hdu
state real NCA ij misc 1 - r "NCA" "COUNTER OF THE CLOUD RELAXATION TIME IN KF CUMULUS SCHEME" ""
state integer LOWLYR ij misc 1 - - "LOWLYR" "INDEX OF LOWEST MODEL LAYER ABOVE THE GROUND IN BMJ SCHEME" ""
state real MASS_FLUX ij misc 1 - r "MASS_FLUX" "DOWNDRAFT MASS FLUX FOR IN GRELL CUMULUS SCHEME" "mb hour-1"
# NN for RRTMG-K
state real i_play ikj misc 1 - rhdu "I_PLAY" "NNRA in" "hPa"
state real i_tlay ikj misc 1 - rhdu "I_TLAY" "NNRA in" "K"
state real i_h2ovmr ikj misc 1 - rhdu "I_H2OVMR" "NNRA in" "kg kg-1"
state real i_o3vmr ikj misc 1 - rhdu "I_O3VMR" "NNRA in" "ppmv"
state real i_cldfrac ikj misc 1 - rhdu "I_CLDFRAC" "NNRA in" "0-1"
state real i_o3 ij misc 1 - rhdu "I_O3" "NNRA in" "g m-2"
state real i_qc ij misc 1 - rhdu "I_QC" "NNRA in" "g m-2"
state real i_qi ij misc 1 - rhdu "I_QI" "NNRA in" "g m-2"
state real i_qs ij misc 1 - rhdu "I_QS" "NNRA in" "g m-2"
state real i_rel ikj misc 1 - rhdu "I_REI" "NNRA in" "um"
state real i_rei ikj misc 1 - rhdu "I_REL" "NNRA in" "um"
state real i_res ikj misc 1 - rhdu "I_RES" "NNRA in" "um"
state real i_clwpth ikj misc 1 - rhdu "I_CLWPTH" "NNRA in" "g m-2"
state real i_ciwpth ikj misc 1 - rhdu "I_CIWPTH" "NNRA in" "g m-2"
state real i_cswpth ikj misc 1 - rhdu "I_CSWPTH" "NNRA in" "g m-2"
state real i_coszen ij misc 1 - rhdu "I_COSZEN" "NNRA in" "-1~1"
state real i_albedo ij misc 1 - rhdu "I_ALBEDO" "NNRA in" "0-1"
state real i_tsfc ij misc 1 - rhdu "I_TSFC" "NNRA in" "K"
state real i_emiss ij misc 1 - rhdu "I_EMISS" "NNRA in" "0-1"
state real i_topo ij misc 1 - rhdu "I_TOPO" "NNRA in" "m"
state real o_rthratensw ikj misc 1 - rhdu "O_RTHRATENSW" "NNRA out" "K/s"
state real o_swupt ij misc 1 - rhdu "O_SWUPT" "NNRA out" "W m-2"
state real o_swuptc ij misc 1 - rhdu "O_SWUPTC" "NNRA out" "W m-2"
state real o_swdnt ij misc 1 - rhdu "O_SWDNT" "NNRA out" "W m-2"
state real o_swdntc ij misc 1 - rhdu "O_SWDNTC" "NNRA out" "W m-2"
state real o_swupb ij misc 1 - rhdu "O_SWUPB" "NNRA out" "W m-2"
state real o_swupbc ij misc 1 - rhdu "O_SWUPBC" "NNRA out" "W m-2"
state real o_swdnb ij misc 1 - rhdu "O_SWDNB" "NNRA out" "W m-2"
state real o_swdnbc ij misc 1 - rhdu "O_SWDNBC" "NNRA out" "K/s"
state real o_rthratenlw ikj misc 1 - rhdu "O_RTHRATENLW" "NNRA out" "W m-2"
state real o_lwupt ij misc 1 - rhdu "O_LWUPT" "NNRA out" "W m-2"
state real o_lwuptc ij misc 1 - rhdu "O_LWUPTC" "NNRA out" "W m-2"
state real o_lwupb ij misc 1 - rhdu "O_LWUPB" "NNRA out" "W m-2"
state real o_lwupbc ij misc 1 - rhdu "O_LWUPBC" "NNRA out" "W m-2"
state real o_lwdnt ij misc 1 - rhdu "O_LWDNT" "NNRA out" "W m-2"
state real o_lwdntc ij misc 1 - rhdu "O_LWDNTC" "NNRA out" "W m-2"
state real o_lwdnb ij misc 1 - rhdu "O_LWDNB" "NNRA out" "W m-2"
state real o_lwdnbc ij misc 1 - rhdu "O_LWDNBC" "NNRA out" "W m-2"

# ckay
state real cldfra_dp ikj misc 1 - r "CLDFRA_DP" "DEEP CONVECTIVE CLOUD FRACTION FROM KF" ""
state real cldfra_sh ikj misc 1 - r "CLDFRA_SH" "SHALLOW CONVECTIVE CLOUD FRACTION FROM KF" ""
Expand Down
24 changes: 23 additions & 1 deletion dyn_em/module_first_rk_step_part1.F
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ SUBROUTINE first_rk_step_part1 ( grid , config_flags &
INTEGER do_capsupress ! =1 do CAP supress, other = don't
#endif

! NN emulation
real, dimension( ims:ime, jms:jme ) :: topography
DO i = ims,ime
DO j = jms,jme
topography(i,j) = (grid%ph_2(i,1,j)+grid%phb(i,1,j))/9.81000042d0
ENDDO
ENDDO

CALL get_ijk_from_subgrid ( grid , &
sids, side, sjds, sjde, skds, skde, &
sims, sime, sjms, sjme, skms, skme, &
Expand Down Expand Up @@ -479,7 +487,21 @@ SUBROUTINE first_rk_step_part1 ( grid , config_flags &
& ,MP_PHYSICS=CONFIG_FLAGS%MP_PHYSICS &
& ,EFCG=grid%EFCG,EFCS=grid%EFCS,EFIG=grid%EFIG &
& ,EFIS=grid%EFIS,EFSG=grid%EFSG,aercu_opt=config_flags%aercu_opt &
& ,EFSS=grid%EFSS,QS_CU=grid%QS_CU &
& ,EFSS=grid%EFSS,QS_CU=grid%QS_CU & ! for NN emulation (Song, 2019-12-03)
& ,I_PLAY=grid%i_play, I_TLAY=grid%i_tlay, I_H2OVMR=grid%i_h2ovmr, I_O3VMR=grid%i_o3vmr &
& ,I_CLDFRAC=grid%i_cldfrac, I_O3=grid%i_o3, I_QC=grid%i_qc, I_QI=grid%i_qi &
& ,I_QS=grid%i_qs, I_REL=grid%i_rel, I_REI=grid%i_rei, I_RES=grid%i_res &
& ,I_CLWPTH=grid%i_clwpth, I_CIWPTH=grid%i_ciwpth, I_CSWPTH=grid%i_cswpth &
& ,I_TSFC=grid%i_tsfc, I_EMISS=grid%i_emiss &
& ,I_COSZEN=grid%i_coszen, I_ALBEDO=grid%i_albedo &
& ,O_RTHRATENSW=grid%o_rthratensw, O_RTHRATENLW=grid%o_rthratenlw &
& ,O_SWUPT=grid%o_swupt, O_SWUPTC=grid%o_swuptc &
& ,O_SWDNT=grid%o_swdnt, O_SWDNTC=grid%o_swdntc, O_SWUPB=grid%o_swupb &
& ,O_SWUPBC=grid%o_swupbc, O_SWDNB=grid%o_swdnb, O_SWDNBC=grid%o_swdnbc &
& ,O_LWUPT=grid%o_lwupt, O_LWUPTC=grid%o_lwuptc &
& ,O_LWDNT=grid%o_lwdnt, O_LWDNTC=grid%o_lwdntc, O_LWUPB=grid%o_lwupb &
& ,O_LWUPBC=grid%o_lwupbc, O_LWDNB=grid%o_lwdnb, O_LWDNBC=grid%o_lwdnbc &
& ,I_TOPO=grid%i_topo, TOPOGRAPHY=topography &
& ,feedback_is_ready=feedback_is_ready &
#if ( WRF_CMAQ == 1)
& ,mass_ws_i=grid%mass_ws_i &
Expand Down
65 changes: 64 additions & 1 deletion phys/module_ra_rrtmg_swk.F
Original file line number Diff line number Diff line change
Expand Up @@ -10196,7 +10196,13 @@ subroutine rad_rrtmg_driver( &
!sh
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte )
its,ite, jts,jte, kts,kte, &
! for NN emulation
i_play, i_tlay, i_h2ovmr, i_o3vmr, i_cldfrac, i_o3, i_qc, i_qi, i_qs, &
i_rel, i_rei, i_res, i_clwpth, i_ciwpth, i_cswpth, &
i_albedo, i_coszen, i_tsfc, i_emiss, o_rthratensw, o_rthratenlw, &
o_swupt, o_swuptc, o_swdnt, o_swdntc, o_swupb, o_swupbc, o_swdnb, o_swdnbc, &
o_lwupt, o_lwuptc, o_lwdnt, o_lwdntc, o_lwupb, o_lwupbc, o_lwdnb, o_lwdnbc, i_topo, topography )
!-------------------------------------------------------------------------------
! abstract : unified rrtmg sw lw driver
!
Expand Down Expand Up @@ -10334,6 +10340,15 @@ subroutine rad_rrtmg_driver( &
real, dimension(its:ite) :: xice
integer :: dyofyr

! for NN emulation
real, dimension(ims:ime,kms:kme,jms:jme) :: &
i_play, i_tlay, i_h2ovmr, i_o3vmr, i_cldfrac, o_rthratensw, o_rthratenlw, &
i_rel, i_rei, i_res, i_clwpth, i_ciwpth, i_cswpth

real, dimension(ims:ime,jms:jme) :: &
i_tsfc, i_emiss, i_coszen, i_albedo, i_o3, i_qc, i_qi, i_qs, &
o_swupt, o_swuptc, o_swdnt, o_swdntc, o_swupb, o_swupbc, o_swdnb, o_swdnbc, &
o_lwupt, o_lwuptc, o_lwdnt, o_lwdntc, o_lwupb, o_lwupbc, o_lwdnb, o_lwdnbc, i_topo, topography

!
! Set trace gas volume mixing ratios, 2005 values, IPCC (2007)
Expand Down Expand Up @@ -10852,6 +10867,54 @@ subroutine rad_rrtmg_driver( &
lwupbc(i,j) = uflxc(1,1)
lwdnb(i,j) = dflx(1,1)
lwdnbc(i,j) = dflxc(1,1)

! Inputs for NN emulation
i_play(i,:,j) = play(1,:) ! pressure (hPa)
i_tlay(i,:,j) = tlay(1,:) ! temperature (K)
i_h2ovmr(i,:,j) = h2ovmr(1,:) ! water vapor mixing ratio (kg/kg)
i_o3vmr(i,:,j) = o3vmr(1,:) ! ozone mixing ratio (ppmv)
i_cldfrac(i,:,j) = cldfrac(1,:) ! layer cloud fraction
i_o3(i,j) = 0
i_qc(i,j) = 0
i_qi(i,j) = 0
i_qs(i,j) = 0
do k = kts, kte
i_o3(i,j) = o3vmr(1,k)*pdel(k)*1000./g + o3vmr(1,k) ! g m-2
i_qc(i,j) = clwpth(1,k) + i_qc(i,j) ! liquid water path
i_qi(i,j) = ciwpth(1,k) + i_qi(i,j) ! ice water path
i_qs(i,j) = cswpth(1,k) + i_qs(i,j) ! snow water path
enddo
i_rel(i,:,j) = rel(1,:) ! cloud liquid effective radius (um)
i_rei(i,:,j) = rei(1,:) ! cloud ice effective radius (um)
i_res(i,:,j) = res(1,:) ! cloud snow effective radius (um)
i_clwpth(i,:,j) = clwpth(1,:) ! layer cloud liquid water path (g/m2)
i_ciwpth(i,:,j) = ciwpth(1,:) ! layer cloud ice water path (g/m2)
i_cswpth(i,:,j) = cswpth(1,:) ! layer cloud snow water path (g/m2)
i_tsfc(i,j) = tsfc(1) ! surface temperature (K)
i_emiss(i,j) = emiss(i,j) ! surface emissivity
i_coszen(i,j) = coszen(1) ! cosine of solar zenith angle
i_albedo(i,j) = albedo(i,j) ! surface albedo
i_topo(i,j) = topography(i,j) ! surface elevation OR topography
! Outputs for NN emulation
o_rthratensw(i,:,j) = rthratensw(i,:,j) ! total sky shortwave radiative heating rate (K/s)
o_swupt(i,j) = swupt(i,j) ! total sky shortwave upward flux at TOA (W/m2)
o_swuptc(i,j) = swuptc(i,j) ! clear sky shortwave upward flux at TOA (W/m2)
o_swdnt(i,j) = swdnt(i,j) ! total sky shortwave downward flux at TOA (W/m2)
o_swdntc(i,j) = swdntc(i,j) ! clear sky shortwave downward flux at TOA (W/m2)
o_swupb(i,j) = swupb(i,j) ! total sky shortwave upward flux at surface (W/m2)
o_swupbc(i,j) = swupbc(i,j) ! clear sky shortwave upward flux at surface (W/m2)
o_swdnb(i,j) = swdnb(i,j) ! total sky shortwave downward flux at surface (W/m2)
o_swdnbc(i,j) = swdnbc(i,j) ! clear sky shortwave downward flux at surface (W/m2)
o_rthratenlw(i,:,j) = rthratenlw(i,:,j) ! total sky longwave radiative heating rate (K/s)
o_lwupt(i,j) = lwupt(i,j) ! total sky longwave upward flux at TOA (W/m2)
o_lwuptc(i,j) = lwuptc(i,j) ! clear sky longwave upward flux at TOA (W/m2)
o_lwdnt(i,j) = lwdnt(i,j) ! total sky longwave downward flux at TOA (W/m2)
o_lwdntc(i,j) = lwdntc(i,j) ! clear sky longwave downward flux at TOA (W/m2)
o_lwupb(i,j) = lwupb(i,j) ! total sky longwave upward flux at surface (W/m2)
o_lwupbc(i,j) = lwupbc(i,j) ! clear sky longwave upward flux at surface (W/m2)
o_lwdnb(i,j) = lwdnb(i,j) ! total sky longwave downward flux at surface (W/m2)
o_lwdnbc(i,j) = lwdnbc(i,j) ! clear sky longwave downward flux at surface (W/m2)

enddo ! jts:jte end j LOOP
enddo ! its:ite end GRAND LOOP
end subroutine rad_rrtmg_driver
Expand Down
29 changes: 28 additions & 1 deletion phys/module_radiation_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ SUBROUTINE radiation_driver ( &
,chem_opt &
,gsfcrad_gocart_coupling &
#endif
,i_play, i_tlay, i_h2ovmr, i_o3vmr, i_cldfrac, i_o3, i_qc, i_qi, i_qs &
,i_rel, i_rei, i_res, i_clwpth, i_ciwpth, i_cswpth &
,i_coszen, i_albedo, i_tsfc, i_emiss, o_rthratensw, o_rthratenlw &
,o_swupt, o_swuptc, o_swdnt, o_swdntc, o_swupb, o_swupbc, o_swdnb, o_swdnbc &
,o_lwupt, o_lwuptc, o_lwdnt, o_lwdntc, o_lwupb, o_lwupbc, o_lwdnb, o_lwdnbc, i_topo, topography &
,feedback_is_ready & ! WRF-CMAQ twoway coupled model
,mass_ws_i & ! WRF-CMAQ twoway coupled model
,mass_ws_j & ! WRF-CMAQ twoway coupled model
Expand Down Expand Up @@ -1017,6 +1022,17 @@ SUBROUTINE radiation_driver ( &
INTEGER, PARAMETER:: taer_ssa_opt = 3 ! input option for aerosol ssa
INTEGER, PARAMETER:: taer_asy_opt = 3 ! input option for aerosol asy


! for NN emulation
real, dimension(ims:ime,kms:kme,jms:jme) :: &
i_play, i_tlay, i_h2ovmr, i_o3vmr, i_cldfrac, o_rthratensw, o_rthratenlw, &
i_rel, i_rei, i_res, i_clwpth, i_ciwpth, i_cswpth
real, dimension(ims:ime,jms:jme) :: &
i_tsfc, i_emiss, i_coszen, i_albedo, i_o3, i_qc, i_qi, i_qs, i_topo, &
o_swupt, o_swuptc, o_swdnt, o_swdntc, o_swupb, o_swupbc, o_swdnb, o_swdnbc, &
o_lwupt, o_lwuptc, o_lwdnt, o_lwdntc, o_lwupb, o_lwupbc, o_lwdnb, o_lwdnbc
real, dimension(ims:ime, jms:jme) :: nn_lon, nn_lat, topography

! WRF-Solar EPS
real, dimension(:, :, :), allocatable :: qv_tmp, qc_tmp, qs_tmp

Expand Down Expand Up @@ -2103,6 +2119,11 @@ SUBROUTINE radiation_driver ( &
#if( BUILD_RRTMK == 1)
CASE (RRTMK_LWSCHEME)

! NN emulator
nn_lon(ims:ime,jms:jme) = XLONG(ims:ime,jms:jme)
nn_lat(ims:ime,jms:jme) = XLAT(ims:ime,jms:jme)


IF ( PRESENT(F_QNC) .AND. PRESENT(QNC_CURR) ) THEN
call rad_rrtmg_driver( &
RTHRATEN, RTHRATENSW, &
Expand All @@ -2125,7 +2146,13 @@ SUBROUTINE radiation_driver ( &
aer_opt, aerod, no_src_types, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
its,ite, jts,jte, kts,kte, &
! for NN emulation
i_play, i_tlay, i_h2ovmr, i_o3vmr, i_cldfrac, i_o3, i_qc, i_qi, i_qs, &
i_rel, i_rei, i_res, i_clwpth, i_ciwpth, i_cswpth, &
i_albedo, i_coszen, i_tsfc, i_emiss, o_rthratensw, o_rthratenlw, &
o_swupt, o_swuptc, o_swdnt, o_swdntc, o_swupb, o_swupbc, o_swdnb, o_swdnbc, &
o_lwupt, o_lwuptc, o_lwdnt, o_lwdntc, o_lwupb, o_lwupbc, o_lwdnb, o_lwdnbc, i_topo, topography )
ELSE
call wrf_error_fatal('Can not call RRTMG-K. Missing QNC field.')
ENDIF
Expand Down