From 8c4099ea6e402e585925fa8b6595ff1b5857c0c5 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Tue, 29 Jul 2025 13:56:30 -0400 Subject: [PATCH] print messages on rootpe only --- get_stochy_pattern.F90 | 10 +++++----- stochastic_physics.F90 | 2 +- stochy_data_mod.F90 | 24 ++++++++++++------------ stochy_patterngenerator.F90 | 30 ++++++++++++++++-------------- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/get_stochy_pattern.F90 b/get_stochy_pattern.F90 index f61ea337..31c7cb6c 100644 --- a/get_stochy_pattern.F90 +++ b/get_stochy_pattern.F90 @@ -22,7 +22,7 @@ module get_stochy_pattern_mod implicit none private - public get_random_pattern_vector,get_random_pattern_spp + public get_random_pattern_vector,get_random_pattern_spp public get_random_pattern_sfc,get_random_pattern_scalar public write_stoch_restart_atm,write_stoch_restart_ocn logical :: first_call=.true. @@ -92,7 +92,7 @@ subroutine get_random_pattern_sfc(rpattern,npatterns,& end subroutine get_random_pattern_sfc -!>@brief The subroutine 'get_random_pattern_fv3_vect' converts spherical harmonics to a vector on gaussian grid then interpolates to the target grid +!>@brief The subroutine 'get_random_pattern_fv3_vect' converts spherical harmonics to a vector on gaussian grid then interpolates to the target grid !>@details This subroutine is for a 2-D (lat-lon) vector field subroutine get_random_pattern_vector(rpattern,npatterns,& gis_stochy,upattern_3d,vpattern_3d) @@ -219,7 +219,7 @@ subroutine get_random_pattern_vector(rpattern,npatterns,& enddo first_call=.false. -end subroutine get_random_pattern_vector +end subroutine get_random_pattern_vector !>@brief The subroutine 'get_random_pattern_scalar' converts spherical harmonics to the gaussian grid then interpolates to the target grid !>@details This subroutine is for a 2-D (lat-lon) scalar field @@ -561,7 +561,7 @@ subroutine write_stoch_restart_ocn(sfile) integer :: ncid,varid1a,varid1b,varid2a,varid2b,varid3a,varid3b,varid4a,varid4b integer :: seed_dim_id,spec_dim_id,np_dim_id include 'netcdf.inc' - print*,'in write restart',do_ocnsppt,pert_epbl,do_ocnskeb + if (is_rootpe() ) print*,'in write restart',do_ocnsppt,pert_epbl,do_ocnskeb if ( ( .NOT. do_ocnsppt) .AND. (.NOT. pert_epbl) .AND. ( .NOT. do_ocnskeb) ) return stochlun=99 if (is_rootpe()) then @@ -680,7 +680,7 @@ subroutine write_pattern(rpattern,outlun,lev,np,varid1,varid2,slice_of_3d,iret) endif deallocate(pattern2d) end subroutine write_pattern -!>@brief The subroutine 'vrtdivspect_to_uvgrid' converts vorticty and divergence spherical harmonics to +!>@brief The subroutine 'vrtdivspect_to_uvgrid' converts vorticty and divergence spherical harmonics to ! zonal and meridional winds on the gaussian grid !>@details This subroutine is for a 2-D (lat-lon) vector field subroutine vrtdivspect_to_uvgrid(& diff --git a/stochastic_physics.F90 b/stochastic_physics.F90 index af78691c..d1503387 100644 --- a/stochastic_physics.F90 +++ b/stochastic_physics.F90 @@ -366,7 +366,7 @@ subroutine init_stochastic_physics_ocn(delt, geoLonT, geoLatT, nxT, nyT, nz, & end do WLON = gg_lons(1) - (gg_lons(2)-gg_lons(1)) RNLAT = gg_lats(1)*2 - gg_lats(2) -print*, 'finished ocean init' +if (is_rootpe()) print*, 'finished ocean init' end subroutine init_stochastic_physics_ocn !!!!!!!!!!!!!!!!!!!! diff --git a/stochy_data_mod.F90 b/stochy_data_mod.F90 index f2c9cb6f..810435bc 100644 --- a/stochy_data_mod.F90 +++ b/stochy_data_mod.F90 @@ -1,5 +1,5 @@ !>@brief The module 'stochy_data_mod' contains the initilization routine that read the stochastic phyiscs -!! namelist and determins the number of random patterns. +!! namelist and determines the number of random patterns. module stochy_data_mod ! set up and initialize stochastic random patterns. @@ -32,8 +32,8 @@ module stochy_data_mod integer, public :: nsppt=0 integer, public :: nshum=0 integer, public :: nskeb=0 - integer, public :: nlndp=0 ! this is the number of different patterns (determined by the tau/lscale input) - integer, public :: nspp =0 ! this is the number of different patterns (determined by the tau/lscale input) + integer, public :: nlndp=0 ! this is the number of different patterns (determined by the tau/lscale input) + integer, public :: nspp =0 ! this is the number of different patterns (determined by the tau/lscale input) real(kind=kind_dbl_prec), public,allocatable :: sl(:) real(kind=kind_phys),public, allocatable :: vfact_sppt(:),vfact_shum(:),vfact_skeb(:),vfact_spp(:) @@ -52,7 +52,7 @@ module stochy_data_mod subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret) !\callgraph -! initialize random patterns. +! initialize random patterns. use netcdf implicit none integer, intent(in) :: nlunit,nlevs @@ -78,7 +78,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret) ! read in namelist call compns_stochy (mype,size(input_nml_file,1),input_nml_file(:),fn_nml,nlunit,real(delt,kind=kind_phys),iret) - + if (iret/=0) return ! need to make sure that non-zero irets are being trapped. if ( (.NOT. do_sppt) .AND. (.NOT. do_shum) .AND. (.NOT. do_skeb) .AND. (lndp_type==0) .AND. (.NOT. do_spp)) return @@ -169,7 +169,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret) end if endif endif - print*,'calling init',lonf,latg,jcap + if (is_rootpe()) print*,'calling init',lonf,latg,jcap call patterngenerator_init(sppt_lscale(1:nsppt),spptint,sppt_tau(1:nsppt),sppt(1:nsppt),iseed_sppt,rpattern_sppt, & lonf,latg,jcap,gis_stochy%ls_node,nsppt,1,0,new_lscale) do n=1,nsppt @@ -359,7 +359,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret) gis_stochy%kenorm_o(indlsod(jcap+1,l)) = 0. endif enddo - + endif ! skeb > 0 ! mg, sfc-perts if (nlndp > 0) then @@ -485,12 +485,12 @@ subroutine init_stochdata_ocn(nlevs,delt,iret) integer, intent(in) :: nlevs real(kind=kind_dbl_prec), intent(in) :: delt integer, intent(out) :: iret - + integer :: nn,nm,stochlun,n,jcapin,n2 integer :: l,jbasev,jbasod integer :: varid1,varid2,varid3,varid4,ierr real(kind=kind_dbl_prec) :: gamma_sum,pi - + real(kind_dbl_prec),allocatable :: noise_e(:,:),noise_o(:,:) include 'netcdf.inc' stochlun=99 @@ -532,7 +532,7 @@ subroutine init_stochdata_ocn(nlevs,delt,iret) endif enddo - if (nepbl > 0) then + if (nepbl > 0) then allocate(rpattern_epbl1(nepbl)) allocate(rpattern_epbl2(nepbl)) endif @@ -629,7 +629,7 @@ subroutine init_stochdata_ocn(nlevs,delt,iret) rpattern_epbl1(n)%spec_o(nn,2,1) = rpattern_epbl1(n)%stdev*rpattern_epbl1(n)%spec_o(nn,2,1)*rpattern_epbl1(n)%varspectrum(nm) enddo call patterngenerator_advance(rpattern_epbl1(n),1,.false.) - + call getnoise(rpattern_epbl2(n),noise_e,noise_o) do nn=1,len_trie_ls rpattern_epbl2(n)%spec_e(nn,1,1)=noise_e(nn,1) @@ -753,7 +753,7 @@ subroutine init_stochdata_ocn(nlevs,delt,iret) rpattern_ocnskeb(n)%spec_o(nn,1,1) = rpattern_ocnskeb(n)%stdev*rpattern_ocnskeb(n)%spec_o(nn,1,1)*rpattern_ocnskeb(n)%varspectrum(nm) rpattern_ocnskeb(n)%spec_o(nn,2,1) = rpattern_ocnskeb(n)%stdev*rpattern_ocnskeb(n)%spec_o(nn,2,1)*rpattern_ocnskeb(n)%varspectrum(nm) enddo - print*,'calling patterngenerator_advance norm init' + if (is_rootpe()) print*,'calling patterngenerator_advance norm init' call patterngenerator_advance_jb(rpattern_ocnskeb(n)) !call patterngenerator_advance(rpattern_ocnskeb(n)) ! if (is_rootpe()) then diff --git a/stochy_patterngenerator.F90 b/stochy_patterngenerator.F90 index 5d753499..81c575b4 100644 --- a/stochy_patterngenerator.F90 +++ b/stochy_patterngenerator.F90 @@ -1,6 +1,6 @@ !>@brief The module 'stochy_patterngenerator_mod' contains the derived type random_pattern !! which controls the characteristics of the random pattern -!! This is a modified version of the original one stochy_patterngenerator.F90, where the +!! This is a modified version of the original one stochy_patterngenerator.F90, where the !! the random patterns are not properly normalized module stochy_patterngenerator_mod @@ -72,11 +72,13 @@ subroutine patterngenerator_init(lscale, delt, tscale, stdev, iseed, rpattern,& include 'function_indlsev' bn_local=.false. if (present(bn)) bn_local=bn - if (present(bn)) then - print*,'Berner norm=',bn - else - print*,'old norm' - endif + if (is_rootpe()) then + if (present(bn)) then + print*,'Berner norm=',bn + else + print*,'old norm' + endif + end if nlons = nlon nlats = nlat ntrunc = jcap @@ -205,7 +207,7 @@ subroutine patterngenerator_destroy(rpattern,npatterns) enddo end subroutine patterngenerator_destroy -!>@brief The subroutine 'computevarspec' compute the globally integrated +!>@brief The subroutine 'computevarspec' compute the globally integrated !! variance from complex spectral coefficients !>@details this is necessary to ensure the proper global variance subroutine computevarspec(rpattern,dataspec,var) @@ -225,7 +227,7 @@ subroutine computevarspec(rpattern,dataspec,var) enddo end subroutine computevarspec -!>@brief The subroutine 'computevarspec_r' compute the globally integrated +!>@brief The subroutine 'computevarspec_r' compute the globally integrated !! variance from real spectral coefficients !>@details this is necessary to ensure the proper global variance subroutine computevarspec_r(rpattern,dataspec,var) @@ -394,7 +396,7 @@ subroutine setvarspect(rpattern,varspect_opt,new_lscale,berner_normalize) type(random_pattern), intent(inout) :: rpattern integer, intent(in) :: varspect_opt logical, intent(in) :: new_lscale - logical, intent(in) :: berner_normalize + logical, intent(in) :: berner_normalize integer :: n, nm complex(kind_dbl_prec) noise(ndimspec) real(kind_dbl_prec) var,b_jb,rerth,inv_rerth_sq,pi,gamma_sum,deltaE @@ -404,24 +406,24 @@ subroutine setvarspect(rpattern,varspect_opt,new_lscale,berner_normalize) !print*,'setvarspect,ntrunc',berner_normalize,ntrunc ! 1d variance spectrum (as a function of total wavenumber) if (varspect_opt == 0) then ! gaussian - print*, 'Gaussian variance spectrum' + if (is_rootpe()) print*, 'Gaussian variance spectrum' ! rpattern%lengthscale is interpreted as an efolding length ! scale, in meters. ! scaling factors for spectral coeffs of white noise pattern with unit variance if (new_lscale) then !fix for proper lengthscale - print*, 'Proper lengthscale condition' + if (is_rootpe()) print*, 'Proper lengthscale condition' rpattern%varspectrum = exp((rpattern%lengthscale*0.25)**2*rpattern%lap*inv_rerth_sq) do n=0,ntrunc rpattern%varspectrum1d(n) = exp(-(rpattern%lengthscale*0.25)**2*float(n)*(float(n)+1.)*inv_rerth_sq) enddo else - print*, 'Not proper lengthscale condition' + if (is_rootpe()) print*, 'Not proper lengthscale condition' rpattern%varspectrum = exp(rpattern%lengthscale**2*rpattern%lap/(4.*rerth**2)) do n=0,ntrunc rpattern%varspectrum1d(n) = exp(-rpattern%lengthscale**2*(float(n)*(float(n)+1.))/(4.*rerth**2)) enddo - print*,'Finished' + if (is_rootpe()) print*,'Finished' endif else if (varspect_opt == 1) then ! power law ! rpattern%lengthscale is interpreted as a power, not a length. @@ -452,7 +454,7 @@ subroutine setvarspect(rpattern,varspect_opt,new_lscale,berner_normalize) call computevarspec(rpattern,noise,var) rpattern%varspectrum = rpattern%varspectrum/sqrt(var) rpattern%varspectrum1d = rpattern%varspectrum1d/var - + else if (berner_normalize) then ! normalize by Berner et al. 2009 do n=1,len_trie_ls nm = rpattern%idx_e(n)