@@ -309,6 +309,42 @@ subroutine define_clm_statevec(mype)
309309 endif
310310 ! end hcp
311311
312+ ! skin temperature state vector
313+ if (clmupdate_T.eq. 2 ) then
314+
315+ IF (allocated (state_clm2pdaf_p)) deallocate (state_clm2pdaf_p)
316+ allocate (state_clm2pdaf_p(begp:endp,1 ))
317+
318+ do p= clm_begp,clm_endp
319+ state_clm2pdaf_p(p,1 ) = (p - clm_begp + 1 )
320+ end do
321+
322+ clm_varsize = endp- begp+1
323+ ! clm_paramsize = endp-begp+1 !LAI
324+ clm_statevecsize = (endp- begp+1 ) ! TSKIN
325+
326+ IF (allocated (state_pdaf2clm_p_p)) deallocate (state_pdaf2clm_p_p)
327+ allocate (state_pdaf2clm_p_p(clm_statevecsize))
328+ IF (allocated (state_pdaf2clm_c_p)) deallocate (state_pdaf2clm_c_p)
329+ allocate (state_pdaf2clm_c_p(clm_statevecsize))
330+ IF (allocated (state_pdaf2clm_j_p)) deallocate (state_pdaf2clm_j_p)
331+ allocate (state_pdaf2clm_j_p(clm_statevecsize))
332+
333+ cc = 0
334+
335+ do p= clm_begp,clm_endp
336+ cc = cc + 1
337+ state_pdaf2clm_p_p(cc) = p ! TG
338+ state_pdaf2clm_c_p(cc) = patch% column(p) ! TG
339+ state_pdaf2clm_j_p(cc) = 1
340+ state_pdaf2clm_p_p(cc+ clm_varsize) = p ! TV
341+ state_pdaf2clm_c_p(cc+ clm_varsize) = patch% column(p) ! TV
342+ state_pdaf2clm_j_p(cc+ clm_varsize) = 1
343+ end do
344+
345+ endif
346+
347+
312348#ifdef PDAF_DEBUG
313349 ! Debug output of clm_statevecsize
314350 WRITE (* , ' (a,x,a,i5,x,a,i10)' ) " TSMP-PDAF-debug" , " mype(w)=" , mype, " define_clm_statevec: clm_statevecsize=" , clm_statevecsize
@@ -323,7 +359,7 @@ subroutine define_clm_statevec(mype)
323359
324360 ! write(*,*) 'clm_paramsize is ',clm_paramsize
325361 if (allocated (clm_paramarr)) deallocate (clm_paramarr) ! hcp
326- if ((clmupdate_T.ne. 0 )) then ! hcp
362+ if ((clmupdate_T.eq. 1 )) then ! hcp
327363 allocate (clm_paramarr(clm_paramsize))
328364 end if
329365
@@ -374,6 +410,7 @@ subroutine set_clm_statevec(tstartcycle, mype)
374410 ! LST variables (t_veg is patch variable...)
375411 t_grnd = > temperature_inst% t_grnd_col
376412 t_veg = > temperature_inst% t_veg_patch
413+ t_skin = > temperature_inst% t_skin_patch
377414 tlai = > canopystate_inst% tlai_patch
378415
379416
@@ -416,6 +453,14 @@ subroutine set_clm_statevec(tstartcycle, mype)
416453 endif
417454 ! end hcp LAI
418455
456+ ! skin temperature state vector
457+ if (clmupdate_T.eq. 2 ) then
458+ do cc = 1 , clm_statevecsize
459+ ! t_skin iterated over patches
460+ clm_statevec(cc) = t_skin(state_pdaf2clm_p_p(cc))
461+ end do
462+ endif
463+
419464 ! write average swc to state vector (CRP assimilation)
420465 if (clmupdate_swc.eq. 2 ) then
421466 error stop " Not implemented: clmupdate_swc.eq.2"
@@ -521,6 +566,7 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
521566 ! LST
522567 t_grnd = > temperature_inst% t_grnd_col
523568 t_veg = > temperature_inst% t_veg_patch
569+ t_skin = > temperature_inst% t_skin_patch
524570 ! tlai => canopystate_inst%tlai_patch
525571
526572#ifdef PDAF_DEBUG
@@ -678,6 +724,14 @@ subroutine update_clm(tstartcycle, mype) bind(C,name="update_clm")
678724 endif
679725 ! end hcp TG, TV
680726
727+ ! skin temperature state vector
728+ if (clmupdate_T.EQ. 2 ) then
729+ do p = clm_begp, clm_endp
730+ c = patch% column(p)
731+ t_skin(p) = clm_statevec(state_clm2pdaf_p(p,1 ))
732+ end do
733+ endif
734+
681735 ! ! update liquid water content
682736 ! do j=clm_begg,clm_endg
683737 ! do i=1,nlevsoi
0 commit comments