Skip to content

Commit

Permalink
write lmc with mwrtm no matter landassim status (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyuan-jiang committed Jul 22, 2020
1 parent bed6cbc commit 2d5c156
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/Components/GEOSldas_GridComp/GEOS_LdasGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,12 @@ subroutine Run(gc, import, export, clock, rc)

enddo

if ( mwRTM .and. LSM_CHOICE == 1 ) then
! output_smapl4smlmc
call ESMF_GridCompRun(gcs(LANDASSIM), importState=gim(LANDASSIM), exportState=gex(LANDASSIM), clock=clock,phase=4, userRC=status)
VERIFY_(status)
endif

! Run land analysis
if (land_assim) then
igc = LANDASSIM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ subroutine SetServices ( GC, RC )
)
_VERIFY(status)

!phase 4: output_smapl4smlmc
call MAPL_GridCompSetEntryPoint( &
gc, &
ESMF_METHOD_RUN, &
OUTPUT_SMAPL4SMLMC, &
rc=status &
)
_VERIFY(status)

call MAPL_GridCompSetEntryPoint( &
gc, &
ESMF_METHOD_FINALIZE, &
Expand Down Expand Up @@ -1452,20 +1461,21 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )

! Pointers to internals
!----------------------
if (mwRTM) then
call get_mwrtm_param(INTERNAL, N_catl, rc=STATUS)
_VERIFY(STATUS)
endif
!if (mwRTM) then
! call get_mwrtm_param(INTERNAL, N_catl, rc=STATUS)
! _VERIFY(STATUS)
!endif

! assert mwRTM parameters are not nodata for all tiles
if (mwRTM_all_nodata) then
_ASSERT(.false., "Tb innovations or assimilation requested but all mwRTM parameters are nodata")
endif

if (firsttime) then
firsttime = .false.
if (mwRTM) &
call GEOS_output_smapL4SMlmc( GC, start_time, trim(out_path), trim(exp_id), &
N_catl, tile_coord_l, cat_param, mwRTM_param )
!if (mwRTM) &
! call GEOS_output_smapL4SMlmc( GC, start_time, trim(out_path), trim(exp_id), &
! N_catl, tile_coord_l, cat_param, mwRTM_param )
if (root_proc) then
! for out put
call read_cat_bias_inputs( trim(out_path), trim(exp_id), start_time, update_type, &
Expand Down Expand Up @@ -2260,7 +2270,75 @@ subroutine CALC_LAND_TB(gc, import, export, clock, rc)

RETURN_(_SUCCESS)
end subroutine CALC_LAND_TB


subroutine OUTPUT_SMAPL4SMLMC(gc, import, export, clock, rc)
type(ESMF_GridComp), intent(inout) :: gc ! Gridded component
type(ESMF_State), intent(inout) :: import ! Import state
! this import is from land grid component
type(ESMF_State), intent(inout) :: export ! Export state
type(ESMF_Clock), intent(inout) :: clock ! The clock
integer, optional, intent( out) :: rc ! Error code

integer :: status
character(len=ESMF_MAXSTR) :: Iam='Output_smapL4SMlmc'
character(len=ESMF_MAXSTR) :: comp_name
! MAPL variables
type(MAPL_MetaComp), pointer :: MAPL=>null() ! MAPL obj
type(ESMF_State) :: INTERNAL
type(T_TILECOORD_STATE), pointer :: tcinternal
type(TILECOORD_WRAP) :: tcwrap
type(tile_coord_type), dimension(:), pointer :: tile_coord_l => null()
character(len=300) :: out_path
character(len=ESMF_MAXSTR) :: exp_id
integer :: N_catl
type(MAPL_LocStream) :: locstream
type(ESMF_Time) :: ModelTimeCur
type(date_time_type) :: start_time
logical, save :: first_time = .true.

if (.not. first_time) then
_RETURN(_SUCCESS)
endif

call ESMF_GridCompGet ( GC, name=COMP_NAME, RC=STATUS )
_VERIFY(STATUS)

call MAPL_GetObjectFromGC ( GC, MAPL, RC=STATUS )
_VERIFY(status)
call MAPL_Get(MAPL, LocStream=locstream,rc=status)
_VERIFY(status)
call MAPL_LocStreamGet(locstream, NT_LOCAL=N_catl,rc=status)
_VERIFY(status)

call ESMF_UserCompGetInternalState(gc, 'TILE_COORD', tcwrap, status)
_VERIFY(status)
tcinternal =>tcwrap%ptr
tile_coord_l =>tcinternal%tile_coord

call MAPL_Get(MAPL, INTERNAL_ESMF_STATE=INTERNAL, rc=status)
_VERIFY(status)

call MAPL_GetResource ( MAPL, out_path, Label="OUT_PATH:", DEFAULT="./", RC=STATUS)
_VERIFY(STATUS)
call MAPL_GetResource ( MAPL, exp_id, Label="EXP_ID:", DEFAULT="exp_id", RC=STATUS)
_VERIFY(STATUS)
! Get current time
call ESMF_ClockGet(clock, currTime=ModelTimeCur, rc=status)
_VERIFY(status)
call esmf2ldas(ModelTimeCur, start_time, rc=status)
_VERIFY(status)

call get_mwrtm_param(INTERNAL, N_catl, rc=status)
_VERIFY(status)

call GEOS_output_smapL4SMlmc( GC, start_time, trim(out_path), trim(exp_id), &
N_catl, tile_coord_l, cat_param, mwRTM_param )
first_time = .false.

_RETURN(_SUCCESS)

end subroutine OUTPUT_SMAPL4SMLMC

! ******************************************************************************

subroutine read_pert_rseed(id_string,seed_fname,pert_rseed_r8)
Expand Down

0 comments on commit 2d5c156

Please sign in to comment.