@startuml
title UCB diagram ; 2 + N_MBH <= mpid < 2 + N_MBH + N_UCB

|#white|GlobalFit.c|
start
  :// Forked from MPI_Init();

  |#white|GalacticBinaryIO.c|
  :// Reads known-sources file.
  parse_vb_list();

  |#white|MBHWrapper.c|
  :// search_sources.dat found
  // get N_MBH = number of line
  parse_mbh_args();

  |#white|GalacticBinaryIO.c|
  :// Parse any UCB 
  parse();

  |#white|GlobalFit.c|
  :// Allocates GlobalFit TDI AE structures
  alloc_gf_data();

  |#white|GalacticBinaryWrapper.c|
  :// Allocates UCB structures (flags, orbit, chain, data, prior).
  alloc_gbmcmc_data();

  |#white|VerificationBinaryWrapper.c|
  :// Allocates VG structures (flags, orbit, chain_vec, data_vec,_prior_vec, trial_vec, model_vec).
  alloc_vbmcmc_data();

  |#white|MBHWrapper.c|
  :// Allocates MBH structures (data, het, flags, tdi).
  alloc_mbh_data();

  |#white|NoiseWrapper.c|
  :alloc_noise_data();

  :// Propagates input TDI to all mpids.
  share_data();

  :initialize_gbmcmc_sampler();

  repeat
    :// Remove from TDI AE all found signals from last iteration of UCB VGB MBH
    create_residual();

    |#white|GalacticBinaryWrapper.c|
    group setup_frequency_segment();

    if (ucb_frequency_spacing.dat found?) then (found)
      :mpidUcb1 fmin_1 fmax_1
      mpidUcb2 fmin_2 fmax_2
      mpidUcb3 fmin_3 fmax_3
      ...
      mpidUcbN_UCB fmin_N_UCB fmax_N_UCB ;
    else (not found)
      :?;
    endif
    end group

    |#white|NoiseWrapper.c|
    :// Keep only noise from related frequencies band
    select_noise_segment();

    |#white|GalacticBinaryWrapper.c|
    :// cycle = round ( the max time of all VGB MBH UCB process time) / ( time of one update_gbmcmc_sampler() time );

    :exchange_gbmcmc_source_params();
    if (mpid?) then (even)
      while (Loop until done 'cycle' time)
        :// MCMC
        update_gbmcmc_sampler();
      endwhile
      :exchange_gbmcmc_source_params();
    else (odd)
      :exchange_gbmcmc_source_params();
      while (Loop until done 'cycle' time)
        :// MCMC
        update_gbmcmc_sampler();
      endwhile
    endif
  
    |#white|GlobalFit.c|
    :// Sends TDI AE from UCB to root process, then from root to all non-UCB processes.
    share_gbmcmc_model();

    :// Receives TDI AE from root process.
    share_mbh_model();

    :// Receives noise model from root process.
    share_noise_model();

    :// Receives TDI AE from root process.
    share_vbmcmc_model();

  repeat while (GBMCMC steps finished?) is (no)
  ->yes;
stop
@enduml