Skip to content

Commit

Permalink
remove useless global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tgastine committed Dec 14, 2023
1 parent e5d858e commit fe17667
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 98 deletions.
4 changes: 0 additions & 4 deletions src/Namelists.f90
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ subroutine readNamelists(tscheme)

!-- Determine what has to be calculated depending on mode:
lMagMem =1
ldtBMem =0
l_conv =.true.
l_conv_nl=.true.
l_mag =.true.
Expand Down Expand Up @@ -744,9 +743,6 @@ subroutine readNamelists(tscheme)
if ( ( l_rot_ma .and. ktopv == 2 ) .or. &
& ( l_rot_ic .and. kbotv == 2 ) ) l_z10mat= .true.

!-- Check whether memory has been reserved:
if ( l_RMS .or. l_DTrMagSpec ) ldtBMem=1

!-- Output of angular moment?
l_AM=l_AM .or. l_correct_AMe .or. l_correct_AMz
l_AM=l_AM .or. l_power
Expand Down
12 changes: 6 additions & 6 deletions src/RMS.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module RMS
use chebyshev, only: type_cheb_odd
use radial_scheme, only: type_rscheme
use truncation, only: n_r_max, n_cheb_max, n_r_maxMag, lm_max, lm_maxMag, &
& l_max, n_phi_max, n_theta_max, minc, n_r_max_dtB, &
& lm_max_dtB, fd_ratio, fd_stretch, nlat_padded
& l_max, n_phi_max, n_theta_max, minc, fd_ratio, &
& fd_stretch, nlat_padded
use physical_parameters, only: ra, ek, pr, prmag, radratio, CorFac, n_r_LCR, &
& BuoFac, ChemFac, ThExpNb, ViscHeatFac
use radial_data, only: nRstop, nRstart, radial_balance, nRstartMag, nRstopMag
Expand Down Expand Up @@ -1285,10 +1285,10 @@ subroutine dtBrms(time)
real(cp) :: TdynRms,TdynAsRms
real(cp) :: dummy1,dummy2,dummy3

complex(cp) :: PdynLM(llmMag:ulmMag,n_r_max_dtB)
complex(cp) :: drPdynLM(llmMag:ulmMag,n_r_max_dtB)
complex(cp) :: TdynLM(llmMag:ulmMag,n_r_max_dtB)
complex(cp) :: work_LMloc(llmMag:ulmMag,n_r_max_dtB)
complex(cp) :: PdynLM(llmMag:ulmMag,n_r_maxMag)
complex(cp) :: drPdynLM(llmMag:ulmMag,n_r_maxMag)
complex(cp) :: TdynLM(llmMag:ulmMag,n_r_maxMag)
complex(cp) :: work_LMloc(llmMag:ulmMag,n_r_maxMag)
complex(cp) :: work_Rloc(lm_maxMag,nRstartMag:nRstopMag)

real(cp) :: dtBP(n_r_max),dtBPAs(n_r_max)
Expand Down
2 changes: 1 addition & 1 deletion src/RMS_helpers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RMS_helpers
use precision_mod
use parallel_mod
use communications, only: reduce_radial
use truncation, only: l_max, lm_max_dtB, n_r_max, lm_max
use truncation, only: l_max, n_r_max
use radial_functions, only: or2, rscheme_oc, r
use useful, only: cc2real
use integration, only: rInt_R
Expand Down
99 changes: 42 additions & 57 deletions src/dtB.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ module dtB_mod
use precision_mod
use parallel_mod
use mem_alloc, only: bytes_allocated
use truncation, only: n_r_maxMag, n_r_ic_maxMag, n_r_max, lm_max_dtB, &
& n_r_max_dtB, n_r_ic_max_dtB, lm_max, n_cheb_max, &
& n_r_ic_max, l_max, n_phi_max, ldtBmem, &
use truncation, only: n_r_maxMag, n_r_ic_maxMag, n_r_max, lm_max, &
& n_cheb_max, n_r_ic_max, l_max, n_phi_max, &
& n_theta_max, nlat_padded
use communications, only: gather_all_from_lo_to_rank0, gt_OC, gt_IC
use mpi_transp_mod, only: type_mpitransp
Expand Down Expand Up @@ -77,73 +76,59 @@ subroutine initialize_dtB_mod

