Useful additional libraries

mean_sd.f90

Description

This module contains a small type that simply handles two arrays (mean and SD) This type is used for time-averaged outputs (and their standard deviations).

Quick access

Types:

mean_sd_2d_type, mean_sd_type

Routines:

compute_1d_complex(), compute_1d_real(), compute_2d_1d_input(), compute_2d_2d_input(), finalize_1d(), finalize_2d(), finalize_sd_1d(), finalize_sd_2d(), initialize_1d(), initialize_2d()

Needed modules

Types

  • type  mean_sd/mean_sd_type
    Type fields:
    • % mean (*) [real ,allocatable]

    • % nstart [integer ]

    • % nstop [integer ]

    • % sd (*) [real ,allocatable]

  • type  mean_sd/mean_sd_2d_type
    Type fields:
    • % l_sd [logical ]

    • % mean (*,*) [real ,allocatable]

    • % n_start_col [integer ]

    • % n_start_row [integer ]

    • % n_stop_col [integer ]

    • % n_stop_row [integer ]

    • % sd (*,*) [real ,allocatable]

Variables

Subroutines and functions

subroutine  mean_sd/initialize_1d(this, n_start, n_stop)

Memory allocation

Parameters:
  • this [real ]

  • n_start [integer ,in]

  • n_stop [integer ,in]

subroutine  mean_sd/compute_1d_real(this, input_data, n_ave, dt, totaltime)
Parameters:
  • this [real ]

  • input_data (*) [real ,in]

  • n_ave [integer ,in]

  • dt [real ,in]

  • totaltime [real ,in]

subroutine  mean_sd/compute_1d_complex(this, scal_lm, llm, ulm, n_r_max, n_ave, dt, totaltime)

This computes the mean and the spatial-variance of a scalar quantity

Parameters:
  • this [real ]

  • scal_lm (1 - llm + ulm,n_r_max) [complex ,in]

  • llm [integer ,in,required]

  • ulm [integer ,in,required]

  • n_r_max [integer ,in,]

  • n_ave [integer ,in]

  • dt [real ,in]

  • totaltime [real ,in]

Call to:

cc2real()

subroutine  mean_sd/finalize_sd_1d(this, totaltime)

Finish computation of standard-deviation

Parameters:
  • this [real ]

  • totaltime [real ,in]

subroutine  mean_sd/finalize_1d(this)

Memory deallocation

Parameters:

this [real ]

subroutine  mean_sd/initialize_2d(this, n_start_row, n_stop_row, n_start_col, n_stop_col, l_sd)

Memory allocation

Parameters:
  • this [real ]

  • n_start_row [integer ,in]

  • n_stop_row [integer ,in]

  • n_start_col [integer ,in]

  • n_stop_col [integer ,in]

  • l_sd [logical ,in]

subroutine  mean_sd/compute_2d_1d_input(this, input_data, n_ave, dt, totaltime, ind)
Parameters:
  • this [real ]

  • input_data (*) [real ,in]

  • n_ave [integer ,in]

  • dt [real ,in]

  • totaltime [real ,in]

  • ind [integer ,in]

subroutine  mean_sd/compute_2d_2d_input(this, input_data, n_ave, dt, totaltime)
Parameters:
  • this [real ]

  • input_data (1 - this%n_start_row + this%n_stop_row,1 - this%n_start_col + this%n_stop_col) [real ,in]

  • n_ave [integer ,in]

  • dt [real ,in]

  • totaltime [real ,in]

subroutine  mean_sd/finalize_sd_2d(this, totaltime)

Finish computation of standard-deviation

Parameters:
  • this [real ]

  • totaltime [real ,in]

subroutine  mean_sd/finalize_2d(this)

Memory deallocation

Parameters:

this [real ]

useful.f90

Description

This module contains several useful routines.

Quick access

Routines:

abortrun(), cc22real(), cc2real(), factorise(), l_correct_step(), logwrite(), polynomial_interpolation(), polynomial_interpolation_real(), round_off()

Needed modules

Variables

Subroutines and functions

function  useful/l_correct_step(n, t, t_last, n_max, n_step, n_intervals, n_ts, times, n_eo)

