Difference between revisions of "CyberShake BBP Integration"
Line 117: | Line 117: | ||
getpar("scale","f",&scale);<br /> | getpar("scale","f",&scale);<br /> | ||
endpar();<br /> | endpar();<br /> | ||
− | + | <br /> | |
s1 = NULL;<br /> | s1 = NULL;<br /> | ||
s1 = read_wccseis(infile,&head1,s1,inbin);<br /> | s1 = read_wccseis(infile,&head1,s1,inbin);<br /> | ||
Line 133: | Line 133: | ||
getpar("scale","f",&scale);<br /> | getpar("scale","f",&scale);<br /> | ||
endpar();<br /> | endpar();<br /> | ||
− | + | <br /> | |
for(i=0;i<head1->nt;i++)<br /> | for(i=0;i<head1->nt;i++)<br /> | ||
...<br /> | ...<br /> |
Revision as of 22:11, 11 February 2020
This page details the process of integrating CyberShake with the Broadband Platform. The goals of this integration are both to enable CyberShake to produce stochastic high-frequency seismograms as a complement to deterministic low-frequency seismograms, and also to avoid having to repeat the same integration process we went through for CyberShake 1.4 and CyberShake Study 15.12 every time we want to use the BBP stochastic codes.
Approach
We have identified the following BBP executables, or elements, which are needed in CyberShake:
- srf2stoch (C)
- hb_high (Fortran)
- wcc_getpeak (C)
- wcc_siteamp14 (C)
- wcc_tfilter (C)
- wcc_resamp_arbdt (C)
- wcc_add (C)
- integ_diff (C)
As part of the BBP, each of these pieces of code contains a main() function, which typically works as follows:
main() { // Parse command-line parameters // Open and read input files into input data structure // Execute science kernel, populating output data structure // Open and write output files from output data structure }
For CyberShake, we would like to be able to use the science kernels of the BBP elements, but provide CyberShake-specific parameters, pass data structures around in memory between multiple elements, and read from and write to different data formats. To accomplish this, we propose extracting the science kernels from the main() functions and creating subroutines with them, separating the I/O from the scientific calculations. Following this approach, a revised main method would contain:
main() { // Open and read input files into input data structure science_kernel_subroutine(command-line arguments, input_data_structure, output_data_structure) // Open and write output files from output data structure }
Then, in the CyberShake codebase, we would use this function as follows:
// Open and read input files into input data structure // Allocate memory for output data structure // Create parameter string with CyberShake-specific parameters for getpar to parse science_kernel_subroutine(parameter_string, input_data_structure, output_data_structure) // Do additional processing with output data structure // Open and write output data structure to file
The intent is that these changes would be pushed out to the BBP codebase and also to Rob Graves, so that future revisions work from this refactored version and are straightforward to integrate with CyberShake.
Example
As an example, below we show the proposed modifications for wcc_getpeak.
Change | Old code | Modified code |
---|---|---|
Subroutine prototype | float wcc_getpeak(int param_string_len, char** param_string, float* seis, struct statdata* head1); | |
Extract science kernel into subroutine | ... |
... |
Relocate parsing of non-I/O parameters to subroutine | ... |
float wcc_getpeak(int param_string_len, char** param_string, float* s1, struct statdata* head1) { |
Here is possible CyberShake code which could use this modified code:
... float* seis = malloc(nt*sizeof(float)); fread(fp_in, sizeof(float), nt, seis); struct statdata head1; head1.nt = nt; char** param_string = NULL; float peak = wcc_getpeak(param_string, 0, seis, &head1); ... <pre>