Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add landice gridcomp #18

Draft
wants to merge 27 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
70df564
initial check in (it can be built)
weiyuan-jiang Feb 9, 2024
6566c79
Merge branch 'develop' into feature/wjiang/add_landice
gmao-rreichle Feb 16, 2024
7bd6302
fixed locstream and timer for LANDICE
weiyuan-jiang Feb 19, 2024
b5be8c0
Merge branch 'feature/wjiang/add_landice' of github.com:GEOS-ESM/GEOS…
weiyuan-jiang Feb 19, 2024
157004f
add landice grid comp
weiyuan-jiang Apr 9, 2024
a145779
add postprocess for landice
weiyuan-jiang Apr 9, 2024
a09206b
Merge branch 'feature/wjiang/add_landice_1' into feature/wjiang/add_l…
weiyuan-jiang Apr 10, 2024
199ddc1
remove unnecessary arguments
weiyuan-jiang Apr 12, 2024
54304cd
Merge branch 'develop' into feature/wjiang/add_landice
weiyuan-jiang Apr 12, 2024
0c5bf7c
distribute forces
weiyuan-jiang Apr 25, 2024
430a4d6
use partial tiel_coord in metforce
weiyuan-jiang Apr 25, 2024
2184d72
change local index to global index
weiyuan-jiang Apr 26, 2024
9c0b76f
remove name '_internal" from landassim_obs...
weiyuan-jiang Apr 26, 2024
dddd9f1
rename model to landmodel
weiyuan-jiang Apr 29, 2024
1ea1c10
Merge branch 'develop' into feature/wjiang/add_landice
gmao-rreichle May 17, 2024
8bfa673
Merge branch 'develop' into feature/wjiang/add_landice
gmao-rreichle Jun 13, 2024
d553e78
first check in for mapping files
weiyuan-jiang Jun 17, 2024
e158958
change f2g contents for other tile types
weiyuan-jiang Jul 17, 2024
abfe6f0
works for no zoom in
weiyuan-jiang Jul 18, 2024
0242100
good for zoomin without other tile types
weiyuan-jiang Jul 18, 2024
72c8daf
create zoomin landice restart and more cleanup
weiyuan-jiang Aug 14, 2024
13f7bac
working...
weiyuan-jiang Aug 16, 2024
d4936a6
consolidate creating the restarts
weiyuan-jiang Aug 19, 2024
18102e8
Merge branch 'develop' into feature/wjiang/add_landice
biljanaorescanin Aug 19, 2024
2c5102e
bug fix
weiyuan-jiang Aug 19, 2024
10709a4
more bug fix
weiyuan-jiang Aug 19, 2024
6f343db
bug fixed (i_indg) and add LAND_TYPES item
weiyuan-jiang Aug 29, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added landice grid comp

### Changed

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ esma_add_library(${this}
SRCS GEOS_LdasGridComp.F90
SUBCOMPONENTS ${alldirs}
SUBDIRS LDAS_Shared
DEPENDENCIES GEOSland_GridComp makebcs MAPL
DEPENDENCIES GEOSland_GridComp GEOSlandice_GridComp makebcs MAPL
INCLUDES ${INC_ESMF})

esma_add_subdirectory(GEOSldas_App)
127 changes: 91 additions & 36 deletions GEOS_LdasGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module GEOS_LdasGridCompMod
use GEOS_LandPertGridCompMod, only: LandPertSetServices => SetServices
use GEOS_EnsGridCompMod, only: EnsSetServices => SetServices
use GEOS_LandAssimGridCompMod, only: LandAssimSetServices => SetServices
use GEOS_LandiceGridCompMod, only : LandiceSetServices => SetServices

use EASE_conv, only: ease_inverse
use LDAS_TileCoordType, only: tile_coord_type , T_TILECOORD_STATE, TILECOORD_WRAP
Expand Down Expand Up @@ -50,6 +51,7 @@ module GEOS_LdasGridCompMod

! All children
integer,allocatable :: LAND(:)
integer,allocatable :: LANDICE(:)
integer,allocatable :: LANDPERT(:)
integer,allocatable :: METFORCE(:)
integer :: ENSAVG, LANDASSIM
Expand All @@ -59,7 +61,7 @@ module GEOS_LdasGridCompMod
logical :: land_assim
logical :: mwRTM
logical :: ensemble_forcing ! switch between deterministic and ensemble forcing