Suppose we have a (loop) maximum of n_max steps! If n_intervals times in these steps a certain action should be carried out this can be invoked by l_correct_step=true if on input n_intervals>0 and n_step=0. Alternatively the action can be invoked every n_step steps if on input n_intervals=0 and n_step>0. In both cases l_correct_step=true for n=n_max.

The argument controls whether in addition n should be even (n_eo=2) or odd (n_eo=1)

Parameters:
  • n [integer ,in] :: current step

  • t [real ,in] :: time at current step

  • t_last [real ,in] :: last time at current step

  • n_max [integer ,in] :: max number of steps

  • n_step [integer ,in] ::

  • n_intervals [integer ,in] :: number of actions

  • n_ts [integer ,in] :: number of times t

  • times (*) [real ,in] :: times where l_correct_step == true

  • n_eo [integer ,in] :: even/odd controller

Return:

l_correct_step [logical ]

Called from:

step_time()

Call to:

abortrun()

subroutine  useful/factorise(n, n_facs, fac, n_factors, factor)

Purpose of this subroutine is factorize n into a number of given factors fac(i).

Parameters:
  • n [integer ,in] :: remaining

  • n_facs [integer ,in] :: number of facs to be tried !

  • fac (*) [integer ,in] :: list of fators to be tried !

  • n_factors [integer ,out] :: number of factors

  • factor (*) [integer ,out]

Called from:

init_fft()

Call to:

abortrun()

function  useful/cc2real(c, m)

This function computes the norm of complex number, depending on the azimuthal wavenumber.

Parameters:
  • c [complex ,in] :: A complex number

  • m [integer ,in] :: Azimuthal wavenumber

Return:

cc2real [real ]

Called from:

get_poltorrms(), hint2dpol(), hint2dpollm(), hintrms(), getdlm(), get_e_kin(), get_u_square(), get_e_mag(), compute_1d_complex(), get_power(), rbrspec(), rbpspec(), spectrum(), spectrum_scal(), spectrum_vec(), spectrum_vec_ic(), get_amplitude(), getstartfields(), get_mag_rhs_imp(), get_mag_rhs_imp_ghost(), get_pol_rhs_imp(), get_pol_rhs_imp_ghost(), assemble_pol(), assemble_single(), get_single_rhs_imp(), get_tor_rhs_imp(), get_tor_rhs_imp_ghost()

function  useful/cc22real(c1, c2, m)
Parameters:
  • c1 [complex ,in]

  • c2 [complex ,in]

  • m [integer ,in]

Return:

cc22real [real ]

Called from:

get_e_mag(), spectrum_vec_ic()

subroutine  useful/logwrite(message)

This subroutine writes a message in the log.TAG file and in the STDOUT If l_save_out is set to .true. the log.TAG file is opened and closed.

Parameters:

message [character(len=*),in] :: Message to be written

Called from:

dt_courant(), get_fd_grid(), outto(), output(), precalc(), radial(), spectrum(), getstartfields(), step_time()

subroutine  useful/polynomial_interpolation(xold, yold, xnew, ynew)
Parameters:
  • xold (4) [real ,in]

  • yold (4) [complex ,in]

  • xnew [real ,in]

  • ynew [complex ,out]

Called from:

mapdatar()

Call to:

polynomial_interpolation_real()

subroutine  useful/polynomial_interpolation_real(xold, yold, xnew, ynew)

This subroutine performs a polynomial interpolation of ynew(xnew) using input data xold and yold.

Parameters:
  • xold (*) [real ,in] :: Old grid

  • yold (*) [real ,in] :: Old data

  • xnew [real ,in] :: Point of interpolation

  • ynew [real ,out] :: Data interpolated at xnew

Called from:

polynomial_interpolation()

Call to:

abortrun()

subroutine  useful/abortrun(message)

This routine properly terminates a run

Parameters:

message [character(len=*),in] :: Message printing before termination

Called from:

