I have been writing an adaptive mesh refinement (amr) code. As a prototype for the code, I have been looking at an adaptive mesh refinement code written by my adviser (written in c). I find looking at their code to be useful, but the code also does things like make heavy use of global variables, and I am wondering if there are potentially better ways of implementing Berger and Oliger syle amr.

Could someone point me to some source code for a simple (say one dimensional) amr code for hyperbolic pde? I'd like to compare and contrast with what my adviser wrote (which is not publicly available so I unfortunately cannot link to it here). I have been looking at the websites of other amr codes (e.g. chombo) but I haven't found a simple example implementation of the basic Berger and Oliger algorithm.

EDIT: while there is now an "accepted" answer (a link to Berger's website which includes good documentation), that code is mostly written in Fortran; I would certainly appreciate links to example amr codes with documentation written in other languages (e.g. c++)!

Another EDIT: Perhaps this a bit shameless but I finally wrote my own simple amr code (in c), which you can find here. I'd still appreciate more links to other AMR codes that have relatively simple apis and good documentation (I should say my code meets neither of those criteria...)

  • 1
    $\begingroup$ I can pretty much say with certainty that no code needs global variables. So the answer should be yes, there are better ways of implementing the software. I don’t know if and when you’ll find a good example code, but in the meantime you can work on laying out the sort of objects you need to represent, the operations that will be performed on and by them, what the data will be you’re working with.. and with this, you should be able to come up with a design that avoids global variables. $\endgroup$
    – spektr
    Commented Jul 31, 2019 at 13:59

2 Answers 2


Marsha has made quite a bit of her source code available over the years. Some of it is no longer supported, but given that she is the Berger in Berger and Oliger, checking her website and the clawpack website (which also has her code and given that its a collaboration between her, Randy and others), seems like a good start.


  • $\begingroup$ This is very useful, although the amr code is mostly in Fortran and also uses some older constructs like gotos (e.g. the code example given in cs.nyu.edu/berger/amrsoftware.html) $\endgroup$ Commented Aug 2, 2019 at 1:26

Newer versions of Clawpack and AMRClaw/GeoClaw do include some 1D versions but I am not sure that's going to be entirely helpful. Donna Calhoun has a page that attempts to list some well-used codes that you might find interesting.

Also sorry for not getting to post this earlier.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.