The String datatype is an encapsulated pointer to a one-dimensional array of single characters. This allows one to define variable-length strings, and arrays of variable-length strings.
INTERFACE:
module m_StringUSES:
No external modules are used in the declaration section of this module. implicit none private ! exceptPUBLIC TYPES:
public :: String ! The class data structure Type String #ifdef SEQUENCE sequence #endif character(len=1),dimension(:),pointer :: c End Type StringPUBLIC MEMBER FUNCTIONS:
public :: toChar public :: char ! convert to a CHARACTER(*) public :: String_init public :: init ! set a CHARACTER(*) type to a String public :: String_clean public :: clean ! Deallocate memory occupied by a String public :: String_len public :: len ! length of a String public :: String_bcast public :: bcast ! Broadcast a String public :: String_mci ! Track memory used to store a String public :: String_mco public :: ptr_chars ! Assign a pointer to a String's ! character buffer interface char; module procedure & str2ch0_, & ch12ch0_ end interface interface toChar; module procedure & str2ch0_, & ch12ch0_ end interface interface String_init; module procedure & initc_, & initc1_, & inits_ end interface interface init; module procedure & initc_, & initc1_, & inits_ end interface interface String_clean; module procedure clean_; end interface interface clean; module procedure clean_; end interface interface String_len; module procedure len_; end interface interface len; module procedure len_; end interface interface String_bcast; module procedure bcast_; end interface interface bcast; module procedure bcast_; end interface interface String_mci; module procedure & mci0_, & mci1_, & mci2_, & mci3_ end interface interface String_mco; module procedure & mco0_, & mco1_, & mco2_, & mco3_ end interface interface ptr_chars; module procedure & ptr_chars_ end interfaceREVISION HISTORY:
22Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This function returns the contents of the character buffer of the input String argument str as a CHARCTER suitable for printing.
INTERFACE:
function str2ch0_(str)USES:
No external modules are used by this function. implicit noneINPUT PARAMETERS:
type(String), intent(in) :: strOUTPUT PARAMETERS:
character(len=size(str%c,1)) :: str2ch0_REVISION HISTORY:
23Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This function takes an input one-dimensional array of single characters and returns a single character string.
INTERFACE:
function ch12ch0_(ch1)USES:
No external modules are used by this function. implicit noneINPUT PARAMETERS:
character(len=1), dimension(:), intent(in) :: ch1OUTPUT PARAMETERS:
character(len=size(ch1,1)) :: ch12ch0_REVISION HISTORY:
22Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine takes an input scalar CHARACTER argument chr, and uses it to create the output String argument str.
INTERFACE:
subroutine initc_(str, chr)USES:
use m_die, only : die,perr use m_mall,only : mall_mci,mall_ison implicit noneINPUT PARAMETERS:
character(len=*), intent(in) :: chrOUTPUT PARAMETERS:
type(String), intent(out) :: strREVISION HISTORY:
23Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine takes an input CHARACTER(:) argument chr, and uses it to create the output String argument str.
INTERFACE:
subroutine initc1_(str, chr)USES:
use m_die, only : die,perr use m_mall,only : mall_mci,mall_ison implicit noneINPUT PARAMETERS:
character, dimension(:), intent(in) :: chrOUTPUT PARAMETERS:
type(String), intent(out) :: strREVISION HISTORY:
2Aug02 - J. Larson <[email protected]> - initial prototype
This routine takes an input String argument iStr and creates an output String argument oStr. In other words, it copies iStr to oStr.
INTERFACE:
subroutine inits_(oStr, iStr)USES:
use m_die, only : die use m_mall,only : mall_mci,mall_ison implicit noneINPUT PARAMETERS:
type(String), intent(in) :: iStrOUTPUT PARAMETERS:
type(String), intent(out) :: oStrREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
This routine deallocates memory associated with the input/output String argument str. This amounts to deallocating str%c.
INTERFACE:
subroutine clean_(str)USES:
use m_die, only : die,perr use m_mall,only : mall_mco,mall_ison implicit noneINPUT/OUTPUT PARAMETERS:
type(String), intent(inout) :: strREVISION HISTORY:
23Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine performs an MPI broadcast of the input/output String argument Str on a communicator associated with the Fortran integer handle comm. The broadcast originates from the process with rank given by root on comm. The String argument Str is on entry valid only on the root process, and is valid on exit on all processes on the communicator comm. The success (failure) is signified by a zero (non-zero) value of the optional INTEGER output argument stat.
INTERFACE:
subroutine bcast_(Str, root, comm, stat)USES:
use m_mpif90 use m_die, only : perr,die use m_mall,only : mall_mci,mall_ison implicit noneINPUT PARAMETERS:
integer, intent(in) :: root integer, intent(in) :: commINPUT/OUTPUT PARAMETERS:
type(String), intent(inout) :: Str ! (IN) on the root, ! (OUT) elsewhereOUTPUT PARAMETERS:
integer, optional, intent(out) :: statREVISION HISTORY:
27Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
INTERFACE:
subroutine mci0_(marg,thread)USES:
use m_mall, only : mall_ci implicit noneINPUT PARAMETERS:
type(String), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mco0_(marg,thread)USES:
use m_mall, only : mall_co implicit none type(String), intent(in) :: marg character(len=*),intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mci1_(marg,thread)USES:
use m_mall, only : mall_ci implicit noneINPUT PARAMETERS:
type(String), dimension(:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mco1_(marg,thread)USES:
use m_mall, only : mall_co implicit noneINPUT PARAMETERS:
type(String), dimension(:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mci2_(marg, thread)USES:
use m_mall, only : mall_ci implicit noneINPUT PARAMETERS:
type(String), dimension(:,:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mco2_(marg,thread)USES:
use m_mall, only : mall_co implicit noneINPUT PARAMETERS:
type(String), dimension(:,:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mci3_(marg,thread)USES:
use m_mall, only : mall_ci implicit noneINPUT PARAMETERS:
type(String), dimension(:,:,:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
subroutine mco3_(marg,thread)USES:
use m_mall, only : mall_co implicit noneINPUT PARAMETERS:
type(String), dimension(:,:,:), intent(in) :: marg character(len=*), intent(in) :: threadREVISION HISTORY:
07Feb00 - Jing Guo <[email protected]> - initial prototype/prolog/code
INTERFACE:
integer function len_(str)USES:
No external modules are used by this function. implicit noneINPUT PARAMETERS:
type(String),intent(in) :: strREVISION HISTORY:
10Apr00 - Jing Guo <[email protected]> - initial prototype/prolog/code
This pointer-valued function provides a direct interface to the character buffer in the input String argument str. That is, ptr_chars_ => str%c.
INTERFACE:
function ptr_chars_(str)USES:
No external modules are used by this function. implicit noneINPUT PARAMETERS:
type(String), intent(in) :: strOUTPUT PARAMETERS:
character(len=1), dimension(:), pointer :: ptr_chars_REVISION HISTORY:
10Apr00 - Jing Guo <[email protected]> - initial prototype/prolog/code