parallel_solve_phase(), parallel_solve(), readnamelists(), init_rnb(), prepare_mat(), initialize_blocking(), get_subblocks(), get_standard_lm_blocking(), get_lorder_lm_blocking(), get_snake_lm_blocking(), lm2lo_redist(), lo2lm_redist(), set_dt_array(), init_fft(), get_fd_grid(), getdlm(), inits(), initxi(), initb(), j_cond(), xi_cond(), pt_cond(), ps_cond(), get_e_kin(), get_movie_type(), movie_gather_frames_to_rank0(), get_b_nl_bcs(), write_movie_frame(), plm_theta(), precalc(), get_hit_times(), writeinfo(), transportproperties(), getbackground(), get_dr_rloc(), get_ddr_rloc(), get_ddr_ghost(), get_ddddr_ghost(), readstartfields_old(), readstartfields(), readstartfields_mpi(), checktruncation(), prepareb_fd(), fill_ghosts_b(), assemble_mag(), assemble_mag_rloc(), get_bmat(), get_bmat_rdist(), get_phimat(), get_smat(), assemble_pol_rloc(), get_wpmat(), get_elliptic_mat(), get_wmat(), get_p0mat(), assemble_single(), get_wpsmat(), get_ps0mat(), get_ximat(), assemble_tor(), assemble_tor_rloc(), get_z10mat(), get_zmat(), get_z10mat_rdist(), l_correct_step(), factorise(), polynomial_interpolation_real()

function  useful/round_off(param, ref[, cut])

This function rounds off tiny numbers. This is only used for some outputs.

Parameters:
  • param [real ,in] :: parameter to be checked

  • ref [real ,in] :: reference value

Options:

cut [real ,in,] :: cutoff factor compared to machine epsilon

Return:

round_off [real ]

Called from:

outhemi(), outheat(), outphase(), outpar(), outperppar(), get_power(), spectrum()

mem_alloc.f90

Description

This little module is used to estimate the global memory allocation used in MagIC

Quick access

Variables:

memory_file, n_memory_file, n_ranks_print, ranks_selected

Routines:

finalize_memory_counter(), human_readable_size(), initialize_memory_counter(), memwrite()

Needed modules

Variables

  • mem_alloc/bytes_allocated [integer,public]
  • mem_alloc/memory_file [character(len=72),private]
  • mem_alloc/n_memory_file [integer,private]
  • mem_alloc/n_ranks_print [integer,private]
  • mem_alloc/ranks_selected (*) [integer,private/allocatable]

Subroutines and functions

subroutine  mem_alloc/initialize_memory_counter()
Called from:

magic

subroutine  mem_alloc/memwrite(origin, bytes_alloc)
Parameters:
  • origin [character(len=*),in]

  • bytes_alloc [integer ,in]

Called from:

initialize_lmloop(), initialize_blocking(), initialize_communications(), initialize_radialloop(), magic

Call to:

human_readable_size()

subroutine  mem_alloc/finalize_memory_counter()
Called from:

magic

Call to:

human_readable_size()

function  mem_alloc/human_readable_size(bytes)
Parameters:

bytes [integer ,in]

Return:

st [real ]

Called from:

memwrite(), finalize_memory_counter()

char_manip.f90

Description

This module contains several useful routines to manipule character strings

Quick access

Routines:

capitalize(), dble2str(), delete_string(), write_long_string()

Needed modules

  • precision_mod: This module controls the precision used in MagIC

Subroutines and functions

subroutine  charmanip/capitalize(string_bn)

Convert lower-case letters into capital letters

Parameters:

string_bn [character(len=*),inout]

Called from:

readnamelists(), select_tscheme(), initialize_communications(), get_movie_type(), read_signal_file()

subroutine  charmanip/delete_string(string_bn, string_del, length)

Deletes string_del from string and returns new length of string.

Parameters:
  • string_bn [character(len=*),inout]

  • string_del [character(len=*),in]

  • length [integer ,out]

Called from:

get_movie_type()

subroutine  charmanip/dble2str(num, str)

converts a 1 number num into a character str

Parameters:
  • num [real ,in]

  • str [character(len=*),out]

Called from:

get_movie_type(), store(), store_mpi()

subroutine  charmanip/write_long_string(prefix, long_string, out_unit)

This subroutine is used to split a long string (with len(str)>85) into a multi-lines string for a cleaner printout.

Parameters:
  • prefix [character(len=*),in]

  • long_string [character(len=*),in]

  • out_unit [integer ,in]

Called from:

magic