42c42,45
<       INTEGER     :: sm31 , em31 , sm32 , em32 , sm33 , em33
---
> !  see http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm
>    INTEGER     :: sm31 , em31 , sm32 , em32 , sm33 , em33
>    INTEGER     :: sm31x, em31x, sm32x, em32x, sm33x, em33x
>    INTEGER     :: sm31y, em31y, sm32y, em32y, sm33y, em33y
117a121,129
> #ifdef DEREF_KLUDGE
> !  see http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm
>       INTEGER     :: sm31 , em31 , sm32 , em32 , sm33 , em33
>       INTEGER     :: sm31x, em31x, sm32x, em32x, sm33x, em33x
>       INTEGER     :: sm31y, em31y, sm32y, em32y, sm33y, em33y
> #endif
> 
> #include "deref_kludge.h"
> 
181a194,202
>       !  Save the TSK field for later use in the sea ice surface temperature
>       !  for the Noah LSM scheme.
> 
>        DO j = jts, MIN(jte,jde-1)
>          DO i = its, MIN(ite,ide-1)
>             tsk_save(i,j) = tsk(i,j)
>          END DO
>       END DO
> 
203a225,245
>       !  We require input data for the various LSM schemes.
> 
>       enough_data : SELECT CASE ( model_config_rec%sf_surface_physics(grid%id) )
> 
>          CASE (SLABSCHEME)
>             IF ( num_st_levels_input .LT. 2 ) THEN
>                CALL wrf_error_fatal ( 'Not enough soil temperature data for 5-layer soil scheme.')
>             END IF
> 
>          CASE (LSMSCHEME)
>             IF ( num_st_levels_input .LT. 2 ) THEN
>                CALL wrf_error_fatal ( 'Not enough soil temperature data for Noah LSM scheme.')
>             END IF
> 
>          CASE (RUCLSMSCHEME)
>             IF ( num_st_levels_input .LT. 2 ) THEN
>                CALL wrf_error_fatal ( 'Not enough soil temperature data for RUC LSM scheme.')
>             END IF
> 
>       END SELECT enough_data
> 
465c507
<       CALL adjust_for_seaice_post ( xice , landmask , tsk , ivgtyp , vegcat , lu_index , &
---
>       CALL adjust_for_seaice_post ( xice , landmask , tsk , tsk_save , ivgtyp , vegcat , lu_index , &
467c509
<                                     soilcbot , tmn , &
---
>                                     soilcbot , tmn , vegfra , &
517a560,567
> ! fill sst array with tsk if missing in real input (needed for time-varying sst in wrf)
>       DO j = jts, MIN(jde-1,jte)
>          DO i = its, MIN(ide-1,ite)
>            IF ( flag_sst .NE. 1 ) THEN
>              sst(i,j) = tsk(i,j)
>            ENDIF
>          END DO
>       END DO
711c761
<             qvf1 = 0.5*(moist_2(i,k,j,P_QV)+moist_2(i,k,j,P_QV))
---
>             qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k,j,P_QV))
716c766
<             qvf = 1. + rvovrd*moist_2(i,k,j,P_QV)
---
>             qvf = 1. + rvovrd*moist(i,k,j,P_QV)
724c774
<                qvf1 = 0.5*(moist_2(i,k,j,P_QV)+moist_2(i,k+1,j,P_QV))
---
>                qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k+1,j,P_QV))
728c778
<                qvf = 1. + rvovrd*moist_2(i,k,j,P_QV)
---
>                qvf = 1. + rvovrd*moist(i,k,j,P_QV)
745a796,817
>       DO j = jts, min(jde-1,jte)
>          DO i = its, min(ide,ite)
>             u10(i,j)=u_2(i,1,j)
>          END DO
>       END DO
> 
>       DO j = jts, min(jde,jte)
>          DO i = its, min(ide-1,ite)
>             v10(i,j)=v_2(i,1,j)
>          END DO
>       END DO
> 
>       DO j = jts, min(jde-1,jte)
>          DO i = its, min(ide-1,ite)
>             p_surf = p00 * EXP ( -t00/a + ( (t00/a)**2 - 2.*g*ht(i,j)/a/r_d ) **0.5 ) 
>             psfc(i,j)=p_surf + p(i,1,j)
>             q2(i,j)=moist(i,1,j,P_QV)
>             th2(i,j)=t_2(i,1,j)+300.
>             t2(i,j)=th2(i,j)*(((p(i,1,j)+pb(i,1,j))/p00)**(r_d/cp))
>          END DO
>       END DO
> 
781a854
> !  see http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm
782a856,857
>       INTEGER     :: sm31x, em31x, sm32x, em32x, sm33x, em33x
>       INTEGER     :: sm31y, em31y, sm32y, em32y, sm33y, em33y
825a901,909
> #ifdef DEREF_KLUDGE
> !  see http://www.mmm.ucar.edu/wrf/WG2/topics/deref_kludge.htm
>       INTEGER     :: sm31 , em31 , sm32 , em32 , sm33 , em33
>       INTEGER     :: sm31x, em31x, sm32x, em32x, sm33x, em33x
>       INTEGER     :: sm31y, em31y, sm32y, em32y, sm33y, em33y
> #endif
> 
> #include "deref_kludge.h"
> 
961c1045
<             qvf1 = 0.5*(moist_2(i,k,j,P_QV)+moist_2(i,k,j,P_QV))
---
>             qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k,j,P_QV))
966c1050
<             qvf = 1. + rvovrd*moist_2(i,k,j,P_QV)
---
>             qvf = 1. + rvovrd*moist(i,k,j,P_QV)
974c1058
<                qvf1 = 0.5*(moist_2(i,k,j,P_QV)+moist_2(i,k+1,j,P_QV))
---
>                qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k+1,j,P_QV))
978c1062
<                qvf = 1. + rvovrd*moist_2(i,k,j,P_QV)
---
>                qvf = 1. + rvovrd*moist(i,k,j,P_QV)