Skip to content

Commit

Permalink
Merge pull request #73 from mauzey1/add_gsw_sa_ct_interp
Browse files Browse the repository at this point in the history
Add gsw_sa_ct_interp and gsw_tracer_ct_interp
  • Loading branch information
efiring authored Sep 25, 2024
2 parents 2d1cf8e + 7865575 commit e6afedf
Show file tree
Hide file tree
Showing 7 changed files with 1,094 additions and 2 deletions.
205 changes: 204 additions & 1 deletion gsw_check_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
** version_date: 15th_May_2011
** version_number: 3.06.16
** mat_zip_version: 3_06_16
** This file created on: 2024-02-12 11:26:21.045021
** This file created on: 2024-09-12 12:38:26.783150
*/

/*
Expand All @@ -24,6 +24,8 @@
#define cast_ice_n 3
#define cast_mpres_m 44
#define cast_mpres_n 3
#define interp_m 51
#define interp_n 3

static UNUSED double ct[135] = {
27.996436412058213, 27.993857176639086, 27.944017615967979, 27.948372399994319,
Expand Down Expand Up @@ -296,6 +298,13 @@ static UNUSED double p[135] = {
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90
};

static UNUSED double p_i[51] = {
0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400,
1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700,
2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000,
4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000
};

static UNUSED double delta_p[135] = {
0, 10, 10, 10, 10, 10, 26, 25, 25, 25, 25, 26, 50, 51, 50, 51, 101, 101, 101,
101, 101, 101, 101, 102, 101, 102, 101, 254, 254, 254, 255, 255, 256, 255, 256,
Expand Down Expand Up @@ -7933,6 +7942,200 @@ static UNUSED double rsubrho[132] = {

#define rsubrho_ca 1.690921180852456e-08

static UNUSED double sai_sactinterp[153] = {
34.468236430490606, 34.981684011594275, 34.845532135029757, 34.594880552563986,
34.646910055942165, 34.658726028373025, 34.667610684451823, 34.681241443337626,
34.693152815925814, 34.704242814066355, 34.715310018759446, 34.727191420710305,
34.737970181514079, 34.749908756622247, 34.75865652413632, 34.767977853907084,
34.776667058040957, 34.784334257348284, 34.79178015056219, 34.799429517990411,
34.806552614204548, 34.812691689382405, 34.818169026804789, 34.822997593767191,
34.827267561289105, 34.83107566345695, 34.834475961281619, 34.837525533487018,
34.840341326091348, 34.843005908156698, 34.845452404272699, 34.847569222979239,
34.849391445147802, 34.851249802860892, 34.853492505612103, 34.855706803475442,
34.857247772994597, 34.858497276933569, 34.859092057229148, 34.858381605762077,
34.856823030966915, 34.855679183654935, 34.854739459543588, 34.854308742400669,
34.855299304684273, 34.857513577115284, 34.85900682590129, 34.859483671997552,
34.859866852752297, 34.860716166459341, 34.862075375111715, 34.556977983037378,
35.143552028278961, 34.743955515099316, 34.823482547808247, 34.804942319288521,
34.760842876649718, 34.73197711758587, 34.714860568930348, 34.713553992644862,
34.718238136890584, 34.723558346430032, 34.732932331364822, 34.741835167338756,
34.751656516251295, 34.760987253055077, 34.770634831831927, 34.779831462444207,
34.787896487807899, 34.795973697286236, 34.804846003583471, 34.812671598162424,
34.817995350850836, 34.822145849128248, 34.826452359442619, 34.831415297815248,
34.836065183487634, 34.839513990464418, 34.842264529794129, 34.845044087445629,
34.848173560330608, 34.851227079351254, 34.853788960522365, 34.856002592079761,
34.858008149143096, 34.859816041891456, 34.861511533268335, 34.863314423422317,
34.865265218099864, 34.86708175309419, 34.868590932972623, 34.869910820929661,
34.871133587707021, 34.872546396459661, 34.873351690456062, 34.872775691608311,
34.871547239164059, 34.870721688384769, 34.870383374148055, 34.870265396867914,
34.870338679141682, 34.870546744141642, 6.6699043409245728, 10.346695553446363,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90
};

#define sai_sactinterp_ca 1.3001510978938313e-10

static UNUSED double cti_sactinterp[153] = {
27.996436412058227, 25.533144569030263, 16.019861520340768, 10.341891502382861,
8.4456966374532545, 7.2721994214211767, 6.5074004434211012, 5.8840829086292556,
5.3600631828344829, 4.8832999981632534, 4.4343297157729946, 4.0194186111174233,
3.6464959786663744, 3.3302175416713258, 3.0360389453491519, 2.7908185312784872,
2.5904631148025259, 2.423166010494068, 2.2715684781542738, 2.1281996714820086,
2.0038859800808941, 1.9057066559935123, 1.8235890129026773, 1.7482666532235847,
1.6762447258413102, 1.6115589460702915, 1.5572356514838051, 1.5101427761616257,
1.4678690688374059, 1.4291052039518444, 1.3940324397786752, 1.3631384058258678,
1.3360645039300703, 1.3092326083968704, 1.2796554533485569, 1.2504454968981085,
1.2262396689330433, 1.2054680503482365, 1.187164480536496, 1.1684829755830797,
1.1477518433658003, 1.1286972420975527, 1.1093760918020004, 1.0943939612593574,
1.0873483431052355, 1.0817477224915897, 1.0745478755635225, 1.0634152009122975,
1.0515515736003886, 1.0426620383447947, 1.0351918856149576, 27.322890736362599,
22.011254836061603, 11.560227514375722, 9.8757443413275237, 9.0022892545844027,
8.05506023421108, 7.1412969334874559, 6.2985045169753038, 5.6689611002002005,
5.1619651842686372, 4.6499362388415042, 4.3058993935480157, 3.9759763533444907,
3.6420020781766036, 3.3196655649536524, 2.9994634344611657, 2.7820843247989426,
2.6147405296234192, 2.4435788959532885, 2.2471193199195505, 2.0822572605932823,
1.9899103600091417, 1.9259139687763396, 1.8589909978970756, 1.7804728271451022,
1.705937917028272, 1.6475130925660368, 1.5987301233149647, 1.5517208830746407,
1.5039888179174263, 1.4579677965960154, 1.4151089811281323, 1.3749691776165345,
1.3359607264588433, 1.2978547591325253, 1.2603848521798859, 1.2218814621548661,
1.1820088935554813, 1.1431502947536156, 1.1066031829996259, 1.0714954834787538,
1.0377190422510292, 1.0030329830608418, 0.97360861725787962,
0.9534590677768886, 0.93592175165578984, 0.92023524972450943,
0.90565719701788883, 0.8921688460133359, 0.8795567615391916,
0.86702210345731012, 10.502767735302228, 4.5888811896604285,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90
};

#define cti_sactinterp_ca 6.2611249518340628e-10

static UNUSED double traceri_tracerctinterp[153] = {
34.468236430490606, 34.981684011594275, 34.845532135029757, 34.594880552563986,
34.646910055942165, 34.658726028373025, 34.667610684451823, 34.681241443337626,
34.693152815925814, 34.704242814066355, 34.715310018759446, 34.727191420710305,
34.737970181514079, 34.749908756622247, 34.75865652413632, 34.767977853907084,
34.776667058040957, 34.784334257348284, 34.79178015056219, 34.799429517990411,
34.806552614204548, 34.812691689382405, 34.818169026804789, 34.822997593767191,
34.827267561289105, 34.83107566345695, 34.834475961281619, 34.837525533487018,
34.840341326091348, 34.843005908156698, 34.845452404272699, 34.847569222979239,
34.849391445147802, 34.851249802860892, 34.853492505612103, 34.855706803475442,
34.857247772994597, 34.858497276933569, 34.859092057229148, 34.858381605762077,
34.856823030966915, 34.855679183654935, 34.854739459543588, 34.854308742400669,
34.855299304684273, 34.857513577115284, 34.85900682590129, 34.859483671997552,
34.859866852752297, 34.860716166459341, 34.862075375111715, 34.556977983037378,
35.143552028278961, 34.743955515099316, 34.823482547808247, 34.804942319288521,
34.760842876649718, 34.73197711758587, 34.714860568930348, 34.713553992644862,
34.718238136890584, 34.723558346430032, 34.732932331364822, 34.741835167338756,
34.751656516251295, 34.760987253055077, 34.770634831831927, 34.779831462444207,
34.787896487807899, 34.795973697286236, 34.804846003583471, 34.812671598162424,
34.817995350850836, 34.822145849128248, 34.826452359442619, 34.831415297815248,
34.836065183487634, 34.839513990464418, 34.842264529794129, 34.845044087445629,
34.848173560330608, 34.851227079351254, 34.853788960522365, 34.856002592079761,
34.858008149143096, 34.859816041891456, 34.861511533268335, 34.863314423422317,
34.865265218099864, 34.86708175309419, 34.868590932972623, 34.869910820929661,
34.871133587707021, 34.872546396459661, 34.873351690456062, 34.872775691608311,
34.871547239164059, 34.870721688384769, 34.870383374148055, 34.870265396867914,
34.870338679141682, 34.870546744141642, 6.6699043409245728, 10.346695553446363,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90
};

#define traceri_tracerctinterp_ca 1.3001510978938313e-10

static UNUSED double cti_tracerctinterp[153] = {
27.996436412058227, 25.533144569030263, 16.019861520340768, 10.341891502382861,
8.4456966374532545, 7.2721994214211767, 6.5074004434211012, 5.8840829086292556,
5.3600631828344829, 4.8832999981632534, 4.4343297157729946, 4.0194186111174233,
3.6464959786663744, 3.3302175416713258, 3.0360389453491519, 2.7908185312784872,
2.5904631148025259, 2.423166010494068, 2.2715684781542738, 2.1281996714820086,
2.0038859800808941, 1.9057066559935123, 1.8235890129026773, 1.7482666532235847,
1.6762447258413102, 1.6115589460702915, 1.5572356514838051, 1.5101427761616257,
1.4678690688374059, 1.4291052039518444, 1.3940324397786752, 1.3631384058258678,
1.3360645039300703, 1.3092326083968704, 1.2796554533485569, 1.2504454968981085,
1.2262396689330433, 1.2054680503482365, 1.187164480536496, 1.1684829755830797,
1.1477518433658003, 1.1286972420975527, 1.1093760918020004, 1.0943939612593574,
1.0873483431052355, 1.0817477224915897, 1.0745478755635225, 1.0634152009122975,
1.0515515736003886, 1.0426620383447947, 1.0351918856149576, 27.322890736362599,
22.011254836061603, 11.560227514375722, 9.8757443413275237, 9.0022892545844027,
8.05506023421108, 7.1412969334874559, 6.2985045169753038, 5.6689611002002005,
5.1619651842686372, 4.6499362388415042, 4.3058993935480157, 3.9759763533444907,
3.6420020781766036, 3.3196655649536524, 2.9994634344611657, 2.7820843247989426,
2.6147405296234192, 2.4435788959532885, 2.2471193199195505, 2.0822572605932823,
1.9899103600091417, 1.9259139687763396, 1.8589909978970756, 1.7804728271451022,
1.705937917028272, 1.6475130925660368, 1.5987301233149647, 1.5517208830746407,
1.5039888179174263, 1.4579677965960154, 1.4151089811281323, 1.3749691776165345,
1.3359607264588433, 1.2978547591325253, 1.2603848521798859, 1.2218814621548661,
1.1820088935554813, 1.1431502947536156, 1.1066031829996259, 1.0714954834787538,
1.0377190422510292, 1.0030329830608418, 0.97360861725787962,
0.9534590677768886, 0.93592175165578984, 0.92023524972450943,
0.90565719701788883, 0.8921688460133359, 0.8795567615391916,
0.86702210345731012, 10.502767735302228, 4.5888811896604285,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90
};

#define cti_tracerctinterp_ca 6.2611249518340628e-10

static UNUSED double p_mid_tursr[132] = {
5, 15, 25, 35, 45, 63, 88.5, 113.5, 138.5, 163.5, 189, 227, 277.5, 328, 378.5,
454.5, 555.5, 656.5, 757.5, 858.5, 959.5, 1060.5, 1162, 1263.5, 1365, 1466.5,
Expand Down
Binary file modified gsw_check_data.nc
Binary file not shown.
35 changes: 34 additions & 1 deletion gsw_check_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ main(int argc, char **argv)
int count = cast_m*cast_n, i, j, k, l, n;
double saturation_fraction, value[cast_m*cast_n], lat[cast_m*cast_n],
lon[cast_m*cast_n], val1[cast_m*cast_n], val2[cast_m*cast_n], val3[cast_m*cast_n],
val4[cast_m*cast_n], val5[cast_m*cast_n];
val4[cast_m*cast_n], val5[cast_m*cast_n], val6[interp_m*interp_n],
val7[interp_m*interp_n];

if (argc==2 && !strcmp(argv[1],"-debug"))
debug = 1;
Expand Down Expand Up @@ -583,6 +584,38 @@ main(int argc, char **argv)
test_func(o2sol, (sa[i],ct[i],p[i],lon[i],lat[i]), value, o2sol);
test_func(o2sol_sp_pt, (sp[i],pt[i]), value, o2sol_sp_pt);

section_title("Vertical Interpolation");

for (j = 0; j<cast_n; j++) {
k = j*cast_m;
l = j*interp_m;
for (n=0; n<cast_m; n++)
if (isnan(sa[k+n]) || fabs(sa[k+n]) >= GSW_ERROR_LIMIT)
break;
if (gsw_sa_ct_interp(&sa[k],&ct[k],&p[k],n,
p_i,interp_m,&val6[l],&val7[l]) == 1)
printf("gsw_sa_ct_interp returned error.\n");
}
check_accuracy("gsw_sa_ct_interp",sai_sactinterp_ca,
"sai_sactinterp",interp_n*interp_m, val6, sai_sactinterp);
check_accuracy("gsw_sa_ct_interp",cti_sactinterp_ca,
"cti_sactinterp",interp_n*interp_m, val7, cti_sactinterp);

for (j = 0; j<cast_n; j++) {
k = j*cast_m;
l = j*interp_m;
for (n=0; n<cast_m; n++)
if (isnan(sa[k+n]) || fabs(sa[k+n]) >= GSW_ERROR_LIMIT)
break;
if (gsw_tracer_ct_interp(&sa[k],&ct[k],&p[k],n,
p_i,interp_m,9.,&val6[l],&val7[l]) == 1)
printf("gsw_tracer_ct_interp returned error.\n");
}
check_accuracy("gsw_tracer_ct_interp",traceri_tracerctinterp_ca,
"traceri_tracerctinterp",interp_n*interp_m, val6, traceri_tracerctinterp);
check_accuracy("gsw_tracer_ct_interp",cti_tracerctinterp_ca,
"cti_tracerctinterp",interp_n*interp_m, val7, cti_tracerctinterp);

test_infunnel();

if (gsw_error_flag)
Expand Down
11 changes: 11 additions & 0 deletions gsw_data_ncdump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dimensions:
test_cast_midpressure_number = 3 ;
test_cast_midlocation_length = 45 ;
test_cast_midlocation_number = 2 ;
test_interp_length = 51 ;
test_interp_number = 3 ;
variables:
double p_ref(nz) ;
p_ref:standard_name = "pressure_reference_atlas" ;
Expand Down Expand Up @@ -85,6 +87,7 @@ variables:
double SP_chck_cast(test_cast_number, test_cast_length) ;
double t_chck_cast(test_cast_number, test_cast_length) ;
double p_chck_cast(test_cast_number, test_cast_length) ;
double p_i(test_interp_length) ;
double lat_chck_cast(test_cast_number) ;
double long_chck_cast(test_cast_number) ;
double pr(value_test_cast) ;
Expand Down Expand Up @@ -320,6 +323,14 @@ variables:
Tu:computation_accuracy = 2.19097096021414e-08 ;
double Rsubrho(test_cast_number, test_cast_midpressure_length) ;
Rsubrho:computation_accuracy = 1.70965819279445e-08 ;
double SAi_SACTinterp(test_interp_number, test_interp_length) ;
SAi_SACTinterp:computation_accuracy = 1.300151097893831e-10 ;
double CTi_SACTinterp(test_interp_number, test_interp_length) ;
CTi_SACTinterp:computation_accuracy = 6.261124951834063e-10 ;
double traceri_tracerCTinterp(test_interp_number, test_interp_length) ;
traceri_tracerCTinterp:computation_accuracy = 1.300151097893831e-10 ;
double CTi_tracerCTinterp(test_interp_number, test_interp_length) ;
CTi_tracerCTinterp:computation_accuracy = 6.261124951834063e-10 ;
double p_mid_TuRsr(test_cast_number, test_cast_midpressure_length) ;
p_mid_TuRsr:computation_accuracy = 2.30002115131356e-08 ;
double n2(test_cast_number, test_cast_midpressure_length) ;
Expand Down
Loading

0 comments on commit e6afedf

Please sign in to comment.