Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d71b76e
update files from main_forAPL
Sep 11, 2026
8ad9e78
Merge branch 'develop' into tmp
abukowski21 Oct 2, 2026
e125dbd
FIX: Do not normalize aurora to HP unconditionally
abukowski21 Oct 2, 2026
62c16a4
FIX: Change limits to IMF/SW values to filter bad OMNI data but allow…
abukowski21 Oct 2, 2026
f6d7675
STY: optimize AE -> HP scaling calc
abukowski21 Oct 2, 2026
12d530e
STY: Fprettify, yo
abukowski21 Oct 2, 2026
f4eb405
BUG: calc_chemistry.Earth was missing an I on a chemicalHeatingSubI term
abukowski21 Oct 6, 2026
31861d3
BUG: Calculate iVelocityPar when restarting
abukowski21 Oct 7, 2026
f15030e
BUG: UseSecondsInFileName was ignored in set_inputs.f90
abukowski21 Oct 7, 2026
31602e3
FIX: Initialize CO2 vibration since its a major species
abukowski21 Oct 7, 2026
fb25aee
FIX: calc_{rates,collisions} in calc_electrodynamics + clean up array…
abukowski21 Oct 7, 2026
76e179d
FIX: Typos!
abukowski21 Oct 7, 2026
50eac33
BUG: fix HaveSomeAurora & AllowAurWithoutDiffuse logic
abukowski21 Oct 7, 2026
aa318a8
FEAT: Add F107 -> B107 conversion
abukowski21 Oct 7, 2026
bc6c3c1
FIX: another typo, missed the CO2 cooling full removal
abukowski21 Oct 7, 2026
9e1d0e5
FEAT: Allow the altitude of IE stuff to be changed
abukowski21 Oct 7, 2026
1773909
FEAT: Leave loudly if (nBlocksMax /= 1) on Earth
abukowski21 Oct 7, 2026
a191eb6
FIX: protect against wave aurora with avgE > max energy in aurora
abukowski21 Oct 7, 2026
3677a1a
FIX: Read in optional dynamo options correctly
abukowski21 Oct 7, 2026
20b1ad6
STY: Fprettify, yo
abukowski21 Oct 7, 2026
47ebac7
FIX: Remove grid info from restart headers
abukowski21 Oct 7, 2026
b21de66
FIX: Remove chapman_integral() from output(), changed EUV terms
abukowski21 Oct 7, 2026
abd4704
FIX: Update gitm_makerun.py auroral stuff
abukowski21 Oct 7, 2026
751de8f
FEAT: Makefile.conf for ifx (intel OneAPI compilers)
abukowski21 Oct 7, 2026
e803989
FIX: Move planet-specific inputs out of ModInputs
abukowski21 Oct 7, 2026
e4f00f9
FIX: Revert 9e1d0e, IE altitude re-mapping, for just the dynamo
abukowski21 Oct 8, 2026
a7bafdb
DOC: Denote default values + make sure set_inputs.{f90,md} are in sync
abukowski21 Oct 14, 2026
819782e
TEST: DiffNum.py prints lines + update run_all_tests.sh outputs
abukowski21 Oct 14, 2026
ebd2024
DOC: update stale links, incorrect info, etc. across all docs
abukowski21 Oct 14, 2026
7fea3f7
MAINT: Remove unused variables from Chemistry
abukowski21 Oct 14, 2026
a322c3c
FIX: correct energies in ChemicalHeating terms
abukowski21 Oct 14, 2026
bf05f05
TEST: Update reference solutions (MSIS21 is default)
abukowski21 Oct 15, 2026
ca3125b
Merge branch 'tmp' into bugs/restarts_etc
abukowski21 Oct 15, 2026
d608c88
FIX: Initialize Eclipse{Start,End}Time variables
abukowski21 Oct 15, 2026
e20e769
BUG: remove AuroralHeating from 3DHME output
abukowski21 Oct 15, 2026
76f2df0
FIX: Add He auroral ionization rate to 3DTHM output
abukowski21 Oct 15, 2026
c5c0ff7
DOC: Update docs with changes to outputs
abukowski21 Oct 15, 2026
bf57d89
TEST: Update reference solutions
abukowski21 Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is the home of the Global Ionosphere/Thermosphere Model (GITM).
[![DOI](https://zenodo.org/badge/468565917.svg)](https://doi.org/10.5281/zenodo.7509933)

GITM has been developed in fortran-90. It has been tested with gfortran
on Linux and MacOS as well as ifort on NASA's Pleiades computer.
on Linux and MacOS as well as ifort/ifx on HPC systems.

For the complete documentation, see [GITM's Read the Docs Page](https://gitm.readthedocs.io).

Expand All @@ -14,7 +14,7 @@ GITM's stable version is the main branch, which is downloaded by default. If yo
## Quick Start

> GITM needs MPI to work properly. This can be installed with your system's package manager, or loaded as a `module` on an HPC system.
> See [the installation guide](https://gitm.readthedocs.io/en/latest/quick_start/#requirements) for more information.
> See [the installation guide](https://gitm.readthedocs.io/en/latest/install/#requirements) for more information.

1\. Clone the repository and cd into the repo folder

Expand Down Expand Up @@ -71,6 +71,9 @@ And you can use the below line below to configure the code:
./Config.pl -install -earth -compiler=ifort
```

If you are using the newer `ifx` compiler (with the `mpiifx` wrapper), use
`-compiler=ifx` instead. See the installation guide for more options.

4\. Make the binary:

```shell
Expand Down Expand Up @@ -158,7 +161,7 @@ python setup.py develop --user
```shell
cd <directory where you started from>
cd GITM/run/UA/data
../../../srcPython/run_plot_model_results.py -var=34 -alt=300 3DALL_t021221_000500.bin
../../../srcPython/aetherpy/run_plot_model_results.py -var=34 -alt=300 3DALL_t021221_000500.bin
```

(look at the beautiful plot)
Expand Down Expand Up @@ -218,5 +221,5 @@ processors, so you can adjust `src/ModSize.f90` to have 18 cells in lat and
lon, then ask for 2 (lat) x 4 (lon) blocks to get 5 deg x 5 deg resolution.

See the
[grid page](https://gitm.readthedocs.io/en/latest/grid/#horizontal-resolution)
[grid page](https://gitm.readthedocs.io/en/latest/internals/grid/#horizontal-resolution)
in the documentation for more details and some examples.
143 changes: 106 additions & 37 deletions share/Scripts/DiffNum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import numpy as np
import argparse, sys
import datetime
import difflib
from itertools import zip_longest

## DEFAULTS
RELTOL = 1e-6
ATOL = 1e-3
TIMETOL = 0.25 # seconds
START_STRING = "#START"
NROWS = 5 # rows printed at the head and at the tail


def parse_args():
Expand Down Expand Up @@ -39,6 +41,13 @@ def parse_args():
action="store_true",
help="report every column, not just failures",
)
parser.add_argument(
"-n",
"--rows",
type=int,
default=NROWS,
help=f"rows to print at head and tail, 0 for all (default {NROWS})",
)
# Accepted for compatibility with DiffNum.pl call sites; no text channel here.
parser.add_argument(
"-b", "--blank", "--ignore-blanks", action="store_true", help=argparse.SUPPRESS
Expand Down Expand Up @@ -131,26 +140,69 @@ def read_file(fname, headerText=START_STRING, parse_datetimes=True):
return outData


def assess_diffs(name, arr1, arr2, times=None, reltol=RELTOL, atol=ATOL):
"""
returns a string with info about how/where two arrays differ
"""
def read_header(fname, headerText=START_STRING):
"""Return the lines above the data block (the echoed inputs)"""
header = []
with open(fname, "r") as file:
for line in file:
if headerText in line:
break
header.append(line.rstrip())
return header

# Boolean array of compliant values
equal_ma = np.isclose(arr1, arr2, rtol=reltol, atol=atol, equal_nan=False)
nDifferent = len(equal_ma) - np.count_nonzero(equal_ma)
firstDifferent = int(np.argmin(equal_ma))

msg = f">>> {name}: ({nDifferent} / {len(equal_ma)}) values differ, first at "
def pick_rows(first, nTotal, n):
"""Head (from the first difference, or the top if it is near) and tail"""
if n <= 0:
return list(range(nTotal))
top = 0 if first < n else first
head = list(range(top, min(top + n, nTotal)))
tail = list(range(max(nTotal - n, head[-1] + 1), nTotal))
return head + tail

if times is not None:
msg += f"+{(times[firstDifferent] - times[0]).total_seconds():g} s, or "
msg += f"index {firstDifferent}"

return msg
def value_table(names, log1, log2, bad, rows, times=None):
"""One line per (column, file), one field per printed row.

Time runs across the page, so any number of failing columns fits;
a gap in the printed rows shows up as a '...' field.
"""
def num(v):
# the logs write %.3f; keep that, unless it would hide the value
if v == 0 or 1e-3 <= abs(v) < 1e6:
return f"{v:.3f}"
return f"{v:.4e}"

# Field list: a row index, or None for a gap
fields = []
for i in rows:
if fields and i != fields[-1] + 1:
fields.append(None)
fields.append(i)

steps = log1.get("iStep", np.arange(len(log1[names[0]])))
cells = {(k, f): [num(log[k][i]) if i is not None else "..." for i in fields]
for k in names for f, log in (("ref", log1), ("test", log2))}
tops = [str(steps[i]) if i is not None else "..." for i in fields]
hms = [times[i].strftime("%H:%M:%S") if times is not None and i is not None
else "" for i in fields]
w = max(len(c) for v in list(cells.values()) + [tops, hms] for c in v) + 1
lw = max(len(k) for k in names + ["iStep"]) + 1

def line(label, tag, vals):
return f"{label:<{lw}}{tag:<5}" + "".join(f"{v:>{w}}" for v in vals)

out = [line("iStep", "", tops)]
if times is not None:
out.append(line("", "", hms))
for k in names:
out.append("")
out.append(line(k, "ref", cells[(k, "ref")]))
out.append(line(f"({np.count_nonzero(bad[k])})", "test", cells[(k, "test")]))
return "\n".join(out)

def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False):

def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False, nRows=NROWS):

# Run every check, then fail at the end if any did not pass
errors = []
Expand All @@ -166,7 +218,7 @@ def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False):
if only1 or only2:
w = max(len(k) for k in only1 + only2) + 3
s = "Unmatched column names, not compared:\n"
s += f" {'file 1':<{w}}file 2"
s += f" {'ref':<{w}}test"
for a, b in zip_longest(only1, only2, fillvalue="-"):
s += f"\n {a:<{w}}{b}"
errors.append(s)
Expand All @@ -181,7 +233,7 @@ def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False):
print("Number of lines in the two files are off by 1")
else:
errors.append(
f"\nfile 1 has {nLines1} lines, file 2 has {nLines2}")
f"\nref has {nLines1} lines, test has {nLines2}")
# Only compare over the overlap
minLines = min(nLines1, nLines2)
for log in (log1, log2):
Expand All @@ -199,35 +251,51 @@ def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False):
i = int(np.argmax(bad))
errors.append(
f"\nTimes differ: {np.count_nonzero(bad)} / {n} rows "
f"\n first at row {i}: file 1 {t1[i]} file 2 {t2[i]}")
f"\n first at row {i}: ref {t1[i]} test {t2[i]}")