if ( l_dtBmovie ) then
if ( rank == 0 ) then
allocate( PstrLM(lm_max_dtB,n_r_max_dtB) )
allocate( PadvLM(lm_max_dtB,n_r_max_dtB) )
allocate( TstrLM(lm_max_dtB,n_r_max_dtB) )
allocate( TadvLM(lm_max_dtB,n_r_max_dtB) )
allocate( TomeLM(lm_max_dtB,n_r_max_dtB) )
allocate( PdifLM(lm_max_dtB,n_r_max_dtB) )
allocate( TdifLM(lm_max_dtB,n_r_max_dtB) )
bytes_allocated = bytes_allocated+ &
& 7*lm_max_dtB*n_r_max_dtB*SIZEOF_DEF_COMPLEX
allocate( PstrLM(lm_max,n_r_max), PadvLM(lm_max,n_r_max) )
allocate( TstrLM(lm_max,n_r_max), TadvLM(lm_max,n_r_max) )
allocate( TomeLM(lm_max,n_r_max), PdifLM(lm_max,n_r_max) )
allocate( TdifLM(lm_max,n_r_max) )
bytes_allocated = bytes_allocated+7*lm_max*n_r_max*SIZEOF_DEF_COMPLEX
else
allocate( PstrLM(1,1) )
allocate( PadvLM(1,1) )
allocate( PdifLM(1,1) )
allocate( TdifLM(1,1) )
allocate( TstrLM(1,1) )
allocate( TadvLM(1,1) )
allocate( TomeLM(1,1) )
allocate( PstrLM(1,1), PadvLM(1,1), PdifLM(1,1), TdifLM(1,1) )
allocate( TstrLM(1,1), TadvLM(1,1), TomeLM(1,1) )
end if

if ( rank == 0 ) then
allocate( PadvLMIC(lm_max_dtB,n_r_ic_max_dtB) )
allocate( PdifLMIC(lm_max_dtB,n_r_ic_max_dtB) )
allocate( TadvLMIC(lm_max_dtB,n_r_ic_max_dtB) )
allocate( TdifLMIC(lm_max_dtB,n_r_ic_max_dtB) )
bytes_allocated = bytes_allocated+ &
& 4*lm_max_dtB*n_r_ic_max_dtB*SIZEOF_DEF_COMPLEX
allocate( PadvLMIC(lm_max,n_r_ic_max), PdifLMIC(lm_max,n_r_ic_max) )
allocate( TadvLMIC(lm_max,n_r_ic_max), TdifLMIC(lm_max,n_r_ic_max) )
bytes_allocated = bytes_allocated+4*lm_max*n_r_ic_max*SIZEOF_DEF_COMPLEX
else
allocate( PadvLMIC(1,1) )
allocate( PdifLMIC(1,1) )
allocate( TadvLMIC(1,1) )
allocate( PadvLMIC(1,1), PdifLMIC(1,1), TadvLMIC(1,1) )
allocate( TdifLMIC(1,1) )
end if
end if

allocate( PdifLM_LMloc(llmMag:ulmMag,n_r_max_dtB) )
allocate( TdifLM_LMloc(llmMag:ulmMag,n_r_max_dtB) )
allocate( PdifLM_LMloc(llmMag:ulmMag,n_r_max) )
allocate( TdifLM_LMloc(llmMag:ulmMag,n_r_max) )
bytes_allocated = bytes_allocated+ &
& 2*(ulmMag-llmMag+1)*n_r_max_dtB*SIZEOF_DEF_COMPLEX
allocate( PadvLMIC_LMloc(llmMag:ulmMag,n_r_ic_max_dtB) )
allocate( PdifLMIC_LMloc(llmMag:ulmMag,n_r_ic_max_dtB) )
allocate( TadvLMIC_LMloc(llmMag:ulmMag,n_r_ic_max_dtB) )
allocate( TdifLMIC_LMloc(llmMag:ulmMag,n_r_ic_max_dtB) )
& 2*(ulmMag-llmMag+1)*n_r_max*SIZEOF_DEF_COMPLEX
allocate( PadvLMIC_LMloc(llmMag:ulmMag,n_r_ic_max) )
allocate( PdifLMIC_LMloc(llmMag:ulmMag,n_r_ic_max) )
allocate( TadvLMIC_LMloc(llmMag:ulmMag,n_r_ic_max) )
allocate( TdifLMIC_LMloc(llmMag:ulmMag,n_r_ic_max) )
bytes_allocated = bytes_allocated+ &
& 4*(ulmMag-llmMag+1)*n_r_ic_max_dtB*SIZEOF_DEF_COMPLEX

