json_controller_class Module

Contains json-fortran routines for reading/writing config files


Used by


Interfaces

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Derived Types

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
procedure, public :: closeFile
procedure, public :: setAlternativeJSONPath
procedure, public :: getAlternativeJSONPath
procedure, public :: loadArrayParams
procedure, public :: loadScalarParams
procedure, public :: outputArrayParamsToFile
procedure, public :: outputScalarParamsToFile
generic, public :: load => loadNamedIntArrays, loadNamedInts, loadNamedLogicals, loadNamedLogicalArrays, loadNamedRealArrays, loadNamedReals, loadNamedStringArrays, loadNamedStrings, loadArrayParams, loadScalarParams
generic, public :: output => outputNamedIntArraysToFile, outputNamedIntsToFile, outputNamedLogicalsToFile, outputNamedLogicalArraysToFile, outputNamedRealArraysToFile, outputNamedRealsToFile, outputNamedStringArraysToFile, outputNamedStringsToFile, outputArrayParamsToFile, outputScalarParamsToFile
procedure, public :: loadNamedReals
procedure, public :: loadNamedInts
procedure, public :: loadNamedLogicals
procedure, public :: loadNamedStrings
procedure, public :: loadNamedRealArrays
procedure, public :: loadNamedIntArrays
procedure, public :: loadNamedLogicalArrays
procedure, public :: loadNamedStringArrays
procedure, public :: outputNamedRealsToFile
procedure, public :: outputNamedIntsToFile
procedure, public :: outputNamedLogicalsToFile
procedure, public :: outputNamedStringsToFile
procedure, public :: outputNamedRealArraysToFile
procedure, public :: outputNamedIntArraysToFile
procedure, public :: outputNamedLogicalArraysToFile
procedure, public :: outputNamedStringArraysToFile