Skip to content

Conversation

@rem1776
Copy link
Contributor

@rem1776 rem1776 commented Nov 21, 2025

Description

  • Refactors create_xgrid_2dx2d_order1 into smaller functions (to be eventually reused in the other variants)
  • Removes any wrapper functions with an underscore and instead just redefines them with the preprocessor so they can be used in Fortran
  • Changes any unnecessary pointer arguments (ie. nlons/nlats that are defined as int*) to scalars
  • Renames the xgrid files and moves the C code from the include to the horiz_interp directory (in hindsight im not sure if this was necessary..)

How Has This Been Tested?
gcc 14 on amd

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@rem1776 rem1776 requested review from mlee03 and removed request for bensonr and vithikashah001 November 21, 2025 22:33
@rem1776 rem1776 marked this pull request as draft November 21, 2025 22:34
@mlee03
Copy link
Contributor

mlee03 commented Nov 24, 2025

is this the same one as in fmsgridtools repo?

return the grid area.
*******************************************************************************/
void get_grid_area_(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area)
void get_grid_area_(const int nlon, const int nlat, const double *lon, const double *lat, double *area)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the pass in by value work when fortran calls function_?


nx = *nlon;
ny = *nlat;
nx = nlon;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's going to be a pain to fix, but nx and ny are not needed anymore

double *x=NULL, *y=NULL, *z=NULL;

nl = *npts;
nl = npts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise, n1 is not needed

nx = *nlon;
ny = *nlat;
nx = nlon;
ny = nlat;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nx, ny here too, not needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and for all the following functions :)

return (product<=SMALL) ? 1:0;

} /* inside_edge */

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra lines

&istart2, &iend2, &pstart, &pnxgrid, nx_output_cells, ny_output_cells);

// allocate the rest of the arrays used
lon_out_min_list = (double *)malloc(nx_output_cells*ny_output_cells*sizeof(double));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be a pain to put this malloc section into compute_output_cell_ bounds?

int nx_input_cells, int ny_input_cells, int nx_input_points,
const double *input_grid_lon, const double *input_grid_lat,
const double *skip_input_cells,
int nx_output_cells,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put int nx_output_cells with the rest of the ints in the front?

return nxgrid;

}/* get_xgrid_2Dx2D_order1 */
};/* get_xgrid_2Dx2D_order1 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the semicolon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think C functions definitions don't need the semicolon at the end, just when your declaring them in a header file.

for(m=0; m<nblocks; m++) {
for(i=0; i<pnxgrid[m]; i++) {
nn = pstart[m] + i;
for(curr_thread=0; curr_thread<nthreads; curr_thread++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, is there a way to remove the if statement and replace it with a #if defined(_OPENMP)?

}

/* compute per-output-cell min/max/avg and store vertex lists */
void compute_output_cell_bounds(const int nx_output_cells, const int ny_output_cells,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the block_setup and comput_output_cell_bounds will also replace sections of create_xgrid_2dx2d_order2?

@mlee03 mlee03 moved this from Backlog to In review in first release Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants