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

miscellaneous changes from NRL #798

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ foreach(typedef_module ${TYPEDEFS})
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${typedef_module})
endforeach()

# This is a hack because I don't know how to get the pre_build to add these
Copy link
Collaborator Author

@grantfirl grantfirl Dec 9, 2021

Choose a reason for hiding this comment

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

specific to NRL (all current changes in CMakeLists.txt)

# modules to the install list --PAR
if (PROJECT STREQUAL "CCPP-NEPTUNE")
# added for CCPP 5: ozne_def.mod, h2o_def.mod, module_radiation_surface.mod
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/namelist_soilveg.mod
${CMAKE_CURRENT_BINARY_DIR}/set_soilveg_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/physcons.mod
${CMAKE_CURRENT_BINARY_DIR}/funcphys.mod
${CMAKE_CURRENT_BINARY_DIR}/ozne_def.mod
${CMAKE_CURRENT_BINARY_DIR}/h2o_def.mod
${CMAKE_CURRENT_BINARY_DIR}/module_radiation_surface.mod
)
endif (PROJECT STREQUAL "CCPP-NEPTUNE")

#------------------------------------------------------------------------------
# Set the sources: physics schemes
set(SCHEMES $ENV{CCPP_SCHEMES})
Expand Down Expand Up @@ -263,7 +277,7 @@ target_include_directories(ccpp_physics PUBLIC

target_link_libraries(ccpp_physics PUBLIC w3nco::w3nco_d NetCDF::NetCDF_Fortran)

if (PROJECT STREQUAL "CCPP-FV3")
if (PROJECT STREQUAL "CCPP-FV3" OR PROJECT STREQUAL "CCPP-NEPTUNE")
# Define where to install the library
install(TARGETS ccpp_physics
EXPORT ccpp_physics-targets
Expand All @@ -279,4 +293,4 @@ if (PROJECT STREQUAL "CCPP-FV3")
# Define where to install the C headers and Fortran modules
#install(FILES ${HEADERS_C} DESTINATION include)
install(FILES ${MODULES_F90} DESTINATION include)
endif (PROJECT STREQUAL "CCPP-FV3")
endif (PROJECT STREQUAL "CCPP-FV3" OR PROJECT STREQUAL "CCPP-NEPTUNE")
1 change: 1 addition & 0 deletions physics/GFS_MP_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ subroutine GFS_MP_generic_post_run(
errmsg, errflg)
!
use machine, only: kind_phys
use mod_calpreciptype

implicit none

Expand Down
61 changes: 46 additions & 15 deletions physics/GFS_rad_time_vary.fv3.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module GFS_rad_time_vary
!> \section arg_table_GFS_rad_time_vary_timestep_init Argument Table
!! \htmlinclude GFS_rad_time_vary_timestep_init.html
!!
subroutine GFS_rad_time_vary_timestep_init ( &
subroutine GFS_rad_time_vary_timestep_init (nthrds, blksz, lrseeds, &
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All changes in this file seem specific to NRL to me.

Choose a reason for hiding this comment

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

I think these changes make the random number generator _not specific to FV3. The random number generation has always been grid specific and this generalizes it.

rseeds, &
lslwr, lsswr, isubc_lw, isubc_sw, icsdsw, icsdlw, cnx, cny, isc, jsc, &
imap, jmap, sec, kdt, imp_physics, imp_physics_zhao_carr, ps_2delt, &
ps_1delt, t_2delt, t_1delt, qv_2delt, qv_1delt, t, qv, ps, errmsg, errflg)
Expand All @@ -28,6 +29,10 @@ subroutine GFS_rad_time_vary_timestep_init (
implicit none

! Interface variables
integer, intent(in) :: nthrds
integer, intent(in) :: blksz(:)
logical, intent(in) :: lrseeds
integer, intent(in) :: rseeds(:,:)
integer, intent(in) :: isubc_lw, isubc_sw, cnx, cny, isc, jsc, kdt
integer, intent(in) :: imp_physics, imp_physics_zhao_carr
logical, intent(in) :: lslwr, lsswr
Expand All @@ -46,7 +51,7 @@ subroutine GFS_rad_time_vary_timestep_init (

! Local variables
type (random_stat) :: stat
integer :: ix, j, i, nblks, ipseed
integer :: ii, ix, nb, j, i, nblks, ipseed
integer :: numrdm(cnx*cny*2)

! Initialize CCPP error handling variables
Expand All @@ -55,24 +60,50 @@ subroutine GFS_rad_time_vary_timestep_init (

if (lsswr .or. lslwr) then

!--- call to GFS_radupdate_timestep_init is now in GFS_rrtmg_setup_timestep_init
nblks = size(blksz)
Copy link
Contributor

Choose a reason for hiding this comment

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

This update and those below that allow the seeds to be supplied by the host model appear to be NRL/NEPTUNE-specific. These for NEPTUNE, but are there any issues for other codes? (I'm not sure how to determine that other than asking other groups to review.)


!--- call to GFS_radupdate_run is now in GFS_rrtmg_setup_run

!$OMP parallel num_threads(nthrds) default(none) &
!$OMP private (nb,ix,ii, i,j) &
!$OMP shared (lrseeds,isubc_lw,isubc_sw,ipsdlim,ipsd0,ipseed) &
!$OMP shared (cnx,cny,sec,numrdm,stat,nblks,isc,jsc) &
!$OMP shared (blksz,icsdsw,icsdlw,jmap,imap)

!--- set up random seed index in a reproducible way for entire cubed-sphere face (lat-lon grid)
if ((isubc_lw==2) .or. (isubc_sw==2)) then
ipseed = mod(nint(con_100*sqrt(sec)), ipsdlim) + 1 + ipsd0
call random_setseed (ipseed, stat)
call random_index (ipsdlim, numrdm, stat)

do ix=1,size(jmap)
j = jmap(ix)
i = imap(ix)
!--- for testing purposes, replace numrdm with '100'
icsdsw(ix) = numrdm(i+isc-1 + (j+jsc-2)*cnx)
icsdlw(ix) = numrdm(i+isc-1 + (j+jsc-2)*cnx + cnx*cny)
enddo

!NRL If random seeds supplied by NEPTUNE
if(lrseeds) then
ii = 1
do nb=1,nblks
do ix=1,blksz(nb)
icsdsw(ix) = rseeds(ix,1)
icsdlw(ix) = rseeds(ix,2)
end do
enddo
else
!$OMP single
ipseed = mod(nint(con_100*sqrt(sec)), ipsdlim) + 1 + ipsd0
call random_setseed (ipseed, stat)
call random_index (ipsdlim, numrdm, stat)
!$OMP end single

!$OMP do schedule (dynamic,1)
do nb=1,nblks
do ix=1,blksz(nb)
j = jmap(ix)
i = imap(ix)
!--- for testing purposes, replace numrdm with '100'
icsdsw(ix) = numrdm(i+isc-1 + (j+jsc-2)*cnx)
icsdlw(ix) = numrdm(i+isc-1 + (j+jsc-2)*cnx + cnx*cny)
enddo
enddo
!$OMP end do
end if
endif ! isubc_lw and isubc_sw

!$OMP end parallel

if (imp_physics == imp_physics_zhao_carr) then
if (kdt == 1) then
t_2delt = t
Expand Down
29 changes: 28 additions & 1 deletion physics/GFS_rad_time_vary.fv3.meta
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
[ccpp-arg-table]
name = GFS_rad_time_vary_timestep_init
type = scheme
[nthrds]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All changes in this file correspond to NRL-specific changes in the corresponding Fortran.

standard_name = omp_threads
long_name = number of OpenMP threads available for physics schemes
units = count
dimensions = ()
type = integer
intent = in
[blksz]
standard_name = ccpp_block_sizes
long_name = for explicit data blocking: block sizes of all blocks
units = count
dimensions = (ccpp_block_count)
type = integer
intent = in
[lrseeds]
standard_name = flag_for_model_specific_random_seeds
long_name = flag for model specific random seeds
units = flag
dimensions = ()
type = logical
intent = in
[rseeds]
standard_name = model_specific_random_seeds
long_name = model specific random seeds
units = none
dimensions = (horizontal_dimension,number_of_random_streams)
type = integer
intent = in
[lslwr]
standard_name = flag_for_calling_longwave_radiation
long_name = logical flags for lw radiation calls
Expand Down Expand Up @@ -207,4 +235,3 @@
dimensions = ()
type = integer
intent = out

2 changes: 1 addition & 1 deletion physics/GFS_rrtmg_post.meta
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
[ltp]
standard_name = extra_top_layer
long_name = extra top layers
units = none
units = count
dimensions = ()
type = integer
intent = in
Expand Down
15 changes: 9 additions & 6 deletions physics/GFS_rrtmg_pre.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end subroutine GFS_rrtmg_pre_init
!!
! Attention - the output arguments lm, im, lmk, lmp must not be set
! in the CCPP version - they are defined in the interstitial_create routine
subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &
subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, lextop, ltp, n_var_lndp, &
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are the changes in this file related to a bugfix or are they specific to NRL?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think these may be NRL/NEPTUNE-specific.

Choose a reason for hiding this comment

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

I think they are bug fixes when using lextop=.true. @matusmartini can comment more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember those, yes. It would be really good to get the lextop bugfixes in. The UFS doesn't use the capability and there are no regression tests that cover it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we use this capabilty with success for several suites and maintain it so it does not break our warm restart tests. I added a capability to have lextop as a namelist control flag so it can be turned on/off.

imfdeepcnv, imfdeepcnv_gf, me, ncnd, ntrac, num_p3d, npdf3d, ncnvcld3d,&
ntqv, ntcw,ntiw, ntlnc, ntinc, ntrw, ntsw, ntgl, ntwa, ntoz, &
ntclamt, nleffr, nieffr, nseffr, lndp_type, kdt, imp_physics, &
Expand All @@ -37,11 +37,10 @@ subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &
clouds9, cldsa, cldfra, faersw1, faersw2, faersw3, faerlw1, faerlw2, &
faerlw3, alpha, errmsg, errflg)

use machine, only: kind_phys
use machine, only: kind_phys, r8=>kind_dbl_prec
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the definition of r8. Not used in this routine. Was probably added during debugging and forgot to remove.


use physparam

use radcons, only: itsfc,ltp, lextop, qmin, &
use radcons, only: itsfc, qmin, &
qme5, qme6, epsq, prsmin
use funcphys, only: fpvs

Expand Down Expand Up @@ -79,7 +78,7 @@ subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &

implicit none

integer, intent(in) :: im, levs, lm, lmk, lmp, n_var_lndp, &
integer, intent(in) :: im, levs, lm, lmk, lmp, ltp, n_var_lndp, &
imfdeepcnv, &
imfdeepcnv_gf, me, ncnd, ntrac, &
num_p3d, npdf3d, ncnvcld3d, ntqv, &
Expand All @@ -98,7 +97,7 @@ subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &

character(len=3), dimension(:), intent(in) :: lndp_var_list

logical, intent(in) :: lsswr, lslwr, ltaerosol, lgfdlmprad, &
logical, intent(in) :: lextop, lsswr, lslwr, ltaerosol, lgfdlmprad, &
uni_cld, effr_in, do_mynnedmf, &
lmfshal, lmfdeep2, pert_clds

Expand Down Expand Up @@ -295,6 +294,8 @@ subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &
plyr(i,k1) = prsl(i,k2) * 0.01 ! pa to mb (hpa)
tlyr(i,k1) = tgrs(i,k2)
prslk1(i,k1) = prslk(i,k2)
rho(i,k1) = prsl(i,k2)/(con_rd*tlyr(i,k1))
orho(i,k1) = 1.0/rho(i,k1)

!> - Compute relative humidity.
es = min( prsl(i,k2), fpvs( tgrs(i,k2) ) ) ! fpvs and prsl in pa
Expand Down Expand Up @@ -351,6 +352,8 @@ subroutine GFS_rrtmg_pre_run (im, levs, lm, lmk, lmp, n_var_lndp, &
plyr(i,lyb) = 0.5 * plvl(i,lla)
tlyr(i,lyb) = tlyr(i,lya)
prslk1(i,lyb) = (plyr(i,lyb)*0.001) ** rocp ! plyr in hPa
rho(i,lyb) = plyr(i,lyb) *100.0/(con_rd*tlyr(i,lyb))
orho(i,lyb) = 1.0/rho(i,lyb)
rhly(i,lyb) = rhly(i,lya)
qstl(i,lyb) = qstl(i,lya)
enddo
Expand Down
12 changes: 12 additions & 0 deletions physics/GFS_rrtmg_pre.meta
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
dimensions = ()
type = integer
intent = in
[lextop]
standard_name = flag_for_extra_top_layer_for_radiation_calculations
long_name = flag for extra top layer for radiation calculations
units = flag
dimensions = ()
type = logical
[ltp]
standard_name = extra_top_layer
long_name = extra top layer
units = count
dimensions = ()
type = integer
[n_var_lndp]
standard_name = number_of_perturbed_land_surface_variables
long_name = number of land surface variables perturbed
Expand Down
13 changes: 6 additions & 7 deletions physics/GFS_rrtmg_setup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ module GFS_rrtmg_setup
& iswcliq, &
& kind_phys

use radcons, only: ltp, lextop

implicit none

public GFS_rrtmg_setup_init, GFS_rrtmg_setup_timestep_init, GFS_rrtmg_setup_finalize
Expand Down Expand Up @@ -46,7 +44,7 @@ subroutine GFS_rrtmg_setup_init ( &
si, levr, ictm, isol, ico2, iaer, ntcw, &
num_p3d, npdf3d, ntoz, iovr, isubc_sw, isubc_lw, &
icliq_sw, crick_proof, ccnorm, &
imp_physics, &
imp_physics, ltp, &
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are the changes in this file related to a bugfix or are they specific to NRL?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am checking with our developers. They appear to be NRL-specific, but I'll let you know.

Choose a reason for hiding this comment

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

These are related to using lextop=.true.

norad_precip, idate, iflip, &
do_RRTMGP, me, errmsg, errflg)
! ================= subprogram documentation block ================ !
Expand Down Expand Up @@ -164,6 +162,7 @@ subroutine GFS_rrtmg_setup_init ( &
logical, intent(in) :: crick_proof
logical, intent(in) :: ccnorm
integer, intent(in) :: imp_physics
integer, intent(in) :: ltp
logical, intent(in) :: norad_precip
integer, intent(in) :: idate(:)
integer, intent(in) :: iflip
Expand Down Expand Up @@ -241,7 +240,7 @@ subroutine GFS_rrtmg_setup_init ( &

call radinit &
! --- inputs:
& ( si, levr, imp_physics, me )
& ( si, levr, imp_physics, ltp, me )
! --- outputs:
! ( none )

Expand Down Expand Up @@ -322,7 +321,7 @@ end subroutine GFS_rrtmg_setup_finalize
! Private functions


subroutine radinit( si, NLAY, imp_physics, me )
subroutine radinit( si, NLAY, imp_physics, ltp, me )
!...................................

! --- inputs:
Expand Down Expand Up @@ -435,7 +434,7 @@ subroutine radinit( si, NLAY, imp_physics, me )
implicit none

! --- inputs:
integer, intent(in) :: NLAY, me, imp_physics
integer, intent(in) :: NLAY, me, imp_physics, ltp

real (kind=kind_phys), intent(in) :: si(:)

Expand Down Expand Up @@ -465,7 +464,7 @@ subroutine radinit( si, NLAY, imp_physics, me )
print *,' IVFLIP=',ivflip,' IOVR=',iovrRad, &
& ' ISUBCSW=',isubcsw,' ISUBCLW=',isubclw
print *,' LCRICK=',lcrick,' LCNORM=',lcnorm,' LNOPREC=',lnoprec
print *,' LTP =',ltp,', add extra top layer =',lextop
print *,' LTP =',ltp,', add extra top layer =', ltp == 1

if ( ictmflg==0 .or. ictmflg==-2 ) then
print *,' Data usage is limited by initial condition!'
Expand Down
7 changes: 7 additions & 0 deletions physics/GFS_rrtmg_setup.meta
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
dimensions = ()
type = integer
intent = in
[ltp]
standard_name = extra_top_layer
long_name = extra top layer for radiation calculations
units = count
dimensions = ()
type = integer
intent = in
[norad_precip]
standard_name = flag_for_turning_off_precipitation_radiative_effect
long_name = radiation precip flag for Ferrier/Moorthi
Expand Down
3 changes: 3 additions & 0 deletions physics/calpreciptype.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module mod_calpreciptype
contains
!>\file calpreciptype.f90
!! This file contains the subroutines that calculates dominant precipitation type.

Expand Down Expand Up @@ -1377,3 +1379,4 @@ subroutine calwxt_dominant(nalg,rain,freezr,sleet,snow, &
return
end
!! @}
end module mod_calpreciptype
3 changes: 3 additions & 0 deletions physics/cires_orowam2017.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module mod_cires_orowam2017
contains
subroutine oro_wam_2017(im, levs,npt,ipt, kref,kdt,me,master,
& dtp,dxres, taub, u1, v1, t1, xn, yn, bn2, rho, prsi, prsL,
& del, sigma, hprime, gamma, theta,
Expand Down Expand Up @@ -384,3 +386,4 @@ subroutine ugwpv0_tofd1d(levs, sigflt, elvmax, zsurf,
enddo
!
end subroutine ugwpv0_tofd1d
end module mod_cires_orowam2017
4 changes: 4 additions & 0 deletions physics/cires_ugwp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module cires_ugwp

use gwdps, only: gwdps_run

use mod_cires_ugwp_triggers

use mod_ugwp_driver_v0

implicit none

private
Expand Down
3 changes: 3 additions & 0 deletions physics/cires_ugwp_triggers.F90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module mod_cires_ugwp_triggers
contains
!
subroutine slat_geos5_tamp_v0(im, tau_amp, xlatdeg, tau_gw)
!=================
Expand Down Expand Up @@ -97,3 +99,4 @@ subroutine init_nazdir_v0(naz, xaz, yaz)
yaz(4) =-1.0 !S
endif
end subroutine init_nazdir_v0
end module mod_cires_ugwp_triggers
5 changes: 3 additions & 2 deletions physics/cires_ugwpv1_sporo.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

module mod_cires_ugwpv1_sporo
contains
subroutine oro_spectral_solver(im, levs,npt,ipt, kref,kdt,me,master, &
dtp,dxres, taub, u1, v1, t1, xn, yn, bn2, rho, prsi, prsL, &
del, sigma, hprime, gamma, theta, &
Expand Down Expand Up @@ -348,4 +349,4 @@ subroutine oro_meanflow(nz, nzi, u1, v1, t1, pint, pmid, &
dzi(k) = dzi(k-1)

end subroutine oro_meanflow

end module mod_cires_ugwpv1_sporo
Loading