Startup

General Startup procedure of the Octopus Code

The flow chart for most calculations has many steps in common, most of them related to setting up the basic data structures of the code.

The ‘main’ program only performs tasks which are independent of the actual calculation and the physical system:

main/main.F90:

In a strongly simplified way, we have:

program main

  [...]

  ! "constructors":           ! start code components

  call global_init()               ! initialize the mpi, clocks, etc.
  call parser_init()               ! initialize the input parser
  call messages_init()             ! initialize the message system
  call walltimer_init()            ! initialize the timer module
  call io_init()                   ! initialize the I/O subsystem
  call calc_mode_par_init()        ! initialize parallelization strategy
  call profiling_init()            ! initialize and start the profiling system

  call run(inp_calc_mode)          ! pass control to the 'actual code' running the calculation

  ! "destructors":            ! stop code components in reverse order

  call profiling_end()
  call calc_mode_par_end()
  call io_end()
  call walltimer_end()
  call messages_end()
  call parser_end()
  call global_end()

end programme

The actual calculation is started from the routine run(), which initialized the data structures representing the actual system and calculation mode, before starting the corresponding calculation:

main/run.F90 defines the module run_oct_m:

This module does not contain own data (apart from constants).

Definition of run()

scf/ground_state.F90:

  subroutine ground_state_run(electrons, from_scratch)
    class(electrons_t), intent(inout) :: electrons
    logical,            intent(inout) :: from_scratch

    PUSH_SUB(ground_state_run)

    call electrons_ground_state_run(electrons%namespace, electrons%mc, electrons%gr, &
      electrons%ions, electrons%ext_partners, &
      electrons%st, electrons%ks, electrons%hm, electrons%outp, electrons%space, from_scratch)

    POP_SUB(ground_state_run)
  end subroutine ground_state_run
  subroutine electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, fromScratch)
    type(namespace_t),        intent(in)    :: namespace
    type(multicomm_t),        intent(in)    :: mc
    type(grid_t),             intent(inout) :: gr
    type(ions_t),             intent(inout) :: ions
    type(partner_list_t),     intent(in)    :: ext_partners
    type(states_elec_t),      intent(inout) :: st
    type(v_ks_t),             intent(inout) :: ks
    type(hamiltonian_elec_t), intent(inout) :: hm
    type(output_t),           intent(in)    :: outp
    type(electron_space_t),   intent(in)    :: space
    logical,                  intent(inout) :: fromScratch

    type(rdm_t)     :: rdm
    type(scf_t)     :: scf

    PUSH_SUB(ground_state_run_legacy)

    call gs_allocate_wavefunctions(namespace, gr, st, hm, scf, ks, ions, mc, space)

    if (.not. fromScratch) then
      call gs_load_from_restart(namespace, scf, gr, mc, st, hm, ks, space, ions, ext_partners, fromScratch)
    end if

    call gs_initialize(namespace, scf, rdm, gr, mc, st, hm, ions, ks, space, ext_partners, fromScratch)

    call gs_run(namespace, scf, rdm, mc, gr, ions, ext_partners, st, ks, hm, outp, space)

    call gs_cleanup(ks, scf, rdm, st, hm)

    POP_SUB(ground_state_run_legacy)
  end subroutine electrons_ground_state_run