# Then check the numerics, skipping any cols necessary
skip_cols = ["time"]
failed = []
for name in log1:
if name in skip_cols or name not in log2:
continue
if np.allclose(
log1[name], log2[name], rtol=reltol, atol=atol, equal_nan=False
):
if verbose:
print(f" {name}: ok")
else:
s = assess_diffs(
name, log1[name], log2[name],
times=log1.get("time"), reltol=reltol, atol=atol)
failed.append(s)
if failed:
errors.append('\n')
errors.extend(failed)
if not errors:
compared = [k for k in log1 if k not in skip_cols and k in log2]
bad = {k: ~np.isclose(log1[k], log2[k], rtol=reltol, atol=atol,
equal_nan=False) for k in compared}
failed = [k for k in compared if bad[k].any()]
if verbose:
for k in compared:
if k not in failed:
print(f" {k}: ok")
if not errors and not failed:
sys.exit(0)

# Name the files once, here, so the lines above stay short
print("\n" + "=" * 70 + f"\n file 1: {file1}\n file 2: {file2}\n" + "-" * 70)
print("Test did not pass!\n")
print("\n" + "=" * 70 + f"\n ref: {file1}\n test: {file2}\n" + "-" * 70)
print(f"Test did not pass! (rtol {reltol:g}, atol {atol:g})")
for s in errors:
print(s)

