Skip to content

Commit

Permalink
Added const qualifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Jan 28, 2024
1 parent c56ddcf commit 3b6afb4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 63 deletions.
8 changes: 4 additions & 4 deletions src/atm2grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ int main(

/* Allocate... */
ALLOC(atm, atm_t, 1);

/* Check arguments... */
if (argc < 3)
ERRMSG("Give parameters: <ctl> <atm_in>");

/* Read control parameters... */
read_ctl(argv[1], argc, argv, &ctl);

/* Read atmospheric data... */
if (!read_atm(argv[2], &ctl, atm))
ERRMSG("Cannot open file!");

/* Set output filename... */
char filename[3 * LEN];
int year, mon, day, hour, min;
Expand All @@ -68,6 +68,6 @@ int main(

/* Free... */
free(atm);

return EXIT_SUCCESS;
}
50 changes: 17 additions & 33 deletions src/libtrac.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2013-2023 Forschungszentrum Juelich GmbH
Copyright (C) 2013-2024 Forschungszentrum Juelich GmbH
*/

/*!
Expand All @@ -26,21 +26,6 @@

/*****************************************************************************/

double buoyancy_frequency(
const double p0,
const double t0,
const double p1,
const double t1) {

double theta0 = THETA(p0, t0);
double theta1 = THETA(p1, t1);
double dz = RI / MA / G0 * 0.5 * (t0 + t1) * (log(p0) - log(p1));

return sqrt(2. * G0 / (theta0 + theta1) * (theta1 - theta0) / dz);
}

/*****************************************************************************/

void cart2geo(
const double *x,
double *z,
Expand Down Expand Up @@ -1563,7 +1548,7 @@ void level_definitions(

ctl->met_np = 138;

double press[138] = {
const double press[138] = {
0.0200, 0.0310, 0.0467, 0.0683, 0.0975, 0.1361, 0.1861, 0.2499,
0.3299, 0.4288, 0.5496, 0.6952, 0.8690, 1.0742, 1.3143, 1.5928, 1.9134,
2.2797, 2.6954, 3.1642, 3.6898, 4.2759, 4.9262, 5.6441, 6.4334, 7.2974,
Expand Down Expand Up @@ -1592,7 +1577,7 @@ void level_definitions(

ctl->met_np = 92;

double press[92] = {
const double press[92] = {
0.0200, 0.0398, 0.0739, 0.1291, 0.2141, 0.3395, 0.5175, 0.7617,
1.0872, 1.5099, 2.0464, 2.7136, 3.5282, 4.5069, 5.6652, 7.0181,
8.5795, 10.3617, 12.3759, 14.6316, 17.1371, 19.8987, 22.9216, 26.2090,
Expand All @@ -1616,7 +1601,7 @@ void level_definitions(

ctl->met_np = 60;

double press[60] = {
const double press[60] = {
0.01, 0.1361, 0.2499, 0.4288, 0.6952, 1.0742,
2.2797, 3.1642, 4.2759, 7.2974, 9.2634, 11.5685, 14.2377, 20.761,
24.6577, 33.8174, 39.1149, 51.199, 57.9834, 73.1187, 81.6182,
Expand All @@ -1634,7 +1619,7 @@ void level_definitions(

ctl->met_np = 147;

double press[147] = {
const double press[147] = {
0.0200, 0.0310, 0.0467, 0.0683, 0.0975, 0.1361, 0.1861, 0.2499,
0.3299, 0.4288, 0.5496, 0.6952, 0.8690, 1.0742, 1.3143, 1.5928, 1.9134,
2.2797, 2.6954, 3.1642, 3.6898, 4.2759, 4.9262, 5.6441, 6.4334, 7.2974,
Expand Down Expand Up @@ -1665,7 +1650,7 @@ void level_definitions(

ctl->met_np = 101;

double press[101] = {
const double press[101] = {
0.0200, 0.0398, 0.0739, 0.1291, 0.2141, 0.3395, 0.5175, 0.7617,
1.0872, 1.5099, 2.0464, 2.7136, 3.5282, 4.5069, 5.6652, 7.0181,
8.5795, 10.3617, 12.3759, 14.6316, 17.1371, 19.8987, 22.9216, 26.2090,
Expand All @@ -1691,7 +1676,7 @@ void level_definitions(

ctl->met_np = 62;

double press[62] = {
const double press[62] = {
0.01, 0.1361, 0.2499, 0.4288, 0.6952, 1.0742,
2.2797, 3.1642, 4.2759, 7.2974, 9.2634, 11.5685, 14.2377, 20.761,
24.6577, 33.8174, 39.1149, 51.199, 57.9834, 73.1187, 81.6182,
Expand Down Expand Up @@ -2106,7 +2091,7 @@ void read_clim(
/*****************************************************************************/

void read_clim_photo(
char *filename,
const char *filename,
clim_photo_t * photo) {

int ncid, varid, ip, is, io;
Expand Down Expand Up @@ -2194,7 +2179,7 @@ void read_clim_photo(
/*****************************************************************************/

int read_clim_ts(
char *filename,
const char *filename,
clim_ts_t * ts) {

/* Write info... */
Expand Down Expand Up @@ -2248,7 +2233,7 @@ int read_clim_ts(
/*****************************************************************************/

void read_clim_zm(
char *filename,
const char *filename,
char *varname,
clim_zm_t * zm) {

Expand Down Expand Up @@ -3137,7 +3122,7 @@ void read_kernel(
/*****************************************************************************/

int read_met(
char *filename,
const char *filename,
ctl_t * ctl,
clim_t * clim,
met_t * met) {
Expand Down Expand Up @@ -3887,7 +3872,7 @@ void read_met_geopot(
/*****************************************************************************/

void read_met_grid(
char *filename,
const char *filename,
int ncid,
ctl_t * ctl,
met_t * met) {
Expand Down Expand Up @@ -5254,7 +5239,7 @@ void read_met_tropo(
/*****************************************************************************/

void read_obs(
char *filename,
const char *filename,
double *rt,
double *rz,
double *rlon,
Expand Down Expand Up @@ -6066,7 +6051,6 @@ void write_atm_clams(

}


/*****************************************************************************/

void write_atm_nc(
Expand Down Expand Up @@ -6664,9 +6648,7 @@ void write_grid_asc(
double dz,
int *np) {

FILE *in, *out;

char line[LEN];
FILE *out;

/* Check if gnuplot output is requested... */
if (ctl->grid_gpfile[0] != '-') {
Expand All @@ -6686,6 +6668,8 @@ void write_grid_asc(
year, mon, day, hour, min);

/* Dump gnuplot file to pipe... */
FILE *in;
char line[LEN];
if (!(in = fopen(ctl->grid_gpfile, "r")))
ERRMSG("Cannot open file!");
while (fgets(line, LEN, in))
Expand Down Expand Up @@ -6878,7 +6862,7 @@ void write_grid_nc(
/*****************************************************************************/

int write_met(
char *filename,
const char *filename,
ctl_t * ctl,
met_t * met) {

Expand Down
23 changes: 8 additions & 15 deletions src/libtrac.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2013-2023 Forschungszentrum Juelich GmbH
Copyright (C) 2013-2024 Forschungszentrum Juelich GmbH
*/

/*!
Expand Down Expand Up @@ -1983,13 +1983,6 @@ typedef struct {
Functions...
------------------------------------------------------------ */

/*! Calculate buoyancy frequency. */
double buoyancy_frequency(
const double p0,
const double t0,
const double p1,
const double t1);

/*! Convert Cartesian coordinates to geolocation. */
void cart2geo(
const double *x,
Expand Down Expand Up @@ -2402,18 +2395,18 @@ void read_clim(

/*! Read climatological time series. */
int read_clim_ts(
char *filename,
const char *filename,
clim_ts_t * ts);

/*! Read climatological zonal means. */
void read_clim_zm(
char *filename,
const char *filename,
char *varname,
clim_zm_t * zm);

/*! Read climatological photolysis rates. */
void read_clim_photo(
char *filename,
const char *filename,
clim_photo_t * photo);

/*! Read control parameters. */
Expand All @@ -2432,7 +2425,7 @@ void read_kernel(

/*! Read meteo data file. */
int read_met(
char *filename,
const char *filename,
ctl_t * ctl,
clim_t * clim,
met_t * met);
Expand Down Expand Up @@ -2478,7 +2471,7 @@ void read_met_geopot(

/*! Read coordinates of meteo data. */
void read_met_grid(
char *filename,
const char *filename,
int ncid,
ctl_t * ctl,
met_t * met);
Expand Down Expand Up @@ -2556,7 +2549,7 @@ void read_met_tropo(

/*! Read observation data. */
void read_obs(
char *filename,
const char *filename,
double *rt,
double *rz,
double *rlon,
Expand Down Expand Up @@ -2739,7 +2732,7 @@ void write_grid_nc(

/*! Read meteo data file. */
int write_met(
char *filename,
const char *filename,
ctl_t * ctl,
met_t * met);

Expand Down
22 changes: 11 additions & 11 deletions src/trac.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2013-2023 Forschungszentrum Juelich GmbH
Copyright (C) 2013-2024 Forschungszentrum Juelich GmbH
*/

/*!
Expand Down Expand Up @@ -177,9 +177,9 @@ void module_mixing_help(
ctl_t * ctl,
clim_t * clim,
atm_t * atm,
int *ixs,
int *iys,
int *izs,
const int *ixs,
const int *iys,
const int *izs,
int qnt_idx);

/*! Calculate grid data for chemistry modules. */
Expand Down Expand Up @@ -263,8 +263,8 @@ void module_sort(
/*! Helper function for sorting module. */
void module_sort_help(
double *a,
int *p,
int np);
const int *p,
const int np);

/*! Calculate time steps. */
void module_timesteps(
Expand Down Expand Up @@ -1984,9 +1984,9 @@ void module_mixing_help(
ctl_t * ctl,
clim_t * clim,
atm_t * atm,
int *ixs,
int *iys,
int *izs,
const int *ixs,
const int *iys,
const int *izs,
int qnt_idx) {

double *cmean;
Expand Down Expand Up @@ -2329,8 +2329,8 @@ void module_sort(

void module_sort_help(
double *a,
int *p,
int np) {
const int *p,
const int np) {

/* Allocate... */
double *restrict const help =
Expand Down

0 comments on commit 3b6afb4

Please sign in to comment.