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

Butterfly effect (from @DusanJovic-NOAA) #21

Merged
Merged
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
4 changes: 4 additions & 0 deletions model/fv_arrays.F90
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,10 @@ module fv_arrays_mod
!< Useful for perturbing initial conditions. -1 by default;
!< disabled if 0 or negative.

logical :: butterfly_effect = .false. !< Flip the least-significant-bit of the lowest level temperature
!< at the center of the domain (the center of tile 1), if set to .true.
!< The default value is .false.

integer :: a2b_ord = 4 !< Order of interpolation used by the pressure gradient force
!< to interpolate cell-centered (A-grid) values to the grid corners.
!< The default value is 4 (recommended), which uses fourth-order
Expand Down
4 changes: 3 additions & 1 deletion model/fv_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ module fv_control_mod
logical , pointer :: make_hybrid_z
logical , pointer :: nudge_qv
real, pointer :: add_noise
logical , pointer :: butterfly_effect

integer , pointer :: a2b_ord
integer , pointer :: c2l_ord
Expand Down Expand Up @@ -669,7 +670,7 @@ subroutine run_setup(Atm, dt_atmos, grids_on_this_pe, p_split)
pnats, dnats, a2b_ord, remap_t, p_ref, d2_bg_k1, d2_bg_k2, &
c2l_ord, dx_const, dy_const, umax, deglat, &
deglon_start, deglon_stop, deglat_start, deglat_stop, &
phys_hydrostatic, use_hydro_pressure, make_hybrid_z, old_divg_damp, add_noise, &
phys_hydrostatic, use_hydro_pressure, make_hybrid_z, old_divg_damp, add_noise, butterfly_effect, &
nested, twowaynest, parent_grid_num, parent_tile, nudge_qv, &
refinement, nestbctype, nestupdate, nsponge, s_weight, &
ioffset, joffset, check_negative, nudge_ic, halo_update_type, gfs_phil, agrid_vel_rst, &
Expand Down Expand Up @@ -1328,6 +1329,7 @@ subroutine setup_pointers(Atm)
make_hybrid_z => Atm%flagstruct%make_hybrid_z
nudge_qv => Atm%flagstruct%nudge_qv
add_noise => Atm%flagstruct%add_noise
butterfly_effect => Atm%flagstruct%butterfly_effect
a2b_ord => Atm%flagstruct%a2b_ord
c2l_ord => Atm%flagstruct%c2l_ord
ndims => Atm%flagstruct%ndims
Expand Down
21 changes: 21 additions & 0 deletions tools/fv_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ subroutine fv_restart(fv_domain, Atm, dt_atmos, seconds, days, cold_start, grid_
integer :: npts
real :: sumpertn

integer :: i_butterfly, j_butterfly

rgrav = 1. / grav

if(.not.module_is_initialized) call mpp_error(FATAL, 'You must call fv_restart_init.')
Expand Down Expand Up @@ -627,6 +629,25 @@ subroutine fv_restart(fv_domain, Atm, dt_atmos, seconds, days, cold_start, grid_
call mpp_error(NOTE, errstring)
endif

if (Atm(n)%flagstruct%butterfly_effect) then
if (n==1 .and. Atm(n)%tile == 1) then
i_butterfly = Atm(n)%npx / 2
j_butterfly = Atm(n)%npy / 2
if (isc <= i_butterfly .and. i_butterfly <= iec) then
if (jsc <= j_butterfly .and. j_butterfly <= jec) then

write(*,'(A, I0, A, I0)') "Adding butterfly effect at (i,j) ", i_butterfly, ", ", j_butterfly
write(*,'(A, E24.17)') "pt (before) :", Atm(n)%pt(i_butterfly,j_butterfly,Atm(n)%npz)

Atm(n)%pt(i_butterfly,j_butterfly,Atm(n)%npz) = nearest(Atm(n)%pt(i_butterfly,j_butterfly,Atm(n)%npz), -1.0)

write(*,'(A, E24.17)') "pt (after) :", Atm(n)%pt(i_butterfly,j_butterfly,Atm(n)%npz)

endif
endif
endif
endif

if (Atm(n)%grid_number > 1) then
write(gn,'(A2, I1)') " g", Atm(n)%grid_number
else
Expand Down