Module: Base#

Simulation system size, and the size setup subroutine.

  • Name: mod_mupro_base

  • Depends on: None

  • Defined variables: idp, rdp, cdp

  • Defined types: type_mupro_SizeContext

  • Defined subroutines: mupro_size_setup, [mupro_mpi_setup](#mupro_mpi_setup(rank, process)), [mupro_toml_read_file](#mupro_toml_read_file(file, table)), [mupro_toml_get_value_evaluate](#mupro_toml_get_value_evaluate(table, name, out))

The module is to set commonly used double precision variable kind.

Defined variables#

    use, intrinsic :: ISO_Fortran_env
    integer, parameter::idp = int64
    integer, parameter::rdp = real64
    integer, parameter::cdp = real64

Defined Types#

type_mupro_SizeContext#

Variable

Type

Meaning

nx

int32

Number of simulation grids along x direction

ny

int32

Number of simulation grids along y direction

nz

int32

Number of simulation grids along z direction

ns

int32

Number of simulation grids in the substrate for thin film setup

nf

int32

Number of simulation grids in the film for thin film setup

dx

real64

Simulation size along x in real dimension (m)

dy

real64

Simulation size along y in real dimension (m)

dz

real64

Simulation size along z in real dimension (m)

Defined Subroutines#

mupro_size_setup(context)#

Set the simulation size for the whole simulation, the variables will be used implicitly later in almost all the modules and subroutines.

Important

This is the base for all other modules. You must call the mupro_size_setup subroutine before you can use any other functionalities provided by the SDK.

Argument

Type(Intent)

Meaning

context

type_mupro_SizeContext(IN)

The simulation size you want to have for the solvers

mupro_mpi_setup(rank, process)#

Initialize the MPI, this is necessary for all simulation using our SDK.

Important

This is the base for all other modules. You must call the mupro_mpi_setup subroutine before you can use any other functionalities provided by the SDK. There is no particular sequence requested between mupro_mpi_setup and mupro_size_setup.

Argument

Type(Intent)

Meaning

rank

integer(out)

The MPI rank for current core, starting from 0

process

integer(out)

The total number of processes(cores)

mupro_toml_read_file(file, table)#

Read a toml file into toml_table type (from the toml-f package).

Important

You must use this subroutine before you and use the get_value and mupro_toml_get_value_evaluate subroutine to read parameters from the toml file.

Argument

Type(Intent)

Meaning

file

character(len=*)(in)

The toml file name

table

toml_table(out)

The toml_table to be used later in the get_value subroutine

mupro_toml_get_value_evaluate(table, name, out)#

This subroutine combine the funtionalities of get_value from toml-f package, which can read a string from the toml file, and the exprtk::expression, exprtk::parser functions which evaluate string math expression into numbers.

Argument

Type(Intent)

Meaning

table

toml_table(in)

The toml_table obtained from mupro_toml_read_file

name

character(len=*)(in)

The key of the to be parsed toml variable

out

real(kind=rdp)(out)

The exprtk evaluated number

Usage#

Set up basic environment#

When we use the L0_Base tool, we need to first import the mod_mupro_base module. Secondly, we need to call the initialization function mupro_size_default to create a variable of type a type_mupro_SizeContext. Then we can call subroutines related to type type_mupro_SizeContext to view the relevant information about this variable. Of course, we can use the mupro_mpi_setup function to initialize variables of type type_mupro_SizeContext. Alternatively, we can use the mupro_size_read function to read data from a toml file and initialize variables of type type_mupro_SizeContext.

Initialize mpi environment#

If you want to set the simulation size for the entire simulation, you can use mupro_mpi_setup to initialize mpi, which will return a variable that will be implicitly used later in almost all modules and subroutines. If you want to add variables and constants during calculation, please use mupro_add_variable and mupro_add_constant respectively.

Perform calculations#

You can use mupro_evaluate for calculations.

Quit Calculation#

If you want to exit the calculation, please use mupro_mpi_exit

Example#

We have some sample programs to demonstrate how to call our interface

About murop_size_context#

Modify ctx, initialize, assign values, and other operations

PROGRAM MAIN
    USE mod_mupro_base
    ! use mupro_lib_test
    
    IMPLICIT NONE

    call test_mupro_context()
 
END PROGRAM

subroutine test_mupro_context()
    use mod_mupro_base
    implicit none
    type(type_mupro_SizeContext):: context
    call mupro_size_default(context)
    ! call prepare_SizeContext(context)
    call print_SizeContext(context)

    call mupro_size_read("input.toml",context)
    call print_SizeContext(context)

    call mupro_size_setup(context)
  

end subroutine test_mupro_context

subroutine print_SizeContext(context)
    use mod_mupro_base
    implicit none
    type(type_mupro_SizeContext), intent(in) ::  context
    character(len=100) :: fmtInt, fmtDouble
    fmtInt = '(a20," = ",i10)'
    fmtDouble = '(a20," = ",e10.5)'
    print *, "Inside library"
    print fmtInt, "context%nx", context%nx
    print fmtInt, "context%ny", context%ny
    print fmtInt, "context%nz", context%nz
    print fmtDouble, "context%dx", context%dx
    print fmtDouble, "context%dy", context%dy
    print fmtDouble, "context%dz", context%dz
    print fmtInt, "context%ns", context%ns
    print fmtInt, "context%nf", context%nf
    ! print fmtDouble, "context%l0", context%l0
    ! print fmtInt, "context%kt", context%kt
    ! print fmtDouble, "context%dt0", context%dt0
end subroutine

About toml file read#

Modify ctx, initialize, assign values, and other operations

PROGRAM MAIN
    USE mod_mupro_base
    ! use mupro_lib_test

    IMPLICIT NONE

    call test_toml_table()

END PROGRAM

subroutine test_toml_table()
    use tomlf, only: toml_table, get_value, toml_array, len
    USE mod_mupro_base
    integer :: out
    character(len=20) :: infilename = "test_evaluate.toml"
    type(toml_table), target, allocatable :: table
    type(toml_table),  pointer :: child
    character(len = 17) :: name
    real(kind = rdp) :: result

    !about  toml file
    call mupro_toml_read_file(infilename, table)

    name="c"
    call get_value(table, "test_evaluate", child)
    call mupro_toml_get_value_evaluate(child, name, result)
    print *, "c expression value is: ", result

end subroutine test_toml_table