logical :: with_landice
contains

!BOP
Expand All @@ -85,7 +87,7 @@ subroutine SetServices(gc, rc)
character(len=ESMF_MAXSTR) :: Iam
character(len=ESMF_MAXSTR) :: comp_name
character(len=ESMF_MAXSTR) :: ensid_string,childname
character(len=ESMF_MAXSTR) :: LAND_ASSIM_STR, mwRTM_file, ENS_FORCING_STR
character(len=ESMF_MAXSTR) :: LAND_ASSIM_STR, mwRTM_file, ENS_FORCING_STR, WITH_LANDICE_STR
integer :: ens_id_width
! Local variables
type(T_TILECOORD_STATE), pointer :: tcinternal
Expand All @@ -94,7 +96,7 @@ subroutine SetServices(gc, rc)
type(ESMF_Config) :: CF
integer :: LSM_CHOICE
integer :: FIRST_ENS_ID

! Begin...

! Get my name and setup traceback handle
Expand Down Expand Up @@ -156,6 +158,12 @@ subroutine SetServices(gc, rc)
VERIFY_(STATUS)
land_assim = (trim(LAND_ASSIM_STR) /= 'NO')

call MAPL_GetResource ( MAPL, WITH_LANDICE_STR, Label="WITH_LANDICE:", DEFAULT="NO", RC=STATUS)
VERIFY_(STATUS)
WITH_LANDICE_STR = ESMF_UtilStringUpperCase(WITH_LANDICE_STR, rc=STATUS)
VERIFY_(STATUS)
with_landice = (trim(WITH_LANDICE_STR) /= 'NO')

call MAPL_GetResource ( MAPL, mwRTM_file, Label="LANDASSIM_INTERNAL_RESTART_FILE:", DEFAULT='', RC=STATUS)
VERIFY_(STATUS)
mwRTM = ( len_trim(mwRTM_file) /= 0 )
Expand All @@ -172,6 +180,7 @@ subroutine SetServices(gc, rc)
endif

allocate(LAND(NUM_ENSEMBLE),LANDPERT(NUM_ENSEMBLE))
if (with_landice) allocate(LANDICE(NUM_ENSEMBLE))

! ens_id_with = 2 + number of digits = total number of chars in ensid_string ("_eXXXX")
!
Expand Down Expand Up @@ -212,6 +221,12 @@ subroutine SetServices(gc, rc)
childname='LAND'//trim(ensid_string)
LAND(i) = MAPL_AddChild(gc, name=childname, ss=LandSetServices, rc=status)
VERIFY_(status)

if (with_landice) then
childname='LANDICE'//trim(ensid_string)
LANDICE(i) = MAPL_AddChild(gc, name=childname, ss=LandiceSetServices, rc=status)
VERIFY_(status)
endif
enddo

ENSAVG = MAPL_AddChild(gc, name='ENSAVG', ss=EnsSetServices, rc=status)
Expand All @@ -224,19 +239,8 @@ subroutine SetServices(gc, rc)

! Connections
do i=1,NUM_ENSEMBLE
! -METFORCE-feeds-LANDPERT's-imports-
k = 1
if ( ensemble_forcing ) k = i
call MAPL_AddConnectivity( &
gc, &
SHORT_NAME = ['Tair ', 'Qair ', 'Psurf ', 'Rainf_C', 'Rainf ', &
'Snowf ', 'LWdown ', 'SWdown ', 'PARdrct', 'PARdffs', &
'Wind ', 'RefH '], &
SRC_ID = METFORCE(k), &
DST_ID = LANDPERT(i), &
rc = status &
)
VERIFY_(status)
! -LANDPERT-feeds-LAND's-imports-
call MAPL_AddConnectivity( &
gc, &
Expand All @@ -254,22 +258,7 @@ subroutine SetServices(gc, rc)
rc = status &
)
VERIFY_(status)
! -METFORCE-feeds-LAND's-imports-
call MAPL_AddConnectivity( &
gc, &
SRC_NAME = ['Psurf', 'RefH ', &
'DUDP ', 'DUSV ', 'DUWT ', 'DUSD ', 'BCDP ', 'BCSV ', &
'BCWT ', 'BCSD ', 'OCDP ', 'OCSV ', 'OCWT ', 'OCSD ', &
'SUDP ', 'SUSV ', 'SUWT ', 'SUSD ', 'SSDP ', 'SSSV ' ], &
SRC_ID = METFORCE(k), &
DST_NAME = ['PS ', 'DZ ', &
'DUDP', 'DUSV', 'DUWT', 'DUSD', 'BCDP', 'BCSV', &
'BCWT', 'BCSD', 'OCDP', 'OCSV', 'OCWT', 'OCSD', &
'SUDP', 'SUSV', 'SUWT', 'SUSD', 'SSDP', 'SSSV' ], &
DST_ID = LAND(i), &
rc = status &
)
VERIFY_(status)

