programmain[...]! "constructors": ! start code components
callglobal_init()! initialize the mpi, clocks, etc.
callparser_init()! initialize the input parser
callmessages_init()! initialize the message system
callwalltimer_init()! initialize the timer module
callio_init()! initialize the I/O subsystem
callcalc_mode_par_init()! initialize parallelization strategy
callprofiling_init()! initialize and start the profiling system
callrun(inp_calc_mode)! pass control to the 'actual code' running the calculation
! "destructors": ! stop code components in reverse order
callprofiling_end()callcalc_mode_par_end()callio_end()callwalltimer_end()callmessages_end()callparser_end()callglobal_end()endprogramme
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:
This module does not contain own data (apart from constants).
Definition of run()
subroutinerun(namespace,calc_mode_id)type(namespace_t),intent(in)::namespaceinteger,intent(in)::calc_mode_idtype(partner_list_t)::partners!< structured (hierarchical) list of partners
class(system_t),pointer::systems!< top level system (either electrons or multisystem_basic container)
type(system_factory_t)::system_factorytype(interactions_factory_t)::interactions_factorylogical::from_scratchinteger::iunit_outtype(partner_iterator_t)::iterclass(interaction_partner_t),pointer::partnerPUSH_SUB(run)callmessages_print_with_emphasis(msg="Calculation Mode",namespace=namespace)callmessages_print_var_option("CalculationMode",calc_mode_id,namespace=namespace)callmessages_print_with_emphasis(namespace=namespace)callcalc_mode_init()if(calc_mode_id==OPTION__CALCULATIONMODE__RECIPE)thencallpulpo_print()POP_SUB(run)returnendifcallrestart_module_init(namespace)callunit_system_init(namespace)callaccel_init(mpi_world,namespace)! initialize FFTs
callfft_all_init(namespace)if(calc_mode_id==OPTION__CALCULATIONMODE__TEST)thencalltest_run(namespace)callfft_all_end()callmpi_debug_statistics()POP_SUB(run)returnendif! Create systems
if(parse_is_defined(namespace,"Systems"))then! We are running in multi-system mode
systems=>system_factory%create(namespace,SYSTEM_MULTISYSTEM)else! Fall back to old behaviour
systems=>electrons_t(namespace,generate_epot=calc_mode_id/=OPTION__CALCULATIONMODE__DUMMY)endif! initialize everything that needs parallelization
callsystems%init_parallelization(mpi_world)! Create list of partners
selecttype(systems)classis(multisystem_basic_t)! Systems are also partners
partners=systems%list! Add external potentials to partners list
callload_external_potentials(partners,namespace)callload_external_waves(partners,namespace)! Add lasers to the partner list
callload_lasers(partners,namespace)typeis(electrons_t)callpartners%add(systems)endselect! Initialize algorithms (currently only propagators are supported)
selecttype(systems)classis(multisystem_basic_t)selectcase(calc_mode_id)case(OPTION__CALCULATIONMODE__GS)callsystems%new_algorithm(minimizer_factory_t(systems%namespace))case(OPTION__CALCULATIONMODE__TD)callsystems%new_algorithm(propagator_factory_t(systems%namespace))endselectendselect![create_interactions] !doxygen marker. Dont delete
! Create and initialize interactions
!
! This function is called recursively for all subsystems of systems.
! If systems is a multisystem_basic_t container, the partners list contains all subsystems.
callsystems%create_interactions(interactions_factory,partners)![create_interactions]
selecttype(systems)classis(multisystem_basic_t)! Write the interaction graph as a DOT graph for debug
if((debug%interaction_graph.or.debug%interaction_graph_full).and.mpi_grp_is_root(mpi_world))theniunit_out=io_open('debug/interaction_graph.dot',systems%namespace,action='write')write(iunit_out,'(a)')'digraph {'callsystems%write_interaction_graph(iunit_out,debug%interaction_graph_full)write(iunit_out,'(a)')'}'callio_close(iunit_out)endifendselectif(.not.systems%process_is_slave())thencallmessages_write('Info: Octopus initialization completed.',new_line=.true.)callmessages_write('Info: Starting calculation mode.')callmessages_info(namespace=namespace)!%Variable FromScratch
!%Type logical
!%Default false
!%Section Execution
!%Description
!% When this variable is set to true, <tt>Octopus</tt> will perform a
!% calculation from the beginning, without looking for restart
!% information.
!% NOTE: If available, mesh partitioning information will be used for
!% initializing the calculation regardless of the set value for this variable.
!%End
callparse_variable(namespace,'FromScratch',.false.,from_scratch)callprofiling_in("CALC_MODE")selectcase(calc_mode_id)case(OPTION__CALCULATIONMODE__GS)selecttype(systems)classis(multisystem_basic_t)callmultisystem_run(systems,from_scratch)typeis(electrons_t)callground_state_run(systems,from_scratch)endselectcase(OPTION__CALCULATIONMODE__UNOCC)callunocc_run(systems,from_scratch)case(OPTION__CALCULATIONMODE__TD)selecttype(systems)classis(multisystem_basic_t)callmultisystem_run(systems,from_scratch)typeis(electrons_t)calltime_dependent_run(systems,from_scratch)endselectcase(OPTION__CALCULATIONMODE__GO)callgeom_opt_run(systems,from_scratch)case(OPTION__CALCULATIONMODE__OPT_CONTROL)callopt_control_run(systems)case(OPTION__CALCULATIONMODE__EM_RESP)selectcase(get_resp_method(namespace))case(FD)callstatic_pol_run(systems,from_scratch)case(LR)callem_resp_run(systems,from_scratch)endselectcase(OPTION__CALCULATIONMODE__CASIDA)callcasida_run(systems,from_scratch)case(OPTION__CALCULATIONMODE__VDW)callvdW_run(systems,from_scratch)case(OPTION__CALCULATIONMODE__VIB_MODES)selectcase(get_resp_method(namespace))case(FD)callphonons_run(systems)case(LR)callphonons_lr_run(systems,from_scratch)endselectcase(OPTION__CALCULATIONMODE__ONE_SHOT)message(1)="CalculationMode = one_shot is obsolete. Please use gs with MaximumIter = 0."callmessages_fatal(1,namespace=namespace)case(OPTION__CALCULATIONMODE__KDOTP)callkdotp_lr_run(systems,from_scratch)case(OPTION__CALCULATIONMODE__DUMMY)case(OPTION__CALCULATIONMODE__INVERT_KS)callinvert_ks_run(systems)case(OPTION__CALCULATIONMODE__RECIPE)ASSERT(.false.)!this is handled before, if we get here, it is an error
endselectcallprofiling_out("CALC_MODE")endifselecttype(systems)classis(multisystem_basic_t)!Deallocate the external potentials
calliter%start(partners)dowhile(iter%has_next())selecttype(ptr=>iter%get_next())classis(external_potential_t)partner=>ptrSAFE_DEALLOCATE_P(partner)classis(external_waves_t)partner=>ptrSAFE_DEALLOCATE_P(partner)classis(lasers_t)partner=>ptrSAFE_DEALLOCATE_P(partner)endselectenddoendselect! Finalize systems
SAFE_DEALLOCATE_P(systems)callfft_all_end()callaccel_end(global_namespace)callmpi_debug_statistics()POP_SUB(run)containssubroutinecalc_mode_init()PUSH_SUB(calc_mode_init)selectcase(calc_mode_id)case(OPTION__CALCULATIONMODE__GS,OPTION__CALCULATIONMODE__GO,OPTION__CALCULATIONMODE__UNOCC)callground_state_run_init()case(OPTION__CALCULATIONMODE__TD)calltd_run_init()case(OPTION__CALCULATIONMODE__CASIDA)callcasida_run_init()endselectPOP_SUB(calc_mode_init)endsubroutinecalc_mode_init