# Environment variables or global definitions in input files?

**URL:** <https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501>\
**Category:** ASPECT\
**Created:** [March 31, 2026, 2:20pm UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501 "2026-03-31T14:20:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxrudolph](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/maxrudolph/32/248_2.png) [@maxrudolph](https://community.geodynamics.org/u/maxrudolph)\
**Post date:** [March 31, 2026, 2:20pm UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501/1 "2026-03-31T14:20:44Z")

</div>

I’m wondering - is there a way to include environment variables in ASPECT input files? I could imagine this being useful in a couple of ways - first, on TACC systems, users-specific $SCRATCH and $WORK directories are defined. Second, it is often useful to have global definitions like $R for planet radius that appear many times within function expressions in input files.

Thanks!

Max

---

<div class="post-metadata">

**Author:** ![tiannh7](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/tiannh7/32/2467_2.png) [@tiannh7](https://community.geodynamics.org/u/tiannh7)\
**Post date:** [March 31, 2026, 3:35pm UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501/2 "2026-03-31T15:35:22Z")

</div>

Hi @maxrudolph,

I’ve wondered about this too.

As far as I know, ASPECT does not currently support general environment-variable expansion in input files. `$ASPECT_SOURCE_DIR` is a special case, but variables like `$SCRATCH` or `$WORK` are not automatically expanded in `.prm` files.

For function expressions, muparser supports `Function constants`, for example:

```prm
set Function constants = R=6371e3

```

but these are only local to a single function subsection. So R can be reused within that subsection, but not defined once globally and shared across multiple parts of the input file.

One possible idea might be to add a global constants mechanism at the .prm level, for example something like

```prm
subsection Global constants
  set Constants = R=6371e3, eta0=1e21
end

```

or perhaps a simpler form such as

```prm
set Global constants = R=6371e3, eta0=1e21, DATA=$SCRATCH/my_case

```

That could help with both repeated physical constants and machine-specific paths.

A global variable or macro mechanism for .prm files would be very useful.

Best,  
Ninghui

---

<div class="post-metadata">

**Author:** ![bangerth](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/bangerth/32/52_2.png) [@bangerth](https://community.geodynamics.org/u/bangerth)\
**Post date:** [March 31, 2026, 3:57pm UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501/3 "2026-03-31T15:57:26Z")

</div>

@maxrudolph Interesting idea. That wouldn’t be too difficult to implement. My suggestion is to use the syntax `$ENV{VAR}` to query an environment variable `VAR` – this syntax is already used in other languages.

The right place to implement this would be in `main.cc`, at the bottom of the `read_parameter_file()` function.

Best  
W.

---

<div class="post-metadata">

**Author:** ![maxrudolph](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/maxrudolph/32/248_2.png) [@maxrudolph](https://community.geodynamics.org/u/maxrudolph)\
**Post date:** [March 31, 2026, 5:48pm UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501/4 "2026-03-31T17:48:04Z")

</div>

Thanks! I will take a look at this and see if the implementation would be straightforward.

---

<div class="post-metadata">

**Author:** ![optimux](https://avatars.discourse-cdn.com/v4/letter/o/f14d63/32.png) [@optimux](https://community.geodynamics.org/u/optimux)\
**Post date:** [April 1, 2026, 2:00am UTC](https://community.geodynamics.org/t/environment-variables-or-global-definitions-in-input-files/4501/5 "2026-04-01T02:00:27Z")

</div>

Perhaps list them where `set Dimension, set End time` etc live? Setting global constants sometimes avoid inconsistent parameters, which may hide bugs. 👍

Cheers,  
MM
