From 876b1430b232169c329baabbd28c6d98366100f4 Mon Sep 17 00:00:00 2001 From: Andreas Zach Date: Sat, 10 Jan 2026 18:00:01 +0100 Subject: [PATCH 1/4] Don't automatically append '.in' to the config file name in the library API --- src/config.f90 | 9 ++++----- src/lib.f90 | 8 ++++---- src/main.f90 | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/config.f90 b/src/config.f90 index adfda2e..6f5fbdf 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -64,9 +64,8 @@ subroutine set_config(config) call set_log_level(config%log_level) end subroutine set_config - subroutine read_and_set_config(base_path) - ! Set global control parameters directly from file - ! The file name is only the base without the extension '.in' + subroutine read_and_set_config(config_file) + ! Set global control parameters directly from a file use do_magfie_mod, only: s, bfac, inp_swi use do_magfie_pert_mod, only: mph, set_mph use driftorbit, only: epsmn, m0, comptorque, magdrift, nopassing, pertfile, nonlin, efac @@ -76,14 +75,14 @@ subroutine read_and_set_config(base_path) use neort_profiles, only: M_t, vth use util, only: qe, mu, qi, mi - character(len=*), intent(in) :: base_path + character(len=*), intent(in) :: config_file real(dp) :: qs, ms integer :: log_level namelist /params/ s, M_t, qs, ms, vth, epsmn, m0, mph, comptorque, magdrift, & nopassing, noshear, pertfile, nonlin, bfac, efac, inp_swi, vsteps, log_level - open (unit=9, file=trim(adjustl(base_path))//".in", status="old", form="formatted") + open (unit=9, file=config_file, status="old", form="formatted") read (9, nml=params) close (unit=9) diff --git a/src/lib.f90 b/src/lib.f90 index 30f11e9..022fcd1 100644 --- a/src/lib.f90 +++ b/src/lib.f90 @@ -26,7 +26,7 @@ module neort_lib contains - subroutine init_from_config_file(config_file_base, boozer_file, boozer_pert_file) + subroutine init_from_config_file(config_file, boozer_file, boozer_pert_file) use do_magfie_mod, only: read_boozer_file use do_magfie_pert_mod, only: read_boozer_pert_file use driftorbit, only: pertfile, nonlin @@ -34,14 +34,14 @@ subroutine init_from_config_file(config_file_base, boozer_file, boozer_pert_file use thetadata_mod, only: init_attenuation_data use util, only: check_file - character(len=*), intent(in) :: config_file_base + character(len=*), intent(in) :: config_file character(len=*), intent(in) :: boozer_file character(len=*), intent(in), optional :: boozer_pert_file - call check_file(trim(config_file_base) // ".in", .true., ".in could not be found") + call check_file(config_file, .true., " could not be found") call check_file(boozer_file, .true., " could not be found") - call read_and_set_config(config_file_base) + call read_and_set_config(config_file) call read_boozer_file(boozer_file) if (present(boozer_pert_file) .and. pertfile) then diff --git a/src/main.f90 b/src/main.f90 index 8874063..a091991 100644 --- a/src/main.f90 +++ b/src/main.f90 @@ -23,7 +23,7 @@ subroutine main call get_command_argument(1, runname) - call neort_init(trim(runname), boozer_file, boozer_pert_file) + call neort_init(trim(runname)//".in", boozer_file, boozer_pert_file) if (files_exist(plasma_file, profile_file)) then call neort_prepare_splines(plasma_file, profile_file) From 2cb17f2468804dc3dd742b65b85a3089475b7233 Mon Sep 17 00:00:00 2001 From: Andreas Zach Date: Sat, 10 Jan 2026 18:08:38 +0100 Subject: [PATCH 2/4] Adapt tests and diagnostics --- src/diag/diag_atten_map.f90 | 2 +- src/diag/diag_bounce_debug.f90 | 2 +- src/diag/diag_bounce_nonlin.f90 | 2 +- src/diag/diag_contrib_map.f90 | 2 +- test/test_multi_init.f90 | 2 +- test/test_neort_lib.f90 | 6 +++--- test/test_omega_prime.f90 | 2 +- test/test_parallel.f90 | 2 +- test/test_torque.f90 | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/diag/diag_atten_map.f90 b/src/diag/diag_atten_map.f90 index f473d35..9c782ee 100644 --- a/src/diag/diag_atten_map.f90 +++ b/src/diag/diag_atten_map.f90 @@ -33,7 +33,7 @@ subroutine run_atten_map_diag(arg_runname) ! Initialize like main runname = trim(arg_runname) - call read_and_set_config(runname) + call read_and_set_config(runname//".in") call do_magfie_init("in_file") if (pertfile) call do_magfie_pert_init("in_file_pert") call init_profiles(R0) diff --git a/src/diag/diag_bounce_debug.f90 b/src/diag/diag_bounce_debug.f90 index 1f5b26c..8f7a179 100644 --- a/src/diag/diag_bounce_debug.f90 +++ b/src/diag/diag_bounce_debug.f90 @@ -35,7 +35,7 @@ subroutine run_bounce_debug(arg_runname) ! Initialize environment just like main runname = trim(arg_runname) - call read_and_set_config(runname) + call read_and_set_config(runname//".in") call do_magfie_init("in_file") if (pertfile) call do_magfie_pert_init("in_file_pert") call init_profiles(R0) diff --git a/src/diag/diag_bounce_nonlin.f90 b/src/diag/diag_bounce_nonlin.f90 index 8b8d217..9685e93 100644 --- a/src/diag/diag_bounce_nonlin.f90 +++ b/src/diag/diag_bounce_nonlin.f90 @@ -33,7 +33,7 @@ subroutine run_bounce_nonlin_diag(arg_runname) ! Initialize NEO-RT environment similar to neort:main runname = trim(arg_runname) - call read_and_set_config(runname) + call read_and_set_config(runname//".in") call do_magfie_init("in_file") if (pertfile) call do_magfie_pert_init("in_file_pert") call init_profiles(R0) diff --git a/src/diag/diag_contrib_map.f90 b/src/diag/diag_contrib_map.f90 index a00b93d..4260a4c 100644 --- a/src/diag/diag_contrib_map.f90 +++ b/src/diag/diag_contrib_map.f90 @@ -42,7 +42,7 @@ subroutine run_contrib_diag(arg_runname) ! Initialize environment runname = trim(arg_runname) - call read_and_set_config(runname) + call read_and_set_config(runname//".in") call do_magfie_init("in_file") if (pertfile) call do_magfie_pert_init("in_file_pert") call init_profiles(R0) diff --git a/test/test_multi_init.f90 b/test/test_multi_init.f90 index 61dba7f..d7d98f8 100644 --- a/test/test_multi_init.f90 +++ b/test/test_multi_init.f90 @@ -17,7 +17,7 @@ program test_multi_init print *, "" ! Initialize once to load data - call read_and_set_config("driftorbit") + call read_and_set_config("driftorbit.in") call do_magfie_init("in_file") nmode_prev = nmode diff --git a/test/test_neort_lib.f90 b/test/test_neort_lib.f90 index 5a90eec..b9b2301 100644 --- a/test/test_neort_lib.f90 +++ b/test/test_neort_lib.f90 @@ -24,7 +24,7 @@ subroutine test_single_s() print *, "Test: single s computation..." - call neort_init("driftorbit", "in_file") + call neort_init("driftorbit.in", "in_file") call neort_prepare_splines("plasma.in", "profile.in") call neort_compute_at_s(TEST_S, result) @@ -61,7 +61,7 @@ subroutine test_parallel_loop() s_array(i) = 0.2_dp + 0.1_dp * real(i, dp) end do - call neort_init("driftorbit", "in_file") + call neort_init("driftorbit.in", "in_file") call neort_prepare_splines("plasma.in", "profile.in") !$omp parallel do schedule(dynamic) @@ -100,7 +100,7 @@ subroutine test_spline_update() print *, "Test: spline update (KAMEL use case)..." - call neort_init("driftorbit", "in_file") + call neort_init("driftorbit.in", "in_file") call read_plasma_input("plasma.in", nplasma, am1, am2, Z1, Z2, plasma_data) call readdata("profile.in", 2, profile_data) diff --git a/test/test_omega_prime.f90 b/test/test_omega_prime.f90 index 9329e1f..1a5526c 100644 --- a/test/test_omega_prime.f90 +++ b/test/test_omega_prime.f90 @@ -42,7 +42,7 @@ subroutine main type(freq_data_t) :: freq_data(NUM_SAMPLES) call get_command_argument(1, runname) - call read_and_set_config(runname) + call read_and_set_config(trim(runname)//".in") call setup s0 = s v0 = 0.9_dp * vth diff --git a/test/test_parallel.f90 b/test/test_parallel.f90 index e025efa..01927b5 100644 --- a/test/test_parallel.f90 +++ b/test/test_parallel.f90 @@ -52,7 +52,7 @@ subroutine run_test() call set_log_level(-1) print *, "Reading input files..." - call read_and_set_config("driftorbit") + call read_and_set_config("driftorbit.in") call read_boozer_file("in_file") call read_plasma_input("plasma.in", nplasma, am1, am2, Z1, Z2, plasma) call prepare_plasma_splines(nplasma, am1, am2, Z1, Z2, plasma) diff --git a/test/test_torque.f90 b/test/test_torque.f90 index f597fc3..a150a1f 100644 --- a/test/test_torque.f90 +++ b/test/test_torque.f90 @@ -30,7 +30,7 @@ program test_torque_prog subroutine setup runname = TEST_RUN - call read_and_set_config(runname) + call read_and_set_config(trim(runname)//".in") call do_magfie_init("in_file") call init_profiles(R0) call read_and_init_plasma_input("plasma.in", s) From d8e0cf89adab751959edad2fd5f716519351dea2 Mon Sep 17 00:00:00 2001 From: Andreas Zach Date: Sat, 10 Jan 2026 18:10:32 +0100 Subject: [PATCH 3/4] Order mode numbers (m,n)=(poloidal,toroidal) in config struct --- src/config.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.f90 b/src/config.f90 index 6f5fbdf..59c2353 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -10,8 +10,8 @@ module neort_config real(dp) :: ms = 0.0_dp ! particle mass / u !*! real(dp) :: vth = 0.0_dp ! thermal velocity / cm/s !*! real(dp) :: epsmn = 0.0_dp ! perturbation amplitude B1/B0 (if pertfile==F) - real(dp) :: mph = 0.0_dp ! toroidal perturbation mode (if pertfile==F, n>0!) integer :: m0 = 0 ! poloidal perturbation mode (if pertfile==F) + real(dp) :: mph = 0.0_dp ! toroidal perturbation mode (if pertfile==F, n>0!) logical :: comptorque = .false. ! compute torque logical :: magdrift = .false. ! consider magnetic drift logical :: nopassing = .false. ! neglect passing particles From be295181bb80b3e6307dbbe65515de6e62fb6f89 Mon Sep 17 00:00:00 2001 From: Andreas Zach Date: Sat, 10 Jan 2026 18:45:52 +0100 Subject: [PATCH 4/4] Preserve comment at the correct location --- src/do_magfie_standalone.f90 | 1 - src/lib.f90 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/do_magfie_standalone.f90 b/src/do_magfie_standalone.f90 index fcb3f71..88c8ab4 100644 --- a/src/do_magfie_standalone.f90 +++ b/src/do_magfie_standalone.f90 @@ -475,7 +475,6 @@ subroutine init_mph_from_shared() end subroutine init_mph_from_shared subroutine do_magfie_pert_init(path) - ! else epsmn*exp(imun*(m0*th + mph*ph)) ! Backward compatibility wrapper: calls read_boozer_pert_file + init_magfie_pert_at_s character(len=*), intent(in) :: path diff --git a/src/lib.f90 b/src/lib.f90 index 022fcd1..da510ba 100644 --- a/src/lib.f90 +++ b/src/lib.f90 @@ -130,7 +130,7 @@ subroutine neort_compute_at_s(s_val, transport_data_out) call set_s(s_val) call init_magfie_at_s() - if (pertfile) call init_magfie_pert_at_s() + if (pertfile) call init_magfie_pert_at_s() ! else epsmn*exp(imun*(m0*th + mph*ph)) call init_mph_from_shared() call init_plasma_at_s() ! overwrites qi, mi and vth from config