if failed:
times = log1.get("time")
nTotal = len(log1[failed[0]])
anyBad = np.any([bad[k] for k in failed], axis=0)
first = int(np.argmax(anyBad))
where = f"iStep {log1['iStep'][first]}" if "iStep" in log1 else f"row {first}"
if times is not None:
where += f" (+{(times[first] - times[0]).total_seconds():g} s)"
print(f"\n{len(failed)} of {len(compared)} columns differ, in "
f"{np.count_nonzero(anyBad)} of {nTotal} rows; first at {where}."
f"\n(n) under a name = rows that column differs in."
f" -n sets rows shown at head and tail, -n 0 all.\n")
print(value_table(failed, log1, log2, bad,
pick_rows(first, nTotal, nRows), times) + "\n")

# The echoed inputs often say why: report them, but never fail on them
h1, h2 = read_header(file1), read_header(file2)
if h1 != h2:
diff = list(difflib.unified_diff(h1, h2, "ref", "test",
n=0, lineterm=""))
print("Header (echoed inputs) also differs:")
for line in diff[2:]:
if line[0] in "-+":
print(f" {'ref only: ' if line[0] == '-' else 'test only:'} {line[1:]}")
sys.exit(1)


Expand All @@ -239,4 +307,5 @@ def main(file1, file2, reltol=RELTOL, atol=ATOL, verbose=False):
reltol=args.rtol,
atol=args.atol,
verbose=args.verbose,
nRows=args.rows,
)
88 changes: 88 additions & 0 deletions share/build/Makefile.Linux.ifx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright (C) 2002 Regents of the University of Michigan,
# portions used with permission
# For more information, see http://csem.engin.umich.edu/tools/swmf

