Skip to content

Commit

Permalink
Modified function definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Jun 22, 2022
1 parent ac842f6 commit bd25932
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 37 deletions.
21 changes: 10 additions & 11 deletions src/libtrac.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ double clim_hno3(
/*****************************************************************************/

double clim_oh(
clim_t * clim,
double t,
double lat,
double p,
clim_t * clim) {
double p) {

/* Get seconds since begin of year... */
double sec = FMOD(t, 365.25 * 86400.);
Expand Down Expand Up @@ -406,13 +406,13 @@ double clim_oh(

double clim_oh_diurnal(
ctl_t * ctl,
clim_t * clim,
double t,
double p,
double lon,
double lat,
clim_t * clim) {
double lat) {

double oh = clim_oh(t, lat, p, clim), sza2 = sza(t, lon, lat);
double oh = clim_oh(clim, t, lat, p), sza2 = sza(t, lon, lat);

if (sza2 <= M_PI / 2. * 89. / 90.)
return oh * exp(-ctl->oh_chem_beta / cos(sza2));
Expand All @@ -423,9 +423,8 @@ double clim_oh_diurnal(
/*****************************************************************************/

void clim_oh_init(
char *filename,
clim_t * clim,
ctl_t * ctl) {
ctl_t * ctl,
clim_t * clim) {

int ncid, dimid, varid;

Expand All @@ -434,10 +433,10 @@ void clim_oh_init(
double *help;

/* Write info... */
LOG(1, "Read OH data: %s", filename);
LOG(1, "Read OH data: %s", ctl->clim_oh_filename);

/* Open netCDF file... */
if (nc_open(filename, NC_NOWRITE, &ncid) != NC_NOERR) {
if (nc_open(ctl->clim_oh_filename, NC_NOWRITE, &ncid) != NC_NOERR) {
WARN("OH climatology data is missing!");
return;
}
Expand Down Expand Up @@ -1892,7 +1891,7 @@ void read_clim(
SELECT_TIMER("READ_CLIM", "INPUT", NVTX_READ);

/* Read OH climatology... */
clim_oh_init(ctl->clim_oh_filename, clim, ctl);
clim_oh_init(ctl, clim);

}

Expand Down
13 changes: 6 additions & 7 deletions src/libtrac.h
Original file line number Diff line number Diff line change
Expand Up @@ -1367,28 +1367,27 @@ double clim_hno3(
#pragma acc routine (clim_oh)
#endif
double clim_oh(
clim_t * clim,
double t,
double lat,
double p,
clim_t * clim);
double p);

/*! Climatology of OH number concentrations with diurnal variation. */
#ifdef _OPENACC
#pragma acc routine (clim_oh_diurnal)
#endif
double clim_oh_diurnal(
ctl_t * ctl,
clim_t * clim,
double t,
double p,
double lon,
double lat,
clim_t * clim);
double lat);

/*! Initialization function for OH climatology. */
void clim_oh_init(
char *filename,
clim_t * clim,
ctl_t * ctl);
ctl_t * ctl,
clim_t * clim);

/*! Apply diurnal correction to OH climatology. */
double clim_oh_init_help(
Expand Down
2 changes: 1 addition & 1 deletion src/met_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int main(
tnatm[ix][iy] +=
nat_temperature(p0, h2o, clim_hno3(met->time, lats[iy], p0));
ohm[ix][iy] +=
clim_oh_diurnal(&ctl, met->time, p0, lons[ix], lats[iy], clim);
clim_oh_diurnal(&ctl, clim, met->time, p0, lons[ix], lats[iy]);
rhm[ix][iy] += RH(p0, t, h2o);
rhicem[ix][iy] += RHICE(p0, t, h2o);
tdewm[ix][iy] += TDEW(p0, h2o);
Expand Down
2 changes: 1 addition & 1 deletion src/met_prof.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int main(
nat_temperature(plev[iz], h2o,
clim_hno3(met->time, lat, plev[iz]));
ohm[iz] +=
clim_oh_diurnal(&ctl, met->time, plev[iz], lon, lat, clim);
clim_oh_diurnal(&ctl, clim, met->time, plev[iz], lon, lat);
np[iz]++;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/met_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ int main(
atm->p[ip])), clim_hno3(atm->time[ip],
atm->lat[ip],
atm->p[ip]),
clim_oh_diurnal(&ctl, atm->time[ip], atm->p[ip], atm->lon[ip],
atm->lat[ip], clim)
, pbl);
clim_oh_diurnal(&ctl, clim, atm->time[ip], atm->p[ip],
atm->lon[ip], atm->lat[ip]), pbl);
}

/* Close file... */
Expand Down
4 changes: 2 additions & 2 deletions src/met_zm.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ int main(
nat_temperature(plev[iz], h2o,
clim_hno3(met->time, lats[iy], plev[iz]));
ohm[iz][iy] +=
clim_oh_diurnal(&ctl, met->time, plev[iz], met->lon[ix],
lats[iy], clim);
clim_oh_diurnal(&ctl, clim, met->time, plev[iz], met->lon[ix],
lats[iy]);
np[iz][iy]++;
}
}
Expand Down
25 changes: 13 additions & 12 deletions src/trac.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ void module_isosurf(
/*! Interpolate meteo data for air parcel positions. */
void module_meteo(
ctl_t * ctl,
clim_t * clim,
met_t * met0,
met_t * met1,
atm_t * atm,
clim_t * clim);
atm_t * atm);

/*! Calculate OH chemistry. */
void module_oh_chem(
ctl_t * ctl,
clim_t * clim,
met_t * met0,
met_t * met1,
atm_t * atm,
clim_t * clim,
double *dt);

/*! Check position of air parcels. */
Expand Down Expand Up @@ -379,15 +379,15 @@ int main(
/* Interpolate meteo data... */
if (ctl.met_dt_out > 0
&& (ctl.met_dt_out < ctl.dt_mod || fmod(t, ctl.met_dt_out) == 0))
module_meteo(&ctl, met0, met1, atm, clim);
module_meteo(&ctl, clim, met0, met1, atm);

/* Decay of particle mass... */
if (ctl.tdec_trop > 0 && ctl.tdec_strat > 0)
module_decay(&ctl, atm, dt);

/* OH chemistry... */
if (ctl.oh_chem_reaction != 0)
module_oh_chem(&ctl, met0, met1, atm, clim, dt);
module_oh_chem(&ctl, clim, met0, met1, atm, dt);

/* Dry deposition... */
if (ctl.dry_depo[0] > 0)
Expand Down Expand Up @@ -1065,10 +1065,10 @@ void module_isosurf(

void module_meteo(
ctl_t * ctl,
clim_t * clim,
met_t * met0,
met_t * met1,
atm_t * atm,
clim_t * clim) {
atm_t * atm) {

/* Set timer... */
SELECT_TIMER("MODULE_METEO", "PHYSICS", NVTX_GPU);
Expand Down Expand Up @@ -1125,8 +1125,8 @@ void module_meteo(
SET_ATM(qnt_cin, cin);
SET_ATM(qnt_hno3, clim_hno3(atm->time[ip], atm->lat[ip], atm->p[ip]));
SET_ATM(qnt_oh,
clim_oh_diurnal(ctl, atm->time[ip], atm->p[ip], atm->lon[ip],
atm->lat[ip], clim));
clim_oh_diurnal(ctl, clim, atm->time[ip], atm->p[ip],
atm->lon[ip], atm->lat[ip]));
SET_ATM(qnt_vh, sqrt(u * u + v * v));
SET_ATM(qnt_vz, -1e3 * H0 / atm->p[ip] * w);
SET_ATM(qnt_psat, PSAT(t));
Expand Down Expand Up @@ -1155,10 +1155,10 @@ void module_meteo(

void module_oh_chem(
ctl_t * ctl,
clim_t * clim,
met_t * met0,
met_t * met1,
atm_t * atm,
clim_t * clim,
double *dt) {

/* Set timer... */
Expand Down Expand Up @@ -1210,8 +1210,9 @@ void module_oh_chem(

/* Calculate exponential decay... */
double rate_coef =
k * clim_oh_diurnal(ctl, atm->time[ip], atm->p[ip], atm->lon[ip],
atm->lat[ip], clim);
k * clim_oh_diurnal(ctl, clim, atm->time[ip], atm->p[ip],
atm->lon[ip],
atm->lat[ip]);
double aux = exp(-dt[ip] * rate_coef);
if (ctl->qnt_m >= 0)
atm->q[ctl->qnt_m][ip] *= aux;
Expand Down

0 comments on commit bd25932

Please sign in to comment.