Skip to content

Commit

Permalink
Add restart option, fix sat rule options and tidy up directory names
Browse files Browse the repository at this point in the history
  • Loading branch information
bpatel2107 committed Apr 30, 2024
1 parent 2791de6 commit 3833775
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cgyro/src/cgyro_write_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ subroutine cgyro_write_restart_one
! Anything but restart_preservation_mode == 4
! User does not want high guarntees for the old file
! So, remove .old file, if it exists
call UNLINK(trim(path)//runfile_restart//".old")
i_err = UNLINK(trim(path)//runfile_restart//".old")
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
endif

if ((i_proc == 0) .and. (restart_preservation_mode<2)) then
! restart_preservation_mode == 1
! User wants to save disk space
! So, remove existing restart file, if it exists
call UNLINK(trim(path)//runfile_restart)
i_err = UNLINK(trim(path)//runfile_restart)
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
endif

Expand Down
1 change: 1 addition & 0 deletions qlgyro/bin/qlgyro_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
x.add('SAT_RULE', '1')
x.add('N_PX0', '1')
x.add('PX0GRID_MODEL', '1')
x.add('RESTART_MODE', '0')

# Perform the parsing
x.read_input('input.qlgyro')
Expand Down
4 changes: 4 additions & 0 deletions qlgyro/src/qlgyro_cgyro_cleanup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ subroutine qlgyro_cgyro_cleanup
if (adjoint .eq. 0) then
open(unit=io, iostat=i_err, file=trim(runpath)//runfile_restart_tag, status='old')
if (i_err == 0) close(io, status='delete')
if (restart_mode .eq. 1) then
open(unit=io, iostat=i_err, file=trim(runpath)//runfile_restart, status='old')
if (i_err == 0) close(io, status='delete')
end if
end if
end if

Expand Down
2 changes: 1 addition & 1 deletion qlgyro/src/qlgyro_globals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ module qlgyro_globals

real, dimension(:, :, :), allocatable :: qlgyro_k_perp, qlgyro_jacobian

integer :: sat_rule
integer :: sat_rule, restart_mode
!
!
! Iteration variables (global)
Expand Down
7 changes: 4 additions & 3 deletions qlgyro/src/qlgyro_px0_spectrum.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ SUBROUTINE qlgyro_px0_spectrum
px0_spectrum(n_px0-1) = 0.25
px0_spectrum(n_px0) = 0.5
else if (px0grid_model .eq. 3) then
do i=1, n_px0 - 2
px0_spectrum(i) = (i-1) * 0.016
do i=1, n_px0 - 3
px0_spectrum(i) = (i-1) * 0.1 / (2.0 * pi)
end do
px0_spectrum(n_px0-1) = 0.2
px0_spectrum(n_px0-2) = 0.4 / (2.0 * pi)
px0_spectrum(n_px0-1) = 1.2 / (2.0 * pi)
px0_spectrum(n_px0) = 0.5
else
do i=1, n_px0
Expand Down
1 change: 1 addition & 0 deletions qlgyro/src/qlgyro_read_input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ subroutine qlgyro_read_input
call ql_readbc_int(sat_rule)
call ql_readbc_int(n_px0)
call ql_readbc_int(px0grid_model)
call ql_readbc_int(restart_mode)

! DONE reading data.
!--------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qlgyro/src/qlgyro_run.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subroutine qlgyro_run(lpath_in, qlgyro_comm_in, i_tran_in)
call qlgyro_comm_sync

! Apply saturation rule
if (sat_rule .eq. 1) then
if (sat_rule .gt. 0) then
call qlgyro_sat1
else if (sat_rule .eq. -1) then
call qlgyro_sat_mg
Expand Down
21 changes: 17 additions & 4 deletions qlgyro/src/qlgyro_run_cgyro_balloon.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ subroutine qlgyro_run_cgyro_balloon
integer :: ios

character(len=5) :: kystr, px0str
real :: ky, timestep, maxtime, kx_max_default, px0
character(len=6) :: fmt_str
real :: ky, timestep, maxtime, kx_max_default, px0, ky_min

integer, dimension(:), allocatable :: ky_run, px0_run
integer, dimension(:), allocatable :: ky_px0_run
Expand Down Expand Up @@ -46,8 +47,14 @@ subroutine qlgyro_run_cgyro_balloon
call map_global2interface
call allocate_cgyro_interface
if (i_proc_global .eq. 0) call tglf_dump_local

call qlgyro_ky_spectrum(0.005)

if (transport_method .eq. 0) then
ky_min = cgyro_ky_in
else if (transport_method .eq. 1) then
ky_min = cgyro_q_in / cgyro_rmin_in * cgyro_rho_star_norm_in
end if

call qlgyro_ky_spectrum(ky_min)
call qlgyro_px0_spectrum

maxtime = cgyro_max_time_in
Expand All @@ -57,6 +64,12 @@ subroutine qlgyro_run_cgyro_balloon
tglf_nmodes_in = n_px0

n_ky = tglf_nky_in

if (tglf_ky_spectrum_out(1) .lt. 0.01) then
fmt_str = "(F5.3)"
else
fmt_str = "(F5.2)"
end if

! Set up ky px0 grid
n_kypx0 = n_ky * n_px0
Expand Down Expand Up @@ -157,7 +170,7 @@ subroutine qlgyro_run_cgyro_balloon
px0 = px0_spectrum(i_px0_local)

! Creates directory for each ky and changes into it for that run
write(kystr, '(F5.2)') ky
write(kystr, fmt_str) ky
write(px0str, '(F5.2)') px0
runpath = trim(trim(path)//'/KY_'//trim(adjustl(kystr)))//"_PX0_"//trim(adjustl(px0str))//"/"

Expand Down

0 comments on commit 3833775

Please sign in to comment.