allocate( dtB_Rloc_container(lm_max_dtB,nRstart:nRstop,8) )
TomeLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,1)
TomeRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,2)
TstrLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,3)
TstrRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,4)
TadvLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,5)
TadvRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,6)
PstrLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,7)
PadvLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max_dtB,nRstart:nRstop,8)
bytes_allocated = bytes_allocated+8*(nRstop-nRstart+1)*lm_max_dtB* &
& 4*(ulmMag-llmMag+1)*n_r_ic_max*SIZEOF_DEF_COMPLEX

allocate( dtB_Rloc_container(lm_max,nRstart:nRstop,8) )
TomeLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,1)
TomeRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,2)
TstrLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,3)
TstrRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,4)
TadvLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,5)
TadvRLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,6)
PstrLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,7)
PadvLM_Rloc(1:,nRstart:) => dtB_Rloc_container(1:lm_max,nRstart:nRstop,8)
bytes_allocated = bytes_allocated+8*(nRstop-nRstart+1)*lm_max* &
& SIZEOF_DEF_COMPLEX

allocate( dtB_LMloc_container(llmMag:ulmMag,n_r_max_dtB,8) )
TomeLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,1)
TomeRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,2)
TstrLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,3)
TstrRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,4)
TadvLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,5)
TadvRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,6)
PstrLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,7)
PadvLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max_dtB,8)
bytes_allocated = bytes_allocated+8*(ulmMag-llmMag+1)*n_r_max_dtB* &
allocate( dtB_LMloc_container(llmMag:ulmMag,n_r_max,8) )
TomeLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,1)
TomeRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,2)
TstrLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,3)
TstrRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,4)
TadvLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,5)
TadvRLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,6)
PstrLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,7)
PadvLM_LMloc(llmMag:,1:) => dtB_LMloc_container(llmMag:ulmMag,1:n_r_max,8)
bytes_allocated = bytes_allocated+8*(ulmMag-llmMag+1)*n_r_max* &
& SIZEOF_DEF_COMPLEX

allocate ( type_mpiptop :: r2lo_dtB )
Expand Down
16 changes: 8 additions & 8 deletions src/dtB_arrays.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module dtB_arrays_mod

use truncation, only: lm_max_dtB
use truncation, only: lm_max
use mem_alloc, only: bytes_allocated
use precision_mod
use constants, only: zero
Expand All @@ -27,13 +27,13 @@ subroutine initialize(this)

class(dtB_arrays_t) :: this

allocate( this%BtVrLM(lm_max_dtB), this%BpVrLM(lm_max_dtB) )
allocate( this%BrVtLM(lm_max_dtB), this%BrVpLM(lm_max_dtB) )
allocate( this%BtVpLM(lm_max_dtB), this%BpVtLM(lm_max_dtB) )
allocate( this%BpVtBtVpCotLM(lm_max_dtB), this%BpVtBtVpSn2LM(lm_max_dtB) )
allocate( this%BrVZLM(lm_max_dtB), this%BtVZLM(lm_max_dtB) )
allocate( this%BtVZsn2LM(lm_max_dtB) )
bytes_allocated = bytes_allocated+ 11*lm_max_dtB*SIZEOF_DEF_COMPLEX
allocate( this%BtVrLM(lm_max), this%BpVrLM(lm_max) )
allocate( this%BrVtLM(lm_max), this%BrVpLM(lm_max) )
allocate( this%BtVpLM(lm_max), this%BpVtLM(lm_max) )
allocate( this%BpVtBtVpCotLM(lm_max), this%BpVtBtVpSn2LM(lm_max) )
allocate( this%BrVZLM(lm_max), this%BtVZLM(lm_max) )
allocate( this%BtVZsn2LM(lm_max) )
bytes_allocated = bytes_allocated+ 11*lm_max*SIZEOF_DEF_COMPLEX

end subroutine initialize
!----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/magic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ program magic
if ( l_TO ) call initialize_outTO_mod() ! Needs to be called after preCalc, r_icb needed
if ( l_movie ) call initialize_movie_data() !Needs to be called after preCalc to get correct coordinate values
call initialize_geos(l_par, l_SRIC, l_geosMovie) ! Needs to be called after preCalc, l_geosMovie defined in movie
if ( ldtBmem == 1 ) call initialize_dtB_mod() ! Needs to be called after movie to make sure l_dtBmovie has been set
if ( l_RMS .or. l_DTrMagSpec ) call initialize_dtB_mod() ! Needs to be called after movie to make sure l_dtBmovie has been set
if (l_probe) call initialize_probes() !Needs to be called after preCalc to get correct coordinate values
if ( l_RMS ) call initialize_RMS()
local_bytes_used=bytes_allocated-local_bytes_used
Expand Down Expand Up @@ -485,7 +485,7 @@ program magic
if ( l_TO ) call finalize_outTO_mod()
if ( l_TO ) call finalize_TO()
call finalize_geos(l_par, l_SRIC, l_geosMovie)
if ( ldtBmem == 1 ) call finalize_dtB_mod
if ( l_RMS .or. l_DTrMagSpec ) call finalize_dtB_mod()
call finalize_fields_average_mod()
if ( l_power ) call finalize_output_power()
call finalize_outRot()
Expand Down
8 changes: 5 additions & 3 deletions src/out_dtB_frame.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module out_dtB_frame

