Search

Fortran Code Repository

Welcome to Lahey's Fortran Code Repository. This is a new area on our website where users can share Fortran code and programming techniques. Through collaboration with customers we're implementing the code repository with the following in mind:

  • Code will be reviewed by our staff before it is posted.
  • Lahey reserves the right to modify code with the intent of improving and will recommend changes for clarity, speed, or other reasons.
  • Code in the repository can be viewed by anyone visiting the website. All donations become public domain.
  • Comments sent to Lahey will be forwarded to the author.
  • Documentation should be in comments as a header.
  • Scripts and instructions for building and testing programs should be provided with submissions. Please download and use GetDateTimeStr.zip as an example of what to submit.
  • If a submission is a revision of an existing example, please note this in the e-mail message.

Submit code by attaching it to an e-mail addressed to support at lahey dot com.


Code
Click on a link below to download code. Send comments to support at lahey dot com.

pb268.zip - A library that looks like CalComp (CALL PLOT, CALL SYMBOL, etc.) but which writes a .BMP file

Ziggurat.zip - Marsaglia & Tsang generator for random normals & random exponentials

GetDateTimeStr.zip - Returns a 15-character string with the current date and time. Month is text, avoiding confusion with European, American and Japanese styles of writing dates.
Posted 8/26/02

CLRKB.F90 - Clear keyboard input buffer of any keystrokes (console mode).
Comments: Clears the keyboard buffer. Useful for cases where you want to make sure there is nothing in the buffer before you start to check for keystrokes. Test code is included at top of same file. Must be compiled with "-ml winapi"
Posted 8/27/02

ESCAPE.F90 - Return true value if Escape key has been pressed in console mode.
Comments: Checks to see if the escape key was pressed. If it was, the input buffer is flushed, and the function returns true. If not the keyboard buffer is left intact. Test code is included at top of same file. Must be compiled with "-ml winapi"
Posted 8/27/02

GETEXDIR.F90 - Return the directory from which the current module was executed.
Comments: Test code is included at top of same file. Must be compiled with "-ml winapi"
Posted 8/27/02

VALIDDIR.F90 - Test a field as a valid directory name, but not a file ID.
Comments: Test code is included at top of same file. Must be compiled with "-ml winapi"
Posted 8/27/02

FINDFID.F90 - Find a file in the current directory or on the search path.
Comments: Finds a file in the current directory or on the current path. Requires linking with VALIDDIR and GETEXDIR. Test code is included at top of same file. Must be compiled with "-ml winapi"
Posted 8/27/02

CHI-SQUARED.zip - Calculates Chi-squared functions and distributions.
Comments: Requires use of SSL2 library. Documentation in English and Hungarian.
Posted 8/28/02

CONWIN.zip - Routines to facilitate use of both menu and console windows in a Fortran program.
Comments: These routines all use various Windows API functions. Compile with LF95 switch: -ml bc or with switch: -ml winapi
Posted 9/19/02

CNC.zip - This zip file contains multiple subroutines and test programs to solve ordinary differential equations using continuous numerical continuation. In addition there are several binary utilities that provide useful date and calendar information.
Comments: This code used Chebyshev approximation as a corrector to solve ODEs. The predictor is multiple steps of the single-step Runge-Kutta-Gill method.
Posted 9/24/02

PRINTWIN.zip - This zip file contains a collection of routines used to contol printing via the Windows API. These routines provide facilities for obtaining a list of available printers, opening one, and sending output to it. This is an update of the original post which uses a slightly different call to API function EnumPrinters when run under Windows NT/2000/XP.  This addresses the issue of printers attached to remote servers not being reported by the earlier version of Printwin under NT/2000/XP.
Comments: To compile with LF95 v5.7 add -ml winapi and winspool.lib to the command line.
Posted 10/7/03

TESTINFNAN.zip - This zip file contains a collection of routines used to test for values of infinity and NaN (Not a Number).
Comments: See comments in infnan.f90 for more detail.
Posted 7/22/04

ISO_FORTRAN_ENV.f90 - This source file contains a non-intrinsic ISO_FORTRAN_ENV module (in source form) from the Fortran 2003 standard (page 360).
Posted 10/6/04

hl.c - Provides a command-line option to colorize the messages numbers produced by LF95. Uses ANSI standard (VT-100) escape sequences.
Comments: Build with gcc. Use with "lf95 source.f90 2>&1| hl"
Posted 10/6/04

fpp.zip - Provides source for a command-line conditional compilation preprocessor application.
Posted 12/2/04


Where to find other code

Matrix Market
National HPCC Software Exchange
Netlib Repository
Fortran Software from Alan Miller