SHELL=/bin/sh

# Fortran language related part of Makefile.conf: Makefile.Linux.ifx
#
# Space Weather Modeling Framework (SWMF)
# Intel Fortran (ifx) compiler with Intel MPI (mpiifx, Intel MPI 2021.11+).
# For older Intel MPI, set LINK.f90 to: mpiifort -fc=ifx
#

COMPILE.f77 = ${CUSTOMPATH_F}ifx
COMPILE.f90 = ${CUSTOMPATH_F}ifx
LINK.f90 = ${CUSTOMPATH_MPI}mpiifx
AR = ar -rs

SINGLEPREC =
DOUBLEPREC = -r8
PRECISION = ${DOUBLEPREC} ${MEM}

MPILIB =
#MPILIB = -L${LIBDIR} -lNOMPI

# Define where modules are stored and add it to the search path
# INCL_EXTRA can be defined to add more search directories.
SEARCH = -module ${INCLDIR} ${INCL_EXTRA}

# -fpe0 traps invalid/zero/overflow, like the gfortran debug build.
# Intel's default -fp-model fast=1 can fold x/=x style NaN tests away;
# add -fp-model precise to CFLAG if that matters for a run.
DEBUGFLAG = -check all,nouninit -g -traceback -fpe0
DEBUG =

OPT0 = -O0
OPT1 = -O1
OPT2 = -O2
OPT3 = -O3
OPT4 = -O4

CFLAG = ${SEARCH} -c -w -diag-disable remark ${DEBUG}

Cflag0 = ${CFLAG} ${PRECISION} ${OPT0}
Cflag1 = ${CFLAG} ${PRECISION} ${OPT1}
Cflag2 = ${CFLAG} ${PRECISION} ${OPT2}
Cflag3 = ${CFLAG} ${PRECISION} ${OPT3}
Cflag4 = ${CFLAG} ${PRECISION} ${OPT4}

# RCM compilation flags
# To allow RCM to compile as double precision, add PRECISION flag
CFLAGS = ${CFLAG} ${OPT2} -save

# Link flags: Lflag1 for MPI parallel code, Lflag2 for serial code
Lflag1 = ${PRECISION} ${MPILIB} ${DEBUG}
Lflag2 = ${PRECISION} ${DEBUG}

# BLAS and LAPACK libraries
LBLAS =
BLAS = lapack.o blas.o

#
# General rules
#

.SUFFIXES:
.SUFFIXES: .f90 .F90 .f .for .ftn .o

.f90.o:
${COMPILE.f90} ${Cflag3} $<

.F90.o:
${COMPILE.f90} -DsysLinux -Dcompifort ${Cflag3} $<

.f.o:
${COMPILE.f77} ${Cflag3} -132 $<

.for.o:
${COMPILE.f77} ${Cflag3} -132 $<

.ftn.o:
${COMPILE.f77} ${Cflag3} -132 $<

clean:
rm -f *~ core *.o *.mod fort.* a.out *.exe *.a *.so *.il *.protex


# keep this line
Loading
Loading