use truncation
use truncation, only: n_r_max, lm_max, n_r_ic_max, lm_maxMag, n_r_maxMag, &
& n_r_ic_maxMag, l_max, m_max, minc, n_theta_max, &
& n_r_tot, nlat_padded, n_phi_max, n_cheb_ic_max
use precision_mod
use radial_functions, only: r, or1, chebt_ic, r_ic, rscheme_oc, r_icb, &
& dr_fac_ic, chebt_ic_even
Expand Down Expand Up @@ -66,8 +68,8 @@ subroutine write_dtB_frame(n_movie,b,db,aj,dj,b_ic,db_ic,aj_ic,dj_ic)
real(cp) :: dtBrframe(n_r_tot*n_phi_max*n_theta_max)
real(cp) :: const,rMov

complex(cp) :: workA(lm_max_dtB,n_r_max_dtB)
complex(cp) :: workB(lm_max_dtB,n_r_ic_max_dtB)
complex(cp) :: workA(lm_max,n_r_max)
complex(cp) :: workB(lm_max,n_r_ic_max)

logical :: l_loop

Expand Down
7 changes: 4 additions & 3 deletions src/rIter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module rIter_mod
& l_TO, l_chemical_conv, l_probe, l_full_sphere, &
& l_precession, l_centrifuge, l_adv_curl, &
& l_double_curl, l_parallel_solve, l_single_matrix,&
& l_temperature_diff, l_RMS, l_phase_field, l_onset
& l_temperature_diff, l_RMS, l_phase_field, &
& l_onset, l_DTrMagSpec
use radial_data, only: n_r_cmb, n_r_icb, nRstart, nRstop, nRstartMag, &
& nRstopMag
use radial_functions, only: or2, orho1, l_R
Expand Down Expand Up @@ -79,7 +80,7 @@ subroutine initialize(this)
class(rIter_single_t) :: this

call this%gsa%initialize()
call this%dtB_arrays%initialize()
if ( l_RMS .or. l_DTrMagSpec ) call this%dtB_arrays%initialize()
call this%nl_lm%initialize(lm_max)

end subroutine initialize
Expand All @@ -89,7 +90,7 @@ subroutine finalize(this)
class(rIter_single_t) :: this

call this%gsa%finalize()
call this%dtB_arrays%finalize()
if ( l_RMS .or. l_DTrMagSpec ) call this%dtB_arrays%finalize()
call this%nl_lm%finalize()

end subroutine finalize
Expand Down
14 changes: 0 additions & 14 deletions src/truncation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ module truncation
integer :: l_maxMag ! Max. degree for magnetic field calculation
integer :: lm_maxMag ! Max. number of l/m combinations for magnetic field calculation

!-- Movie memory control:
integer :: ldtBMem ! Memory for movie output
integer :: lm_max_dtB ! Number of l/m combinations for movie output
integer :: n_r_max_dtB ! Number of radial points for movie output
integer :: n_r_ic_max_dtB ! Number of IC radial points for movie output

contains

subroutine initialize_truncation
Expand Down Expand Up @@ -130,14 +124,6 @@ subroutine initialize_truncation
l_maxMag = max(1,l_maxML)
lm_maxMag = max(1,lm_maxML)

!-- Movie memory control:
lm_max_dL =ldtBMem*lm_max
n_r_max_dL =ldtBMem*n_r_max
n_r_ic_max_dL=ldtBMem*n_r_ic_max
lm_max_dtB =max(lm_max_DL,1)
n_r_max_dtB =max(n_r_max_DL,1)
n_r_ic_max_dtB=max(n_r_ic_max_DL,1)

end subroutine initialize_truncation
!--------------------------------------------------------------------------------
subroutine checkTruncation
Expand Down

0 comments on commit fe17667

Please sign in to comment.