Skip to content

Commit d787db7

Browse files
Merge branch 'rfiorella/lnd/add-era5-to-couplerbypass' (PR #7480)
As noted in #7428, many of the datm timeseries that can be passed through the current coupler bypass end ~10 years ago. This PR adds a few lines to add a new data source for ERA5 to this module. Fixes #7428 [BFB] tested on local systems.
2 parents 339ba28 + d8c18cc commit d787db7

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

components/elm/src/cpl/lnd_import_export.F90

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ subroutine lnd_import( bounds, x2l, atm2lnd_vars, glc2lnd_vars, lnd2atm_vars)
4747
! !ARGUMENTS:
4848
type(bounds_type) , intent(in) :: bounds ! bounds
4949
real(r8) , intent(in) :: x2l(:,:) ! driver import state to land model
50-
type(atm2lnd_type) , intent(inout) :: atm2lnd_vars ! clm internal input data type
51-
type(glc2lnd_type) , intent(inout) :: glc2lnd_vars ! clm internal input data type
50+
type(atm2lnd_type) , intent(inout) :: atm2lnd_vars ! elm internal input data type
51+
type(glc2lnd_type) , intent(inout) :: glc2lnd_vars ! elm internal input data type
5252
type(lnd2atm_type) , intent(in) :: lnd2atm_vars
5353
!
5454
! !LOCAL VARIABLES:
@@ -236,6 +236,8 @@ subroutine lnd_import( bounds, x2l, atm2lnd_vars, glc2lnd_vars, lnd2atm_vars)
236236
atm2lnd_vars%metsource = 4
237237
else if (index(metdata_type,'cpl') .gt. 0) then
238238
atm2lnd_vars%metsource = 5
239+
else if (index(metdata_type,'era5') .gt. 0) then
240+
atm2lnd_vars%metsource = 6
239241
else
240242
call endrun( sub//' ERROR: Invalid met data source for cpl_bypass' )
241243
end if
@@ -306,6 +308,10 @@ subroutine lnd_import( bounds, x2l, atm2lnd_vars, glc2lnd_vars, lnd2atm_vars)
306308
atm2lnd_vars%startyear_met = 566 !76
307309
atm2lnd_vars%endyear_met_spinup = 590 !100
308310
atm2lnd_vars%endyear_met_trans = 590 !100
311+
else if (atm2lnd_vars%metsource == 6) then
312+
atm2lnd_vars%startyear_met = 1950
313+
atm2lnd_vars%endyear_met_spinup = 1970
314+
atm2lnd_vars%endyear_met_trans = 2025
309315
end if
310316

311317
if (use_livneh) then
@@ -404,6 +410,8 @@ subroutine lnd_import( bounds, x2l, atm2lnd_vars, glc2lnd_vars, lnd2atm_vars)
404410
else if (atm2lnd_vars%metsource == 5) then
405411
!metdata_fname = 'WCYCL1850S.ne30_' // trim(metvars(v)) // '_0076-0100_z' // zst(2:3) // '.nc'
406412
metdata_fname = 'CBGC1850S.ne30_' // trim(metvars(v)) // '_0566-0590_z' // zst(2:3) // '.nc'
413+
else if (atm2lnd_vars%metsource == 6) then
414+
metdata_fname = 'ERA5_' // trim(metvars(v)) // '_1950-2025_z' // zst(2:3) // '.nc'
407415
end if
408416

409417
ierr = nf90_open(trim(metdata_bypass) // '/' // trim(metdata_fname), NF90_NOWRITE, met_ncids(v))
@@ -500,22 +508,29 @@ subroutine lnd_import( bounds, x2l, atm2lnd_vars, glc2lnd_vars, lnd2atm_vars)
500508
end do !end variable loop
501509
else
502510
do v=1,met_nvars
503-
if (atm2lnd_vars%npf(v) - 1._r8 .gt. 1e-3) then
511+
if (atm2lnd_vars%npf(v) - 1._r8 .gt. 1e-3) then
504512
if (v .eq. 4 .or. v .eq. 5 .or. (v .ge. 8 .and. v .le. 13)) then !rad/Precipitation
505513
if (mod(tod/get_step_size(),nint(atm2lnd_vars%npf(v))) == 1 .and. nstep .gt. 3) then
506514
atm2lnd_vars%tindex(g,v,1) = atm2lnd_vars%tindex(g,v,1)+1
507515
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+1
508516
end if
509-
else
510-
if (mod(tod/get_step_size()-1,nint(atm2lnd_vars%npf(v))) <= atm2lnd_vars%npf(v)/2._r8 .and. &
511-
mod(tod/get_step_size(),nint(atm2lnd_vars%npf(v))) > atm2lnd_vars%npf(v)/2._r8) then
512-
atm2lnd_vars%tindex(g,v,1) = atm2lnd_vars%tindex(g,v,1)+1
513-
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+1
517+
else
518+
if (atm2lnd_vars%npf(v) .ne. 2._r8) then
519+
if (mod(tod/get_step_size()-1,nint(atm2lnd_vars%npf(v))) <= atm2lnd_vars%npf(v)/2._r8 .and. &
520+
mod(tod/get_step_size(),nint(atm2lnd_vars%npf(v))) > atm2lnd_vars%npf(v)/2._r8) then
521+
atm2lnd_vars%tindex(g,v,1) = atm2lnd_vars%tindex(g,v,1)+1
522+
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+1
523+
end if
524+
else
525+
if (mod(tod/get_step_size(),nint(atm2lnd_vars%npf(v))) == 1 .and. nstep .gt. 3) then
526+
atm2lnd_vars%tindex(g,v,1) = atm2lnd_vars%tindex(g,v,1)+1
527+
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+1
528+
end if
514529
end if
515530
end if
516531
else
517532
atm2lnd_vars%tindex(g,v,1) = atm2lnd_vars%tindex(g,v,1)+nint(1/atm2lnd_vars%npf(v))
518-
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+nint(1/atm2lnd_vars%npf(v))
533+
atm2lnd_vars%tindex(g,v,2) = atm2lnd_vars%tindex(g,v,2)+nint(1/atm2lnd_vars%npf(v))
519534
end if
520535

521536
if (const_climate_hist .or. yr .le. atm2lnd_vars%startyear_met) then
@@ -1377,8 +1392,8 @@ subroutine lnd_export( bounds, lnd2atm_vars, lnd2glc_vars, l2x)
13771392
! !ARGUMENTS:
13781393
implicit none
13791394
type(bounds_type) , intent(in) :: bounds ! bounds
1380-
type(lnd2atm_type), intent(inout) :: lnd2atm_vars ! clm land to atmosphere exchange data type
1381-
type(lnd2glc_type), intent(inout) :: lnd2glc_vars ! clm land to atmosphere exchange data type
1395+
type(lnd2atm_type), intent(inout) :: lnd2atm_vars ! elm land to atmosphere exchange data type
1396+
type(lnd2glc_type), intent(inout) :: lnd2glc_vars ! elm land to atmosphere exchange data type
13821397
real(r8) , intent(out) :: l2x(:,:)! land to coupler export state on land grid
13831398
!
13841399
! !LOCAL VARIABLES:

0 commit comments

Comments
 (0)