Skip to content

Commit

Permalink
Merge pull request #12 from SamuelTrahanNOAA/bugfix/rrfs-debug-mode
Browse files Browse the repository at this point in the history
boundary condition bug fixes
  • Loading branch information
SamuelTrahanNOAA authored Sep 28, 2022
2 parents fad4c9f + 68a833f commit ff5cfe7
Show file tree
Hide file tree
Showing 12 changed files with 705 additions and 357 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ endif()

if(NOT FMS_FOUND)
find_package(FMS REQUIRED COMPONENTS ${kind})
add_library(fms ALIAS FMS::fms_${kind})
string(TOLOWER ${kind} kind_lower)
add_library(fms ALIAS FMS::fms_${kind_lower})
endif()

list(APPEND moving_srcs
Expand Down Expand Up @@ -189,7 +190,7 @@ set_property(SOURCE model/fv_mapz.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${F
set_property(SOURCE tools/fv_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0")

set_target_properties(fv3 PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/fv3)
target_include_directories(fv3 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/fv3>
target_include_directories(fv3 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/fv3>
$<INSTALL_INTERFACE:include/fv3>)

target_include_directories(fv3 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
34 changes: 19 additions & 15 deletions driver/fvGFS/atmosphere.F90
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ module atmosphere_mod
logical :: cold_start = .false. ! used in initial condition

integer, dimension(:), allocatable :: id_tracerdt_dyn
integer :: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, cld_amt ! condensate species tracer indices
integer :: sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hailwat, cld_amt ! condensate species tracer indices

integer :: mygrid = 1
integer :: p_split = 1
Expand Down Expand Up @@ -324,10 +324,12 @@ subroutine atmosphere_init (Time_init, Time, Time_step, Grid_box, area)
logical :: dycore_only = .false.
logical :: debug = .false.
logical :: sync = .false.
logical :: ignore_rst_cksum = .false.
integer, parameter :: maxhr = 4096
real, dimension(maxhr) :: fdiag = 0.
real :: fhmax=384.0, fhmaxhf=120.0, fhout=3.0, fhouthf=1.0,avg_max_length=3600.
namelist /atmos_model_nml/ blocksize, chksum_debug, dycore_only, debug, sync, fdiag, fhmax, fhmaxhf, fhout, fhouthf, ccpp_suite, avg_max_length
namelist /atmos_model_nml/ blocksize, chksum_debug, dycore_only, debug, sync, fdiag, fhmax, fhmaxhf, fhout, fhouthf, ccpp_suite, &
& avg_max_length, ignore_rst_cksum
! *DH 20210326

!For regional
Expand Down Expand Up @@ -357,7 +359,7 @@ subroutine atmosphere_init (Time_init, Time, Time_step, Grid_box, area)
#ifdef MOVING_NEST
call fv_tracker_init(size(Atm))
if (mygrid .eq. 2) call allocate_tracker(mygrid, Atm(mygrid)%bd%isc, Atm(mygrid)%bd%iec, Atm(mygrid)%bd%jsc, Atm(mygrid)%bd%jec)
#endif
#endif

Atm(mygrid)%Time_init = Time_init

Expand Down Expand Up @@ -403,9 +405,10 @@ subroutine atmosphere_init (Time_init, Time, Time_step, Grid_box, area)
rainwat = get_tracer_index (MODEL_ATMOS, 'rainwat' )
snowwat = get_tracer_index (MODEL_ATMOS, 'snowwat' )
graupel = get_tracer_index (MODEL_ATMOS, 'graupel' )
hailwat = get_tracer_index (MODEL_ATMOS, 'hailwat' )
cld_amt = get_tracer_index (MODEL_ATMOS, 'cld_amt')

if (max(sphum,liq_wat,ice_wat,rainwat,snowwat,graupel) > Atm(mygrid)%flagstruct%nwat) then
if (max(sphum,liq_wat,ice_wat,rainwat,snowwat,graupel,hailwat) > Atm(mygrid)%flagstruct%nwat) then
call mpp_error (FATAL,' atmosphere_init: condensate species are not first in the list of &
&tracers defined in the field_table')
endif
Expand Down Expand Up @@ -449,6 +452,15 @@ subroutine atmosphere_init (Time_init, Time, Time_step, Grid_box, area)
!--- allocate pref
allocate(pref(npz+1,2), dum1d(npz+1))

! DH* 20210326
! First, read atmos_model_nml namelist section - this is a workaround to avoid
! unnecessary additional changes to the input namelists, in anticipation of the
! implementation of a generic interface for GFDL and CCPP fast physics soon
read(input_nml_file, nml=atmos_model_nml, iostat=io)
ierr = check_nml_error(io, 'atmos_model_nml')
!write(0,'(a)') "It's me, and my physics suite is '" // trim(ccpp_suite) // "'"
! *DH 20210326

call fv_restart(Atm(mygrid)%domain, Atm, seconds, days, cold_start, Atm(mygrid)%gridstruct%grid_type, mygrid)

fv_time = Time
Expand Down Expand Up @@ -490,15 +502,6 @@ subroutine atmosphere_init (Time_init, Time, Time_step, Grid_box, area)

! Do CCPP fast physics initialization before call to adiabatic_init (since this calls fv_dynamics)

! DH* 20210326
! First, read atmos_model_nml namelist section - this is a workaround to avoid
! unnecessary additional changes to the input namelists, in anticipation of the
! implementation of a generic interface for GFDL and CCPP fast physics soon
read(input_nml_file, nml=atmos_model_nml, iostat=io)
ierr = check_nml_error(io, 'atmos_model_nml')
!write(0,'(a)') "It's me, and my physics suite is '" // trim(ccpp_suite) // "'"
! *DH 20210326

! For fast physics running over the entire domain, block
! and thread number are not used; set to safe values
cdata%blk_no = 1
Expand Down Expand Up @@ -953,10 +956,10 @@ end subroutine get_nth_domain_info
!! the "domain2d" variable associated with the coupling grid and the
!! decomposition for the current cubed-sphere tile.
!>@detail Coupling is done using the mass/temperature grid with no halos.
subroutine atmosphere_domain ( fv_domain, layout, regional, nested, &
subroutine atmosphere_domain ( fv_domain, rd_domain, layout, regional, nested, &
moving_nest_parent, is_moving_nest, &
ngrids_atmos, mygrid_atmos, pelist )
type(domain2d), intent(out) :: fv_domain
type(domain2d), intent(out) :: fv_domain, rd_domain
integer, intent(out) :: layout(2)
logical, intent(out) :: regional
logical, intent(out) :: nested
Expand All @@ -969,6 +972,7 @@ subroutine atmosphere_domain ( fv_domain, layout, regional, nested, &
integer :: n

fv_domain = Atm(mygrid)%domain_for_coupler
rd_domain = Atm(mygrid)%domain_for_read
layout(1:2) = Atm(mygrid)%layout(1:2)
regional = Atm(mygrid)%flagstruct%regional
nested = ngrids > 1
Expand Down
7 changes: 5 additions & 2 deletions model/dyn_core.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ subroutine dyn_core(npx, npy, npz, ng, sphum, nq, bdt, n_map, n_split, zvir, cp,

call timing_on('COMM_TOTAL')
#ifndef ROT3
if ( it/=n_split) &
if ( .not. flagstruct%regional .and. it/=n_split) &
call start_group_halo_update(i_pack(8), u, v, domain, gridtype=DGRID_NE)
#endif
call timing_off('COMM_TOTAL')
Expand Down Expand Up @@ -1351,7 +1351,10 @@ subroutine dyn_core(npx, npy, npz, ng, sphum, nq, bdt, n_map, n_split, zvir, cp,
isd, ied, jsd, jed, &
reg_bc_update_time,it )

call mpp_update_domains(u, v, domain, gridtype=DGRID_NE)
#ifndef ROT3
if (it/=n_split) &
call start_group_halo_update(i_pack(8), u, v, domain, gridtype=DGRID_NE)
#endif

endif

Expand Down
2 changes: 2 additions & 0 deletions model/fv_arrays.F90
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ module fv_arrays_mod
!-----------------------------------------------------------------------------------------------

logical :: reset_eta = .false.
logical :: ignore_rst_cksum = .false. !< enfore (.false.) or override (.true.) data integrity restart checksums
real :: p_fac = 0.05 !< Safety factor for minimum nonhydrostatic pressures, which
!< will be limited so the full pressure is no less than p_fac
!< times the hydrostatic pressure. This is only of concern in mid-top
Expand Down Expand Up @@ -1303,6 +1304,7 @@ module fv_arrays_mod
#if defined(SPMD)

type(domain2D) :: domain_for_coupler !< domain used in coupled model with halo = 1.
type(domain2D) :: domain_for_read !< domain used for reads to increase performance when io_layout=(1,1)

!global tile and tile_of_mosaic only have a meaning for the CURRENT pe
integer :: num_contact, npes_per_tile, global_tile, tile_of_mosaic, npes_this_grid
Expand Down
9 changes: 6 additions & 3 deletions model/fv_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ subroutine fv_control_init(Atm, dt_atmos, this_grid, grids_on_this_pe, p_split,
real, intent(in) :: dt_atmos
integer, intent(OUT) :: this_grid
logical, allocatable, intent(OUT) :: grids_on_this_pe(:)
character(len=32), optional, intent(in) :: nml_filename_in ! alternate nml
character(len=32), optional, intent(in) :: nml_filename_in ! alternate nml
logical, optional, intent(in) :: skip_nml_read_in ! use previously loaded nml

integer, intent(INOUT) :: p_split
Expand Down Expand Up @@ -291,6 +291,7 @@ subroutine fv_control_init(Atm, dt_atmos, this_grid, grids_on_this_pe, p_split,
real(kind=R_GRID) , pointer :: target_lon

logical , pointer :: reset_eta
logical , pointer :: ignore_rst_cksum
real , pointer :: p_fac
real , pointer :: a_imp
integer , pointer :: n_split
Expand Down Expand Up @@ -676,7 +677,8 @@ subroutine fv_control_init(Atm, dt_atmos, this_grid, grids_on_this_pe, p_split,
Atm(this_grid)%flagstruct%grid_type,Atm(this_grid)%neststruct%nested, &
Atm(this_grid)%layout,Atm(this_grid)%io_layout,Atm(this_grid)%bd,Atm(this_grid)%tile_of_mosaic, &
Atm(this_grid)%gridstruct%square_domain,Atm(this_grid)%npes_per_tile,Atm(this_grid)%domain, &
Atm(this_grid)%domain_for_coupler,Atm(this_grid)%num_contact,Atm(this_grid)%pelist)
Atm(this_grid)%domain_for_coupler,Atm(this_grid)%domain_for_read,Atm(this_grid)%num_contact, &
Atm(this_grid)%pelist)
call broadcast_domains(Atm,Atm(this_grid)%pelist,size(Atm(this_grid)%pelist))
do n=1,ngrids
tile_id = mpp_get_tile_id(Atm(n)%domain)
Expand Down Expand Up @@ -857,6 +859,7 @@ subroutine set_namelist_pointers(Atm)
regional_bcs_from_gsi => Atm%flagstruct%regional_bcs_from_gsi
write_restart_with_bcs => Atm%flagstruct%write_restart_with_bcs
reset_eta => Atm%flagstruct%reset_eta
ignore_rst_cksum => Atm%flagstruct%ignore_rst_cksum
p_fac => Atm%flagstruct%p_fac
a_imp => Atm%flagstruct%a_imp
n_split => Atm%flagstruct%n_split
Expand Down Expand Up @@ -1075,7 +1078,7 @@ subroutine read_namelist_fv_core_nml(Atm)
write_coarse_restart_files,&
write_coarse_diagnostics,&
write_only_coarse_intermediate_restarts, &
write_coarse_agrid_vel_rst, write_coarse_dgrid_vel_rst
write_coarse_agrid_vel_rst, write_coarse_dgrid_vel_rst, ignore_rst_cksum


! Read FVCORE namelist
Expand Down
2 changes: 1 addition & 1 deletion model/fv_fill.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module fv_fill_mod
! </table>

use mpp_domains_mod, only: mpp_update_domains, domain2D
use platform_mod, only: kind_phys => r8_kind
use GFS_typedefs, only: kind_phys

implicit none
public fillz
Expand Down
Loading

0 comments on commit ff5cfe7

Please sign in to comment.