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

NoahMP CCPP-compliancy #305

Merged
merged 22 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e48c99c
initial addition of CCPP metadata for NoahMP
grantfirl Aug 20, 2019
366378c
Merge branch 'fix_LSM_units' into noahmp
grantfirl Aug 20, 2019
6236796
put sfc_noahmp_drv.f in module; add init/finalize + meta file html br…
grantfirl Aug 20, 2019
747c5a4
fix soil_moisture_content unit error
grantfirl Aug 21, 2019
aa5aec7
add CCPP error variables to sfc_noahmp_drv.f and fix local name error…
grantfirl Aug 21, 2019
e5e6b78
add NoahMP interstitial code (only pre routine needed for GFS suite f…
grantfirl Aug 22, 2019
6c2cab8
send physical constants through the argument list
grantfirl Aug 23, 2019
24b8942
remove WRF error handling in favor of CCPP error handling
grantfirl Aug 24, 2019
1098500
pass errmsg and errflg down call chain
grantfirl Aug 24, 2019
dab6e6d
move NoahMP calculation of julian day and year length to GFS_time_var…
grantfirl Aug 26, 2019
d0af67a
add set_soilveg to noahmpdrv_init
grantfirl Aug 30, 2019
3e2f892
add calculation of sncovr to GFS_surface_generic_pre_run (not to init…
grantfirl Aug 30, 2019
78523cf
add calculation of sncovr to GFS_phys_time_vary_run (not to init beca…
grantfirl Sep 3, 2019
64f70df
Merge branch 'fix_sncovr' into noahmp
grantfirl Sep 3, 2019
6d04c51
Merge branch 'gmtb/develop' into noahmp
grantfirl Sep 3, 2019
af34508
fix GFS_time_vary_pre.fv3.F90 compilation error
grantfirl Sep 3, 2019
619afe0
add calculation of precipitation variables for NoahMP in GFS_MP_gener…
grantfirl Sep 4, 2019
de728a8
add resetting of sfcprop%t2m and q2m to values from noahmp if noahmp …
grantfirl Sep 5, 2019
775f4ff
(temporarily?) move calculation of precip rates for NoahMP to scheme-…
grantfirl Sep 6, 2019
a311364
Merge branch 'gmtb/develop' into noahmp
grantfirl Sep 10, 2019
e7bb31a
revert whitespace changes to GFS_MP_generic.F90
grantfirl Sep 10, 2019
69c215f
fix bug in metadata table for GFS_phys_time_vary_run for FV3
grantfirl Sep 12, 2019
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
37 changes: 32 additions & 5 deletions physics/GFS_phys_time_vary.fv3.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module GFS_phys_time_vary

use iccn_def, only : ciplin, ccnin, ci_pres
use iccninterp, only : read_cidata, setindxci, ciinterpol

!--- variables needed for calculating 'sncovr'
use namelist_soilveg, only: salp_data, snupx

implicit none

Expand Down Expand Up @@ -318,18 +321,19 @@ end subroutine GFS_phys_time_vary_finalize
!!
!>\section gen_GFS_phys_time_vary_run GFS_phys_time_vary_run General Algorithm
!> @{
subroutine GFS_phys_time_vary_run (Data, Model, nthrds, errmsg, errflg)
subroutine GFS_phys_time_vary_run (Data, Model, nthrds, first_time_step, errmsg, errflg)

use mersenne_twister, only: random_setseed, random_number
use machine, only: kind_phys
use GFS_typedefs, only: GFS_control_type, GFS_data_type

implicit none

! Interface variables
type(GFS_data_type), intent(in) :: Data(:)
type(GFS_data_type), intent(inout) :: Data(:)
type(GFS_control_type), intent(inout) :: Model
integer, intent(in) :: nthrds
logical, intent(in) :: first_time_step
character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

Expand All @@ -338,8 +342,8 @@ subroutine GFS_phys_time_vary_run (Data, Model, nthrds, errmsg, errflg)
real(kind=kind_phys), parameter :: con_99 = 99.0_kind_phys
real(kind=kind_phys), parameter :: con_100 = 100.0_kind_phys

integer :: i, j, k, iseed, iskip, ix, nb, nblks, kdt_rad
real(kind=kind_phys) :: sec_zero
integer :: i, j, k, iseed, iskip, ix, nb, nblks, kdt_rad, vegtyp
real(kind=kind_phys) :: sec_zero, rsnow
real(kind=kind_phys) :: wrk(1)
real(kind=kind_phys) :: rannie(Model%cny)
real(kind=kind_phys) :: rndval(Model%cnx*Model%cny*Model%nrcm)
Expand Down Expand Up @@ -492,6 +496,29 @@ subroutine GFS_phys_time_vary_run (Data, Model, nthrds, errmsg, errflg)
enddo
endif
endif

!Calculate sncovr if it was read in but empty (from FV3/io/FV3GFS_io.F90/sfc_prop_restart_read)
if (first_time_step) then
if (nint(Data(1)%Sfcprop%sncovr(1)) == -9999) then
!--- compute sncovr from existing variables
!--- code taken directly from read_fix.f
do nb = 1, nblks
do ix = 1, Model%blksz(nb)
Data(nb)%Sfcprop%sncovr(ix) = 0.0
if (Data(nb)%Sfcprop%slmsk(ix) > 0.001) then
vegtyp = Data(nb)%Sfcprop%vtype(ix)
if (vegtyp == 0) vegtyp = 7
rsnow = 0.001*Data(nb)%Sfcprop%weasd(ix)/snupx(vegtyp)
if (0.001*Data(nb)%Sfcprop%weasd(ix) < snupx(vegtyp)) then
Data(nb)%Sfcprop%sncovr(ix) = 1.0 - (exp(-salp_data*rsnow) - rsnow*exp(-salp_data))
else
Data(nb)%Sfcprop%sncovr(ix) = 1.0
endif
endif
enddo
enddo
endif
endif

end subroutine GFS_phys_time_vary_run
!> @}
Expand Down
8 changes: 8 additions & 0 deletions physics/GFS_phys_time_vary.fv3.meta
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
type = integer
intent = in
optional = F
[first_time_step]
standard_name = flag_for_first_time_step
long_name = flag for first time step for time integration loop (cold/warmstart)
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down
123 changes: 90 additions & 33 deletions physics/GFS_time_vary_pre.fv3.F90
Original file line number Diff line number Diff line change
Expand Up @@ -65,68 +65,125 @@ end subroutine GFS_time_vary_pre_finalize
!> \section arg_table_GFS_time_vary_pre_run Argument Table
!! \htmlinclude GFS_time_vary_pre_run.html
!!
subroutine GFS_time_vary_pre_run (Model, errmsg, errflg)
subroutine GFS_time_vary_pre_run (jdat, idat, dtp, lsm, lsm_noahmp, nsswr, &
nslwr, idate, debug, me, master, nscyc, sec, phour, zhour, fhour, kdt, &
julian, yearlen, ipt, lprnt, lssav, lsswr, lslwr, solhr, errmsg, errflg)

use machine, only: kind_phys
use GFS_typedefs, only: GFS_control_type

implicit none

type(GFS_control_type), intent(inout) :: Model

integer, intent(in) :: idate(4)
integer, intent(in) :: jdat(1:8), idat(1:8)
integer, intent(in) :: lsm, lsm_noahmp, &
nsswr, nslwr, me, &
master, nscyc
logical, intent(in) :: debug
real(kind=kind_phys), intent(in) :: dtp

integer, intent(out) :: kdt, yearlen, ipt
logical, intent(out) :: lprnt, lssav, lsswr, &
lslwr
real(kind=kind_phys), intent(out) :: sec, phour, zhour, &
fhour, julian, solhr

character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

real(kind=kind_phys), parameter :: con_24 = 24.0_kind_phys
real(kind=kind_phys), parameter :: con_hr = 3600.0_kind_phys
real(kind=kind_phys) :: rinc(5)

integer :: iw3jdn
integer :: jd0, jd1
real :: fjd

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0

! Check initialization status
if (.not.is_initialized) then
write(errmsg,'(*(a))') "Logic error: GFS_time_vary_pre_run called before GFS_time_vary_pre_init"
write(errmsg,'(*(a))') "Logic error: GFS_time_vary_pre_run called &
&before GFS_time_vary_pre_init"
errflg = 1
return
end if

!--- Model%jdat is being updated directly inside of FV3GFS_cap.F90
!--- jdat is being updated directly inside of FV3GFS_cap.F90
!--- update calendars and triggers
rinc(1:5) = 0
call w3difdat(Model%jdat,Model%idat,4,rinc)
Model%sec = rinc(4)
Model%phour = Model%sec/con_hr
call w3difdat(jdat,idat,4,rinc)
sec = rinc(4)
phour = sec/con_hr
!--- set current bucket hour
Model%zhour = Model%phour
Model%fhour = (Model%sec + Model%dtp)/con_hr
Model%kdt = nint((Model%sec + Model%dtp)/Model%dtp)

Model%ipt = 1
Model%lprnt = .false.
Model%lssav = .true.
zhour = phour
fhour = (sec + dtp)/con_hr
kdt = nint((sec + dtp)/dtp)

if(lsm == lsm_noahmp) then
!GJF* These calculations were originally in GFS_physics_driver.F90 for
! NoahMP. They were moved to this routine since they only depends
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will correct the typo "they only depends" to "they only depend" in my collect-and-test PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the record - done.

! on time (not space). Note that this code is included as-is from
! GFS_physics_driver.F90, but it may be simplified by using more
! NCEP W3 library calls (e.g., see W3DOXDAT, W3FS13 for Julian day
! of year and W3DIFDAT to determine the integer number of days in
! a given year). *GJF
! Julian day calculation (fcst day of the year)
! we need yearln and julian to
! pass to noah mp sflx, idate is init, jdat is fcst;idate = jdat when kdt=1
! jdat is changing
!

jd1 = iw3jdn(jdat(1),jdat(2),jdat(3))
jd0 = iw3jdn(jdat(1),1,1)
fjd = float(jdat(5))/24.0 + float(jdat(6))/1440.0

julian = float(jd1-jd0) + fjd

!
! Year length
!
! what if the integration goes from one year to another?
! iyr or jyr ? from 365 to 366 or from 366 to 365
!
! is this against model's noleap yr assumption?
if (mod(jdat(1),4) == 0) then
yearlen = 366
if (mod(jdat(1),100) == 0) then
yearlen = 365
if (mod(jdat(1),400) == 0) then
yearlen = 366
endif
endif
endif
endif

ipt = 1
lprnt = .false.
lssav = .true.

!--- radiation triggers
Model%lsswr = (mod(Model%kdt, Model%nsswr) == 1)
Model%lslwr = (mod(Model%kdt, Model%nslwr) == 1)
lsswr = (mod(kdt, nsswr) == 1)
lslwr = (mod(kdt, nslwr) == 1)
!--- allow for radiation to be called on every physics time step, if needed
if (Model%nsswr == 1) Model%lsswr = .true.
if (Model%nslwr == 1) Model%lslwr = .true.
if (nsswr == 1) lsswr = .true.
if (nslwr == 1) lslwr = .true.

!--- set the solar hour based on a combination of phour and time initial hour
Model%solhr = mod(Model%phour+Model%idate(1),con_24)

if ((Model%debug) .and. (Model%me == Model%master)) then
print *,' sec ', Model%sec
print *,' kdt ', Model%kdt
print *,' nsswr ', Model%nsswr
print *,' nslwr ', Model%nslwr
print *,' nscyc ', Model%nscyc
print *,' lsswr ', Model%lsswr
print *,' lslwr ', Model%lslwr
print *,' fhour ', Model%fhour
print *,' phour ', Model%phour
print *,' solhr ', Model%solhr
solhr = mod(phour+idate(1),con_24)

if ((debug) .and. (me == master)) then
print *,' sec ', sec
print *,' kdt ', kdt
print *,' nsswr ', nsswr
print *,' nslwr ', nslwr
print *,' nscyc ', nscyc
print *,' lsswr ', lsswr
print *,' lslwr ', lslwr
print *,' fhour ', fhour
print *,' phour ', phour
print *,' solhr ', solhr
endif

end subroutine GFS_time_vary_pre_run
Expand Down
Loading