• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gyrokinetics / gs2 / 1969924691

06 Aug 2025 12:51PM UTC coverage: 8.174% (+0.008%) from 8.166%
1969924691

push

gitlab-ci

David Dickinson
Merged in minor/make_dump_response_use_init_system (pull request #1107)

3667 of 44863 relevant lines covered (8.17%)

124414.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/programs/dump_response.f90
1
!> A program to generate response matrix data for a given input file
2
!> and dump the resulting arrays to file to be used by subsequent runs.
3
!>
4
!> By default this will produce a single set of response matrix files
5
!> for the time step in the provided input file. The input file can
6
!> contain a `dump_response_knobs` namelist which specifies
7
!> `n_time_steps`. If this is greater than one then the program will
8
!> produce response matrix files for `n_time_steps`
9
!> timesteps. Specifically, it will produce these files for time steps
10
!> {delt/delt_adj^N, N=0, n_time_steps-1}. This may be useful for
11
!> precomputing the response matrices required for a nonlinear run
12
!> where the timestep is allowed to vary and take values from this sequence.
13
program dump_response
×
14
  use gs2_main, only : gs2_program_state_type, finalize_gs2, initialize_gs2
×
15
  use gs2_init, only: init_level_list, init
16
  use mp, only: init_mp, mp_comm, finish_mp, proc0, broadcast
17
  use fields, only: set_fields_config, fields_config_type
18
  use file_utils, only: input_unit_exist
19
  implicit none
20
  type(gs2_program_state_type) :: state
×
21
  logical :: exist
22
  logical, parameter :: quiet = .false.
23
  integer :: istep, n_time_steps, in_file
24
  type(fields_config_type) :: fields_config
25
  namelist /dump_response_knobs/n_time_steps
26

27
  call init_mp
×
28
  state%mp_comm = mp_comm
×
29
  call initialize_gs2(state, quiet = quiet)
×
30

31
  if(proc0) then
×
32
     n_time_steps=1
×
33
     in_file = input_unit_exist ("dump_response_knobs", exist)
×
34
     if(exist) read(unit=in_file,nml=dump_response_knobs)
×
35
  endif
36
  call broadcast(n_time_steps)
×
37

38
  ! Read in fields config and then override read_response and dump_response
39
  ! so we know that we _always_ need to explicitly dump
40
  call fields_config%init(name = 'fields_knobs', requires_index = .false.)
×
41
  fields_config%read_response = .false.
×
42
  fields_config%dump_response = .false.
×
43
  call set_fields_config(fields_config)
×
44

45
  ! This routine initialises the response matrix and dumps it to file.
46
  ! This call will use the time step as specified in the input file.
47
  call init_and_dump(quiet)
×
48
  ! Now we deal with the other time steps in the sequence if n_time_steps > 1
49
  do istep=2,n_time_steps
×
50
     !Reduce the time step
51
     call next_time_step
×
52

53
     !Dump response
54
     call init_and_dump(quiet)
×
55
  enddo
56

57
  call init(state%init, init_level_list%basic)
×
58
  call finalize_gs2(state, quiet)
×
59
  call finish_mp
×
60

61
contains
62

63
  !> Changes to the next time step in the sequence as determined by the usual
64
  !> rules to reduce the timestep in a nonlinear simulation.
65
  subroutine next_time_step
×
66
    use gs2_time, only: code_dt, save_dt
67
    use gs2_reinit, only: reduce_time_step
68
    implicit none
69

70
    ! Drop to
71
    call init(state%init, init_level_list%override_timestep)
×
72

73
    !First reduce the time step
74
    call reduce_time_step
×
75

76
    !Save the time step
77
    call save_dt(code_dt)
×
78
  end subroutine next_time_step
×
79

80
  !> Initialise the response matrices and write to file
81
  subroutine init_and_dump(quiet)
×
82
    use fields, only: dump_response_to_file
83
    use job_manage, only: time_message
84
    use gs2_time, only: code_dt
85
    use mp, only: proc0
86
    implicit none
87
    logical, intent(in) :: quiet
88
    real :: time_measure(2)
89
    character (len=64) :: str_code_dt
90

91
    if(proc0.and.(.not.quiet)) write(*,'("")')
×
92
    time_measure = 0.
×
93

94
    !Now call the initialisation routine
95
    if(proc0.and.(.not.quiet)) write(*,'("Init")', advance='no')
×
96
    call time_message(.false.,time_measure,'Init')
×
97
    call init(state%init, init_level_list%fields_level_2)
×
98
    call time_message(.false.,time_measure,'Init')
×
99
    if(proc0.and.(.not.quiet)) write(*,'("  --> Done in : ",ES14.6E3," seconds")') time_measure(1)
×
100
    time_measure=0.
×
101

102
    !Now we make the dt string
103
    write(str_code_dt,'(ES14.6E3)') code_dt
×
104

105
    !Now write response to files
106
    if(proc0.and.(.not.quiet)) write(*,'("Dumping to file for timestep ",A,A,A)',advance='no') "'",trim(adjustl(str_code_dt)),"'"
×
107
    call time_message(.false.,time_measure,'Dump')
×
108
    call dump_response_to_file()
×
109
    call time_message(.false.,time_measure,'Dump')
×
110
    if(proc0.and.(.not.quiet)) write(*,'("  --> Done in : ",ES14.6E3," seconds")') time_measure(1)
×
111
    time_measure=0.
×
112
  end subroutine init_and_dump
×
113
end program dump_response
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc