Contents

This file replicates the test case from:

https://ccmc.gsfc.nasa.gov/pub/modelweb/atmospheric/ msis/nrlmsise00/nrlmsis00_c_version/nrlmsise-00_test.c

It also runs a test case for 0 to 2000 km.

%--------------------------------------------------------------------------
%   Copyright (c) 2021 Princeton Satellite Systems, Inc.
%   All rights reserved.
%--------------------------------------------------------------------------
%   Since 2021.1
%--------------------------------------------------------------------------

for i = 1:8
	aph.a(i)=100;
end

z     = zeros(1,24);
flags = struct('switches',z,'sw',z,'swc',z);

flags.switches(1) = 0;

for i = 2:24
	flags.switches(i)=1;
end

input(17) = struct('year',0,'doy',0,'sec',0,'alt',0,'lst',0,'g_lat',0,'g_long',0,...
  'f107A',0,'f107',0,'ap',0,'ap_a',aph);

for i = 1:17
  input(i).doy=172;
	input(i).year=0;
	input(i).sec=29000;
	input(i).alt=400;
	input(i).g_lat=60;
	input(i).g_long=-70;
	input(i).lst=16;
	input(i).f107A=150;
	input(i).f107=150;
	input(i).ap=4;
  input(i).ap_a = aph;
end

input(1).alt = 0;
input(2).doy=81;
input(3).sec=75000;
input(3).alt=1000;
input(4).alt=100;
input(11).alt=0;
input(12).alt=10;
input(13).alt=30;
input(14).alt=50;
input(15).alt=70;
input(17).alt=100;
input(5).g_lat=0;
input(6).g_long=0;
input(7).lst=4;
input(8).f107A=70;
input(9).f107=180;
input(10).ap=40;
input(16).ap_a=aph;
input(17).ap_a=aph;

output(17) = struct('d',[],'t',[]);

flags.switches(10)=1;
for i = 1:15
	output(i) = AtmNRLMSISE( 'gtd7', [], input(i), flags );
end

flags.switches(10)=-1;
for i=16:17
  output(i) = AtmNRLMSISE( 'gtd7', [], input(i), flags );
end

% output type 1 */
for i = 1:17
	for j = 1:9
    fprintf("%E ",output(i).d(j));
  end
	fprintf("%E ",output(i).t(1));
	fprintf("%E \n",output(i).t(2));
end

