Skip to content

Commit

Permalink
put subroutines of six files into modules and rename the files accord…
Browse files Browse the repository at this point in the history
…ingly
  • Loading branch information
jonatanschatzlmayr committed Feb 6, 2025
1 parent 3ba4b9a commit 19e921b
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 58 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ SOURCES = SetWorkingPrecision.f90\
spl_three_to_five_mod.f90 \
spline_vmec_data.f90 \
new_vmec_allocation_stuff.f90 \
binsrc.f90 \
binsrc_mod.f90 \
field_divB0.f90 \
scaling_r_theta.f90\
field_line_integration_for_SYNCH.f90 \
preload_for_SYNCH.f90 \
field_line_integration_for_SYNCH_mod.f90 \
preload_for_SYNCH_mod.f90 \
plag_coeff.f90 \
magdata_in_symfluxcoord.f90 \
points_2d.f90\
Expand All @@ -42,9 +42,9 @@ SOURCES = SetWorkingPrecision.f90\
make_grid_rect.f90 \
bdivfree.f90 \
strong_electric_field_mod.f90 \
differentiate_mod.f90 \
tetra_physics_mod.f90 \
tetra_physics_poly_precomp_mod.f90 \
differentiate.f90 \
spline5_RZ.f90 \
supporting_functions_mod.f90 \
pusher_tetra_func_mod.f90 \
Expand Down
8 changes: 8 additions & 0 deletions SRC/binsrc.f90 → SRC/binsrc_mod.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module binsrc_mod

implicit none

contains
!
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
subroutine binsrc(p,nmin,nmax,xi,i)
Expand Down Expand Up @@ -30,3 +36,5 @@ subroutine binsrc(p,nmin,nmax,xi,i)
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
end module binsrc_mod
7 changes: 7 additions & 0 deletions SRC/differentiate.f90 → SRC/differentiate_mod.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module differentiate_mod

implicit none

contains
!
subroutine differentiate(x,y,z,n,f,fx,fy,fz)
!
Expand Down Expand Up @@ -56,3 +61,5 @@ subroutine differentiate(x,y,z,n,f,fx,fy,fz)
deallocate(df)
!
end subroutine differentiate
!
end module differentiate_mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ module field_line_integration_mod
double precision :: theta0
end module field_line_integration_mod
!
module field_line_integration_for_SYNCH_mod

implicit none

contains

