JSONController Derived Type

type, public :: JSONController

Object responsible for reading and writing to JSON files


Components

Type Visibility Attributes Name Initial
type(json_file), private :: file

json file handle

logical, private :: fileOpen = .false.

True if this controller has opened a file

character(len=:), private, allocatable :: alternativeJSONFilepath

If allocated will be used instead of default config.json


Type-Bound Procedures

procedure, public :: loadFile

  • interface

    public module subroutine loadFile(this, mpiCont, filepath)

    Loads json file on rank 0. The default filepath here is "./config.json".

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(MPIController), intent(inout) :: mpiCont

    MPIController object to be used by the JSONController for communication

    character(len=*), intent(in), optional :: filepath

    Non-default filepath

procedure, public :: closeFile

  • interface

    public module subroutine closeFile(this, mpiCont, saveFile, filepath)

    Closes currently open json file. If saveFile is true, saves the file being worked on before closing. The default filepath here is "./config.json".

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(MPIController), intent(inout) :: mpiCont

    MPIController object to be used by the JSONController for communication

    logical, intent(in), optional :: saveFile

    True if the file should be saved before closing

    character(len=*), intent(in), optional :: filepath

    Non-default filepath for saving

procedure, public :: setAlternativeJSONPath

  • interface

    public module subroutine setAlternativeJSONPath(this, filepath)

    Set alternative default JSON filepath

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    character(len=*), intent(in) :: filepath

procedure, public :: getAlternativeJSONPath

  • interface

    public pure module function getAlternativeJSONPath(this) result(filepath)

    Get alternative default JSON filepath

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(in) :: this

    Return Value character(len=:), allocatable

procedure, public :: loadArrayParams

  • interface

    public module subroutine loadArrayParams(this, vars)

    Load named array parameters by calling individual load routines.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedArrayContainer), intent(inout) :: vars

    Values to load

procedure, public :: loadScalarParams

  • interface

    public module subroutine loadScalarParams(this, vars)

    Load named scalar parameters by calling individual load routines.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedScalarContainer), intent(inout) :: vars

    Values to load

procedure, public :: outputArrayParamsToFile

  • interface

    public module subroutine outputArrayParamsToFile(this, vars)

    Outputs named array parameters to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedArrayContainer), intent(inout) :: vars

    Values to output

procedure, public :: outputScalarParamsToFile

  • interface

    public module subroutine outputScalarParamsToFile(this, vars)

    Outputs named scalar parameters to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedScalarContainer), intent(inout) :: vars

    Values to output

procedure, public :: loadNamedReals

  • interface

    public module subroutine loadNamedReals(this, vars)

    Load named reals from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedReal), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedInts

  • interface

    public module subroutine loadNamedInts(this, vars)

    Load named int from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedInteger), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedLogicals

  • interface

    public module subroutine loadNamedLogicals(this, vars)

    Load named logicals from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedLogical), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedStrings

  • interface

    public module subroutine loadNamedStrings(this, vars)

    Load named strings from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedString), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedRealArrays

  • interface

    public module subroutine loadNamedRealArrays(this, vars)

    Load named real arrays from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedRealArray), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedIntArrays

  • interface

    public module subroutine loadNamedIntArrays(this, vars)

    Load named int arrays from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedIntegerArray), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedLogicalArrays

  • interface

    public module subroutine loadNamedLogicalArrays(this, vars)

    Load named logical arrays from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedLogicalArray), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: loadNamedStringArrays

  • interface

    public module subroutine loadNamedStringArrays(this, vars)

    Load named string arrays from currently open json file. If a variable isn't found, the passed value is not modified.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedStringArray), intent(inout), dimension(:) :: vars

    Values to load

procedure, public :: outputNamedRealsToFile

  • interface

    public module subroutine outputNamedRealsToFile(this, vars)

    Outputs named reals to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedReal), intent(inout), dimension(:) :: vars

    Values to output

procedure, public :: outputNamedIntsToFile

  • interface

    public module subroutine outputNamedIntsToFile(this, vars)

    Outputs named ints to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedInteger), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedLogicalsToFile

  • interface

    public module subroutine outputNamedLogicalsToFile(this, vars)

    Outputs named logicals to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedLogical), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedStringsToFile

  • interface

    public module subroutine outputNamedStringsToFile(this, vars)

    Outputs named strings to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedString), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedRealArraysToFile

  • interface

    public module subroutine outputNamedRealArraysToFile(this, vars)

    Outputs named real arrays to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedRealArray), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedIntArraysToFile

  • interface

    public module subroutine outputNamedIntArraysToFile(this, vars)

    Outputs named int arrays to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedIntegerArray), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedLogicalArraysToFile

  • interface

    public module subroutine outputNamedLogicalArraysToFile(this, vars)

    Outputs named logical arrays to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedLogicalArray), intent(inout), dimension(:) :: vars

    Values ot output

procedure, public :: outputNamedStringArraysToFile

  • interface

    public module subroutine outputNamedStringArraysToFile(this, vars)

    Outputs named string arrays to json file.

    Arguments

    Type IntentOptional Attributes Name
    class(JSONController), intent(inout) :: this
    type(NamedStringArray), intent(inout), dimension(:) :: vars