﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
916	VERY IMPORTANT:  Update WRF ESMF/NUOPC cap module	arango		"We have carefully examined the **DATA-WRF-ROMS** coupling system with the **ESMF/NUOPC** library. We fixed [[span(style=color: #0000FF, **esmf_atm_wrf.h**)]] **NUOPC** ''cap'' module after a detailed analysis of the heat flux balance equation. The documentation of WRF fluxes in the code is confusing about the direction (downward/upward) and the sign (positive/negative) of the **latent** and **sensible** heat fluxes. The [[span(style=color: #FF0000,net heat flux)]] previously exported from WRF to ROMS was incorrect due to the confusing information.

* There are several variables in WRF for the heat component fluxes:

  -- There is downwelling shortwave flux (**swdnb**, downward) and upwelling shortwave flux (**swupb**, upward) at the atmosphere bottom. Both are positive and with W/m^2^ units. Therefore, the net shortwave radiation flux is **swdnb** minus **swupb**, stored in variable **gsw**, is positive and downward since **swupb** is around 8 percent of the magnitude of **swdnb**. Notice that the variable **swdown** is equivalent to **swdnb**. Both are positive and with W/m^2^ units.

  -- Since the ocean needs [[span(style=color: #FF0000,net shortwave radiation flux)]], we decided to use the downward (**swdnb**) and upward (**swupb**) fluxes for clarity. Also, the time-averaged values **swdnb_mean** and **swupb_mean** are available when the RAMS diagnostics are activated for semi-implicit coupling.

 -- Similarly, there is downwelling longtwave flux (**lwdnb**, downward) and upwelling longwave flux (**lwupb**, upward) at the atmosphere bottom. The variable **lwupb** is basically [[span(style=color: #0000FF,''!StefBo * emiss * Tsur^4^'')]]. **Tsur** is the land and ocean temperature at the atmosphere bottom (Kelvin). Likewise, notice that the variable **glw** is equivalent to **lwdnb**. We will use **glw** because its equivalent time-averaged variable is **glw_mean** when the RAMS diagnostics are activated for semi-implicit coupling. The [[span(style=color: #FF0000,net longwave radiation flux)]], **glw** minus **lwupb**, can be positive or negative.

 -- The variable **hfx** is the sensible heat flux (W/m^2^), and **lh** is the latent heat flux (W/m^2^). Both fluxes are **positive** and **upward** from the bottom of the atmosphere. [[span(style=color: #0000FF,Please ignore the conflicting documentation in the WRF source code for these fluxes)]]. The time-averaged values are **hfx_mean** and **lh_mean**, respectively. Therefore, we need to flip the sign and use **minus** when computing the ocean [[span(style=color: #FF0000,surface net heat flux)]].

 -- Therefore, if **BULK_FLUXES** is off, the [[span(style=color: #FF0000, surface net heat flux)]] (W/m^2^) exported to the ocean in subroutine [[span(style=color: #FF0000, **WRF_Export**)]] of ''cap'' module [[span(style=color: #0000FF, **esmf_atm_wrf.h**)]] needs to be:
 {{{
            CASE ('nflx', 'shflux')
              MyFmin(1)= MISSING_dp
              MyFmax(1)=-MISSING_dp
              DO j=Jstr,Jend
                DO i=Istr,Iend
# ifdef WRF_TIMEAVG
                  Fval=(grid%swdnb_mean(i,j)-grid%swupb_mean(i,j))+     &
     &                 (grid%glw_mean(i,j)-grid%lwupb_mean(i,j))-       &
     &                 grid%lh_mean (i,j)-                              &
     &                 grid%hfx_mean(i,j)
# else
                  Fval=(grid%swdnb(i,j)-grid%swupb(i,j))+               &
     &                 (grid%glw(i,j)-grid%lwupb(i,j))-                 &
     &                 grid%lh (i,j)-                                   &
     &                 grid%hfx(i,j)
# endif
                  MyFmin(1)=MIN(MyFmin(1),Fval)
                  MyFmax(1)=MAX(MyFmax(1),Fval)
                  ptr2d(i,j)=Fval
                END DO
              END DO
}}}
 Here, the CPP option **WRF_TIMEAVG** is used to compute the flux with the RAMS time-averaged diagnostics for semi-implicit coupling (see [https://www.myroms.org/wiki/Model_Coupling RunSequence in wikiROMS]).

* Several routines in ROMS were updated to allow importing the components of the heat flux balance for debugging and output purposes when **BULK_FLUXES** is off.

* The test case for Hurricane Irene has been revised accordingly in the **test** repository. Please check this application when configuring your coupling system. 

----

 Snapshots of WRF land and ocean surface temperature and heat flux components are shown below for the hurricane Irene application:

[[Image(https://www.myroms.org/trac/wrf_irene_tsur.png, center, 600)]] 

[[Image(https://www.myroms.org/trac/wrf_irene_swflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/wrf_irene_lwflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/wrf_irene_lhflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/wrf_irene_shflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/wrf_irene_nhflx.png, center, 600)]]

----

 Then, the atmospheric field imported by ROMS are:

[[Image(https://www.myroms.org/trac/roms_irene_swflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_lwflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_lhflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_shflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_nhflx.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_EminusP.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_wstress.png, center, 600)]]

[[Image(https://www.myroms.org/trac/roms_irene_pair.png, center, 600)]]

----

Many thanks to my colleagues at Rutgers, John Wilkin, Julia Levin, and Travis Miles, for the discussions about WRF-ROMS coupling."	upgrade	new	major	Release ROMS/TOMS 4.1	Nonlinear	4.0			