subroutine field_line_integration_for_SYNCH(nstep,nsurfmax,nlabel,ntheta, &
rmn,rmx,zmn,zmx,raxis,zaxis, &
rbeg,rsmall,qsaf,psisurf,phitor, &
Expand Down Expand Up @@ -50,10 +56,6 @@ subroutine field_line_integration_for_SYNCH(nstep,nsurfmax,nlabel,ntheta, &
double precision, dimension(neq) :: ymet
double precision, dimension(nlabel) :: rbeg,rsmall,qsaf,psisurf,phitor
double precision, dimension(nlabel,ntheta) :: R_st,Z_st,bmod_st,sqgnorm_st
!
! external :: rhs_axis, rhs_surf, rhs_surf_theta
external :: rhs_axis, rhs_surf !, rhs_surf_theta
double precision, external :: cross_2d_sign
double precision, dimension(0:0,4) :: coef
!
!
Expand Down Expand Up @@ -389,70 +391,65 @@ subroutine field_line_integration_for_SYNCH(nstep,nsurfmax,nlabel,ntheta, &
!-------------------------------------------------------------------------------
!
end subroutine field_line_integration_for_SYNCH
! -----------------------------------------------------------------
!
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!

subroutine rhs_axis(phi,y,dy)
!
implicit none
implicit none
!
integer, parameter :: ndim = 4
integer, parameter :: ndim = 4
!
double precision, dimension(ndim) :: y,dy
double precision :: R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ, &
dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ
double precision, dimension(ndim) :: y,dy
double precision :: R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ, &
dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ
!
R=y(1)
Z=y(2)
R=y(1)
Z=y(2)
!
call field_eq(R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ &
,dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ)
call field_eq(R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ &
,dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ)
!
dy(1)=Br*R/Bp
dy(2)=Bz*R/Bp
dy(3)=y(1)
dy(4)=y(2)
dy(1)=Br*R/Bp
dy(2)=Bz*R/Bp
dy(3)=y(1)
dy(4)=y(2)
!
return
return
end subroutine rhs_axis
!
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
!-------------------------------------------------------------------------------
!

subroutine rhs_surf(phi,y,dy)
!
use rhs_surf_mod , only: dr_dphi, dz_dphi
use rhs_surf_mod , only: dr_dphi, dz_dphi
!
implicit none
implicit none
!
integer, parameter :: ndim = 4
integer, parameter :: ndim = 4
!
double precision, dimension(ndim) :: y,dy
double precision :: R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ, &
dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ
double precision, dimension(ndim) :: y,dy
double precision :: R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ, &
dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ
!
R=y(1)
Z=y(2)
R=y(1)
Z=y(2)
!
call field_eq(R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ &
,dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ)
call field_eq(R,phi,Z,Br,Bp,Bz,dBrdR,dBrdp,dBrdZ &
,dBpdR,dBpdp,dBpdZ,dBzdR,dBzdp,dBzdZ)
!
dy(1)=Br*R/Bp
dy(2)=Bz*R/Bp
dy(3)=y(1)*dy(2)
dy(4)=y(1)*y(2)*Br
dy(1)=Br*R/Bp
dy(2)=Bz*R/Bp
dy(3)=y(1)*dy(2)
dy(4)=y(1)*y(2)*Br
!
dr_dphi=dy(1)
dz_dphi=dy(2)
dr_dphi=dy(1)
dz_dphi=dy(2)
!
return
return
end subroutine rhs_surf

pure double precision function cross_2d_sign(a, b)
! compute the sign of the 2d cross product a x b
double precision, intent(in), dimension(2) :: a, b

cross_2d_sign = sign(1.d0, a(1) * b(2) - a(2) * b(1))
end function cross_2d_sign
pure double precision function cross_2d_sign(a, b)
! compute the sign of the 2d cross product a x b
double precision, intent(in), dimension(2) :: a, b

cross_2d_sign = sign(1.d0, a(1) * b(2) - a(2) * b(1))
end function cross_2d_sign

end module field_line_integration_for_SYNCH_mod
1 change: 1 addition & 0 deletions SRC/magdata_in_symfluxcoord.f90
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ subroutine magdata_in_symfluxcoord_ext(inp_label,s,psi,theta,q,dq_ds, &
! dZ_dtheta - derivative of Z over polidal angle of symmetry flux coordinates theta
!
use magdata_in_symfluxcoor_mod
use binsrc_mod, only: binsrc
!
implicit none
!
Expand Down
8 changes: 4 additions & 4 deletions SRC/orbit_timestep_gorilla.f90
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ subroutine initialize_gorilla(i_option,ipert_in,bmod_multiplier)
boole_grid = .true.
boole_physics = .true.
end select
if (i_option.ge.10) then
boole_grid = .true.
boole_physics = .true.
endif
else
boole_grid = .true.
boole_physics = .true.
endif
if (i_option.ge.10) then
boole_grid = .true.
boole_physics = .true.
endif
!
if(present(ipert_in)) then
ipert = ipert_in
Expand Down
1 change: 1 addition & 0 deletions SRC/points_2d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ subroutine theta_geom2theta_flux(inp_label, s, psi, theta_geom_vec,theta_flux_ve
use magdata_in_symfluxcoor_mod, only : raxis,zaxis
use field_line_integration_mod, only: theta0
use tetra_grid_settings_mod, only: theta0_at_xpoint
use binsrc_mod, only: binsrc
!
implicit none
!
Expand Down
10 changes: 10 additions & 0 deletions SRC/preload_for_SYNCH.f90 → SRC/preload_for_SYNCH_mod.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
module preload_for_SYNCH_mod

implicit none

contains

subroutine preload_for_SYNCH

use field_line_integration_for_SYNCH_mod, only: field_line_integration_for_SYNCH
!
implicit none
!
Expand Down Expand Up @@ -63,3 +71,5 @@ subroutine preload_for_SYNCH
deallocate(R_st,Z_st,bmod_st,sqgnorm_st)
!
end subroutine preload_for_SYNCH

end module preload_for_SYNCH_mod
1 change: 1 addition & 0 deletions SRC/tetra_grid_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ subroutine make_grid_aligned(grid_size,efit_vmec,n_field_periods)
use constants, only: pi
use circular_mesh, only : calc_mesh, create_points, calc_points_circular, calc_n_tetras, calc_n_verts
use scaling_r_theta, only: scaling_r, scaling_theta
use preload_for_SYNCH_mod, only: preload_for_SYNCH
!
implicit none
!
Expand Down
1 change: 1 addition & 0 deletions SRC/tetra_physics_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ subroutine make_tetra_physics(coord_system_in,ipert_in,bmod_multiplier_in)
& boole_axi_noise_elec_pot, boole_non_axi_noise_vector_pot, axi_noise_eps_A, axi_noise_eps_Phi, &
& non_axi_noise_eps_A, boole_strong_electric_field, boole_save_electric, boole_pert_from_mephit
use strong_electric_field_mod, only: get_electric_field, save_electric_field, get_v_E, save_v_E
use differentiate_mod, only: differentiate
!
integer, intent(in) :: ipert_in,coord_system_in
double precision, intent(in),optional :: bmod_multiplier_in
Expand Down

0 comments on commit 19e921b

Please sign in to comment.