diff --git a/tools/cubic_utils/Makefile.am b/tools/cubic_utils/Makefile.am index e6b9af4c..eeda2c21 100644 --- a/tools/cubic_utils/Makefile.am +++ b/tools/cubic_utils/Makefile.am @@ -20,7 +20,8 @@ bin_PROGRAMS = make_remap_file AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) \ + -I$(top_srcdir)/tools/fregrid LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/cubic_utils/make_remap_file.c b/tools/cubic_utils/make_remap_file.c index a8a9b66a..5051b565 100644 --- a/tools/cubic_utils/make_remap_file.c +++ b/tools/cubic_utils/make_remap_file.c @@ -55,6 +55,7 @@ #include "mosaic_util.h" #include "tool_util.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #define EPSLN (1.e-10) #define D2R (M_PI/180) @@ -556,6 +557,3 @@ int main(int argc, char* argv[]) return 0; } /* end of main */ - - - diff --git a/tools/make_coupler_mosaic/Makefile.am b/tools/make_coupler_mosaic/Makefile.am index d766e9b9..e55a3718 100644 --- a/tools/make_coupler_mosaic/Makefile.am +++ b/tools/make_coupler_mosaic/Makefile.am @@ -23,7 +23,8 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) \ + -I$(top_srcdir)/tools/fregrid LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_coupler_mosaic_SOURCES = make_coupler_mosaic.c diff --git a/tools/make_coupler_mosaic/make_coupler_mosaic.c b/tools/make_coupler_mosaic/make_coupler_mosaic.c index 68e22e4d..083e5531 100644 --- a/tools/make_coupler_mosaic/make_coupler_mosaic.c +++ b/tools/make_coupler_mosaic/make_coupler_mosaic.c @@ -51,6 +51,7 @@ #include "mpp_domain.h" #include "mosaic_util.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #include "read_mosaic.h" #define print_grid 0 diff --git a/tools/make_hgrid/Makefile.am b/tools/make_hgrid/Makefile.am index 5ca65cea..9bce281b 100644 --- a/tools/make_hgrid/Makefile.am +++ b/tools/make_hgrid/Makefile.am @@ -24,7 +24,7 @@ endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_hgrid_SOURCES = create_conformal_cubic_grid.c \ @@ -34,7 +34,7 @@ make_hgrid_SOURCES = create_conformal_cubic_grid.c \ create_lonlat_grid.c \ make_hgrid.c make_hgrid_LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a $(LDADD) - + make_hgrid_parallel_SOURCES = $(make_hgrid_SOURCES) make_hgrid_parallel_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) make_hgrid_parallel_LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils_mpi.a $(LDADD) $(MPI_CLDFLAGS) diff --git a/tools/make_hgrid/create_lonlat_grid.c b/tools/make_hgrid/create_lonlat_grid.c index ebdec7b4..c6de4212 100644 --- a/tools/make_hgrid/create_lonlat_grid.c +++ b/tools/make_hgrid/create_lonlat_grid.c @@ -29,7 +29,7 @@ #include "constant.h" #include "create_hgrid.h" #include "create_xgrid.h" - +#include "create_xgrid_util.h" /********************************************************************************* some private routines used in this file diff --git a/tools/make_quick_mosaic/Makefile.am b/tools/make_quick_mosaic/Makefile.am index 148805cb..5f5dd756 100644 --- a/tools/make_quick_mosaic/Makefile.am +++ b/tools/make_quick_mosaic/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = make_quick_mosaic AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/make_quick_mosaic/make_quick_mosaic.c b/tools/make_quick_mosaic/make_quick_mosaic.c index 27fd1c86..b27f9aff 100644 --- a/tools/make_quick_mosaic/make_quick_mosaic.c +++ b/tools/make_quick_mosaic/make_quick_mosaic.c @@ -30,6 +30,7 @@ #include "read_mosaic.h" #include "mosaic_util.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #define AREA_RATIO_THRESH (1.e-6) #define AREA_RATIO_THRESH2 (1.e-4) diff --git a/tools/make_topog/Makefile.am b/tools/make_topog/Makefile.am index 169ebc18..b0826015 100644 --- a/tools/make_topog/Makefile.am +++ b/tools/make_topog/Makefile.am @@ -23,7 +23,7 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_topog_SOURCES = make_topog.c \ diff --git a/tools/make_topog/topog.c b/tools/make_topog/topog.c index 09f72f6d..bc388c5a 100644 --- a/tools/make_topog/topog.c +++ b/tools/make_topog/topog.c @@ -22,6 +22,7 @@ #include #include "constant.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #include "mosaic_util.h" #include "interp.h" #include "mpp_io.h" @@ -45,7 +46,7 @@ void process_topo(int nk, double *depth, int *num_levels, const double *zw, int tripolar_grid, int cyclic_x, int cyclic_y, int full_cell, int flat_bottom, int adjust_topo, int fill_isolated_cells, double min_thickness, int open_very_this_cell, double fraction_full_cell, int round_shallow, - int deepen_shallow, int fill_shallow, int dont_change_landmask, int kmt_min, + int deepen_shallow, int fill_shallow, int dont_change_landmask, int kmt_min, domain2D domain, int debug ); int kmin(int ni, int *kmt, int i, int j); double hmin(int ni, double *ht, int i, int j); @@ -79,12 +80,12 @@ void create_bowl_topog(int nx, int ny, const double *x, const double *y, double nxp = nx+1; nyp = ny+1; - + for(j=0;j= bowl_east || yy <= bowl_south || yy >= bowl_north) + yy = (y[j*nxp+i]+y[j*nxp+i+1]+y[(j+1)*nxp+i]+y[(j+1)*nxp+i+1])*0.25; + if (xx <= bowl_west || xx >= bowl_east || yy <= bowl_south || yy >= bowl_north) bottom = min_depth; else bottom = min_depth + bottom_depth*(1.0-exp(-pow((yy-bowl_south)/2.0,2))) @@ -118,7 +119,7 @@ void create_gaussian_topog(int nx, int ny, const double *x, const double *y, dou yt[j*nx+i] = (y[j*nxp+i] + y[j*nxp+i+1] + y[(j+1)*nxp+i] + y[(j+1)*nxp+i+1])*0.25; } } - + xw = xt[0]; ys = yt[0]; xe = xw; @@ -151,7 +152,7 @@ void create_gaussian_topog(int nx, int ny, const double *x, const double *y, dou free(xt); free(yt); - + }; /* create_gaussian_topog */ @@ -181,13 +182,13 @@ void create_idealized_topog( int nx, int ny, const double *x, const double *y, for(j=0;j 0.0 ) { arg = bottom_depth*(1-0.4*fabs(cos(((j+1)*M_PI)/nyp)*sin(((i+1)*2*M_PI)/nxp))); - arg = max(arg, min_depth); + arg = max(arg, min_depth); depth[j*nx+i] = arg; } } @@ -269,18 +270,18 @@ void create_idealized_topog( int nx, int ny, const double *x, const double *y, // add "idealized" ridges arg = 0.666*bottom_depth; - + set_depth (nx, ny, xbnd, ybnd, -20.0, 360.0-20.0, 360.0-10.0, 30.0, 360.0-45.0, 360.0-35.0, arg, depth); set_depth (nx, ny, xbnd, ybnd, 30.0, 360.0-45.0, 360.0-35.0, 60.0, 360.0-20.0, 360.0-30.0, arg, depth); set_depth (nx, ny, xbnd, ybnd, -60.0,360.0-100.0, 360.0-130.0, 40.0, 360.0-160.0, 180.0, arg, depth); arg = 0.5*bottom_depth; - + set_depth (nx, ny, xbnd, ybnd, -50.0, 360.0-120.0, 360.0-120.0, 30.0, 190.0, 190.0, arg, depth); free(xbnd); free(ybnd); - + } /* create_idealized_topog */ /********************************************************************* @@ -289,9 +290,9 @@ void create_idealized_topog( int nx, int ny, const double *x, const double *y, set the topography depth "depth[i][j](i,j)" = "depth_in" within the area of the trapezoid bounded by vertices: (alat1,slon1), (alat1,elon1), (alat2,slon2), and (alat2,elon2) - + inputs: - + alat1 = southern latitude of trapezoid (degrees) slon1 = starting longitude of southern edge of trapezoid (deg) elon1 = ending longitude of southern edge of trapezoid (deg) @@ -299,14 +300,14 @@ void create_idealized_topog( int nx, int ny, const double *x, const double *y, slon2 = starting longitude of northern edge of trapezoid (deg) elon2 = ending longitude of northern edge of trapezoid (deg) depth_in = constant depth value - + ********************************************************************/ void set_depth(int nx, int ny, const double *xbnd, const double *ybnd, double alat1, double slon1, double elon1, double alat2, double slon2, double elon2, double depth_in, double *depth) { double rdj, d; int i, j, i1, i2, j1, j2, is, ie, js, je, is1, ie1, is2, ie2; - + j1 = nearest_index(alat1, ybnd, ny ); j2 = nearest_index(alat2, ybnd, ny ); js = min(j1,j2); @@ -329,7 +330,7 @@ void set_depth(int nx, int ny, const double *xbnd, const double *ybnd, double al // the nudging of 1.e-5 is to insure that the test case resolution // generates the same topography and geometry on various computers. - if (js == je) + if (js == je) rdj = 1.0; else rdj = 1.0/(je-js); @@ -350,9 +351,9 @@ void set_depth(int nx, int ny, const double *xbnd, const double *ybnd, double al void create_realistic_topog( ) reading data from source data file topog_file and remap it onto current grid ********************************************************************/ -void create_realistic_topog(int nx_dst, int ny_dst, const double *x_dst, const double *y_dst, const char *vgrid_file, +void create_realistic_topog(int nx_dst, int ny_dst, const double *x_dst, const double *y_dst, const char *vgrid_file, const char* topog_file, const char* topog_field, double scale_factor, - int tripolar_grid, int cyclic_x, int cyclic_y, + int tripolar_grid, int cyclic_x, int cyclic_y, int fill_first_row, int filter_topog, int num_filter_pass, int smooth_topo_allow_deepening, int round_shallow, int fill_shallow, int deepen_shallow, int full_cell, int flat_bottom, int adjust_topo, @@ -387,7 +388,7 @@ void create_realistic_topog(int nx_dst, int ny_dst, const double *x_dst, const d for(k=0; k 0 ) { kmt[j*nip+i] = nearest_index( ht[j*nip+i], zw, nk); @@ -640,8 +641,8 @@ void process_topo(int nk, double *depth, int *num_levels, const double *zw, } free(ht); free(kmt); - - if (adjust_topo) { + + if (adjust_topo) { restrict_partial_cells(nxc, nyc, nk, zw, depth, num_levels, min_thickness, open_very_this_cell, fraction_full_cell, debug); enforce_min_depth(nxc, nyc, nk, zw, round_shallow, deepen_shallow, fill_shallow, @@ -649,9 +650,9 @@ void process_topo(int nk, double *depth, int *num_levels, const double *zw, } for(i=0; i tmp1) { - itmp = kmt[j*ni+i] - 1; + itmp = kmt[j*ni+i] - 1; tmp = zw[k-1]; if(debug)printf("restrict_partial_cells: Resetting kmt at (%d,%d) from %d to %d\n", i,j,kmt[j*ni+i],itmp); kmt[j*ni+i] = itmp; } else tmp = zw[k-1] + p_cell_min[k]; - if(debug)printf("restrict_partial_cells: Resetting depth at (%d,%d) from %g to %g\n", i,j,ht[j*ni+i],tmp); + if(debug)printf("restrict_partial_cells: Resetting depth at (%d,%d) from %g to %g\n", i,j,ht[j*ni+i],tmp); ht[j*ni+i] = tmp; n++; } @@ -932,14 +933,14 @@ void show_deepest(int nk, const double *zw, const double *depth, domain2D domain int i, isc, iec, jsc, jec, nxc, nyc, ni, nj; double deepest; double *ht; - + mpp_get_compute_domain2d( domain, &isc, &iec, &jsc, &jec); mpp_get_global_domain2d( domain, &ni, &nj); nxc = iec-isc+1; nyc = jec-jsc+1; ht = (double *)malloc(ni*nj*sizeof(double)); mpp_global_field_double(domain, nxc, nyc, depth, ht); - + if(mpp_pe() == mpp_root_pe()) { deepest = 0.0; for(i=0; i= min_depth. + ! limit the minimum value of depth, depth should be >= min_depth. ********************************************************************/ void enforce_min_depth(int nx, int ny, int nk, const double *zw, int round_shallow, int deepen_shallow, int fill_shallow, double *depth, int *kmt, int kmt_min, int debug) { int i, j, n, l, count, kmt_shallow, kmt_min_local; char errmsg[256]; - - + + if(debug) printf(" Enforcing the minimum number of ocean cells in the vertical to be %d\n", kmt_min); if(nk < kmt_min) { sprintf(errmsg, "topog: number of vertical cells=%d, is less than kmt_min=%d", nk, kmt_min); @@ -983,13 +984,13 @@ void enforce_min_depth(int nx, int ny, int nk, const double *zw, int round_shall } kmt_min_local = kmt_min-1; - + count = 0; if(round_shallow) count++; if(fill_shallow) count++; if(deepen_shallow) count++; if(count > 1) mpp_error("topog: at most one of round_shallow/deepen_shallow/fill_shallow can be set to true"); - + n = 0; for(j=0;j 0 && kmt[l] < kmt_min_local) { n = n + 1; kmt_shallow = kmt[l]; - if( round_shallow || (!deepen_shallow && !fill_shallow) ) { + if( round_shallow || (!deepen_shallow && !fill_shallow) ) { if (zw[kmt[l]] < 0.5*zw[kmt_min_local]) { if(debug) printf("Making location i,j,kmt= %d,%d,%d to land.\n",i, j, kmt[l]); depth[l] = 0.0; @@ -1022,14 +1023,14 @@ void enforce_min_depth(int nx, int ny, int nk, const double *zw, int round_shall } } } - + if(debug) { if(n>0) printf("enforce_min_depth: Modified %d shallow cells\n", n); else printf("enforce_min_depth: No modifications needed\n"); } - + }; /* enforce_min_depth */ @@ -1056,7 +1057,7 @@ void create_box_channel_topog(int nx, int ny, double basin_depth, /* east boundary */ for(j=0; jnorth - - + --->north + + *******************************************************************************/ void create_dome_topog(int nx, int ny, const double *x, const double *y, double dome_slope, double dome_bottom, double dome_embayment_west, double dome_embayment_east, @@ -1096,14 +1097,14 @@ void create_dome_topog(int nx, int ny, const double *x, const double *y, double ys = y[0]; xe = xw; yn = ys; - + for(i=0; i= yn_slope ) depth[i] = 0.0; @@ -1166,7 +1167,5 @@ void create_dome_topog(int nx, int ny, const double *x, const double *y, double y[i] >= ys_embay && y[i] <= yn_embay ) depth[i] = dome_embayment_depth; } - -} - +} diff --git a/tools/river_regrid/Makefile.am b/tools/river_regrid/Makefile.am index 2e29d1bd..6fcd6c76 100644 --- a/tools/river_regrid/Makefile.am +++ b/tools/river_regrid/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = river_regrid AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/river_regrid/river_regrid.c b/tools/river_regrid/river_regrid.c index 0b138c50..b3d8d018 100644 --- a/tools/river_regrid/river_regrid.c +++ b/tools/river_regrid/river_regrid.c @@ -26,6 +26,7 @@ #include "mpp.h" #include "mpp_io.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #include "constant.h" #include "mosaic_util.h" #include "tool_util.h" @@ -1573,6 +1574,3 @@ void qsort_index(double array[], int start, int end, int rank[]) } } } - - - diff --git a/tools/runoff_regrid/Makefile.am b/tools/runoff_regrid/Makefile.am index df9a87d7..fd18f175 100644 --- a/tools/runoff_regrid/Makefile.am +++ b/tools/runoff_regrid/Makefile.am @@ -23,7 +23,7 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) runoff_regrid_SOURCES = runoff_regrid.c diff --git a/tools/runoff_regrid/runoff_regrid.c b/tools/runoff_regrid/runoff_regrid.c index edeb7ace..ee604d5e 100644 --- a/tools/runoff_regrid/runoff_regrid.c +++ b/tools/runoff_regrid/runoff_regrid.c @@ -50,6 +50,7 @@ #include "mpp_io.h" #include "mpp_domain.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" #include "tool_util.h" #define EPSLN10 (1.e-10) @@ -761,4 +762,3 @@ void nearest(int nlon, int nlat, double *mask, const double *lon, const double * /* } */ - diff --git a/tools/transfer_to_mosaic_grid/Makefile.am b/tools/transfer_to_mosaic_grid/Makefile.am index 42d62063..e073af98 100644 --- a/tools/transfer_to_mosaic_grid/Makefile.am +++ b/tools/transfer_to_mosaic_grid/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = transfer_to_mosaic_grid AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) + $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c b/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c index c6f875d3..a03a66d1 100644 --- a/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c +++ b/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c @@ -27,6 +27,7 @@ #include "mpp_domain.h" #include "mpp_io.h" #include "create_xgrid.h" +#include "create_xgrid_util.h" char *usage[] = { "", @@ -42,7 +43,7 @@ char *usage[] = { " ", "--input_file input_file The file name of previous version grid. ", " ", - NULL}; + NULL}; const int MAXBOUNDS = 100; const int STRINGLEN = 255; @@ -52,8 +53,8 @@ const int SHORTSTRING = 32; const char mosaic_version[] = "0.2"; #define PI M_PI - -double *x, *y, *dx, *dy, *area, *angle_dx, *angle_dy; + +double *x, *y, *dx, *dy, *area, *angle_dx, *angle_dy; int nx, ny, nxp, nyp; char *old_file = NULL; @@ -79,22 +80,22 @@ int main(int argc, char* argv[]) char atmos_name[128]="atmos", land_name[128]="land", ocean_name[128]="ocean"; char agrid_file[128], lgrid_file[128], ogrid_file[128]; - int is_coupled_grid = 0, is_ocean_only =1; + int is_coupled_grid = 0, is_ocean_only =1; int interp_order=1; - + int option_index; static struct option long_options[] = { {"input_file", required_argument, NULL, 'o'}, - {"mosaic_dir", required_argument, NULL, 'd'}, + {"mosaic_dir", required_argument, NULL, 'd'}, {NULL, 0, NULL, 0} }; /* ----------------------------- */ - mpp_init(&argc, &argv); /* Initilize */ + mpp_init(&argc, &argv); /* Initilize */ /*mpp_domain_init(); */ errflg = (argc == 1); - + while ((c = getopt_long(argc, argv, "h", long_options, &option_index) ) != -1) switch (c) { case 'o': @@ -104,20 +105,20 @@ int main(int argc, char* argv[]) strcpy(mosaic_dir, optarg); break; case '?': - errflg++; + errflg++; } if(errflg || !old_file) { char **u = usage; while (*u) { fprintf(stderr, "%s\n", *u); u++; } - exit(2); + exit(2); } for(n=0; n0) { size_t start[4], nwrite[4]; - + int fid, dim_string, dim_ncells, dim_two, dims[4]; int id_xgrid_area, id_contact, n; int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist; char contact[STRING]; - + for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; } @@ -1050,7 +1051,7 @@ if(is_coupled_grid) { "contact_spec_version", version, "contact_type", "exchange", "parent1_cell", "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area"); } - + dims[0] = dim_ncells; dims[1] = dim_two; id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1"); id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2"); @@ -1067,18 +1068,18 @@ if(is_coupled_grid) { mpp_put_var_value_block(fid, id_contact, start, nwrite, contact); nwrite[0] = naxl; - atmxlnd_area = (double *)malloc(naxl*sizeof(double)); - atmxlnd_ia = (int *)malloc(naxl*sizeof(int )); - atmxlnd_ja = (int *)malloc(naxl*sizeof(int )); - atmxlnd_il = (int *)malloc(naxl*sizeof(int )); - atmxlnd_jl = (int *)malloc(naxl*sizeof(int )); + atmxlnd_area = (double *)malloc(naxl*sizeof(double)); + atmxlnd_ia = (int *)malloc(naxl*sizeof(int )); + atmxlnd_ja = (int *)malloc(naxl*sizeof(int )); + atmxlnd_il = (int *)malloc(naxl*sizeof(int )); + atmxlnd_jl = (int *)malloc(naxl*sizeof(int )); vid = mpp_get_varid(fid_old, "AREA_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_area); vid = mpp_get_varid(fid_old, "I_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ia); vid = mpp_get_varid(fid_old, "J_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ja); vid = mpp_get_varid(fid_old, "I_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_il); vid = mpp_get_varid(fid_old, "J_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_jl); - - for(i=0;i0) { size_t start[4], nwrite[4]; - + int fid, dim_string, dim_ncells, dim_two, dims[4]; int id_xgrid_area, id_contact, n; int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist; char contact[STRING]; - + for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; } @@ -1165,7 +1166,7 @@ if(is_coupled_grid) { "contact_spec_version", version, "contact_type", "exchange", "parent1_cell", "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area"); } - + dims[0] = dim_ncells; dims[1] = dim_two; id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1"); id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2"); @@ -1182,18 +1183,18 @@ if(is_coupled_grid) { mpp_put_var_value_block(fid, id_contact, start, nwrite, contact); nwrite[0] = naxo; - atmxocn_area = (double *)malloc(naxo*sizeof(double)); - atmxocn_ia = (int *)malloc(naxo*sizeof(int )); - atmxocn_ja = (int *)malloc(naxo*sizeof(int )); - atmxocn_io = (int *)malloc(naxo*sizeof(int )); - atmxocn_jo = (int *)malloc(naxo*sizeof(int )); + atmxocn_area = (double *)malloc(naxo*sizeof(double)); + atmxocn_ia = (int *)malloc(naxo*sizeof(int )); + atmxocn_ja = (int *)malloc(naxo*sizeof(int )); + atmxocn_io = (int *)malloc(naxo*sizeof(int )); + atmxocn_jo = (int *)malloc(naxo*sizeof(int )); vid = mpp_get_varid(fid_old, "AREA_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_area); vid = mpp_get_varid(fid_old, "I_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ia); vid = mpp_get_varid(fid_old, "J_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ja); vid = mpp_get_varid(fid_old, "I_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_io); vid = mpp_get_varid(fid_old, "J_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_jo); - - for(i=0;i0) { size_t start[4], nwrite[4]; - + int fid, dim_string, dim_ncells, dim_two, dims[4]; int id_xgrid_area, id_contact, n; int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist; char contact[STRING]; - + for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; } @@ -1279,7 +1280,7 @@ if(is_coupled_grid) { "contact_spec_version", version, "contact_type", "exchange", "parent1_cell", "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area"); } - + dims[0] = dim_ncells; dims[1] = dim_two; id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1"); id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2"); @@ -1296,18 +1297,18 @@ if(is_coupled_grid) { mpp_put_var_value_block(fid, id_contact, start, nwrite, contact); nwrite[0] = nlxo; - lndxocn_area = (double *)malloc(nlxo*sizeof(double)); - lndxocn_il = (int *)malloc(nlxo*sizeof(int )); - lndxocn_jl = (int *)malloc(nlxo*sizeof(int )); - lndxocn_io = (int *)malloc(nlxo*sizeof(int )); - lndxocn_jo = (int *)malloc(nlxo*sizeof(int )); + lndxocn_area = (double *)malloc(nlxo*sizeof(double)); + lndxocn_il = (int *)malloc(nlxo*sizeof(int )); + lndxocn_jl = (int *)malloc(nlxo*sizeof(int )); + lndxocn_io = (int *)malloc(nlxo*sizeof(int )); + lndxocn_jo = (int *)malloc(nlxo*sizeof(int )); vid = mpp_get_varid(fid_old, "AREA_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_area); vid = mpp_get_varid(fid_old, "I_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_il); vid = mpp_get_varid(fid_old, "J_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jl); vid = mpp_get_varid(fid_old, "I_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_io); vid = mpp_get_varid(fid_old, "J_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jo); - - for(i=0;i