! -LAND-feeds-LANDPERT's-imports-
call MAPL_AddConnectivity( &
gc, &
Expand Down Expand Up @@ -367,6 +356,8 @@ subroutine Initialize(gc, import, export, clock, rc)
! MAPL variables
type(MAPL_LocStream) :: surf_locstream
type(MAPL_LocStream) :: land_locstream
type(MAPL_LocStream) :: landice_locstream
type(MAPL_LocStream) :: force_locstream
type(MAPL_MetaComp), pointer :: MAPL=>null() ! GC's MAPL obj
type(MAPL_MetaComp), pointer :: CHILD_MAPL=>null() ! Child's MAPL obj

Expand All @@ -382,7 +373,7 @@ subroutine Initialize(gc, import, export, clock, rc)
character(len=ESMF_MAXSTR) :: LAND_PARAMS
character(len=ESMF_MAXSTR) :: grid_type

integer :: total_nt,land_nt_local,i,j
integer :: total_nt, land_nt_local, i, j
real, pointer :: LandTileLats(:)
real, pointer :: LandTileLons(:)
integer, pointer :: local_id(:)
Expand Down Expand Up @@ -564,11 +555,32 @@ subroutine Initialize(gc, import, export, clock, rc)
call MAPL_LocStreamCreate( &
land_locstream, &
surf_locstream, &
name=gcnames(LAND(1)), &
name=gcnames(LAND(1)), &
mask=[MAPL_LAND], &
rc=status &
)
VERIFY_(status)

if (with_landice) then
call MAPL_LocStreamCreate( &
force_locstream, &
surf_locstream, &
name=gcnames(METFORCE(1)), &
mask=[MAPL_LAND, MAPL_LANDICE], &
rc=status &
)
VERIFY_(status)

call MAPL_LocStreamCreate( &
landice_locstream, &
surf_locstream, &
name=gcnames(LANDICE(1)), &
mask=[MAPL_LANDICE], &
rc=status &
)
VERIFY_(status)
endif

call MAPL_TimerOff(MAPL, "-LocStreamCreate")
! Convert LAND's LocStream to LDAS' tile_coord and save it in the GridComp
! -get-tile-information-from-land's-locstream-
Expand Down Expand Up @@ -705,10 +717,16 @@ subroutine Initialize(gc, import, export, clock, rc)
do i = 1, NUM_ENSEMBLE
call MAPL_GetObjectFromGC(gcs(METFORCE(i)), CHILD_MAPL, rc=status)
VERIFY_(status) ! CHILD = METFORCE
call MAPL_Set(CHILD_MAPL, LocStream=land_locstream, rc=status)
VERIFY_(status)
if ( with_landice) then
call MAPL_Set(CHILD_MAPL, LocStream=force_locstream, rc=status)
VERIFY_(status)
else
call MAPL_Set(CHILD_MAPL, LocStream=land_locstream, rc=status)
VERIFY_(status)
endif
call ESMF_UserCompSetInternalState(gcs(METFORCE(i)), 'TILE_COORD', tcwrap, status)
VERIFY_(status)

! exit after i=1 if using deterministic forcing
if (.not. ensemble_forcing) exit
enddo
Expand All @@ -723,15 +741,25 @@ subroutine Initialize(gc, import, export, clock, rc)
VERIFY_(status)
call MAPL_Set(CHILD_MAPL, LocStream=land_locstream, rc=status)
VERIFY_(status)

if (with_landice) then
call MAPL_GetObjectFromGC(gcs(LANDICE(i)), CHILD_MAPL, rc=status)
VERIFY_(status)
call MAPL_Set(CHILD_MAPL, LocStream=landice_locstream, rc=status)
VERIFY_(status)
endif

call MAPL_GetObjectFromGC(gcs(LANDPERT(i)), CHILD_MAPL, rc=status)
VERIFY_(status) ! CHILD = LANDPERT
call MAPL_Set(CHILD_MAPL, LocStream=land_locstream, rc=status)
VERIFY_(status)

! Add LAND's tile_coord to children's GridComps
call ESMF_UserCompSetInternalState(gcs(LAND(i)), 'TILE_COORD', tcwrap, status)
VERIFY_(status)
call ESMF_UserCompSetInternalState(gcs(LANDPERT(i)), 'TILE_COORD', tcwrap, status)
VERIFY_(status)

enddo

if (land_assim .or. mwRTM) then
Expand Down Expand Up @@ -822,7 +850,7 @@ subroutine Run(gc, import, export, clock, rc)
type(MAPL_MetaComp), pointer :: MAPL

! Misc variables
integer :: igc,i, ens_id, FIRST_ENS_ID, ens_id_width
integer :: igc, i, ens_id, FIRST_ENS_ID, ens_id_width, k
logical :: IAmRoot
integer :: LSM_CHOICE
type (ESMF_Field) :: field
Expand Down Expand Up @@ -893,13 +921,30 @@ subroutine Run(gc, import, export, clock, rc)
do i = 1, NUM_ENSEMBLE
igc = METFORCE(i)
call MAPL_TimerOn(MAPL, gcnames(igc))
call ESMF_GridCompRun(gcs(igc), importState=gim(igc), exportState=gex(igc), clock=clock, userRC=status)
call ESMF_GridCompRun(gcs(igc), importState=gim(igc), exportState=gex(igc), clock=clock, phase=1, userRC=status)
VERIFY_(status)
call MAPL_TimerOff(MAPL, gcnames(igc))
! exit after i=1 if using deterministic forcing
if (.not. ensemble_forcing) exit
enddo

! distribute force. ( export of focrce to the import of land, landpert and landice)
do i = 1, NUM_ENSEMBLE
k = 1
if (ensemble_forcing) k = i
igc = METFORCE(k)
call MAPL_TimerOn(MAPL, gcnames(igc))

call ESMF_GridCompRun(gcs(igc), importState=gex(igc), exportState=gim(LAND(i)), clock=clock, phase=2, userRC=status)
VERIFY_(status)
call ESMF_GridCompRun(gcs(igc), importState=gex(igc), exportState=gim(LANDPERT(i)), clock=clock, phase=3, userRC=status)
VERIFY_(status)
if (with_landice) then
call ESMF_GridCompRun(gcs(igc), importState=gex(igc), exportState=gim(LANDICE(i)), clock=clock, phase=4, userRC=status)
VERIFY_(status)
endif
call MAPL_TimerOff(MAPL, gcnames(igc))
enddo

do i = 1,NUM_ENSEMBLE

Expand Down Expand Up @@ -927,6 +972,16 @@ subroutine Run(gc, import, export, clock, rc)
VERIFY_(status)
call MAPL_TimerOff(MAPL, gcnames(igc))

if (with_landice) then
igc = LANDICE(i)
call MAPL_TimerOn(MAPL, gcnames(igc))
call ESMF_GridCompRun(gcs(igc), importState=gim(igc), exportState=gex(igc), clock=clock, phase=1, userRC=status)
VERIFY_(status)
call ESMF_GridCompRun(gcs(igc), importState=gim(igc), exportState=gex(igc), clock=clock, phase=2, userRC=status)
VERIFY_(status)
call MAPL_TimerOff(MAPL, gcnames(igc))
endif

! ApplyPrognPert - moved: now before calculating ensemble average that is picked up by land analysis and HISTORY; reichle 28 May 2020
igc = LANDPERT(i)
call MAPL_TimerOn(MAPL, gcnames(igc))
Expand Down
34 changes: 19 additions & 15 deletions GEOSldas_App/lenkf_j_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,24 @@
set THISDIR = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/
if (! -e $THISDIR ) mkdir -p $THISDIR

set rstf = ${{MODEL}}
if (-f ${{rstf}}${{ENSID}}_internal_checkpoint ) then
set tmp_file = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/${{EXPID}}.${{rstf}}_internal_rst.${{eYEAR}}${{eMON}}${{eDAY}}_${{eHour}}${{eMin}}
/bin/mv ${{rstf}}${{ENSID}}_internal_checkpoint $tmp_file
/bin/rm -f $EXPDIR/input/restart/${{rstf}}${{ENSID}}_internal_rst
/bin/ln -rs $tmp_file $EXPDIR/input/restart/${{rstf}}${{ENSID}}_internal_rst
set rstfs = (${{MODEL}} 'landice')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiyuan-jiang: "MODEL" here is the particular flavor of the land (Catchment) model. Now that we're integrating landice and lake, which include their own "model", I think it would be good to rename "MODEL" to "LANDMODEL" for clarity. Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I have changed the name

foreach rstf ( $rstfs )
if (-f ${{rstf}}${{ENSID}}_internal_checkpoint ) then
set tmp_file = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/${{EXPID}}.${{rstf}}_internal_rst.${{eYEAR}}${{eMON}}${{eDAY}}_${{eHour}}${{eMin}}
/bin/mv ${{rstf}}${{ENSID}}_internal_checkpoint $tmp_file
/bin/rm -f $EXPDIR/input/restart/${{rstf}}${{ENSID}}_internal_rst
/bin/ln -rs $tmp_file $EXPDIR/input/restart/${{rstf}}${{ENSID}}_internal_rst
endif
end

set rstf = 'landassim_obspertrseed'
if (-f ${{rstf}}${{ENSID}}_checkpoint ) then
set tmp_file = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/${{EXPID}}.${{rstf}}_rst.${{eYEAR}}${{eMON}}${{eDAY}}_${{eHour}}${{eMin}}
/bin/mv ${{rstf}}${{ENSID}}_checkpoint $tmp_file
/bin/rm -f $EXPDIR/input/restart/${{rstf}}${{ENSID}}_rst
/bin/ln -rs $tmp_file $EXPDIR/input/restart/${{rstf}}${{ENSID}}_rst
endif

set rstf = 'landpert'
if (-f ${{rstf}}${{ENSID}}_internal_checkpoint ) then
set tmp_file = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/${{EXPID}}.${{rstf}}_internal_rst.${{eYEAR}}${{eMON}}${{eDAY}}_${{eHour}}${{eMin}}
Expand All @@ -737,21 +747,15 @@
/usr/bin/gzip $old_rst &
endif

set rstf = 'landassim_obspertrseed'
if (-f ${{rstf}}${{ENSID}}_checkpoint ) then
set tmp_file = $EXPDIR/output/$EXPDOMAIN/rs/$ENSDIR/Y${{eYEAR}}/M${{eMON}}/${{EXPID}}.${{rstf}}_rst.${{eYEAR}}${{eMON}}${{eDAY}}_${{eHour}}${{eMin}}
/bin/mv ${{rstf}}${{ENSID}}_checkpoint $tmp_file
/bin/rm -f $EXPDIR/input/restart/${{rstf}}${{ENSID}}_rst
/bin/ln -rs $tmp_file $EXPDIR/input/restart/${{rstf}}${{ENSID}}_rst
endif
# move intermediate check point files to output/$EXPDOMAIN/rs/$ENSDIR/Yyyyy/Mmm/ directories
# -------------------------------------------------------------------------------------------

set rstfiles1 = `ls ${{MODEL}}${{ENSID}}_internal_checkpoint.*`
set rstfiles2 = `ls landpert${{ENSID}}_internal_checkpoint.*`
set rstfiles3 = `ls landassim_obspertrseed${{ENSID}}_checkpoint.*`
set rstfiles4 = `ls landice${{ENSID}}_internal_checkpoint.*`

foreach rfile ( $rstfiles1 )
foreach rfile ( $rstfiles1 $rstfiles4 )
set ThisTime = `echo $rfile | rev | cut -d'.' -f2 | rev`
set TY = `echo $ThisTime | cut -c1-4`
set TM = `echo $ThisTime | cut -c5-6`
Expand Down
Loading