urbanjost / M_display

An fpm(1) package for displaying small matrices based on dispmodule(3f)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Name

M_display(3f) - a Fortran 95 module for pretty-printing matrices (LICENSE:FREE)

Description

A standard Fortran 95 module for printing scalars, vectors, and matrices to external files is provided. The module can display variables of default kind of all intrinsic types (integer, real, complex, logical, and character), and add-on modules are provided for data of the nondefault kind. The main module is self-contained and incorporating it only requires that it be compiled and linked with a program containing a “use M_display” statement. A generic interface and optional parameters are used, so that the same subroutine name, DISP, is used to display items of different data type and rank, irrespective of display options. The subroutine is quite versatile, and hopefully can improve Fortran's competitiveness against other array programming languages. The module also contains a function TOSTRING to convert numerical scalars and vectors to strings.

Sample

A simple example ...

   program demo_disp_get
   use M_display, only : disp, disp_set
   implicit none
   real :: x(2,3), y(3,2)
      ! create some simple matrices 
      x(1,:)=[ 1.0, 6.0, 5.0  ]
      x(2,:)=[ 2.4, 4.0, 6.0  ]
   
      y(1,:)=[ 0.0, 3.5  ]
      y(2,:)=[ 2.0, 7.0  ]
      y(3,:)=[ 4.0, 8.22 ]

      ! print the arrays in row-column order   
      call disp('y=',y)
      print *
      ! set a few default preferences
      call disp_set(digmax=4, sep=',')
      call disp('x=',x)
   end program demo_disp_get

Expected output

   y=0.00000  3.50000
     2.00000  7.00000
     4.00000  8.22000
    
   x=1.000,6.000,5.000
     2.400,4.000,6.000

Building the Module Using make(1) gmake

 git clone https://github.com/urbanjost/M_display.git
 cd M_display/src
 # change Makefile if not using one of the listed compilers
 
 # for gfortran
 make clean
 make F90=gfortran gfortran
 
 # for ifort
 make clean
 make F90=ifort ifort

 # for nvfortran
 make clean
 make F90=nvfortran nvfortran

This will compile the Fortran module and basic example program that exercise the routine. -->

Build and Test with FPM -

Download the github repository and build it with fpm ( as described at Fortran Package Manager )

     git clone https://github.com/urbanjost/M_display.git
     cd M_display
     fpm run "*"
     fpm run --example "*"
     fpm test

or just list it as a dependency in your fpm.toml project file.

        [dependencies]
        M_display        = { git = "https://github.com/urbanjost/M_display.git" }

Documentation docs

User

Note in this version the module "dispmodule" has been named "M_display" ...

Developer


Pedigree

Copyright (c) 2008, Kristján Jónasson, Dept. of Computer Science, University of Iceland (jonasson@hi.is). This software is free. For details see the file LICENSE.

References -

   ACM Journals: ACM Transactions on Mathematical Software Vol. 36, No. 1 
   Article No.:  6pp 1–7https://doi.org/10.1145/1486525.1486531
   Author:       Kristjan Jonasson
   Published:    16 March 2009

Additional References sited by the author

  • Chambers, J. M. 2007. Software for Data Analysis: Programming with R. Springer-Verlag, New York, NY. Google ScholarDigital Library
  • Eaton, J. W. 2002. GNU Octave Manual. Network Theory Limited, Bristol, U.K.Google Scholar
  • ISO/IEC. 1997. Information technology—programming languages—Fortran-part 1: Base language. ISO/IEC Tech. rep. 1539-1:1997. ISO, Geneva, Switzerland.Google Scholar

About

An fpm(1) package for displaying small matrices based on dispmodule(3f)

License:Other


Languages

Language:Fortran 99.3%Language:Makefile 0.7%