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:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
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
1 | 3 | 5 | 7 | 9 |
2 | 4 | 6 | 8 | 10 |
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-1 | 1 |
row-2 | 2 |
row-3 | 3 |
row-4 | 4 |
row-5 | 5 |
row-6 | 6 |
row-7 | 7 |
row-8 | 8 |
row-9 | 9 |
row-10 | 10 |
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-1 | col-2 | col-3 | col-4 | col-5 | col-6 | col-7 | col-8 | col-9 | col-10 | |
---|---|---|---|---|---|---|---|---|---|---|
Row heading | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
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 heading | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
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-1 | col-2 | col-3 | col-4 | |
---|---|---|---|---|
row-1 | 0.32706 | 0.66536 | 0.84993 | 0.11635 |
row-2 | 0.57136 | 0.53878 | 0.87319 | 7.87399E-02 |
row-3 | 0.85594 | 0.28422 | 0.46758 | 0.47219 |