Skip to content

Commit

Permalink
split phi-slice movies from phi-avg by defining a new dedicated n_sur…
Browse files Browse the repository at this point in the history
…face value

This is going to ease the reading/handling of movies
  • Loading branch information
tgastine committed Sep 12, 2024
1 parent 05031cd commit a5da8c8
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 175 deletions.
82 changes: 52 additions & 30 deletions src/movie.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module movie_data
character(len=72), public :: movie_file(n_movies_max)

logical, public :: lICField(n_movies_max), lGeosField(n_movies_max)
logical :: lAxiField(n_movies_max), lPhaseField(n_movies_max)
logical :: lPhaseField(n_movies_max)
integer, public :: n_movies
integer, public :: n_movie_surface(n_movies_max)
integer, public :: n_movie_const(n_movies_max)
Expand Down Expand Up @@ -975,7 +975,7 @@ subroutine get_movie_type
const=r_cmb
else if ( index(string,'AX') /= 0 .or. lAxi ) then
!--- Axisymmetric stuff:
n_surface=3 ! PHI=const.
n_surface=4 ! PHI=const.
n_const=1
n_field_size=n_r_max*n_theta_max
n_field_size_ic=n_r_ic_max*n_theta_max
Expand Down Expand Up @@ -1129,7 +1129,6 @@ subroutine get_movie_type
n_movies=n_movies+1
lICField(n_movies)=lIC
lGeosField(n_movies)=lGeos
lAxiField(n_movies)=lAxi
lPhaseField(n_movies)=lPhase

!------ Translate horizontal movies:
Expand Down Expand Up @@ -1176,7 +1175,7 @@ subroutine get_movie_type
if ( n_surface == 1 .and. n_const < 0 ) then
n_fields_oc=0
n_fields_ic=n_fields
else if ( n_surface == 0 .or. n_surface == 2 .or. n_surface == 3 ) then
else if ( n_surface == 0 .or. n_surface == 2 .or. n_surface == 3 .or. n_surface == 4 ) then
n_fields_ic=n_fields
end if
end if
Expand Down Expand Up @@ -1242,6 +1241,8 @@ subroutine get_movie_type
write(n_log_file,'('' ! at theta='',f12.6)') const
else if ( n_surface == 3 ) then
write(n_log_file,'('' ! at phi='',f12.6)') rad*phi(n_const)
else if ( n_surface == -2 ) then
write(n_log_file,*) '! phi average !'
end if
if ( n_fields_ic > 0 ) &
write(n_log_file,'('' ! including inner core magnetic field.'')')
Expand Down Expand Up @@ -1417,35 +1418,56 @@ subroutine movie_gather_frames_to_rank0()
end do
sendcount=local_end-local_start+1

!-- Either only the axisymmetric or both slices
if ( lAxiField(n_movie) ) then
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length)
end if
n_stop=n_start+field_length/2-1
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length/2)
end if
n_start=n_stop+1
n_stop =n_start+field_length/2-1
local_start = local_start+field_length/2
local_end = local_end+field_length/2
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length/2)
end if

else ! Two phi slices
end do ! Do loop over field for one movie

n_stop=n_start+field_length/2-1
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length/2)
end if
n_start=n_stop+1
n_stop =n_start+field_length/2-1
local_start = local_start+field_length/2
local_end = local_end+field_length/2
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length/2)
end if
case(4) ! Surface phi average
! all ranks have a part of the frames array for each movie
! we need to gather

do n_field=1,n_fields
n_start = n_movie_field_start(n_field,n_movie)
n_stop = n_movie_field_stop(n_field,n_movie)
n_field_type = n_movie_field_type(n_field,n_movie)
field_length = n_stop-n_start+1

local_start=n_start+(nRstart-1)*n_theta_max
local_end =local_start+nR_per_rank*n_theta_max-1
do irank=0,n_procs-1
recvcounts(irank)=radial_balance(irank)%n_per_rank*n_theta_max
end do
if ( local_end > n_stop ) then
call abortRun('local_end exceeds n_stop')
end if
displs(0)=0
do irank=1,n_procs-1
displs(irank)=displs(irank-1)+recvcounts(irank-1)
end do
sendcount=local_end-local_start+1

!-- Either only the axisymmetric or both slices
call MPI_Gatherv(frames(local_start),sendcount,MPI_DEF_REAL, &
& field_frames_global,recvcounts,displs, &
& MPI_DEF_REAL,0,MPI_COMM_WORLD,ierr)
if ( rank == 0 ) then
frames(n_start:n_stop)=field_frames_global(1:field_length)
end if
end do ! Do loop over field for one movie

Expand Down
2 changes: 1 addition & 1 deletion src/out_TO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ subroutine initialize_outTO_mod()
version='JW_Movie_Version_2'
write(n_TOmov_file) version
dumm(1)=102 ! type of input
dumm(2)=3 ! marker for constant phi plane
dumm(2)=4 ! marker for constant phi plane
dumm(3)=0.0_cp ! surface constant
dumm(4)=nFields ! no of fields
write(n_TOmov_file) (real(dumm(n),kind=outp),n=1,4)
Expand Down
5 changes: 2 additions & 3 deletions src/out_dtB_frame.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ subroutine calc_dtB_frame()
n_field_type=n_movie_field_type(n_field,n_movie)
n_store_last=n_movie_field_start(n_field,n_movie)-1

if ( n_surface == 3 ) then ! Axisymmetric movies
if ( n_surface == 4 ) then ! Axisymmetric movies

if ( n_field_type == 20 ) then
call lo2r_one%transp_lm2r(PstrLM_LMloc,PstrLM_Rloc)
Expand Down Expand Up @@ -404,8 +404,7 @@ subroutine calc_dtB_frame_IC()
n_store_last=n_movie_field_start(n_field,n_movie)-1

!--- Axisymmetric dtFL or dtAB:
if ( n_surface == 3 ) then

if ( n_surface == 4 ) then

do n_r=1,n_r_ic_max

Expand Down
Loading

0 comments on commit a5da8c8

Please sign in to comment.