Skip to main content

MdEncode

This module converts Fortran intrinsic types into Markdown format.

Example 1

This example shows how to use MdEncode.

PROGRAM main
USE easifemBase
IMPLICIT NONE
type(String) :: astr
integer( i4b ), allocatable :: ivec( : ), i2vec(:,:)

ivec = [1,2,3,4,5,6,7,8,9,10]
astr = MdEncode( ivec )
write( *, "(A)" ) astr%chars()
See results:
12345678910
  i2vec = reshape(  [1,2,3,4,5,6,7,8,9,10], [2,5] )
astr = MdEncode( i2vec )
CALL Display( astr, "astr" // CHAR_LF )
write( *, "(A)" ) astr%chars()
See results
13579
246810
END PROGRAM main

Example 2

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(String) :: rh(1), ch(1)
INTEGER(i4b), ALLOCATABLE :: ivec(:)

ivec = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ch(1) = "Col heading"
rh(1) = "Row heading"

CALL Display(mdencode(ivec, ch=ch, rh=rh), "")

END PROGRAM main
See results
Col heading
1
2
3
4
5
6
7
8
9
10

Example 3

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(String), ALLOCATABLE :: rh(:), ch(:)
INTEGER(i4b), ALLOCATABLE :: ivec(:)
INTEGER(I4B) :: ii

ivec = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ch = [String("Col heading")]

CALL reallocate(rh, SIZE(ivec))

DO ii = 1, SIZE(ivec)
rh(ii) = "row-"//tostring(ii)
END DO

CALL Display(mdencode(ivec, ch=ch, rh=rh), "")

END PROGRAM main
See results
Col heading
row-11
row-22
row-33
row-44
row-55
row-66
row-77
row-88
row-99
row-1010

Example 4

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(String), ALLOCATABLE :: rh(:), ch(:)
INTEGER(i4b), ALLOCATABLE :: ivec(:)
INTEGER(I4B) :: ii

ivec = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
rh = [String("Row heading")]

CALL reallocate(ch, SIZE(ivec))

DO ii = 1, SIZE(ivec)
ch(ii) = "col-"//tostring(ii)
END DO

CALL Display(mdencode(ivec, ch=ch, rh=rh), "")

END PROGRAM main
See results
col-1col-2col-3col-4col-5col-6col-7col-8col-9col-10
Row heading12345678910

Example 5

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(String), ALLOCATABLE :: rh(:), ch(:)
INTEGER(i4b), ALLOCATABLE :: ivec(:)
INTEGER(I4B) :: ii

ivec = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
rh = [String("Row heading")]
ch = [String("")]
CALL Display(mdencode(ivec, ch=ch, rh=rh), "")

END PROGRAM main
See results
Row heading12345678910

Example 6

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(String), ALLOCATABLE :: rh(:), ch(:)
REAL(DFP), ALLOCATABLE :: amat(:, :)
INTEGER(I4B) :: ii

CALL Reallocate(amat, 3, 4)
CALL RANDOM_NUMBER(amat)

CALL Reallocate(rh, SIZE(amat, 1))
CALL Reallocate(ch, SIZE(amat, 2))
DO ii = 1, SIZE(ch)
ch(ii) = "col-"//tostring(ii)
END DO

DO ii = 1, SIZE(rh)
rh(ii) = "row-"//tostring(ii)
END DO

CALL Display(mdencode(amat, ch=ch, rh=rh), "")

END PROGRAM main
See results
col-1col-2col-3col-4
row-10.327060.665360.849930.11635
row-20.571360.538780.873197.87399E-02
row-30.855940.284220.467580.47219