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

Updates for stochastic GM+E #80

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
if(32BIT)
message ("Force 64 bits in stochastic_physics")
if(CCPP_32BIT)
message(STATUS "Compile stochastic_physics with 32-bit precision to match CCPP slow physics.")
add_definitions(-DCCPP_32BIT)
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -real-size 32")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-default-real-8 -fdefault-double-8")
endif()
else()
message(STATUS "Compile stochastic_physics with 64-bit precision to match CCPP slow physics.")
remove_definitions(-DCCPP_32BIT)
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -real-size 64")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
Expand Down
35 changes: 21 additions & 14 deletions cellular_automata_global.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module cellular_automata_global_mod

use update_ca, only : domain_global,iscnx_g,iecnx_g,jscnx_g,jecnx_g,isdnx_g,iednx_g,jsdnx_g,jednx_g, &
nxncells_g,nyncells_g,csum
nxncells_g,nyncells_g,csum,cold_start_ca_global
implicit none

contains
Expand All @@ -11,12 +11,13 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp
nca,ncells,nlives,nfracseed,nseed,iseed_ca, mytile, &
ca_smooth,nspinup,blocksize,nsmooth,ca_amplitude,mpiroot,mpicomm)

use kinddef, only: kind_dbl_prec
use mpi_f08
use kinddef, only: kind_dbl_prec, kind_phys
use update_ca, only: update_cells_global,define_ca_domain
use halo_exchange, only: atmosphere_scalar_field_halo
use random_numbers, only: random_01_CB
use mpp_domains_mod, only: domain2D,mpp_get_global_domain,CENTER, mpp_get_data_domain, mpp_get_compute_domain,mpp_global_sum, &
BITWISE_EFP_SUM, BITWISE_EXACT_SUM
BITWISE_EFP_SUM, BITWISE_EXACT_SUM,mpp_define_io_domain,mpp_get_io_domain_layout
use block_control_mod, only: block_control_type, define_blocks_packed
use mpi_wrapper, only: mp_reduce_sum,mp_reduce_max,mp_reduce_min, &
mpi_wrapper_initialize,mype,is_rootpe
Expand All @@ -30,13 +31,14 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp

!This program evolves a cellular automaton uniform over the globe

integer, intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,nsmooth,mpiroot,mpicomm
integer, intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,nsmooth,mpiroot
type(MPI_Comm), intent(in) :: mpicomm
integer(kind=kind_dbl_prec), intent(in) :: iseed_ca
integer, intent(in) :: mytile
real(kind=kind_dbl_prec), intent(in) :: nfracseed,ca_amplitude
real(kind=kind_phys), intent(in) :: nfracseed,ca_amplitude
logical, intent(in) :: ca_smooth,first_time_step, restart
integer, intent(in) :: nblks,isc,iec,jsc,jec,npx,npy,nlev,blocksize
real(kind=kind_dbl_prec), intent(out) :: ca1_cpl(:,:),ca2_cpl(:,:),ca3_cpl(:,:)
real(kind=kind_phys), intent(out) :: ca1_cpl(:,:),ca2_cpl(:,:),ca3_cpl(:,:)
type(domain2D), intent(inout) :: domain_in
type(block_control_type) :: Atm_block
integer :: nlon, nlat, isize,jsize,nf,nn
Expand All @@ -48,10 +50,11 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp
integer,save :: iscnx,iecnx,jscnx,jecnx
integer :: nxncells, nyncells
integer(8) :: count, count_rate, count_max, count_trunc,nx_full
integer(8) :: iscale = 10000000000
integer(8) :: iscale = 10000000000_8
integer, allocatable :: iini_g(:,:,:),ilives_g(:,:)
real(kind=kind_dbl_prec), allocatable :: field_out(:,:,:), field_smooth(:,:)
real(kind=kind_dbl_prec), allocatable :: CA(:,:),CA1(:,:),CA2(:,:),CA3(:,:),CAprime(:,:)
integer, allocatable :: io_layout(:)
real(kind=kind_phys), allocatable :: field_out(:,:,:), field_smooth(:,:)
real(kind=kind_phys), allocatable :: CA(:,:),CA1(:,:),CA2(:,:),CA3(:,:),CAprime(:,:)
real*8 , allocatable :: noise(:,:,:)
real*8 :: psum,CAmean,sq_diff,CAstdv,inv9
real*8 :: Detmax,Detmin
Expand All @@ -73,7 +76,7 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp
call mpi_wrapper_initialize(mpiroot,mpicomm)
end if

halo=1
halo=3
k_in=1

!----------------------------------------------------------------------------
Expand Down Expand Up @@ -102,8 +105,12 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp
!Get CA domain

if(first_time_step)then
! if (.not. restart) call define_ca_domain(domain_in,domain_global,ncells,nxncells_g,nyncells_g)
domain_global=domain_in
if (.not. restart) then
allocate(io_layout(2))
io_layout=mpp_get_io_domain_layout(domain_in)
call define_ca_domain(domain_in,domain_global,halo,ncells,nxncells_g,nyncells_g)
call mpp_define_io_domain(domain_global, io_layout)
endif
call mpp_get_data_domain (domain_global,isdnx_g,iednx_g,jsdnx_g,jednx_g)
call mpp_get_compute_domain (domain_global,iscnx_g,iecnx_g,jscnx_g,jecnx_g)
endif
Expand Down Expand Up @@ -160,7 +167,7 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp
else
! don't rely on compiler to truncate integer(8) to integer(4) on
! overflow, do wrap around explicitly.
count4 = mod(((iseed_ca+7)*mytile)*(i1+nx_full*(j1-1))+ 2147483648, 4294967296) - 2147483648
count4 = int(mod(int(((iseed_ca+7)*mytile)*(i1+nx_full*(j1-1)), 8) + 2147483648_8, 4294967296_8) - 2147483648_8)
endif
ct=1
do nf=1,nca
Expand Down Expand Up @@ -203,7 +210,7 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp

CA(:,:)=0.

call update_cells_global(kstep,first_time_step,iseed_ca,restart,nca,nxc,nyc,nxch,nych,nlon,nlat,isc,iec,jsc,jec, &
call update_cells_global(kstep,halo,first_time_step,iseed_ca,restart,nca,nxc,nyc,nxch,nych,nlon,nlat,isc,iec,jsc,jec, &
npx,npy,CA,iini_g,ilives_g, &
nlives,ncells,nfracseed,nseed,nspinup,nf,mytile)

Expand Down
Loading