From 5f0643e9ec87e0d83c8b8936d7819719aac98bfa Mon Sep 17 00:00:00 2001 From: Tracy Date: Wed, 17 Sep 2025 09:59:15 -0600 Subject: [PATCH 1/4] updates for ufs/dev PR301 --- .gitmodules | 4 +- ccpp/physics | 2 +- scm/src/GFS_typedefs.F90 | 185 +++++++++++++++++++++++++++----------- scm/src/GFS_typedefs.meta | 18 ++++ scm/src/scm_setup.F90 | 25 +++--- 5 files changed, 168 insertions(+), 66 deletions(-) diff --git a/.gitmodules b/.gitmodules index dc0798c32..03bff1420 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,8 +4,8 @@ branch = main [submodule "ccpp-physics"] path = ccpp/physics - url = https://github.com/NCAR/ccpp-physics - branch = main + url = https://github.com/hertneky/ccpp-physics + branch = ufs-dev-PR301 [submodule "CMakeModules"] path = CMakeModules url = https://github.com/noaa-emc/CMakeModules diff --git a/ccpp/physics b/ccpp/physics index 2bd74bab4..927acf94b 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 2bd74bab4cddeb1d24b1cec132b3762ec1464be4 +Subproject commit 927acf94b468e29fe26350d23ef5f82488954158 diff --git a/scm/src/GFS_typedefs.F90 b/scm/src/GFS_typedefs.F90 index 35164f022..d56b440bc 100644 --- a/scm/src/GFS_typedefs.F90 +++ b/scm/src/GFS_typedefs.F90 @@ -770,6 +770,11 @@ module GFS_typedefs ! integer :: fire_aux_data_levels !< vertical levels of fire auxiliary data +!--- dycore control parameters + integer :: dycore_active !< Choice of dynamical core + integer :: dycore_fv3 = 1 !< Choice of FV3 dynamical core + integer :: dycore_mpas = 2 !< Choice of MPAS dynamical core + !--- coupling parameters logical :: cplflx !< default no cplflx collection logical :: cplice !< default no cplice collection (used together with cplflx) @@ -1826,6 +1831,7 @@ module GFS_typedefs real (kind=kind_phys), pointer :: dku3d_h (:,:) => null() !< Horizontal eddy diffusitivity for momentum real (kind=kind_phys), pointer :: dku3d_e (:,:) => null() !< Eddy diffusitivity for momentum for tke + !--- dynamical forcing variables for Grell-Freitas convection real (kind=kind_phys), pointer :: forcet (:,:) => null() !< real (kind=kind_phys), pointer :: forceq (:,:) => null() !< @@ -3372,15 +3378,15 @@ end subroutine coupling_create !---------------------- ! GFS_control_type%init !---------------------- - subroutine control_initialize (Model, nlunit, fn_nml, me, master, & - logunit, isc, jsc, nx, ny, levs, & - cnx, cny, gnx, gny, dt_dycore, & + subroutine control_initialize (Model, nlunit, fn_nml, me, & + master, logunit, levs, dt_dycore, & dt_phys, iau_offset, idat, jdat, & nwat, tracer_names, tracer_types, & - input_nml_file, tile_num, blksz, & - ak, bk, restart, hydrostatic, & - communicator, ntasks, nthreads) - + input_nml_file, blksz, restart, & + communicator, ntasks, nthreads, & + tile_num, isc, jsc, nx, ny, cnx, & + cny, gnx, gny, ak, bk, hydrostatic) + !--- modules use physcons, only: con_rerth, con_pi, con_p0, rhowater use mersenne_twister, only: random_setseed, random_number @@ -3395,16 +3401,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & integer, intent(in) :: me integer, intent(in) :: master integer, intent(in) :: logunit - integer, intent(in) :: tile_num - integer, intent(in) :: isc - integer, intent(in) :: jsc - integer, intent(in) :: nx - integer, intent(in) :: ny integer, intent(in) :: levs - integer, intent(in) :: cnx - integer, intent(in) :: cny - integer, intent(in) :: gnx - integer, intent(in) :: gny real(kind=kind_phys), intent(in) :: dt_dycore real(kind=kind_phys), intent(in) :: dt_phys integer, intent(in) :: iau_offset @@ -3415,13 +3412,23 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & integer, intent(in) :: tracer_types(:) character(len=:), intent(in), dimension(:), pointer :: input_nml_file integer, intent(in) :: blksz(:) - real(kind=kind_phys), dimension(:), intent(in) :: ak - real(kind=kind_phys), dimension(:), intent(in) :: bk logical, intent(in) :: restart - logical, intent(in) :: hydrostatic type(MPI_Comm), intent(in) :: communicator integer, intent(in) :: ntasks integer, intent(in) :: nthreads + !--- optional variables (Dycore specific) + integer, optional, intent(in) :: tile_num + integer, optional, intent(in) :: isc + integer, optional, intent(in) :: jsc + integer, optional, intent(in) :: nx + integer, optional, intent(in) :: ny + integer, optional, intent(in) :: cnx + integer, optional, intent(in) :: cny + integer, optional, intent(in) :: gnx + integer, optional, intent(in) :: gny + logical, optional, intent(in) :: hydrostatic + real(kind_phys), optional, dimension(:), intent(in) :: ak + real(kind_phys), optional, dimension(:), intent(in) :: bk !--- local variables integer :: i, j, n @@ -4331,6 +4338,58 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & !--- NRL ozone physics character(len=128) :: err_message + !--- If initializing model with FV3 dynamical core. + if (Model%dycore_active == Model%dycore_fv3) then + if (.not. present(tile_num)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(isc)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(jsc)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(nx)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(ny)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(cnx)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(cny)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(gnx)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(gny)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(hydrostatic)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(ak)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + if (.not. present(bk)) then + write(6,*) 'ERROR: is required when using FV3 dynamical core' + stop + endif + endif + !--- CCPP suite simulator integer :: ncid, dimID, varID, status, ntime_sim_data, nlev_sim_data, errflg character(len=256) :: errmsg @@ -4526,23 +4585,28 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%sfcpress_id = sfcpress_id Model%gen_coord_hybrid = gen_coord_hybrid - !--- set some grid extent parameters - Model%tile_num = tile_num - Model%isc = isc - Model%jsc = jsc - Model%nx = nx - Model%ny = ny + !--- set some grid extent parameters (dycore specific) + if (Model%dycore_active == Model%dycore_fv3) then + Model%tile_num = tile_num + Model%isc = isc + Model%jsc = jsc + Model%nx = nx + Model%ny = ny + allocate (Model%ak(1:size(ak))) + allocate (Model%bk(1:size(bk))) + Model%ak = ak + Model%bk = bk + Model%cnx = cnx + Model%cny = cny + Model%lonr = gnx ! number longitudinal points + Model%latr = gny ! number of latitudinal points from pole to pole + endif + if (Model%dycore_active == Model%dycore_mpas) then + + end if Model%levs = levs - allocate (Model%ak(1:size(ak))) - allocate (Model%bk(1:size(bk))) - Model%ak = ak - Model%bk = bk Model%levsp1 = Model%levs + 1 Model%levsm1 = Model%levs - 1 - Model%cnx = cnx - Model%cny = cny - Model%lonr = gnx ! number longitudinal points - Model%latr = gny ! number of latitudinal points from pole to pole Model%nblks = size(blksz) allocate (Model%blksz(1:Model%nblks)) Model%blksz = blksz @@ -5904,28 +5968,38 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%first_time_step = .true. Model%restart = restart Model%lsm_cold_start = .not. restart - Model%hydrostatic = hydrostatic if (Model%me == Model%master) then print *,'in atm phys init, phour=',Model%phour,'fhour=',Model%fhour,'zhour=',Model%zhour,'kdt=',Model%kdt endif - - if(Model%hydrostatic .and. Model%lightning_threat) then - write(0,*) 'Turning off lightning threat index for hydrostatic run.' - Model%lightning_threat = .false. - lightning_threat = .false. + if (Model%dycore_active == Model%dycore_fv3) then + Model%hydrostatic = hydrostatic + if(Model%hydrostatic .and. Model%lightning_threat) then + write(0,*) 'Turning off lightning threat index for hydrostatic run.' + Model%lightning_threat = .false. + lightning_threat = .false. + endif endif - Model%jdat(1:8) = jdat(1:8) - allocate (Model%si(Model%levs+1)) - !--- Define sigma level for radiation initialization + !--- Define sigma level for radiation initialization (FV3) !--- The formula converting hybrid sigma pressure coefficients to sigma coefficients follows Eckermann (2009, MWR) !--- ps is replaced with p0. The value of p0 uses that in http://www.emc.ncep.noaa.gov/officenotes/newernotes/on461.pdf !--- ak/bk have been flipped from their original FV3 orientation and are defined sfc -> toa - Model%si(1:Model%levs+1) = (ak(1:Model%levs+1) + bk(1:Model%levs+1) * con_p0 - ak(Model%levs+1)) / (con_p0 - ak(Model%levs+1)) + allocate (Model%si(Model%levs+1)) + if (Model%dycore_active == Model%dycore_fv3) then + Model%si(1:Model%levs+1) = (ak(1:Model%levs+1) + bk(1:Model%levs+1) * con_p0 - ak(Model%levs+1)) / (con_p0 - ak(Model%levs+1)) + end if + ! DJS2025: NOT YET IMPLEMENTED + if (Model%dycore_active == Model%dycore_mpas) then + Model%si(1:Model%levs+1) = 1._kind_phys + endif + + ! --- Set default time + Model%jdat(1:8) = jdat(1:8) Model%sec = 0 Model%yearlen = 365 Model%julian = -9999. + !--- Set vertical flag used by radiation schemes Model%top_at_1 = .false. if (Model%do_RRTMGP) then @@ -6730,18 +6804,23 @@ subroutine control_print(Model) print *, ' thermodyn_id : ', Model%thermodyn_id print *, ' sfcpress_id : ', Model%sfcpress_id print *, ' gen_coord_hybrid : ', Model%gen_coord_hybrid - print *, ' hydrostatic : ', Model%hydrostatic + if (Model%dycore_active == Model%dycore_fv3) then + print *, ' hydrostatic : ', Model%hydrostatic + endif print *, ' ' print *, 'grid extent parameters' - print *, ' isc : ', Model%isc - print *, ' jsc : ', Model%jsc - print *, ' nx : ', Model%nx - print *, ' ny : ', Model%ny - print *, ' levs : ', Model%levs - print *, ' cnx : ', Model%cnx - print *, ' cny : ', Model%cny - print *, ' lonr : ', Model%lonr - print *, ' latr : ', Model%latr + if (Model%dycore_active == Model%dycore_fv3) then + print *, ' isc : ', Model%isc + print *, ' jsc : ', Model%jsc + print *, ' nx : ', Model%nx + print *, ' ny : ', Model%ny + print *, ' levs : ', Model%levs + print *, ' cnx : ', Model%cnx + print *, ' cny : ', Model%cny + print *, ' lonr : ', Model%lonr + print *, ' latr : ', Model%latr + end if + print *, ' nblks : ', Model%nblks print *, ' blksz(1) : ', Model%blksz(1) print *, ' blksz(nblks) : ', Model%blksz(Model%nblks) print *, ' Model%ncols : ', Model%ncols diff --git a/scm/src/GFS_typedefs.meta b/scm/src/GFS_typedefs.meta index 675589479..09975eeb1 100644 --- a/scm/src/GFS_typedefs.meta +++ b/scm/src/GFS_typedefs.meta @@ -3699,6 +3699,24 @@ units = index dimensions = () type = integer +[dycore_active] + standard_name = control_for_dynamical_core + long_name = choice of dynamical core + units = flag + dimensions = () + type = integer +[dycore_fv3] + standard_name = identifier_for_fv3_dynamical_core + long_name = identifier for FV3 dynamical core + units = flag + dimensions = () + type = integer +[dycore_mpas] + standard_name = identifier_for_mpas_dynamical_core + long_name = identifier for MPAS dynamical core + units = flag + dimensions = () + type = integer [tile_num] standard_name = index_of_cubed_sphere_tile long_name = tile number diff --git a/scm/src/scm_setup.F90 b/scm/src/scm_setup.F90 index 7eb3cecd8..3c27fe589 100644 --- a/scm/src/scm_setup.F90 +++ b/scm/src/scm_setup.F90 @@ -325,20 +325,25 @@ subroutine GFS_suite_setup (Model, Statein, Stateout, Sfcprop, integer :: i !--- set control properties (including namelist read) + Model%dycore_active = Model%dycore_fv3 call Model%init (Init_parm%nlunit, Init_parm%fn_nml, & Init_parm%me, Init_parm%master, & - Init_parm%logunit, Init_parm%isc, & - Init_parm%jsc, Init_parm%nx, Init_parm%ny, & - Init_parm%levs, Init_parm%cnx, Init_parm%cny, & - Init_parm%gnx, Init_parm%gny, & + Init_parm%logunit, Init_parm%levs, & Init_parm%dt_dycore, Init_parm%dt_phys, & - Init_parm%iau_offset, & - Init_parm%bdat, Init_parm%cdat, Init_parm%nwat, & + Init_parm%iau_offset, Init_parm%bdat, & + Init_parm%cdat, Init_parm%nwat, & Init_parm%tracer_names, Init_parm%tracer_types, & - Init_parm%input_nml_file, Init_parm%tile_num, & - Init_parm%blksz, Init_parm%ak, Init_parm%bk, & - Init_parm%restart, Init_parm%hydrostatic, & - Init_parm%fcst_mpi_comm, ntasks, nthreads) + Init_parm%input_nml_file, Init_parm%blksz, & + Init_parm%restart, Init_parm%fcst_mpi_comm, & + ntasks, nthreads, & + ! Below only needed for FV3 dynamical core. + tile_num = Init_parm%tile_num, & + Init_parm%isc, Init_parm%jsc, & + Init_parm%nx, Init_parm%ny, & + Init_parm%cnx, Init_parm%cny, & + Init_parm%gnx, Init_parm%gny, & + Init_parm%ak, Init_parm%bk, & + hydrostatic = Init_parm%hydrostatic) !--- initialize DDTs From d34e04e560f9ac3439cbe0e7ef43bda1c7236e7e Mon Sep 17 00:00:00 2001 From: Tracy Date: Wed, 17 Sep 2025 11:07:55 -0600 Subject: [PATCH 2/4] rearrange code to see if it fixes build issue --- scm/src/GFS_typedefs.F90 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scm/src/GFS_typedefs.F90 b/scm/src/GFS_typedefs.F90 index d56b440bc..7280867bf 100644 --- a/scm/src/GFS_typedefs.F90 +++ b/scm/src/GFS_typedefs.F90 @@ -1831,7 +1831,6 @@ module GFS_typedefs real (kind=kind_phys), pointer :: dku3d_h (:,:) => null() !< Horizontal eddy diffusitivity for momentum real (kind=kind_phys), pointer :: dku3d_e (:,:) => null() !< Eddy diffusitivity for momentum for tke - !--- dynamical forcing variables for Grell-Freitas convection real (kind=kind_phys), pointer :: forcet (:,:) => null() !< real (kind=kind_phys), pointer :: forceq (:,:) => null() !< @@ -4338,6 +4337,10 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, & !--- NRL ozone physics character(len=128) :: err_message +!--- CCPP suite simulator + integer :: ncid, dimID, varID, status, ntime_sim_data, nlev_sim_data, errflg + character(len=256) :: errmsg + !--- If initializing model with FV3 dynamical core. if (Model%dycore_active == Model%dycore_fv3) then if (.not. present(tile_num)) then @@ -4390,10 +4393,6 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, & endif endif -!--- CCPP suite simulator - integer :: ncid, dimID, varID, status, ntime_sim_data, nlev_sim_data, errflg - character(len=256) :: errmsg - ! dtend selection: default is to match all variables: dtend_select(1)='*' do ipat=2,pat_count From 66c5d1aaa5f440f409988e7e14000cb6dbe3b4af Mon Sep 17 00:00:00 2001 From: Tracy Date: Wed, 17 Sep 2025 11:28:15 -0600 Subject: [PATCH 3/4] fix keyword argument complaint --- scm/src/scm_setup.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm/src/scm_setup.F90 b/scm/src/scm_setup.F90 index 3c27fe589..7904e304d 100644 --- a/scm/src/scm_setup.F90 +++ b/scm/src/scm_setup.F90 @@ -337,13 +337,13 @@ subroutine GFS_suite_setup (Model, Statein, Stateout, Sfcprop, Init_parm%restart, Init_parm%fcst_mpi_comm, & ntasks, nthreads, & ! Below only needed for FV3 dynamical core. - tile_num = Init_parm%tile_num, & + Init_parm%tile_num, & Init_parm%isc, Init_parm%jsc, & Init_parm%nx, Init_parm%ny, & Init_parm%cnx, Init_parm%cny, & Init_parm%gnx, Init_parm%gny, & Init_parm%ak, Init_parm%bk, & - hydrostatic = Init_parm%hydrostatic) + Init_parm%hydrostatic) !--- initialize DDTs From 4c2de6f0b8bb7314aeda2234e3a6d2bb666d5030 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Tue, 23 Sep 2025 14:06:36 -0400 Subject: [PATCH 4/4] update ccpp/physics submodule pointer after merge --- .gitmodules | 4 ++-- ccpp/physics | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 03bff1420..dc0798c32 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,8 +4,8 @@ branch = main [submodule "ccpp-physics"] path = ccpp/physics - url = https://github.com/hertneky/ccpp-physics - branch = ufs-dev-PR301 + url = https://github.com/NCAR/ccpp-physics + branch = main [submodule "CMakeModules"] path = CMakeModules url = https://github.com/noaa-emc/CMakeModules diff --git a/ccpp/physics b/ccpp/physics index 927acf94b..f1f094009 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 927acf94b468e29fe26350d23ef5f82488954158 +Subproject commit f1f094009e0e36b29baa8dffb6a58e8969c58777