From ff95d68124ecc15d8a1c876c505537efad8390c1 Mon Sep 17 00:00:00 2001 From: Dustin Swales Date: Tue, 15 Jul 2025 22:12:07 +0000 Subject: [PATCH] Initial commit for MPAS interstitials. --- CMakeLists.txt | 2 +- .../GFS_rad_time_vary.mpas.F90 | 72 +++++++++++ .../GFS_rad_time_vary.mpas.meta | 114 ++++++++++++++++++ 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.F90 create mode 100644 physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.meta diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2a2971e..8a79c8df5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ target_link_libraries(ccpp_physics PUBLIC w3emc::w3emc_d NetCDF::NetCDF_Fortran ) #add FMS for FV3 only -if(FV3) +if(FV3 OR MPAS) target_link_libraries(ccpp_physics PUBLIC fms) endif() diff --git a/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.F90 b/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.F90 new file mode 100644 index 000000000..815d629b5 --- /dev/null +++ b/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.F90 @@ -0,0 +1,72 @@ +!>\file GFS_rad_time_vary.mpas.F90 +!! Contains code related to GFS radiation suite setup (radiation part of time_vary_step) +module GFS_rad_time_vary + implicit none + + private + + public GFS_rad_time_vary_timestep_init + +contains + +!> This module contains code related to GFS radiation setup. + +!> \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 (lrseeds, rseeds, lslwr, lsswr, isubc_lw, & + isubc_sw, icsdsw, icsdlw, sec, kdt, ipsd0, ipsdlim, errmsg, errflg) + use mersenne_twister, only: random_setseed, random_index, random_stat + use machine, only: kind_phys + use radcons, only: con_100 + implicit none + + ! Interface variables + logical, intent(in) :: lrseeds + integer, intent(in), optional :: rseeds(:,:) + integer, intent(in) :: isubc_lw, isubc_sw, kdt + integer, intent(in) :: ipsd0, ipsdlim + logical, intent(in) :: lslwr, lsswr + integer, intent(inout), optional :: icsdsw(:), icsdlw(:) + real(kind_phys), intent(in) :: sec + character(len=*), intent(out) :: errmsg + integer, intent(out) :: errflg + + ! Local variables + type (random_stat) :: stat + integer :: ix, j, i, ipseed, ixx + integer, allocatable, dimension(:) :: numrdm + + ! Initialize CCPP error handling variables + errmsg = '' + errflg = 0 + + if (lsswr .or. lslwr) then + !--- 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 + !NRL If random seeds supplied by NEPTUNE + if(lrseeds) then + do ix=1,size(icsdsw) + icsdsw(ix) = rseeds(ix,1) + icsdlw(ix) = rseeds(ix,2) + enddo + else + allocate(numrdm(size(icsdlw)*2)) + ipseed = mod(nint(con_100*sqrt(sec)), ipsdlim) + 1 + ipsd0 + call random_setseed (ipseed, stat) + call random_index (ipsdlim, numrdm, stat) + + ixx = 1 + do ix=1,size(icsdsw)*2,2 + icsdsw(ixx) = numrdm(ix) + icsdlw(ixx) = numrdm(ix+1) + ixx = ixx + 1 + enddo + deallocate(numrdm) + end if ! lrseeds + endif ! isubc_lw and isubc_sw + endif ! lsswr or lslwr + + end subroutine GFS_rad_time_vary_timestep_init + +end module GFS_rad_time_vary diff --git a/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.meta b/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.meta new file mode 100644 index 000000000..28532a5cd --- /dev/null +++ b/physics/Interstitials/UFS_SCM_NEPTUNE/GFS_rad_time_vary.mpas.meta @@ -0,0 +1,114 @@ +[ccpp-table-properties] + name = GFS_rad_time_vary + type = scheme + relative_path = ../../ + dependencies = hooks/machine.F,Radiation/mersenne_twister.f,Radiation/RRTMG/radcons.f90 + +######################################################################## +[ccpp-arg-table] + name = GFS_rad_time_vary_timestep_init + type = scheme +[lrseeds] + standard_name = do_host_provided_random_seeds + long_name = flag to use host-provided random seeds + units = flag + dimensions = () + type = logical + intent = in +[rseeds] + standard_name = random_number_seeds_from_host + long_name = random number seeds from host + units = none + dimensions = (horizontal_dimension, number_of_host_provided_random_number_streams) + type = integer + intent = in + optional = True +[lslwr] + standard_name = flag_for_calling_longwave_radiation + long_name = logical flags for lw radiation calls + units = flag + dimensions = () + type = logical + intent = in +[lsswr] + standard_name = flag_for_calling_shortwave_radiation + long_name = logical flags for sw radiation calls + units = flag + dimensions = () + type = logical + intent = in +[isubc_lw] + standard_name = flag_for_lw_clouds_sub_grid_approximation + long_name = flag for lw clouds sub-grid approximation + units = flag + dimensions = () + type = integer + intent = in +[isubc_sw] + standard_name = flag_for_sw_clouds_grid_approximation + long_name = flag for sw clouds sub-grid approximation + units = flag + dimensions = () + type = integer + intent = in +[icsdsw] + standard_name = random_number_seed_for_mcica_shortwave + long_name = random seeds for sub-column cloud generators sw + units = none + dimensions = (horizontal_dimension) + type = integer + intent = inout + optional = True +[icsdlw] + standard_name = random_number_seed_for_mcica_longwave + long_name = random seeds for sub-column cloud generators lw + units = none + dimensions = (horizontal_dimension) + type = integer + intent = inout + optional = True +[sec] + standard_name = forecast_time_in_seconds + long_name = seconds elapsed since model initialization + units = s + dimensions = () + type = real + kind = kind_phys + intent = in +[kdt] + standard_name = index_of_timestep + long_name = current forecast iteration + units = index + dimensions = () + type = integer + intent = in +[ipsd0] + standard_name = initial_seed_for_mcica + long_name = initial permutaion seed for mcica radiation + units = 1 + dimensions = () + type = integer + intent = in +[ipsdlim] + standard_name = limit_for_initial_seed_for_mcica + long_name = limit for initial permutaion seed for mcica radiation + units = 1 + dimensions = () + type = integer + intent = in +[errmsg] + standard_name = ccpp_error_message + long_name = error message for error handling in CCPP + units = none + dimensions = () + type = character + kind = len=* + intent = out +[errflg] + standard_name = ccpp_error_code + long_name = error code for error handling in CCPP + units = 1 + dimensions = () + type = integer + intent = out +