Fortran/C/Pascal

            At one time all computers came with Basic ready for programming.  This is no longer the case.  I recommend using any system that is native to your computer, but I usually install Watfor and Watcom.  These and other possible codes are described in SoftWare.html

General codes – editors, html’s and such

Word Processing.mht for simple word processing and thoughts about editors and IDE’s

WirthsLaw.htm – From Scientific American – code get slower faster than machines get faster.

batfiles.htm  – the setup’ that I use and recommend for making a PC user tolerant.  This file also contains details about setting the path to and setting the options for /watfor

Drive letter.htm – changing the drive letter in windows xp.

Wsystem.doc .htm details about Watfor.

ROOM1213.mht – this room is no longer used for this, but there are some hints about using a public machine.  Includes Doskey.

command line input.doc -- .htm

../integration/Tcheby.htm#Gauss_Legendre_points

bfind.htm – a search routine in C

 

A few linux/unix commands  

LSUnix.doc  .htm

Automatic compilation of only the files needed make

Timing Etime

Simple codes

Command line.htm Sample subroutine using the standard command line input – Watcom specific

Format.txt  - details about formatting in both C and Fortran

..\Homework\Assignment 1.htm shows the hello code in Watfor.

FortvsC.htm gives details about Fortran and C and some sample codes.

                read_comma – a fix to the annoying problem that entering 1,5 causes C to crash.

FandC2.htm  gives the hello code and a slightly more complex one in C

GINPUT.htm  Talks about general input

Read_Direct.mht C code for reading indexing and writing binary files.

 

Fortran Rules and sample codes

Watcom Fortran Help.htm

STRINGRW\String read-write.mht

      for\RTOC.FOR  A code that uses a string write to convert a real to a string.

XMLRR XMLRR\Welcome.htm Code for reading and replacing data in an XML file.

Fortran specifics

Open.txt

Passing function names as arguments in Fortran.htm

Maopen.htm details about the general open file that Bob usually uses in Watfor.

unformatted\Binary files.htm – making a binary file from an unformatted file.

Wsystem.doc#Scratch_files – a bit of nonsense needed for Watfor to use scratch files.

 

C rules and sample codes 

Watcom C Help.htm

 

The gnu C compiler, gcc, is included with the usual releases of linux. The dos version is available on the web from http://www.delorie.com/djgpp/zip-picker.html.  Probably best to start at http://www.delorie.com/djgpp/. I t is also included on a CD-ROM in [Stephen R. Davis, C++ WEEKEND CRASH COURSE, IDG Books Worldwide (2000) http://www.idgbooks.com.

 

The emacs editor.htm is a short summary of the emacs commands. 

test.c is demonstrates scanf, fscanf, file opens and the conversion of the file zeff.out to a c function.

                To read a character from the input file, it is necessary to clean it of left over line feeds from previous reads.  The following works.

#include <stdio.h>

void main()

  {char ans;

   fflush(stdin);

   scanf(“%c”,&ans);

   return;  }

 

Passing function names as arguments in C.htm

PANDA.mht pointers and addresses  Also Fortran cals C and v.v.

static_variables – allows them to remain as set on subsequent calls to the same subroutine.

calloc.htm Allows dynamic allocation of memory.

      bfind.htm – a search routine in C.  The code cpp\bfind.c is a practical example of using C to issue a system command and then to look inside files for various patterns.  It is analogous to the windows search command, which is a bit deficient in my copy of Windows XP.

                An input/output example for which C is superior to Fortran is described in Read_Direct.mht.

Complex.htm – Ansi C does not contain complex numbers.  This file links to a Cpp code that runs both in Watcom and Borland.

Mixing Fortran and C

                This is “easy” in UNIX and LINUX, but considered to be very difficult in DOS and Windows.  This has changed with the introduction of openwatcom. See Mixing Fortran and C with Watcom.htm.  Arrays are a bit of a problem Arrays.doc.  For unix/linux see Mixing FORTRAN and C.htm  panda3.html. 

A simple Watcom test code is contained in fsleep/Sleep test.htm.

Sorting – random numbers – locate

                sorting\Sorting.htm

Dll’s

                Dll’s are stand alone subroutines that can be compiled separately for use with main codes.  A search for .dll on your computer will yield a very impressive list.  The dll is called by the main code or operating system, does its job and then returns.  It may have no I/O overhead and does not need to include most of what the system does.  Thus in principle an upgrade to the system would need to only modify a few dll’s and these could be transmitted to it without the need to transmit the entire system.  This should make code development and system upgrades much faster.  These uses for dll’s almost all involve main codes and dll’s in the same language usually C.  It is rare for a dll written in one language to be used with a main code written in another language.

                It is, however, possible to write a dll in one computer language to work with a code written in another language.  My principle interest in this is due to the fact that in nlfit (..\Fittery\nlfit\Welcome.htm) the only code that needs to change is the very short poly routine that calculates the approximating function fA(c,xi) and its first derivatives with respect to cJ.  The hope was thst a user could compile a poly dll  with a compiler and language of his choice and use it with a downloadable executable of nlfit.  My attempts and partial successes with this are in dll dll/Welcome.htm.  An older(10-11-2007) set of work is in dll.zip.