# Numerical Programming

Again, a page with just some handy tricks I found out in practice. This page mainly serves as a scrapbook for my personal use.

## Visualisation

I used to have problems with dense adaptive mesh pictures in beamer presentations, but now I found a workable solution:

Mesh graphics without moiré
## Data files

### Formatted IO

#### Long exponentials

For very big or very small numbers, i.e. where the exponent has more than two digits, FORTRAN is quite flexible in its output. It is able to drop the character `E` in the number and still understand it: '1.234E-167' is the same as '1.234-167'. I am only talking about formatted

`READ`

and

`WRITE`

here, not FORTRAN code! Read more at

http://www.qmw.ac.uk/~cgaa260/BUILDING/INTR_F90/IO/EDITDESC.HTM
My problems was: when reading FORTRAN produced data files in C (actually MATLAB), the dropped 'E' causes problems. A dirty workaround is to drop the least significant digit in the number and replace it by an 'E':

$ echo '123+12 45 .33 -.34-5 67E+5 89-167 8.00349801-289' | \
sed -e 's/\(\.[0-9]*\)[0-9]\([-+]\)\([0-9]*\)/\1E\2\3/g'
This produces:
123+12 45 .33 -.3E-5 67E+5 89-167 8.0034980E-289

Note how I only replace numbers with a decimal point (replacing `89-167`

by `8E-167`

would be wrong). This is not too difficult, but still a todo...

to top