% output type 2
for i=0:2
  fprintf("\n");
  fprintf("\nDAY   ");
  for j=1:5
    fprintf("         %3i",input(i*5+j).doy);
  end
	fprintf("\nUT    ");
	for j=1:5
    fprintf("       %5.0f",input(i*5+j).sec);
  end
	fprintf("\nALT   ");
	for j=1:5
    fprintf("        %4.0f",input(i*5+j).alt);
  end
	fprintf("\nLAT   ");
	for j=1:5
    fprintf("         %3.0f",input(i*5+j).g_lat);
  end
	fprintf("\nLONG  ");
	for j=1:5
    fprintf("         %3.0f",input(i*5+j).g_long);
  end
	fprintf("\nLST   ");
	for j=1:5
    fprintf("       %5.0f",input(i*5+j).lst);
  end
	fprintf("\nF107A ");
	for j=1:5
    fprintf("         %3.0f",input(i*5+j).f107A);
  end
  fprintf("\nF107  ");
  for j=1:5
    fprintf("         %3.0f",input(i*5+j).f107);
  end
	fprintf("\n\n");
	fprintf("\nTINF  ");
	for j=1:5
    fprintf("     %7.2f",output(i*5+j).t(1));
  end
	fprintf("\nTG    ");
	for j=1:5
    fprintf("     %7.2f",output(i*5+j).t(2));
  end
	fprintf("\nHE    ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(1));
  end
	fprintf("\nO     ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(2));
  end
	fprintf("\nN2    ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(3));
  end
	fprintf("\nO2    ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(4));
  end
	fprintf("\nAR    ");
  for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(5));
  end
	fprintf("\nH     ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(7));
  end
	fprintf("\nN     ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(8));
  end
	fprintf("\nANM 0 ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(9));
  end
	fprintf("\nRHO   ");
	for j=1:5
    fprintf("   %1.3e",output(i*5+j).d(6));
  end
	fprintf("\n");
end
fprintf("\n");
1.375488E+14 0.000000E+00 2.049687E+19 5.498695E+18 2.451733E+17 1.261066E-03 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.814648E+02 
3.407293E+06 1.586333E+08 1.391117E+07 3.262560E+05 1.559618E+03 5.001846E-15 4.854208E+04 4.380967E+06 6.956682E+03 1.166754E+03 1.161710E+03 
1.123767E+05 6.934130E+04 4.247105E+01 1.322750E-01 2.618848E-05 2.756772E-18 2.016750E+04 5.741256E+03 2.374394E+04 1.239892E+03 1.239891E+03 
5.411554E+07 1.918893E+11 6.115826E+12 1.225201E+12 6.023212E+10 3.584426E-10 1.059880E+07 2.615737E+05 2.819879E-42 1.027318E+03 2.068878E+02 
1.851122E+06 1.476555E+08 1.579356E+07 2.633795E+05 1.588781E+03 4.809630E-15 5.816167E+04 5.478984E+06 1.264446E+03 1.212396E+03 1.208135E+03 
8.673095E+05 1.278862E+08 1.822577E+07 2.922214E+05 2.402962E+03 4.355866E-15 3.686389E+04 3.897276E+06 2.667273E+04 1.220146E+03 1.212712E+03 
5.776251E+05 6.979139E+07 1.236814E+07 2.492868E+05 1.405739E+03 2.470651E-15 5.291986E+04 1.069814E+06 2.667273E+04 1.116385E+03 1.112999E+03 
4.727986E+05 5.414973E+07 6.571644E+06 2.296209E+05 7.703397E+02 1.802068E-15 7.918308E+04 1.845167E+06 9.121815E+03 1.087612E+03 1.077431E+03 
6.573214E+05 1.233173E+08 2.307373E+07 4.761402E+05 4.402166E+03 4.492839E-15 2.951213E+04 4.951172E+06 2.667273E+04 1.296482E+03 1.284488E+03 
4.659332E+05 1.047125E+08 3.844218E+07 1.090704E+06 1.161407E+04 4.720430E-15 2.566401E+04 3.899608E+06 1.972139E+04 1.387517E+03 1.371314E+03 
1.375488E+14 0.000000E+00 2.049687E+19 5.498695E+18 2.451733E+17 1.261066E-03 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.814648E+02 
4.427443E+13 0.000000E+00 6.597567E+18 1.769929E+18 7.891680E+16 4.059139E-04 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.274180E+02 
2.127829E+12 0.000000E+00 3.170791E+17 8.506280E+16 3.792741E+15 1.950822E-05 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.374389E+02 
1.412184E+11 0.000000E+00 2.104370E+16 5.645392E+15 2.517142E+14 1.294709E-06 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.795551E+02 
1.254884E+10 0.000000E+00 1.874533E+15 4.923051E+14 2.239685E+13 1.147668E-07 0.000000E+00 0.000000E+00 0.000000E+00 1.027318E+03 2.190732E+02 
5.196477E+05 1.274494E+08 4.850450E+07 1.720838E+06 2.354487E+04 5.881940E-15 2.500078E+04 6.279210E+06 2.667273E+04 1.426412E+03 1.408608E+03 
4.260860E+07 1.241342E+11 4.929562E+12 1.048407E+12 4.993465E+10 2.914304E-10 8.831229E+06 2.252516E+05 2.415246E-42 1.027318E+03 1.934071E+02 


DAY            172          81         172         172         172
UT           29000       29000       75000       29000       29000
ALT              0         400        1000         100         400
LAT             60          60          60          60           0
LONG           -70         -70         -70         -70         -70
LST             16          16          16          16          16
F107A          150         150         150         150         150
F107           150         150         150         150         150


TINF       1027.32     1166.75     1239.89     1027.32     1212.40
TG          281.46     1161.71     1239.89      206.89     1208.14
HE       1.375e+14   3.407e+06   1.124e+05   5.412e+07   1.851e+06
O        0.000e+00   1.586e+08   6.934e+04   1.919e+11   1.477e+08
N2       2.050e+19   1.391e+07   4.247e+01   6.116e+12   1.579e+07
O2       5.499e+18   3.263e+05   1.323e-01   1.225e+12   2.634e+05
AR       2.452e+17   1.560e+03   2.619e-05   6.023e+10   1.589e+03
H        0.000e+00   4.854e+04   2.017e+04   1.060e+07   5.816e+04
N        0.000e+00   4.381e+06   5.741e+03   2.616e+05   5.479e+06
ANM 0    0.000e+00   6.957e+03   2.374e+04   2.820e-42   1.264e+03
RHO      1.261e-03   5.002e-15   2.757e-18   3.584e-10   4.810e-15


DAY            172         172         172         172         172
UT           29000       29000       29000       29000       29000
ALT            400         400         400         400         400
LAT             60          60          60          60          60
LONG             0         -70         -70         -70         -70
LST             16           4          16          16          16
F107A          150         150          70         150         150
F107           150         150         150         180         150


TINF       1220.15     1116.39     1087.61     1296.48     1387.52
TG         1212.71     1113.00     1077.43     1284.49     1371.31
HE       8.673e+05   5.776e+05   4.728e+05   6.573e+05   4.659e+05
O        1.279e+08   6.979e+07   5.415e+07   1.233e+08   1.047e+08
N2       1.823e+07   1.237e+07   6.572e+06   2.307e+07   3.844e+07
O2       2.922e+05   2.493e+05   2.296e+05   4.761e+05   1.091e+06
AR       2.403e+03   1.406e+03   7.703e+02   4.402e+03   1.161e+04
H        3.686e+04   5.292e+04   7.918e+04   2.951e+04   2.566e+04
N        3.897e+06   1.070e+06   1.845e+06   4.951e+06   3.900e+06
ANM 0    2.667e+04   2.667e+04   9.122e+03   2.667e+04   1.972e+04
RHO      4.356e-15   2.471e-15   1.802e-15   4.493e-15   4.720e-15


DAY            172         172         172         172         172
UT           29000       29000       29000       29000       29000
ALT              0          10          30          50          70
LAT             60          60          60          60          60
LONG           -70         -70         -70         -70         -70
LST             16          16          16          16          16
F107A          150         150         150         150         150
F107           150         150         150         150         150


TINF       1027.32     1027.32     1027.32     1027.32     1027.32
TG          281.46      227.42      237.44      279.56      219.07
HE       1.375e+14   4.427e+13   2.128e+12   1.412e+11   1.255e+10
O        0.000e+00   0.000e+00   0.000e+00   0.000e+00   0.000e+00
N2       2.050e+19   6.598e+18   3.171e+17   2.104e+16   1.875e+15
O2       5.499e+18   1.770e+18   8.506e+16   5.645e+15   4.923e+14
AR       2.452e+17   7.892e+16   3.793e+15   2.517e+14   2.240e+13
H        0.000e+00   0.000e+00   0.000e+00   0.000e+00   0.000e+00
N        0.000e+00   0.000e+00   0.000e+00   0.000e+00   0.000e+00
ANM 0    0.000e+00   0.000e+00   0.000e+00   0.000e+00   0.000e+00
RHO      1.261e-03   4.059e-04   1.951e-05   1.295e-06   1.148e-07

Altitude test

flags.switches(10)=1; % Does not use daily ap

alt = linspace(0,2000);
rho = zeros(1,length(alt));
input(1).ap_a = aph;
for k = 1:length(alt)
  input(1).alt = alt(k);
  flags.switches(1) = 0;
	output = AtmNRLMSISE( 'gtd7', [], input(1), flags );
  rho(k) = output.d(6);
end

Plot2D(alt,rho,'Altitude (km)','\rho (gm/cm^3)','Atmosphere','ylog')

%--------------------------------------