/* * CB_2008_nga.c * * Code generation for function 'CB_2008_nga' * * C source code generated on: Wed Aug 26 14:59:34 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "CB_2008_nga.h" #include "SP_1996.h" #include "skew.h" #include "CB_2008_nga_T0.h" #include "baker_jayaram_correlation.h" #include "interp1.h" #include "Select_Ground_Motions_emxutil.h" #include "log.h" #include "CB_2008_nga_high.h" #include "CB_2008_nga_low.h" #include "sqrt.h" #include "mpower.h" #include "mrdivide.h" #include "all.h" #include "exp.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo qp_emlrtRSI = { 47, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo rp_emlrtRSI = { 74, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo sp_emlrtRSI = { 86, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo tp_emlrtRSI = { 87, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo up_emlrtRSI = { 90, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo vp_emlrtRSI = { 91, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo wp_emlrtRSI = { 93, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo xp_emlrtRSI = { 94, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo yp_emlrtRSI = { 96, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo aq_emlrtRSI = { 97, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo bq_emlrtRSI = { 100, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo cq_emlrtRSI = { 143, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo dq_emlrtRSI = { 160, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo eq_emlrtRSI = { 161, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo fq_emlrtRSI = { 163, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo gq_emlrtRSI = { 165, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo hq_emlrtRSI = { 183, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo iq_emlrtRSI = { 184, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo jq_emlrtRSI = { 192, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo kq_emlrtRSI = { 193, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo lq_emlrtRSI = { 196, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo mq_emlrtRSI = { 198, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo xq_emlrtRSI = { 16, "min", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/min.m" }; static emlrtRSInfo pr_emlrtRSI = { 100, "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m" }; static emlrtRSInfo qr_emlrtRSI = { 47, "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m" }; static emlrtRSInfo ks_emlrtRSI = { 159, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo ls_emlrtRSI = { 175, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRSInfo ms_emlrtRSI = { 182, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRTEInfo md_emlrtRTEI = { 30, 33, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtRTEInfo td_emlrtRTEI = { 105, 24, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo rb_emlrtECI = { -1, 100, 14, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtBCInfo he_emlrtBCI = { -1, -1, 100, 14, "Sa(it)", "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m", 0 }; static emlrtECInfo sb_emlrtECI = { -1, 100, 22, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtBCInfo ie_emlrtBCI = { -1, -1, 100, 22, "sigma(it)", "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m", 0 }; static emlrtBCInfo je_emlrtBCI = { -1, -1, 100, 21, "sigma(it)", "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m", 0 }; static emlrtECInfo tb_emlrtECI = { -1, 100, 21, "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m" }; static emlrtBCInfo ke_emlrtBCI = { -1, -1, 100, 14, "Sa(it)", "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m", 0 }; static emlrtECInfo ub_emlrtECI = { -1, 100, 14, "CB_2008_nga_high", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_high.m" }; static emlrtECInfo jd_emlrtECI = { 2, 198, 18, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo kd_emlrtECI = { 2, 196, 12, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo ld_emlrtECI = { 2, 193, 15, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo md_emlrtECI = { 2, 179, 10, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo nd_emlrtECI = { 2, 165, 14, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo od_emlrtECI = { 2, 163, 14, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo pd_emlrtECI = { 2, 161, 13, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo qd_emlrtECI = { 2, 147, 8, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo rd_emlrtECI = { 2, 143, 9, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo sd_emlrtECI = { 2, 138, 16, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo td_emlrtECI = { 2, 136, 16, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; static emlrtECInfo ud_emlrtECI = { 2, 134, 12, "CB_2008_nga", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga.m" }; /* Function Declarations */ static void CB_2008_nga_sub(real_T M, real_T ip, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T *Sa, real_T *sigma); static void e_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T Sa_data[24], int32_T Sa_size[2], real_T sigma_data[24], int32_T sigma_size[2]); /* Function Definitions */ static void CB_2008_nga_sub(real_T M, real_T ip, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T *Sa, real_T *sigma) { static const real_T dv2[24] = { 5.6, 5.6, 5.6, 5.74, 7.09, 8.05, 8.79, 7.6, 6.58, 6.04, 5.3, 4.73, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 5.6, 4.0, 4.0 }; real_T x; boolean_T b; static const int16_T iv89[24] = { 865, 865, 908, 1054, 1086, 1032, 878, 748, 654, 587, 503, 457, 410, 400, 400, 400, 400, 400, 400, 400, 400, 865, 400, 400 }; real_T A1100; real_T y; real_T fsite; static const real_T dv3[24] = { -1.186, -1.219, -1.273, -1.346, -1.471, -1.624, -1.931, -2.188, -2.381, -2.518, -2.657, -2.669, -2.401, -1.955, -1.025, -0.299, 0.0, 0.0, 0.0, 0.0, 0.0, -1.186, -1.955, 0.0 }; static const real_T dv4[24] = { 1.058, 1.102, 1.174, 1.272, 1.438, 1.604, 1.928, 2.194, 2.351, 2.46, 2.587, 2.544, 2.133, 1.571, 0.406, -0.456, -0.82, -0.82, -0.82, -0.82, -0.82, 1.058, 1.694, -0.82 }; static const real_T dv5[24] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.656, 0.972, 1.196, 1.513, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 0.5, 0.696, 1.6 }; static const real_T dv6[24] = { -1.715, -1.68, -1.552, -1.209, -0.657, -0.314, -0.133, -0.486, -0.89, -1.171, -1.466, -2.569, -4.844, -6.406, -8.692, -9.701, -10.556, -11.212, -11.684, -12.505, -13.087, -1.715, 0.954, -5.27 }; real_T b_M; static const real_T dv7[24] = { -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.446, -0.362, -0.294, -0.186, -0.304, -0.578, -0.772, -1.046, -0.978, -0.638, -0.316, -0.07, -0.07, -0.07, -0.53, -0.309, -0.07 }; static const real_T dv8[24] = { -0.262, -0.262, -0.262, -0.267, -0.302, -0.324, -0.339, -0.398, -0.458, -0.511, -0.592, -0.536, -0.406, -0.314, -0.185, -0.236, -0.491, -0.77, -0.986, -0.656, -0.422, -0.262, -0.019, 0.0 }; static const real_T dv9[24] = { 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.077, 0.15, 0.253, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.04, 0.092, 0.3 }; real_T b_Zvs; static const real_T dv10[24] = { 1.839, 1.84, 1.841, 1.843, 1.845, 1.847, 1.852, 1.856, 1.861, 1.865, 1.874, 1.883, 1.906, 1.929, 1.974, 2.019, 2.11, 2.2, 2.291, 2.517, 2.744, 1.839, 1.929, 2.744 }; static const real_T dv11[24] = { 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.7, 0.75, 0.85, 0.883, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.61, 1.0, 1.0 }; static const real_T dv12[24] = { 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.371, 0.154, 0.0, 0.0, 0.0, 0.0, 0.49, 0.358, 0.0 }; static const real_T dv13[24] = { -0.12, -0.12, -0.12, -0.12, -0.12, -0.099, -0.048, -0.012, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.12, 0.0, 0.0 }; static const real_T dv14[24] = { 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.255, 0.161, 0.094, 0.0, 0.0, 0.0, 0.0, 0.0, 0.28, 0.245, 0.0 }; static const real_T dv15[24] = { -2.118, -2.123, -2.145, -2.199, -2.277, -2.318, -2.309, -2.22, -2.146, -2.095, -2.066, -2.041, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.118, -2.016, -2.0 }; static const real_T dv16[24] = { 0.478, 0.48, 0.498, 0.51, 0.52, 0.531, 0.532, 0.534, 0.534, 0.544, 0.541, 0.55, 0.568, 0.568, 0.564, 0.571, 0.558, 0.576, 0.601, 0.628, 0.667, 0.478, 0.484, 0.667 }; static const real_T dv17[24] = { 1.0, 0.999, 0.989, 0.963, 0.922, 0.898, 0.89, 0.871, 0.852, 0.831, 0.785, 0.735, 0.628, 0.534, 0.411, 0.331, 0.289, 0.261, 0.2, 0.174, 0.174, 1.0, 0.691, 0.174 }; static const real_T dv18[24] = { 0.219, 0.219, 0.235, 0.258, 0.292, 0.286, 0.28, 0.249, 0.24, 0.215, 0.217, 0.214, 0.227, 0.255, 0.296, 0.296, 0.326, 0.297, 0.359, 0.428, 0.485, 0.219, 0.203, 0.485 }; static const real_T dv19[24] = { 0.166, 0.166, 0.165, 0.162, 0.158, 0.17, 0.18, 0.186, 0.191, 0.198, 0.206, 0.208, 0.221, 0.225, 0.222, 0.226, 0.229, 0.237, 0.237, 0.271, 0.29, 0.166, 0.19, 0.29 }; /* Magnitude dependence */ /* Distance dependence */ emlrtPushRtStackR2012b(&cq_emlrtRSI, emlrtRootTLSGlobal); x = Rrup * Rrup + dv2[(int32_T)ip - 1] * dv2[(int32_T)ip - 1]; if (x < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&cq_emlrtRSI, emlrtRootTLSGlobal); /* Style of faulting */ /* Hanging-wall effects */ if ((Ztor >= 0.0) && (Ztor < 20.0)) { b = TRUE; } else { b = FALSE; } /* Site conditions */ if (Vs30 < iv89[(int32_T)ip - 1]) { emlrtPushRtStackR2012b(&dq_emlrtRSI, emlrtRootTLSGlobal); A1100 = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&dq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); y = Vs30 / (real_T)iv89[(int32_T)ip - 1]; if (y < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } fsite = Vs30 / (real_T)iv89[(int32_T)ip - 1]; emlrtPushRtStackR2012b(&wq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hd_emlrtRSI, emlrtRootTLSGlobal); if (fsite < 0.0) { emlrtPushRtStackR2012b(&id_emlrtRSI, emlrtRootTLSGlobal); eml_error(); emlrtPopRtStackR2012b(&id_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&hd_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&wq_emlrtRSI, emlrtRootTLSGlobal); fsite = A1100 + 1.88 * muDoubleScalarPower(fsite, 1.18); if (fsite < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } if (A1100 + 1.88 < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } fsite = dv4[(int32_T)ip - 1] * muDoubleScalarLog(y) + dv3[(int32_T)ip - 1] * (muDoubleScalarLog(fsite) - muDoubleScalarLog(A1100 + 1.88)); emlrtPopRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); } else if (Vs30 < 1100.0) { emlrtPushRtStackR2012b(&fq_emlrtRSI, emlrtRootTLSGlobal); y = Vs30 / (real_T)iv89[(int32_T)ip - 1]; fsite = (dv4[(int32_T)ip - 1] + dv3[(int32_T)ip - 1] * 1.18) * muDoubleScalarLog(y); emlrtPopRtStackR2012b(&fq_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&gq_emlrtRSI, emlrtRootTLSGlobal); fsite = (dv4[(int32_T)ip - 1] + dv3[(int32_T)ip - 1] * 1.18) * muDoubleScalarLog(1100.0 / (real_T)iv89[(int32_T)ip - 1]); emlrtPopRtStackR2012b(&gq_emlrtRSI, emlrtRootTLSGlobal); } /* Sediment effects */ /* Median value */ if (M <= 5.5) { b_M = dv6[(int32_T)ip - 1] + dv5[(int32_T)ip - 1] * M; } else if (M <= 6.5) { b_M = (dv6[(int32_T)ip - 1] + dv5[(int32_T)ip - 1] * M) + dv7[(int32_T)ip - 1] * (M - 5.5); } else { b_M = ((dv6[(int32_T)ip - 1] + dv5[(int32_T)ip - 1] * M) + dv7[(int32_T)ip - 1] * (M - 5.5)) + dv8[(int32_T)ip - 1] * (M - 6.5); } if (Zvs < 1.0) { b_Zvs = dv9[(int32_T)ip - 1] * (Zvs - 1.0); } else if (Zvs <= 3.0) { b_Zvs = 0.0; } else { b_Zvs = dv11[(int32_T)ip - 1] * dv10[(int32_T)ip - 1] * 0.47236655274101469 * (1.0 - muDoubleScalarExp(-0.25 * (Zvs - 3.0))); } *Sa = muDoubleScalarExp(((((b_M + (dv15[(int32_T)ip - 1] + 0.17 * M) * muDoubleScalarLog(muDoubleScalarSqrt(x))) + (dv14[(int32_T)ip - 1] * (real_T) Frv * ffltz + dv13[(int32_T)ip - 1] * (real_T)Fnm)) + dv12[(int32_T)ip - 1] * fhngr * fhngm * ((20.0 - Ztor) / 20.0 * (real_T)b) * ((real_T)(delta <= 70.0) + (90.0 - delta) / 20.0 * (real_T)(delta > 70.0))) + fsite) + b_Zvs); /* Standard deviation computations */ if (Vs30 < iv89[(int32_T)ip - 1]) { emlrtPushRtStackR2012b(&hq_emlrtRSI, emlrtRootTLSGlobal); A1100 = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&hq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&iq_emlrtRSI, emlrtRootTLSGlobal); y = Vs30 / (real_T)iv89[(int32_T)ip - 1]; emlrtPushRtStackR2012b(&wq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hd_emlrtRSI, emlrtRootTLSGlobal); if (y < 0.0) { emlrtPushRtStackR2012b(&id_emlrtRSI, emlrtRootTLSGlobal); eml_error(); emlrtPopRtStackR2012b(&id_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&hd_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&wq_emlrtRSI, emlrtRootTLSGlobal); fsite = dv3[(int32_T)ip - 1] * A1100 * (1.0 / (A1100 + 1.88 * muDoubleScalarPower(y, 1.18)) - 1.0 / (A1100 + 1.88)); emlrtPopRtStackR2012b(&iq_emlrtRSI, emlrtRootTLSGlobal); } else { fsite = 0.0; } emlrtPushRtStackR2012b(&jq_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&jq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); x = (dv16[(int32_T)ip - 1] * dv16[(int32_T)ip - 1] + fsite * fsite * 0.138484) + 2.0 * fsite * dv17[(int32_T)ip - 1] * muDoubleScalarSqrt(dv16[(int32_T)ip - 1] * dv16[(int32_T)ip - 1] - 0.09) * 0.37213438432910229; if (x < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } fsite = muDoubleScalarSqrt(x); emlrtPopRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); *sigma = muDoubleScalarSqrt(fsite * fsite + dv18[(int32_T)ip - 1] * dv18 [(int32_T)ip - 1]); emlrtPopRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); if (arb == 1.0) { emlrtPushRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); *sigma = muDoubleScalarSqrt(*sigma * *sigma + dv19[(int32_T)ip - 1] * dv19 [(int32_T)ip - 1]); emlrtPopRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); } } static void e_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T Sa_data[24], int32_T Sa_size[2], real_T sigma_data[24], int32_T sigma_size[2]) { emxArray_real_T *y; emxArray_real_T *b_y; emxArray_real_T *c_y; int32_T fmag_size[2]; int32_T i; int32_T d_y; static const real_T dv73[24] = { -1.715, -1.68, -1.552, -1.209, -0.657, -0.314, -0.133, -0.486, -0.89, -1.171, -1.466, -2.569, -4.844, -6.406, -8.692, -9.701, -10.556, -11.212, -11.684, -12.505, -13.087, -1.715, 0.954, -5.27 }; real_T fmag_data[24]; static const real_T dv74[24] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.656, 0.972, 1.196, 1.513, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 0.5, 0.696, 1.6 }; int32_T fmag[2]; int32_T e_y[2]; real_T fhngz; static const real_T dv75[24] = { -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.446, -0.362, -0.294, -0.186, -0.304, -0.578, -0.772, -1.046, -0.978, -0.638, -0.316, -0.07, -0.07, -0.07, -0.53, -0.309, -0.07 }; static const real_T dv76[24] = { -0.262, -0.262, -0.262, -0.267, -0.302, -0.324, -0.339, -0.398, -0.458, -0.511, -0.592, -0.536, -0.406, -0.314, -0.185, -0.236, -0.491, -0.77, -0.986, -0.656, -0.422, -0.262, -0.019, 0.0 }; int32_T fsed_size[2]; static const real_T dv77[24] = { -2.118, -2.123, -2.145, -2.199, -2.277, -2.318, -2.309, -2.22, -2.146, -2.095, -2.066, -2.041, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.118, -2.016, -2.0 }; real_T fsed_data[24]; int32_T fsed[2]; real_T tmp_data[24]; int32_T tmp_size[2]; static const real_T dv78[24] = { 5.6, 5.6, 5.6, 5.74, 7.09, 8.05, 8.79, 7.6, 6.58, 6.04, 5.3, 4.73, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 5.6, 4.0, 4.0 }; emxArray_real_T b_tmp_data; const mxArray *f_y; static const int32_T iv118[2] = { 1, 45 }; const mxArray *m40; char_T cv144[45]; static const char_T cv145[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'm', 't', 'i', 'm', 'e', 's', '_', 'n', 'o', 'D', 'y', 'n', 'a', 'm', 'i', 'c', 'S', 'c', 'a', 'l', 'a', 'r', 'E', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n' }; const mxArray *g_y; static const int32_T iv119[2] = { 1, 21 }; char_T cv146[21]; static const char_T cv147[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; static const real_T dv79[24] = { 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.255, 0.161, 0.094, 0.0, 0.0, 0.0, 0.0, 0.0, 0.28, 0.245, 0.0 }; int32_T fflt_size[2]; static const real_T dv80[24] = { -0.12, -0.12, -0.12, -0.12, -0.12, -0.099, -0.048, -0.012, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.12, 0.0, 0.0 }; real_T fflt_data[24]; int32_T fflt[2]; boolean_T b; real_T fhngdelta; static const real_T dv81[24] = { 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.371, 0.154, 0.0, 0.0, 0.0, 0.0, 0.49, 0.358, 0.0 }; boolean_T Vs30_data[24]; int32_T Vs30_size[2]; static const int16_T iv120[24] = { 865, 865, 908, 1054, 1086, 1032, 878, 748, 654, 587, 503, 457, 410, 400, 400, 400, 400, 400, 400, 400, 400, 865, 400, 400 }; emxArray_boolean_T b_Vs30_data; emxArray_real_T *h_y; real_T c_tmp_data[24]; int32_T b_tmp_size[2]; real_T b_b; static const real_T dv82[24] = { 1.058, 1.102, 1.174, 1.272, 1.438, 1.604, 1.928, 2.194, 2.351, 2.46, 2.587, 2.544, 2.133, 1.571, 0.406, -0.456, -0.82, -0.82, -0.82, -0.82, -0.82, 1.058, 1.694, -0.82 }; int32_T c_tmp_size[2]; static const real_T dv83[24] = { -1.186, -1.219, -1.273, -1.346, -1.471, -1.624, -1.931, -2.188, -2.381, -2.518, -2.657, -2.669, -2.401, -1.955, -1.025, -0.299, 0.0, 0.0, 0.0, 0.0, 0.0, -1.186, -1.955, 0.0 }; int32_T fsite_size[2]; real_T fsite_data[24]; static const real_T dv84[24] = { 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.077, 0.15, 0.253, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.04, 0.092, 0.3 }; static const real_T dv85[24] = { 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.7, 0.75, 0.85, 0.883, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.61, 1.0, 1.0 }; static const real_T dv86[24] = { 1.839, 1.84, 1.841, 1.843, 1.845, 1.847, 1.852, 1.856, 1.861, 1.865, 1.874, 1.883, 1.906, 1.929, 1.974, 2.019, 2.11, 2.2, 2.291, 2.517, 2.744, 1.839, 1.929, 2.744 }; const mxArray *i_y; static const int32_T iv121[2] = { 1, 45 }; const mxArray *j_y; static const int32_T iv122[2] = { 1, 21 }; boolean_T c_Vs30_data[24]; int32_T b_Vs30_size[2]; emxArray_boolean_T d_Vs30_data; int32_T d_tmp_size[2]; real_T d_tmp_data[24]; int32_T e_tmp_size[2]; static const real_T dv87[24] = { 0.478, 0.48, 0.498, 0.51, 0.52, 0.531, 0.532, 0.534, 0.534, 0.544, 0.541, 0.55, 0.568, 0.568, 0.564, 0.571, 0.558, 0.576, 0.601, 0.628, 0.667, 0.478, 0.484, 0.667 }; emxArray_real_T e_tmp_data; real_T f_tmp_data[24]; int32_T f_tmp_size[2]; emxArray_real_T g_tmp_data; emxArray_real_T b_fflt_data; static const real_T dv88[24] = { 1.0, 0.999, 0.989, 0.963, 0.922, 0.898, 0.89, 0.871, 0.852, 0.831, 0.785, 0.735, 0.628, 0.534, 0.411, 0.331, 0.289, 0.261, 0.2, 0.174, 0.174, 1.0, 0.691, 0.174 }; const mxArray *k_y; static const int32_T iv123[2] = { 1, 45 }; const mxArray *l_y; static const int32_T iv124[2] = { 1, 21 }; const mxArray *m_y; static const int32_T iv125[2] = { 1, 45 }; const mxArray *n_y; static const int32_T iv126[2] = { 1, 21 }; emxArray_real_T c_fflt_data; real_T h_tmp_data[24]; int32_T g_tmp_size[2]; static const real_T dv89[24] = { 0.219, 0.219, 0.235, 0.258, 0.292, 0.286, 0.28, 0.249, 0.24, 0.215, 0.217, 0.214, 0.227, 0.255, 0.296, 0.296, 0.326, 0.297, 0.359, 0.428, 0.485, 0.219, 0.203, 0.485 }; emxArray_real_T i_tmp_data; emxArray_real_T b_sigma_data; real_T j_tmp_data[24]; int32_T h_tmp_size[2]; static const real_T dv90[24] = { 0.166, 0.166, 0.165, 0.162, 0.158, 0.17, 0.18, 0.186, 0.191, 0.198, 0.206, 0.208, 0.221, 0.225, 0.222, 0.226, 0.229, 0.237, 0.237, 0.271, 0.29, 0.166, 0.19, 0.29 }; emxArray_real_T k_tmp_data; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* Magnitude dependence */ b_emxInit_real_T(&y, 2, &td_emlrtRTEI, TRUE); b_emxInit_real_T(&b_y, 2, &td_emlrtRTEI, TRUE); b_emxInit_real_T(&c_y, 2, &td_emlrtRTEI, TRUE); if (M <= 5.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv73[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv74[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &ud_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = fmag_data[d_y] + y->data[d_y]; fmag_data[d_y] = fhngz; } } else if (M <= 6.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv73[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv74[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &td_emlrtECI, emlrtRootTLSGlobal); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv75[(int32_T)ip_data[d_y] - 1] * (M - 5.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &td_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fmag_data[d_y] + y->data[d_y]) + b_y->data[d_y]; fmag_data[d_y] = fhngz; } } else { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv73[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv74[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &sd_emlrtECI, emlrtRootTLSGlobal); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv75[(int32_T)ip_data[d_y] - 1] * (M - 5.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &sd_emlrtECI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv76[(int32_T)ip_data[d_y] - 1] * (M - 6.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &sd_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = ((fmag_data[d_y] + y->data[d_y]) + b_y->data[d_y]) + c_y->data[d_y]; fmag_data[d_y] = fhngz; } } /* Distance dependence */ fsed_size[0] = 1; fsed_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = dv77[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = 0.17 * M; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &rd_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cq_emlrtRSI, emlrtRootTLSGlobal); fhngz = Rrup * Rrup; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] += fsed_data[d_y]; } tmp_size[0] = 1; tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { tmp_data[d_y] = dv78[(int32_T)ip_data[d_y] - 1]; } b_tmp_data.data = (real_T *)&tmp_data; b_tmp_data.size = (int32_T *)&tmp_size; b_tmp_data.allocatedSize = 24; b_tmp_data.numDimensions = 2; b_tmp_data.canFreeData = FALSE; mpower(&b_tmp_data, c_y); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = c_y->size[0]; d_y = c_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] += fhngz; } c_sqrt(c_y); c_log(c_y); emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); f_y = NULL; m40 = mxCreateCharArray(2, iv118); for (i = 0; i < 45; i++) { cv144[i] = cv145[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m40, cv144); emlrtAssign(&f_y, m40); error(message(f_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); g_y = NULL; m40 = mxCreateCharArray(2, iv119); for (i = 0; i < 21; i++) { cv146[i] = cv147[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m40, cv146); emlrtAssign(&g_y, m40); error(message(g_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = c_y->size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * c_y->data[c_y->size[0] * d_y]; } emlrtPopRtStackR2012b(&cq_emlrtRSI, emlrtRootTLSGlobal); /* Style of faulting */ d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv79[(int32_T)ip_data[d_y] - 1] * (real_T)Frv * ffltz; } fflt_size[0] = 1; fflt_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = dv80[(int32_T)ip_data[d_y] - 1] * (real_T)Fnm; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(e_y, fflt, &qd_emlrtECI, emlrtRootTLSGlobal); fflt_size[0] = 1; fflt_size[1] = b_y->size[1]; i = b_y->size[0] * b_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] += b_y->data[d_y]; } /* Hanging-wall effects */ if ((Ztor >= 0.0) && (Ztor < 20.0)) { b = TRUE; } else { b = FALSE; } fhngz = (20.0 - Ztor) / 20.0 * (real_T)b; fhngdelta = (real_T)(delta <= 70.0) + (90.0 - delta) / 20.0 * (real_T)(delta > 70.0); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv81[(int32_T)ip_data[d_y] - 1] * fhngr * fhngm * fhngz * fhngdelta; } /* Site conditions */ emlrtPushRtStackR2012b(&ks_emlrtRSI, emlrtRootTLSGlobal); Vs30_size[0] = 1; Vs30_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { Vs30_data[d_y] = (Vs30 < iv120[(int32_T)ip_data[d_y] - 1]); } b_Vs30_data.data = (boolean_T *)&Vs30_data; b_Vs30_data.size = (int32_T *)&Vs30_size; b_Vs30_data.allocatedSize = 24; b_Vs30_data.numDimensions = 2; b_Vs30_data.canFreeData = FALSE; b = b_all(&b_Vs30_data); emlrtPopRtStackR2012b(&ks_emlrtRSI, emlrtRootTLSGlobal); b_emxInit_real_T(&h_y, 2, &td_emlrtRTEI, TRUE); if (b) { emlrtPushRtStackR2012b(&dq_emlrtRSI, emlrtRootTLSGlobal); fhngz = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&dq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv120[(int32_T)ip_data[d_y] - 1]; } b_b = c_mrdivide(Vs30, c_tmp_data, b_tmp_size); b_log(&b_b); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv82[(int32_T)ip_data[d_y] - 1] * b_b; } emlrtPopRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); c_tmp_size[0] = 1; c_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv120[(int32_T)ip_data[d_y] - 1]; } b_b = b_mpower(c_mrdivide(Vs30, c_tmp_data, c_tmp_size)); fhngdelta = fhngz + 1.88; b_log(&fhngdelta); fhngz += 1.88 * b_b; b_log(&fhngz); b_b = fhngz - fhngdelta; d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = dv83[(int32_T)ip_data[d_y] - 1] * b_b; } emlrtPopRtStackR2012b(&eq_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = h_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(e_y, fsed, &pd_emlrtECI, emlrtRootTLSGlobal); fsite_size[0] = 1; fsite_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = c_y->data[d_y] + h_y->data[d_y]; } } else if (Vs30 < 1100.0) { fsite_size[0] = 1; fsite_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = dv82[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv83[(int32_T)ip_data[d_y] - 1] * 1.18; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsite_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &od_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fq_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv120[(int32_T)ip_data[d_y] - 1]; } b_b = c_mrdivide(Vs30, c_tmp_data, b_tmp_size); b_log(&b_b); fsite_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fsite_data[d_y] + c_y->data[d_y]) * b_b; fsite_data[d_y] = fhngz; } emlrtPopRtStackR2012b(&fq_emlrtRSI, emlrtRootTLSGlobal); } else { fsite_size[0] = 1; fsite_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = dv82[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv83[(int32_T)ip_data[d_y] - 1] * 1.18; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsite_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &nd_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&gq_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv120[(int32_T)ip_data[d_y] - 1]; } b_b = b_mrdivide(c_tmp_data, b_tmp_size); b_log(&b_b); fsite_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fsite_data[d_y] + c_y->data[d_y]) * b_b; fsite_data[d_y] = fhngz; } emlrtPopRtStackR2012b(&gq_emlrtRSI, emlrtRootTLSGlobal); } /* Sediment effects */ if (Zvs < 1.0) { fsed_size[0] = 1; fsed_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = dv84[(int32_T)ip_data[d_y] - 1] * (Zvs - 1.0); } } else if (Zvs <= 3.0) { fsed_size[0] = 1; fsed_size[1] = 1; fsed_data[0] = 0.0; } else { emlrtPushRtStackR2012b(&ls_emlrtRSI, emlrtRootTLSGlobal); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = dv85[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv86[(int32_T)ip_data[d_y] - 1]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(h_y->size[1] == 1)) { if ((h_y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); i_y = NULL; m40 = mxCreateCharArray(2, iv121); for (i = 0; i < 45; i++) { cv144[i] = cv145[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m40, cv144); emlrtAssign(&i_y, m40); error(message(i_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); j_y = NULL; m40 = mxCreateCharArray(2, iv122); for (i = 0; i < 21; i++) { cv146[i] = cv147[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m40, cv146); emlrtAssign(&j_y, m40); error(message(j_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); b_b = 1.0 - muDoubleScalarExp(-0.25 * (Zvs - 3.0)); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; fhngz = h_y->data[0]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = fhngz * c_y->data[d_y] * 0.47236655274101469 * b_b; } emlrtPopRtStackR2012b(&ls_emlrtRSI, emlrtRootTLSGlobal); } /* Median value */ for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &md_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &md_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &md_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; fsed[d_y] = fsite_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fsed, &md_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; fsed[d_y] = fsed_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fsed, &md_emlrtECI, emlrtRootTLSGlobal); d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fmag_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fmag_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = ((((fmag_data[d_y] + y->data[d_y]) + fflt_data[d_y]) + b_y->data[d_y]) + fsite_data[d_y]) + fsed_data[d_y]; } emxFree_real_T(&b_y); b_exp(y); Sa_size[0] = 1; Sa_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (d_y = 0; d_y < i; d_y++) { Sa_data[d_y] = y->data[d_y]; } /* Standard deviation computations */ emlrtPushRtStackR2012b(&ms_emlrtRSI, emlrtRootTLSGlobal); b_Vs30_size[0] = 1; b_Vs30_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_Vs30_data[d_y] = (Vs30 < iv120[(int32_T)ip_data[d_y] - 1]); } d_Vs30_data.data = (boolean_T *)&c_Vs30_data; d_Vs30_data.size = (int32_T *)&b_Vs30_size; d_Vs30_data.allocatedSize = 24; d_Vs30_data.numDimensions = 2; d_Vs30_data.canFreeData = FALSE; b = b_all(&d_Vs30_data); emlrtPopRtStackR2012b(&ms_emlrtRSI, emlrtRootTLSGlobal); if (b) { emlrtPushRtStackR2012b(&hq_emlrtRSI, emlrtRootTLSGlobal); fhngz = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&hq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&iq_emlrtRSI, emlrtRootTLSGlobal); d_tmp_size[0] = 1; d_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv120[(int32_T)ip_data[d_y] - 1]; } b_b = b_mpower(c_mrdivide(Vs30, c_tmp_data, d_tmp_size)); b_b = c_mpower(fhngz + 1.88 * b_b) - c_mpower(fhngz + 1.88); fflt_size[0] = 1; fflt_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = dv83[(int32_T)ip_data[d_y] - 1] * fhngz * b_b; } emlrtPopRtStackR2012b(&iq_emlrtRSI, emlrtRootTLSGlobal); } else { fflt_size[0] = 1; fflt_size[1] = 1; fflt_data[0] = 0.0; } emlrtPushRtStackR2012b(&jq_emlrtRSI, emlrtRootTLSGlobal); e_tmp_size[0] = 1; e_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { d_tmp_data[d_y] = dv87[(int32_T)ip_data[d_y] - 1]; } e_tmp_data.data = (real_T *)&d_tmp_data; e_tmp_data.size = (int32_T *)&e_tmp_size; e_tmp_data.allocatedSize = 24; e_tmp_data.numDimensions = 2; e_tmp_data.canFreeData = FALSE; mpower(&e_tmp_data, c_y); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = c_y->size[0]; d_y = c_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] -= 0.09; } c_sqrt(c_y); fsite_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&jq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); f_tmp_size[0] = 1; f_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { f_tmp_data[d_y] = dv87[(int32_T)ip_data[d_y] - 1]; } g_tmp_data.data = (real_T *)&f_tmp_data; g_tmp_data.size = (int32_T *)&f_tmp_size; g_tmp_data.allocatedSize = 24; g_tmp_data.numDimensions = 2; g_tmp_data.canFreeData = FALSE; mpower(&g_tmp_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); b_fflt_data.data = (real_T *)&fflt_data; b_fflt_data.size = (int32_T *)&fflt_size; b_fflt_data.allocatedSize = 24; b_fflt_data.numDimensions = 2; b_fflt_data.canFreeData = FALSE; mpower(&b_fflt_data, h_y); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = h_y->size[0]; d_y = h_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] *= 0.138484; } emlrtPopRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = h_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &ld_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fflt_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fflt_size[0] * fflt_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = 2.0 * fflt_data[d_y]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv88[(int32_T)ip_data[d_y] - 1]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); k_y = NULL; m40 = mxCreateCharArray(2, iv123); for (i = 0; i < 45; i++) { cv144[i] = cv145[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m40, cv144); emlrtAssign(&k_y, m40); error(message(k_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); l_y = NULL; m40 = mxCreateCharArray(2, iv124); for (i = 0; i < 21; i++) { cv146[i] = cv147[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m40, cv146); emlrtAssign(&l_y, m40); error(message(l_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = c_y->size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * c_y->data[c_y->size[0] * d_y]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (fsite_size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); m_y = NULL; m40 = mxCreateCharArray(2, iv125); for (i = 0; i < 45; i++) { cv144[i] = cv145[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m40, cv144); emlrtAssign(&m_y, m40); error(message(m_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); n_y = NULL; m40 = mxCreateCharArray(2, iv126); for (i = 0; i < 21; i++) { cv146[i] = cv147[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m40, cv146); emlrtAssign(&n_y, m40); error(message(n_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fsite_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fsite_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * fsite_data[d_y] * 0.37213438432910229; } emlrtPopRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &ld_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = (fsed_data[d_y] + h_y->data[d_y]) + y->data[d_y]; } emxFree_real_T(&y); c_sqrt(h_y); fflt_size[0] = 1; fflt_size[1] = h_y->size[1]; i = h_y->size[0] * h_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = h_y->data[d_y]; } emxFree_real_T(&h_y); emlrtPopRtStackR2012b(&kq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); c_fflt_data.data = (real_T *)&fflt_data; c_fflt_data.size = (int32_T *)&fflt_size; c_fflt_data.allocatedSize = 24; c_fflt_data.numDimensions = 2; c_fflt_data.canFreeData = FALSE; mpower(&c_fflt_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); g_tmp_size[0] = 1; g_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_tmp_data[d_y] = dv89[(int32_T)ip_data[d_y] - 1]; } i_tmp_data.data = (real_T *)&h_tmp_data; i_tmp_data.size = (int32_T *)&g_tmp_size; i_tmp_data.allocatedSize = 24; i_tmp_data.numDimensions = 2; i_tmp_data.canFreeData = FALSE; mpower(&i_tmp_data, c_y); fflt_size[0] = 1; fflt_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, fflt, &kd_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = fsed_data[d_y] + fflt_data[d_y]; } c_sqrt(c_y); sigma_size[0] = 1; sigma_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { sigma_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lq_emlrtRSI, emlrtRootTLSGlobal); if (arb == 1.0) { emlrtPushRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); b_sigma_data.data = (real_T *)sigma_data; b_sigma_data.size = (int32_T *)sigma_size; b_sigma_data.allocatedSize = 24; b_sigma_data.numDimensions = 2; b_sigma_data.canFreeData = FALSE; mpower(&b_sigma_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); h_tmp_size[0] = 1; h_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { j_tmp_data[d_y] = dv90[(int32_T)ip_data[d_y] - 1]; } k_tmp_data.data = (real_T *)&j_tmp_data; k_tmp_data.size = (int32_T *)&h_tmp_size; k_tmp_data.allocatedSize = 24; k_tmp_data.numDimensions = 2; k_tmp_data.canFreeData = FALSE; mpower(&k_tmp_data, c_y); fflt_size[0] = 1; fflt_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, fflt, &jd_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &td_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = fsed_data[d_y] + fflt_data[d_y]; } c_sqrt(c_y); sigma_size[0] = 1; sigma_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { sigma_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&mq_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&c_y); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } void CB_2008_nga(real_T M, real_T T, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T Sa_data[21], int32_T Sa_size[2], real_T sigma_data [21], int32_T sigma_size[2]) { real_T ffltz; real_T fhngr; real_T fhngm; real_T varargin_2; boolean_T Frv; boolean_T Fnm; int32_T iflg; int32_T i; real_T mtmp; boolean_T exitg6; boolean_T guard6 = FALSE; static const real_T period[24] = { 0.01, 0.02, 0.03, 0.05, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.5, 10.0, 0.0, -1.0, -10.0 }; int32_T i17; int8_T ii_data[24]; boolean_T exitg5; boolean_T guard5 = FALSE; int32_T loop_ub; int32_T tmp_data[24]; int8_T b_ii_data[24]; static const real_T dv1[24] = { 0.01, 0.02, 0.03, 0.05, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.5, 10.0, 0.0, -1.0, -10.0 }; real_T varargin_1_data[24]; const mxArray *y; static const int32_T iv85[2] = { 1, 36 }; const mxArray *m33; char_T cv122[36]; static const char_T cv123[36] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; const mxArray *b_y; static const int32_T iv86[2] = { 1, 39 }; char_T cv124[39]; static const char_T cv125[39] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'm', 'i', 'n', '_', 'o', 'r', '_', 'm', 'a', 'x', '_', 'v', 'a', 'r', 'D', 'i', 'm', 'Z', 'e', 'r', 'o' }; boolean_T exitg4; boolean_T guard4 = FALSE; const mxArray *c_y; static const int32_T iv87[2] = { 1, 36 }; const mxArray *d_y; static const int32_T iv88[2] = { 1, 39 }; int32_T varargin_1_size[2]; real_T sigma_low_data[1]; int32_T sa_low_size[2]; real_T sa_low_data[1]; real_T sa_hi_data[1]; boolean_T exitg3; boolean_T guard3 = FALSE; int32_T i18; boolean_T exitg2; boolean_T guard2 = FALSE; real_T c_ii_data[24]; int32_T ii_size[2]; real_T b_Ztor; real_T b_M; int32_T tmp_size[2]; real_T b_tmp_data[24]; emxArray_real_T *r41; real_T x[2]; emxArray_real_T *r42; int32_T Y_sa_size[2]; real_T Y_sa_data[48]; int32_T sigma_low_size[2]; real_T b_sigma_low_data[2]; boolean_T exitg1; boolean_T guard1 = FALSE; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* by Yoshifumi Yamamoto, 11/10/08 */ /* Stanford University */ /* yama4423@stanford.edu */ /* fix bug 2009/05/05 */ /* */ /* Campbell-Bozorgnia attenuation equation, 2008 */ /* */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* Input Variables */ /* M = Magnitude */ /* T = Period (sec); Use -1 for PGV computation and -10 for PGD */ /* computation */ /* Use 1000 for output the array of Sa with period */ /* Rrup = Closest distance coseismic rupture (km) */ /* Rjb = Joyner-Boore distance (km) */ /* Ztor = Depth to the top of coseismic rupture (km) */ /* delta = average dip of the rupture place (degree) */ /* lambda = rake angle (degree) */ /* Vs30 = shear wave velocity averaged over top 30 m (m/s) */ /* Zvs = Depth to the 2.5 km/s shear-wave velocity horizon (km) */ /* arb = 1 for arbitrary component sigma */ /* = 0 for average component sigma */ /* */ /* Output Variables */ /* Sa = Median spectral acceleration prediction */ /* sigma = logarithmic sdtandard deviation of spectral acceleration */ /* prediction */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ Sa_size[0] = 1; Sa_size[1] = 1; Sa_data[0] = 0.0; sigma_size[0] = 1; sigma_size[1] = 1; sigma_data[0] = 0.0; /* Coefficients */ /* Style of faulting */ if (Ztor < 1.0) { ffltz = Ztor; } else { ffltz = 1.0; } if (Rjb == 0.0) { fhngr = 1.0; } else if (Ztor < 1.0) { emlrtPushRtStackR2012b(&qp_emlrtRSI, emlrtRootTLSGlobal); fhngm = Rjb * Rjb + 1.0; b_sqrt(&fhngm); varargin_2 = Rjb * Rjb + 1.0; b_sqrt(&varargin_2); fhngr = (muDoubleScalarMax(Rrup, fhngm) - Rjb) / muDoubleScalarMax(Rrup, varargin_2); emlrtPopRtStackR2012b(&qp_emlrtRSI, emlrtRootTLSGlobal); } else { fhngr = (Rrup - Rjb) / Rrup; } Frv = ((lambda > 30.0) && (lambda < 150.0)); Fnm = ((lambda > -150.0) && (lambda < -30.0)); if (M <= 6.0) { fhngm = 0.0; } else if (M < 6.5) { fhngm = 2.0 * (M - 6.0); } else { fhngm = 1.0; } iflg = 0; if (T == 1000.0) { iflg = 1; /* Computation with original periods */ Sa_size[0] = 1; Sa_size[1] = 21; sigma_size[0] = 1; sigma_size[1] = 21; for (i = 0; i < 21; i++) { emlrtPushRtStackR2012b(&rp_emlrtRSI, emlrtRootTLSGlobal); CB_2008_nga_sub(M, 1.0 + (real_T)i, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm, &varargin_2, &mtmp); emlrtPopRtStackR2012b(&rp_emlrtRSI, emlrtRootTLSGlobal); Sa_data[i] = varargin_2; sigma_data[i] = mtmp; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } } if (iflg == 0) { Sa_size[0] = 1; Sa_size[1] = 1; sigma_size[0] = 1; sigma_size[1] = 1; /* interpolate between periods if neccesary */ iflg = 0; i = 1; exitg6 = FALSE; while ((exitg6 == FALSE) && (i < 25)) { guard6 = FALSE; if (period[i - 1] == T) { iflg++; if (iflg >= 24) { exitg6 = TRUE; } else { guard6 = TRUE; } } else { guard6 = TRUE; } if (guard6 == TRUE) { i++; } } if (1 > iflg) { i17 = 0; } else { i17 = iflg; } if (i17 == 0) { emlrtPushRtStackR2012b(&sp_emlrtRSI, emlrtRootTLSGlobal); iflg = 0; i = 1; exitg5 = FALSE; while ((exitg5 == FALSE) && (i < 25)) { guard5 = FALSE; if (period[i - 1] < T) { iflg++; ii_data[iflg - 1] = (int8_T)i; if (iflg >= 24) { exitg5 = TRUE; } else { guard5 = TRUE; } } else { guard5 = TRUE; } if (guard5 == TRUE) { i++; } } if (1 > iflg) { loop_ub = 0; } else { loop_ub = iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { tmp_data[iflg] = 1 + iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { i = 0; while (i <= 0) { b_ii_data[iflg] = ii_data[tmp_data[iflg] - 1]; i = 1; } } for (iflg = 0; iflg < loop_ub; iflg++) { ii_data[iflg] = b_ii_data[iflg]; } for (iflg = 0; iflg < loop_ub; iflg++) { varargin_1_data[iflg] = dv1[ii_data[iflg] - 1]; } emlrtPushRtStackR2012b(&eg_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fg_emlrtRSI, emlrtRootTLSGlobal); if ((loop_ub == 1) || (loop_ub != 1)) { Frv = TRUE; } else { Frv = FALSE; } if (Frv) { } else { emlrtPushRtStackR2012b(&gg_emlrtRSI, emlrtRootTLSGlobal); y = NULL; m33 = mxCreateCharArray(2, iv85); for (i = 0; i < 36; i++) { cv122[i] = cv123[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 36, m33, cv122); emlrtAssign(&y, m33); error(message(y, &kb_emlrtMCI), &lb_emlrtMCI); emlrtPopRtStackR2012b(&gg_emlrtRSI, emlrtRootTLSGlobal); } if (loop_ub > 0) { } else { emlrtPushRtStackR2012b(&hg_emlrtRSI, emlrtRootTLSGlobal); b_y = NULL; m33 = mxCreateCharArray(2, iv86); for (i = 0; i < 39; i++) { cv124[i] = cv125[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 39, m33, cv124); emlrtAssign(&b_y, m33); error(message(b_y, &mb_emlrtMCI), &nb_emlrtMCI); emlrtPopRtStackR2012b(&hg_emlrtRSI, emlrtRootTLSGlobal); } emlrtPushRtStackR2012b(&vo_emlrtRSI, emlrtRootTLSGlobal); mtmp = varargin_1_data[0]; if (loop_ub > 1) { emlrtPushRtStackR2012b(&kg_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&kg_emlrtRSI, emlrtRootTLSGlobal); for (iflg = 1; iflg + 1 <= loop_ub; iflg++) { if (varargin_1_data[iflg] > mtmp) { mtmp = varargin_1_data[iflg]; } } } emlrtPopRtStackR2012b(&vo_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&fg_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&eg_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&sp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&tp_emlrtRSI, emlrtRootTLSGlobal); iflg = 0; i = 1; exitg4 = FALSE; while ((exitg4 == FALSE) && (i < 25)) { guard4 = FALSE; if (period[i - 1] > T) { iflg++; ii_data[iflg - 1] = (int8_T)i; if (iflg >= 24) { exitg4 = TRUE; } else { guard4 = TRUE; } } else { guard4 = TRUE; } if (guard4 == TRUE) { i++; } } if (1 > iflg) { loop_ub = 0; } else { loop_ub = iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { tmp_data[iflg] = 1 + iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { i = 0; while (i <= 0) { b_ii_data[iflg] = ii_data[tmp_data[iflg] - 1]; i = 1; } } for (iflg = 0; iflg < loop_ub; iflg++) { ii_data[iflg] = b_ii_data[iflg]; } for (iflg = 0; iflg < loop_ub; iflg++) { varargin_1_data[iflg] = dv1[ii_data[iflg] - 1]; } emlrtPushRtStackR2012b(&xq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fg_emlrtRSI, emlrtRootTLSGlobal); if ((loop_ub == 1) || (loop_ub != 1)) { Frv = TRUE; } else { Frv = FALSE; } if (Frv) { } else { emlrtPushRtStackR2012b(&gg_emlrtRSI, emlrtRootTLSGlobal); c_y = NULL; m33 = mxCreateCharArray(2, iv87); for (i = 0; i < 36; i++) { cv122[i] = cv123[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 36, m33, cv122); emlrtAssign(&c_y, m33); error(message(c_y, &kb_emlrtMCI), &lb_emlrtMCI); emlrtPopRtStackR2012b(&gg_emlrtRSI, emlrtRootTLSGlobal); } if (loop_ub > 0) { } else { emlrtPushRtStackR2012b(&hg_emlrtRSI, emlrtRootTLSGlobal); d_y = NULL; m33 = mxCreateCharArray(2, iv88); for (i = 0; i < 39; i++) { cv124[i] = cv125[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 39, m33, cv124); emlrtAssign(&d_y, m33); error(message(d_y, &mb_emlrtMCI), &nb_emlrtMCI); emlrtPopRtStackR2012b(&hg_emlrtRSI, emlrtRootTLSGlobal); } emlrtPushRtStackR2012b(&vo_emlrtRSI, emlrtRootTLSGlobal); ffltz = varargin_1_data[0]; if (loop_ub > 1) { emlrtPushRtStackR2012b(&kg_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&kg_emlrtRSI, emlrtRootTLSGlobal); for (iflg = 1; iflg + 1 <= loop_ub; iflg++) { if (varargin_1_data[iflg] < ffltz) { ffltz = varargin_1_data[iflg]; } } } emlrtPopRtStackR2012b(&vo_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&fg_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&xq_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&tp_emlrtRSI, emlrtRootTLSGlobal); /* [sa_low sigma_low] = CB_2008_nga (M, T_low, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ /* [sa_hi sigma_hi] = CB_2008_nga (M, T_hi, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ emlrtPushRtStackR2012b(&up_emlrtRSI, emlrtRootTLSGlobal); CB_2008_nga_low(M, mtmp, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, sa_low_data, sa_low_size, sigma_low_data, varargin_1_size); emlrtPopRtStackR2012b(&up_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vp_emlrtRSI, emlrtRootTLSGlobal); /* by Yoshifumi Yamamoto, 11/10/08 */ /* Stanford University */ /* yama4423@stanford.edu */ /* fix bug 2009/05/05 */ /* */ /* Campbell-Bozorgnia attenuation equation, 2008 */ /* */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* Input Variables */ /* M = Magnitude */ /* T = Period (sec); Use -1 for PGV computation and -10 for PGD */ /* computation */ /* Use 1000 for output the array of Sa with period */ /* Rrup = Closest distance coseismic rupture (km) */ /* Rjb = Joyner-Boore distance (km) */ /* Ztor = Depth to the top of coseismic rupture (km) */ /* delta = average dip of the rupture place (degree) */ /* lambda = rake angle (degree) */ /* Vs30 = shear wave velocity averaged over top 30 m (m/s) */ /* Zvs = Depth to the 2.5 km/s shear-wave velocity horizon (km) */ /* arb = 1 for arbitrary component sigma */ /* = 0 for average component sigma */ /* d */ /* Output Variables */ /* Sa = Median spectral acceleration prediction */ /* sigma = logarithmic standard deviation of spectral acceleration */ /* prediction */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* Coefficients */ /* Style of faulting¸ */ if (Rjb == 0.0) { fhngr = 1.0; } else if (Ztor < 1.0) { emlrtPushRtStackR2012b(&qr_emlrtRSI, emlrtRootTLSGlobal); fhngm = Rjb * Rjb; if (fhngm + 1.0 < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } varargin_2 = Rjb * Rjb; if (varargin_2 + 1.0 < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } fhngr = (muDoubleScalarMax(Rrup, muDoubleScalarSqrt(fhngm + 1.0)) - Rjb) / muDoubleScalarMax(Rrup, muDoubleScalarSqrt(varargin_2 + 1.0)); emlrtPopRtStackR2012b(&qr_emlrtRSI, emlrtRootTLSGlobal); } else { fhngr = (Rrup - Rjb) / Rrup; } sa_hi_data[0] = 0.0; varargin_2 = 0.0; /* interpolate between periods if neccesary */ iflg = 0; i = 1; exitg3 = FALSE; while ((exitg3 == FALSE) && (i < 25)) { guard3 = FALSE; if (period[i - 1] == ffltz) { iflg++; if (iflg >= 24) { exitg3 = TRUE; } else { guard3 = TRUE; } } else { guard3 = TRUE; } if (guard3 == TRUE) { i++; } } if (1 > iflg) { i18 = 0; } else { i18 = iflg; } if (i18 == 0) { /* T_low = max(period(find(periodTeach))); */ /* [sa_low sigma_low] = CB_2008_nga (M, T_low, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ /* [sa_hi sigma_hi] = CB_2008_nga (M, T_hi, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ /* [sa_low sigma_low] = CB_2008_nga (M, T_low, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb); */ /* [sa_hi sigma_hi] = CB_2008_nga (M, T_hi, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb); */ /* x = [log(T_low) log(T_hi)]; */ /* Y_sa = [log(sa_low) log(sa_hi)]; */ /* Y_sigma = [sigma_low sigma_hi]; */ /* Sa(it) = exp(interp1(x,Y_sa,log(Teach))); */ /* sigma(it) = interp1(x,Y_sigma,log(Teach)); */ } else { iflg = 0; i = 1; exitg2 = FALSE; while ((exitg2 == FALSE) && (i < 25)) { guard2 = FALSE; if (period[i - 1] == ffltz) { iflg++; ii_data[iflg - 1] = (int8_T)i; if (iflg >= 24) { exitg2 = TRUE; } else { guard2 = TRUE; } } else { guard2 = TRUE; } if (guard2 == TRUE) { i++; } } if (1 > iflg) { loop_ub = 0; } else { loop_ub = iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { tmp_data[iflg] = 1 + iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { i = 0; while (i <= 0) { b_ii_data[iflg] = ii_data[tmp_data[iflg] - 1]; i = 1; } } for (iflg = 0; iflg < loop_ub; iflg++) { ii_data[iflg] = b_ii_data[iflg]; } emlrtPushRtStackR2012b(&pr_emlrtRSI, emlrtRootTLSGlobal); ii_size[0] = 1; ii_size[1] = loop_ub; for (iflg = 0; iflg < loop_ub; iflg++) { c_ii_data[iflg] = ii_data[iflg]; } if (Ztor < 1.0) { b_Ztor = Ztor; } else { b_Ztor = 1.0; } if (M <= 6.0) { b_M = 0.0; } else if (M < 6.5) { b_M = 2.0 * (M - 6.0); } else { b_M = 1.0; } d_CB_2008_nga_sub(M, c_ii_data, ii_size, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, b_Ztor, fhngr, (lambda > 30.0) && (lambda < 150.0), (lambda > -150.0) && (lambda < -30.0), b_M, varargin_1_data, varargin_1_size, b_tmp_data, tmp_size); emlrtPopRtStackR2012b(&pr_emlrtRSI, emlrtRootTLSGlobal); emlrtSizeEqCheck1DFastR2012b(1, varargin_1_size[1], &ub_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, varargin_1_size[1], &ke_emlrtBCI, emlrtRootTLSGlobal); sa_hi_data[0] = varargin_1_data[0]; emlrtSizeEqCheck1DFastR2012b(1, tmp_size[1], &tb_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, tmp_size[1], &je_emlrtBCI, emlrtRootTLSGlobal); varargin_2 = b_tmp_data[0]; } emlrtPopRtStackR2012b(&vp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&wp_emlrtRSI, emlrtRootTLSGlobal); if (mtmp < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } if (ffltz < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } b_emxInit_real_T(&r41, 2, &md_emlrtRTEI, TRUE); x[0] = muDoubleScalarLog(mtmp); x[1] = muDoubleScalarLog(ffltz); emlrtPopRtStackR2012b(&wp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&xp_emlrtRSI, emlrtRootTLSGlobal); iflg = r41->size[0] * r41->size[1]; r41->size[0] = 1; r41->size[1] = 1; emxEnsureCapacity((emxArray__common *)r41, iflg, (int32_T)sizeof(real_T), &md_emlrtRTEI); iflg = 0; while (iflg <= 0) { r41->data[0] = sa_hi_data[0]; iflg = 1; } b_emxInit_real_T(&r42, 2, &md_emlrtRTEI, TRUE); c_log(r41); iflg = r42->size[0] * r42->size[1]; r42->size[0] = 1; r42->size[1] = 1; emxEnsureCapacity((emxArray__common *)r42, iflg, (int32_T)sizeof(real_T), &md_emlrtRTEI); loop_ub = sa_low_size[0] * sa_low_size[1]; for (iflg = 0; iflg < loop_ub; iflg++) { r42->data[iflg] = sa_low_data[iflg]; } c_log(r42); Y_sa_size[0] = 1; Y_sa_size[1] = r42->size[1] + r41->size[1]; loop_ub = r42->size[1]; for (iflg = 0; iflg < loop_ub; iflg++) { Y_sa_data[iflg] = r42->data[r42->size[0] * iflg]; } loop_ub = r41->size[1]; for (iflg = 0; iflg < loop_ub; iflg++) { Y_sa_data[iflg + r42->size[1]] = r41->data[r41->size[0] * iflg]; } emxFree_real_T(&r42); emxFree_real_T(&r41); emlrtPopRtStackR2012b(&xp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&yp_emlrtRSI, emlrtRootTLSGlobal); if (T < 0.0) { emlrtPushRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); b_eml_error(); emlrtPopRtStackR2012b(&pd_emlrtRSI, emlrtRootTLSGlobal); } fhngm = b_interp1(x, Y_sa_data, Y_sa_size, muDoubleScalarLog(T)); Sa_data[0] = muDoubleScalarExp(fhngm); emlrtPopRtStackR2012b(&yp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&aq_emlrtRSI, emlrtRootTLSGlobal); sigma_low_size[0] = 1; sigma_low_size[1] = 2; b_sigma_low_data[0] = sigma_low_data[0]; b_sigma_low_data[1] = varargin_2; sigma_data[0] = b_interp1(x, b_sigma_low_data, sigma_low_size, muDoubleScalarLog(T)); emlrtPopRtStackR2012b(&aq_emlrtRSI, emlrtRootTLSGlobal); } else { iflg = 0; i = 1; exitg1 = FALSE; while ((exitg1 == FALSE) && (i < 25)) { guard1 = FALSE; if (period[i - 1] == T) { iflg++; ii_data[iflg - 1] = (int8_T)i; if (iflg >= 24) { exitg1 = TRUE; } else { guard1 = TRUE; } } else { guard1 = TRUE; } if (guard1 == TRUE) { i++; } } if (1 > iflg) { loop_ub = 0; } else { loop_ub = iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { tmp_data[iflg] = 1 + iflg; } for (iflg = 0; iflg < loop_ub; iflg++) { i = 0; while (i <= 0) { b_ii_data[iflg] = ii_data[tmp_data[iflg] - 1]; i = 1; } } for (iflg = 0; iflg < loop_ub; iflg++) { ii_data[iflg] = b_ii_data[iflg]; } emlrtPushRtStackR2012b(&bq_emlrtRSI, emlrtRootTLSGlobal); ii_size[0] = 1; ii_size[1] = loop_ub; for (iflg = 0; iflg < loop_ub; iflg++) { c_ii_data[iflg] = ii_data[iflg]; } e_CB_2008_nga_sub(M, c_ii_data, ii_size, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm, varargin_1_data, varargin_1_size, b_tmp_data, tmp_size); emlrtPopRtStackR2012b(&bq_emlrtRSI, emlrtRootTLSGlobal); emlrtSizeEqCheck1DFastR2012b(1, varargin_1_size[1], &rb_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, varargin_1_size[1], &he_emlrtBCI, emlrtRootTLSGlobal); Sa_data[0] = varargin_1_data[0]; emlrtSizeEqCheck1DFastR2012b(1, tmp_size[1], &sb_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, tmp_size[1], &ie_emlrtBCI, emlrtRootTLSGlobal); sigma_data[0] = b_tmp_data[0]; } } emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } /* End of code generation (CB_2008_nga.c) */