Aa2dHH $ dR     dFootnote TableFootnote**. . / -  ]&^}LOT TableTitleLOFFigureTOC1Heading2Heading3Heading + U  V  W  X  Y  Z  [  \  ]  ^  _    Ž  L N % k 4    z `  4 ]W  `  D o 854219: AppendixHead: Appendix I A Sample Strategy Module ci})70603: AppendixHead: Appendix II module.hP G+O=23155: AppendixHead: Appendix III Pipeline Interface main_svc )62344: 2Heading: 2.3 Dataset name service U e ` U  V  W  X  Y  Z  [  \  ]  ^  _  854219: AppendixHead: Appendix I A Sample Strategy Module tno)70603: AppendixHead: Appendix II module.h  =23155: AppendixHead: Appendix III Pipeline Interface main_svc} LO)62344: 2Heading: 2.3 Dataset name serviceO <$marker1>di <$marker2> <$paratext[Title]> <$paratext[1Heading]> <$curpagenum> Z<$lastpagenum><$monthname> <$daynum>, <$year>^ (Continued)+ (Sheet <$tblsheetnum> of <$tblsheetcount>)Pagepage<$pagenum>Heading & Page <$paratext> on page<$pagenum>]WSection & Page%Section<$paranum> on page<$pagenum>pSee Heading & Page%See <$paratext> on page<$pagenum>.: Table & Page'Table<$paranumonly> on page<$pagenum>i Figure & Page (Figure<$paranumonly> on page<$pagenum>4:Heading3<$paranumonly>rvSectionUSection<$paranum> !  ``A bb ee ff:Ap hhnx kkty mnA pppdi ss m TOC iLOF: A eLOTInt }IX 2A: @ E3 D &me  2.1.9 E E>di E$ma E Eate E> E$pa Eead C Lpag &2.1.6> E (me> &>, 2.1.7(Co )ed) <(Sh (she * <$ <oun + <e ,gen -He 0age 1tex 2ge T>]W ^tio .%Se /ara 3age 4m>p 5 He 6age 7par 8n p &enu2.1.1 Pa Yabl Iumo 'age1m>i K Fi Lge '<$p2y> K >>4:2.13 Kanu C EU E$pa E &2.1.2A &2.1.4 $eAppendix IIIAp E &x  2.1.10y L EA Kp E s   TO >2.2LO K &e2.2.1  EIX E & 2.2.2& E E1.9 E E>di E$ma E 'ate3> >E2.3ead KC >L2.4 K K> L  3.1 1.73.1.1< K L 3.1.3 L< ,3.1.4 Kage  tex3.2 '>]W4tio K. L/  34.1m>p K5 K6  74.2n p K& L L Pa  4.3' K LK LL L' '25 K>  5.1anu  C5.2U $E Appendix I % %2 %& % % % %ix %E %& % %y % % % % % %  %> % %K %& % %  % % % %2.2 % %1.9 % %>di %$ma % %ate %> % %ead !% "% #% $% %% &% '% (% )% *%1.1 +% ,% -% .%3 /%L 0% 1% 2% 3% 4% 5% 6% 7%K 8%L 9% :% ;%K <%K =% >% ?%K @%L A%L B% C% D%K E%L F%L G%L H%' I%5 J%> K% L%5.1 M%C N%5.2 O%E P%pen Q%% R%% S%% T%% U%% V%% W%% X%% Y%% Z%% [%% \%% ]%% ^% % _% % `% % a% % b% % c%% d%% e%% f%% g%% h&%2.4.2 iK jC2.2 kC l>1.92.5 mK>di nC$ma oC pLate q%> r% s%ead tL uL vC wL xC yK zC {C |$Appendix II }% ~% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % L L4.2 % %2.2 % %1.9 %2.5 %>di %$ma % %ate %> % %ead 9 C  xC C  |$ penI %  % L C %  % %  L% %3.1.2 K C C C C C C C C C C C C C & 2.4.3% C &2.4.1 K% C% C% C% C% C% C% C% C% C% C% C% C% C% K% %% %% %% K% C% E% E% E% E% E% EL EL E% E% E% E% E% E% E% &%2.1.3 C> % E C E E E E E &2.1.5 C CI C C C C E !E "E #E $E %E &E 'E (EL )E *E +E ,E -E .E /E 0E 1L 2E 3&2.1.8 4CC 5CC 6CC 7CC 8C& 9C :C% ;C <C =C4.1 >C% ?C% @C% AC% BC% CC% D%C EL FC GL HC IK J% KL L% M% NC OC PC QC R% S% T% U% V% W% X% YK Z% [% \% ]% ^% _K `% a%1.3 b%> c% d%E e%C f%E g%E h%E i%E j%E k%& l% m% n% o% p% q% r% s% t% u% v% w% x% y% z% {% |% }% ~% % % % % % % % % % %1.8 %C %C %C %C %& % %% % % L4.1 C% L% >%2.6 &%2.6.1D C C C C C K C &2.6.2M% K C C C C L % L L C C C C C C C C C C C C C C C C C C C E E E E E C C C E E E E E E E E E EAodA`edBfkdCDD6h\V0DC 6h\V0F &LUU` n)SDS *sds_read (char *filename, int type) %` 3wLow-level I/O routines C-UU` 4n6int sds_flip (void *data, long length, int num_bytes) <UU` 5n int sds_flip_data (SDS *sdsptr) KUU` 6n.int sds_get_fits_data (FILE *fp, SDS *sdsptr) ZUU` 7nC0int sds_get_fits_header (FILE *fp, SDS *sdsptr) iUU` 8nC,int sds_output_data (SDS *sdsptr, FILE *fp) CxUU` 9n/int sds_output_headers (SDS *sdsptr, FILE *fp) CUU` :n.int sds_put_fits_data (SDS *sdsptr, FILE *fp) UU` ;n0int sds_put_fits_header (SDS *sdsptr, FILE *fp) UU` n&SDS *sds_read_header (char *filename) UU` n=SDS *sds_read_raw (SDS *sds, FILE *encfile, char *firstline) ` w3Routines to query and set the statistics structure ۪UU` <n!char *sds_kurtosis (SDS *sdsptr) ꪞUU` =nchar *sds_max (SDS *sdsptr) UU` @nchar *sds_mean (SDS *sdsptr) UU` >nhachar *sds_min (SDS *sdsptr) UU` ?nle char *sds_min_abs (SDS *sdsptr) 4&UU` An ( char *sds_numvals (SDS *sdsptr) yt5UU` Bn 5char *sds_rms (SDS *sdsptr) sdDUU` nUU"int sds_stats_valid (SDS *sdsptr) SUU` Cn) !char *sds_skewness (SDS *sdsptr) ibUU` np,8void sds_update_stats (SDS *sdsptr, SDS_STATS *statptr) (SqUU` nfpchar *sds_stdev (SDS *sdsptr) ` wSDIDS manipulation routines UU ninZAn IDS is a collection of SDS's. The SDS functions can be used to operate on the individUU nfp[ual SDS's and top level routines can be developed to operate on the collection as a whole. s_rUU@ n F?This set of routines is under development and not well tested. qu˪UU` nat iڪUU` n%int ids_add_sds (IDS *ids, SDS *sds) D骏UU` n%int ids_delete_sds (IDS *ids, int n) rUU` n @void ids_free (IDS *ids) sUU` nUU8int ids_get_series (IDS *ids, FILE *fp[], int numFiles) leUU` ns @int ids_get_series_headers (IDS *ids, FILE *fp[], int numFiles) tr%UU` n BIDS *ids_init () 4UU` n/int ids_insert_sds (IDS *ids, SDS *sds, int n) r) CUU` n) int ids_length (IDS *ids) RUU` nUU5SDS *ids_merge_series (IDS *ids, int start, int end) dEchFFspHh\V0FE puHh\V0DH DS#coUU` n #SDS *ids_nth_sds (IDS *ids, int n) ateUU` nmodule.hndeclarations required for Strategy Modules UU`  Bpe.hdeclarations required for Pipeline Execution elements UU` ro;pe_hdata.hadditional decalarations required for PEs UU` fuLsoi_dbquery.hnfunctions supporting SQL queries to relational databases vi#UU` edKsoi_lago.hnfunctions supporting use of the Lagon datawheel dedMsoNNnsHh\V0NM asHh\V0LP ms#UU nen[None of the libraries described in the above special-purpose files would generally be used UU nso\by analysis functions; their purpose is to describe system support functions and to support leUU@ nal.development of strategy and interface levels. 6UU` nThlA template file template.hn exists in SOIROOT/includen for the creation of new include files. UUM` wInclusion of .hxx files edZUU` nul[NOT YET IMPLEMENTED] q` wat Messages eUU necZThe issuance of messages by functions to report abnormal situations, recording of version UU nUUYor other information, and for debugging purposes, should be handled through the supplied UU nsonlibrary routines history()n and errorlog()n. These routines are in fact pointers to other norUU n[mal I/O routines declared in the user interface as appropriate and bound at load time. For UU nNohexample, errorlog()n might be aliased to printf ()n by an interactive command line inter ƪUU@ nfu@face but to fprintf (logfile, )n by a pipeline program. t` w"Return value and type of function ꪟUU nveaFunctions should generally be typed as intn and return a status value (0 on normal completUU n iYtion without noted exceptions). If a return status is inappropriate, functions should be YUU nbtyped as voidn. In either case, a full parameter typing declaration of the function should UU n rgappear in the include file soi_fun.hn if the function is to be incorporated in the SOI library, dleUU@ nli*for use in strategy modules for example.. 8UU` v aWriting FORTRAN functions HUU` nacDont bother. l` uUUStrategy Layer roUU n tYWe have defined a separate Strategy Layer as a way of isolating the requirements of data lUU nnQset management from the Function Layer and of communicating the Function requireUU nfaYments to the operating environment. The essential purpose of a Strategy Module is to crenUU n f]ate the appropriate argument list for the function(s) it calls. Since Functions are expected tUU norYto operate on internal data structures, this means that the Strategy Module must resolve pUU@ nns^references to externally represented data (e.g.n files) and perform the necessary I/O. تUU( ne dA sample Strategy Module is illustrated in Appendix  I . The essential features of a Strategy to䪑UU nn UModule are discussed here in the context of that example. A few other sample modules UU@ nWr5may be found in the same examplesn directory. hUU` v Include files UU nUUhInclusion of the general file soi.hn should suffice, except for other required libraries for sys*UU nmahtem-provided functions, such as stdlib.hn and math.hn. Here, however, we mention only the t6UU@ nonHsubsets of soi.hn that are specifically required in all modules. dO lPP) 6h\V0PO ct6h\V0NR te,atUU( n miThe module.hn file (shown in Appendix  II ) defines the argument structure, prototypes as UU ns)Yan external the main program (program interface) to which the module must be linked, and eUU nIZdeclares the required external argument lists. It also includes the nearly essential file *UU thvsoi_names.hn and the typically used soi_fun.hn and soi_sds.hn described above. . soi_names.hn 6UU nIndincludes soi_key.hn, which is often used in processing the params and results lists. Thus in orBUU@ nbr@general the required module.hn inclusion should suffice. a`UU` v aDeclarations and externals verpUU nth[The strategy module name should be declared as a global character string constant. This is les|UU nUrequired by the pipeline for information as to which program is executing. In future \UU n[releases it may also be used in references to a data keyword dictionary. Within the module IUU n iit can be used in the same way that argv[0]n would normally be used in a mainn program run tUU n mYin the shell. Obviously strategy module names should be unique within the context of the UU nne[SOI analysis pipelines.. It is also desirable to have the corresponding executable program hUU@ n.h&names correspond to the module names. ЪUU n ZThe arguments list is a specially defined structure containing information about the arguܪUU nUments that the module requires in order to run. Arguments may be of many types; they 誚UU nDeUhave keynames and declared types, and may optionally have default values and maximum cUU nchXand minimum valid values. All values are in the form of strings, and for numeric values orUU n pnthe appropriate atoi()n or atof()n calls are relied upon. Note that some string must be present  UU nhi\for every field, even optional ones; a null string is used when no default or range restricd UU nn Wtion is applicable. The strategy module assumes that values have been supplied for all na$UU nueZarguments by the program in the Use Layer. Note that the last entry in the arguments list 0UU nrrSmust always be of type ARG_END (its associated key name and values are ignored). nam<UU n SThe arguments will have corresponding keys placed in the keylist argument params t tHUU@ nUUavailable to the module. d`UU nde[The supported argument types are listed in module.hn and they should mostly be self-redlUU ntiPexplanatory. Arguments of type ARG_DATASET contain a name that can be parsed to luxUU n i^describe a dataset suitable for input or output using the SDS library routines; it could be a UU nQsimple filename, or a descriptor obeying the SOI dataset naming conventions (see iUU n eW Section2.3 ). Arguments of type ARG_FILEPTR contain names of files that can be UU nicaopened by the simple fopen()n function, and may be defined to have their references point rUU n ito the interactive file descriptors stdinn and stdoutn under certain interfaces. In future UU ns Wreleases, the functionality of these two types of arguments may be combined. The types havUU nysKARG_DATASET_IN and ARG_DATASET_OUT are reserved for future use and not curo t̪UU@ nrently supported. 䪇UU nypPArguments of type ARG_INT and ARG_FLOAT describe integer and floating-point val UU n A]ues respectively of the longest native representation (long int and double). The only way to iUU nblZprovide an integer value larger than the longest signed integer is as an argument of type UU na SARG_FLOAT. It is assumed that arguments of type ARG_FLAG are restricted to the valSeUU@ nguKues 0, n1. Arguments of type ARG_TIME are not currently supported. ,UU ne YFollowing the body of the strategy module (usually at the end of the file) is a required 8UU nhebbinding of the strategy module to an external named procedure DoIt()n. This binding allows DUU ns Wthe particular strategy module to be linked with a common interface program,the driver havPUU nys[program in the Use Layer. The driver program assumes the responsibility for satisfying the @ dQUURR tHh\V0RQ iHh\V0PT UU' AUU n oXstrategy modules arguments list and also providing bindings to the keylists and output UU@ nnt>functions that comprise the arguments to the strategy module. 0UU` vModule parameters @UU n tWEvery strategy module has four parameters: the two keylists params and results and LUU n oWthe two output functions history and errlog. (Of course the names are only defined of XUU@ ne +internally; these names are illustrative.) d pUU nheXThe keylist params has a set of parameter names and values available from the calling ng|UU nUUaprogram, such as main()n in the shell. There is not a one-to-one mapping between the parvUU nysWams list and the arguments list. Some or all of the argument values may be supplied theUU n[from the params list, and there may be values available on the params list which are not V0UU nYrequired module arguments. Thus in the example the verbose option, supplied in the shell iUU@ niscenvironment by providing the flag -vn, is not a required argument, but is still available.. 0ĪUU nMoZThe module can also make a keylist available to its driver by filling the contents of the ЪUU@ n bpointer to the keylist results. Processing of that keylist is the responsibility of the driver. 誜UU nefbThe two virtual output functions history and errlog provide printf()n-like output chanUU n hXnels while deferring the choice of how to handle the output to the driver program. TypiprUU nmucally a main()n program in the shell might bind one to fprintf(fileptr,)n and the other to fprintf g UU  o`(stderr,)n, or possibly choose to ignore them. A strategy module should avoid the use of the erUU naifunctions printf()n and scanf()n. Likewise, default file pointers stdinn, stdoutn, and stderrn $UU nheZshould never appear in the body of a strategy module, along with any other functions such 0UU@ nll'as getchar()n that assume them. moT` u aInterface Layer tlUU nll_The Interface Layer is the user interface to the Strategy Layer. It is intended that the Stratt kxUU non\egy Layer can provide access to the SOI analysis functions for a variety of user interfaces erUU npr[(such as the graphical interfaces forming an essential part of various analysis packages). andUU nheYTwo interfaces are essential however and are being developed by the project. These are a iUU nWcommand interface, for use with operating system shell commands, and an interface to a or UU@ n i-compiled task management pipeline procedure. uƪUU` vCommand interface ֪UU nn^The command-line interface is implemented as a normal interactive main()n program that ⪍UU nUU^operates on its command-line argument list. The main()n program assembles its argument UU n hlist (argvn) into a keylist of parameter values, typed either as strings or (in the case of flag llUU nyesor switch values) as chars, via the function CollectParams()n in libastn. The main()n program rovUU nSO^then checks the required arguments list (in the extern array arguments[]n) against its UU nrm\parameter list. If a required argument is not supplied on the command line, its value will reUU@ n abe supplied from, in turn, pr0UU` Dn ia parameter file; or o?UU` northe environment; or stNUU` n a-the default value in the arguments array; or odSocTT 6h\V0TS UU6h\V0RV pl$d UU` nct"prompting the user interactively. UU tnop\The searching order for parameter values is such that once a valid value is encountered the *UU tnli[search for that parameter ceases. Thus, the interactive prompt will only occur if no value of6UU tnUU]has been specified as a default in the argument array in the module. If prompting is forced, BUU@ tnnIit will continue until a nun-null string is supplied from stdinn. iZUU 1n bOnce the argument list is satisfied, the main()n program then parses dataset names and corfUU 1nom_rects data types before passing the arguments list in the call to the strategy_level function. n irUU 1n; XAlthough the interface program would be the logical place to check for whether supplied t~UU 1n; ^argument values are within their acceptable ranges as specified in the argument list, this is UU@ 1n0not currently done. UU` EnHParameter values on the command line are normally specified in the form seUU` Fpa key= valuen or key=value v̪UU Gnun\(the white space following the = sign is optional). Parameter values in a parameter file ptتUU Gnf [are specified in the same way, one per line. The only exceptions are arguments declared to e m䪜UU@ Gng Rbe of type ARG_FLAG, which may only be declared on the command line in the forms: UU` Hn-keyn or +key UU unUUYKeynames of flag arguments are restricted to single letters. Command line symbols of the UUU@ untaform b,UU` xnar-xyz DUU wno uare interpreted to concurrently set the values of flag arguments xn, yn, and zn to -1. An excepkPUU wnieZtion is provided for printer names, which may be specified on the command line in the typ\UU@ wn, ical shell format: @ 1nUU` vny -Pxxx UU nPaWArgument values are placed in the users shell environment with the normal external compaUU@ nr 'mands, e.g.n (for the c shell): e UU` insetenv keyname value .UU` ynin pªUU nSA few command line flags and arguments relate to the operating environment and are e aΪUU nto_always meaningful to the main()n program itself, regardless of their use as arguments. theڪUU@ nUU They are: 쪌UU` Pn -qset query mode UU` Nn a-vset verbose mode d  UU` On C-sset silent mode f tUU` Qn u9param=name of file to be read for additional parameters (UU` znto9history=name of file to be used for the history channel 7UU` {n8logfile=name of file to be used for the errlog channel fdUciVVneHh\V0VU icHh\V0TX -P*x UU nPa\The history and logfile parameters can also be specified in a parameter file or in the enviUU nmaVronment in the same way as normal arguments. The parameter file name can be specified UU@ ninDin the environment, but it requires a special environment variable: e 0UU` nv#setenv PARAMFILE paramfilename ntoHUU nl ^In query mode, the full argument list is printed out, together with the parameter values that TUU nXwould be supplied from the environment or by default, but the function is not executed. UU`UU nilcThus, it is impossible to use the "qn" flag as an argument to a strategy module. In verbose UUlUU nnemode, the values and sources for all arguments are sent to stderrn prior to invocation of the fxUU@ nnestrategy module. UU nci\Verbose and silent modes also affect the binding of the *history() and *errlog() functions. UU nnBy default, the history channel is stdoutn and the errlog channel is stderrn. Either or both of UU nma[these channels can be redirected to write on a specified file with the history and logfile UU nhe[parameters. In verbose mode, however, the history channel is unconditionally redirected to PARUU@ nleMthe errlog channel, while in silent mode output to both channels is ignored. oتUU KnthlWith the exception of flags qn and Pn, the command line interface does not interfere with the nc䪛UU KnedXuse of any symbols as argument names, but it would clearly be unwise for a strategy modt UU KnleZule to use the other reserved names for arguments of substantially different purpose from UU Kn Ztheir command line interpretations. Note that there is nothing to prevent the same single-UU KnodUcharacter symbols from being used as both flags and parameters, so a strategy module UU@ KnthNcould use qn or Pn as the names for arguments of non-flag type. ,UU nkThe command line interface allows customary shell redirection of files to stdinn and stdoutn 8UU nheXfor any arguments of type ARG_FILEPTR, provided that the default values of the relevant toDUU n ]arguments have been specified as either < or >, respectively. If filenames are specified UPUU n eVfor the values of arguments of type ARG_FILEPTR, the files will be opened with a type \UU n_specified in the mimimun valid valuen field in the argument list, or r (read-only) by mohUU@ n KHdefault. This is obscure, but the required C declaration looks natural. ifUU` vm Pipeline interface ZthUU InntWThe Pipeline Interface allows strategy modules to be run in a pipeline environment speUchUU InomWcially designed for efficient use of computational resources. The pipeline environment ld UU InTminimally consists of a Pipeline Execution (PE) module running a number of strategy liUU Ins [modules as defined in a pipeline map file. The map file defines which strategy modules are nheƪUU Ins Wto run, the order of execution, and the machines to be used. When a strategy module is n ҪUU Inee\complete, its output is available as the input of the next strategy module. In this way the eުUU Inf Ydata can be visualized as flowing down a pipe of strategy level modules. Multiple copies pꪈUU Inm[of the same strategy module can be run in parallel in the same or different host machines, n KUU@ In oKwith each strategy module working on different files of the input dataset. PiUU Ynth^In order to interface a strategy layer module with the pipeline, it is only necessary to link UU Ynjthe strategy module with the pipeline interface module, main_svcn (see Appendix  III ). This  UU YnTforms a Parallel Virtual Machine (PVM) task which can be spawned by and communicate li,UU@ Yns Iwith PE. The strategy module becomes a pipeline server to the PE client. a>UU _nheZPE will first request the strategy modules argument list. It will satisfy this list from JUU _n [parameters specified in the pipeline map file, or use the default values given in the arguuledW IXXal6h\V0XW 6h\V0VZ  IUU _nstYment list. Any dataset names are resolved via environmental variables defined in the map UUU _nh Tfile, or by SQL requests to the Data Storage and Distribution System (DSDS) server, thUU _rf^dsds_svcn, as specified in the map file. The resolved arguments are passed to the strategy *UU _nulWserver as a keylist in the same form as done in the command interface discussed above. 6UU@ _nfo[The status integer and output keylist from the strategy module are then passed back to PE. UUdYduZZseHh\V0ZY UUHh\V0X\ gy0eh ut  A Sample Strategy Module UU` qpa/* ers+UU` qpi/* e m7UU` qe , * reflect.c~soi/(level)/src/examples CUU` q * OUU` qalH * This is a sample strategy module. It reflects all the members of a [UU` q) * data series about a selected axis. agUU` qvi, * Library functions used ("illustrated"): sUU` q, E *getkey_int, sds_in, sds_sizeof, sds_datatype, sds_data, sds_rank, eUU` qUUG *sds_length, sds_replicate, sds_set_data, sds_set_attribute, sds_out ntsUU` q s * UU` qse; * Responsible: Rick BogartRBogart@solar.Stanford.EDU erfUU` qe. * 6UU` qTh * Usage: gerUU` qt  * reflect in= [out= axis=] paǪUU` qUU * ӪUU` q. * Parameters: (type default description) ߪUU` qUU( *inDataSet(none)the input dataset gy몙UU` q. *outDataSetmirror.fitsthe output dataset UU` qrs& *axisint0the axis of reflection UU` qec * UU` qxa * Bugs: UU` q *M * The module exists as a heuristic example and is of limited usefulness. l'UU` qE * Assignments are done byte-wise, so not particularly efficient. 3UU` qLiM * The bulk of the program might be better implemented as an sds function s?UU` qdsF *[data_reflect (SDS *in, SDS *out, int reflection_axis)] if it were KUU` qt_4 *useful, greatly simplifying the strategy module. sWUU` q * ` cUU` qbl( * Revision history is at end of file. DUoUU` q  */ *{UU` q % /* required .h inclusion */ UU` q= #include UU` q UU` q *#define VERSION_NUM(0.8) dUU` q UUU` qtaO /* required module name (comparable to argv[0] in shell environment) */ theêUU` q"char strategy_name[] = "reflect"; ϪUU` qn , /* required arguments list */ xa۪UU` !qargument arguments[] = { u窄UU` "qri# {ARG_DATASET, "in", "", "", ""}, nesUU` #q / {ARG_DATASET, "out", "mirror.fits", "", ""}, t pUU` $qen" {ARG_INT, "axis", "0", "0",""},  UU` %qm  {ARG_END, "", "", "", ""} aUU` &q}; UU#UU` 'q_r% /* strategy module body */ o/~UU` (qe Lint reflect (KEY *params, KEY **results, int (*history)(), int (*errlog)()) ;}UU` )q *{ G|UU` *qbl SDS *in, *out; od[UU\\6h\V0\[ .h6h\V0Z^ lu2duUU` +qUUC int i, j, k, n, key_axis, dsize, rank, plngth, n_above, n_below; UU` ,q int *length; O UU` -qdu char *nd, *od, *infile; *UU` .qnm char comment[64]; UU6UU` /qat _BUU` 0q; * key_axis = getkey_int (params, "axis"); NUU` 1q *& infile = getkey_str (params, "in"); ZUU` 2q! in = sds_in (infile, SDS_ANY); fUU` 3q* dsize = sds_sizeof (sds_datatype (in)); rUU` 4q},: /* alternatively, use sds_numbytes (in); */ ~UU` 5qm  od = sds_data (in); UU` 6qUU rank = sds_rank (in); UUUU` 7q/* length = sds_length (in); ~UU` 8qin if (key_axis >= rank) Y UU` 9qis { ),UU` :q key_axis = rank - 1; |ƪUU` ;q M (*errlog) ("Warning from %s: requested reflection axis reduced to %d\n", ҪUU` <qstrategy_name, key_axis); ުUU` =q } ꪗUU` >q + UUU` ?q,  out = sds_replicate (in); nUU` @q. nd = malloc (dsize * sds_data_length (in)); UU` Aqar sds_set_data (out, nd); UU` Bqar: sprintf (comment, "reflected about axis %d", key_axis); &UU` CqkeB sds_set_attribute (out, "SOURCE", infile, SDS_STRING, comment); 2UU` Dq >UU` Eq =: /* Effective function data_reflect() begins here */ JUU` Fqta plngth = length[key_axis]; ,VUU` Gqal n_above = 1; sdsbUU` Hq/ " for (i=key_axis+1; i<$paratext><$pagenum> ` m^"<$paranum><$paratext><$pagenum> )US UT`  R"<$paranum><$paratext><$pagenum> HnVbC ^ RuHwHwTable of Contents Specification HR- ^HR- teUU` n"<$paranum><$paratext><$pagenum> HP> ^ HHList of Figures SpecificationHR6 HR6  vUU` n"<$paranum><$paratext><$pagenum> HP>Jh ^ HHList of Tables Specificationd;H~ H~ e` x1, 23 ` x$<$symbols><$numerics><$alphabetics> ` x Level3IX &` x Level2IX 0` x$p Level1IX pC` wLSymbols[\ ];Numerics[0];A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z $pL` x> <$pagenum> ^HlAmN ^ HuHueIndex SpecificationHdc_ UUc_ > P>  o Programming in the SOI Analysis Li" @ oif Environment R>` p!R. S. Bogart & J. Aloise et al.? XUU` vSOI Technical Note TN-93-107 avUU n$pUThis note describes a layered approach to the development of analysis software to be eUU nQused in the pipeline reductions and analysis of data from the Solar Oscillations UU n]Investigation. Four layers are defined: a library layer, a function layer, a strategy layer, bUU nlpZand an interface layer. The layers are designed to use the internal standardized data set UU nQrepresentation and the dataset naming scheme. By encapsulating and standardizing ;UU nQsystem-dependent features such as data I/O and communication between program and ĪUU nicRuser we have sought to provide a platform in which analysis software from various ѪUU@ nUU1sources can be incorporated with minimal effort. >HhX inHhX Enen` u Introduction aUU nalVThe SOI software package has been designed to simplify the generation of analysis pro+UU nd Wgrams that can be used interchangeably in both pipeline and various exploratory envi pi7UU nanZronments. We have also attempted to standardize the treatment of data in order to isolate CUU na Wsystem dependent input-output functions and particularly to support the use of an autoe lOUU nreYmated data service. These twin aims of interoperability and I/O independence have led us d[UU ng Zto build a modular system with four software layers: a library layer, a function layer, a gUU nnd[strategy layer, and a program interface layer. The layers make use of an internal standardatfsUU@ nsiTized data set representation and the dataset naming scheme defined for the project. eUU n[The function layer is the heart of the analysis software from the algorithmic viewpoint. A u UU nVcontributor of analysis software need be aware only of the constraints and interfaces UU nb\imposed on this layer. On the other hand, by following a simple template it is very easy to atUU nYwrite a strategy module implementing the desired function, so in practice many functions rUU nYmay only exist within the corresponding strategy modules unless they are required in diffǪUU@ nferent implementations. erߪUU pnimbThe programs and structures described here exist in the an-release version 0.8 of SOI soft몛UU pnwaUware of 5 May. 1994. Future releases will be accompanied by updated versions of this nUU@ pnacdocument as required. ` ul Library Layer 3UU nizYThe library layer consists of the elementary functions required to manipulate data struc?UU nfu[tures and to provide interfaces to the query language, together with basic numerical, mathKUU@ nri%ematical, and statistical functions. edfab6h\V0 he6h\V0 is&eaUU` vUUSDS UU n m[The routines to support manipulation of SDS internal data structures are listed below. man Yma"UU nn [pages should be consulted for detailed information. Access to theses functions is provided ent.UU@ nerMby linking with the library libsds.an and including soi_sds.hn E` wrsSDS creation and allocation UUUUU` n5 SDS *sds_create() dUU` nom"SDS_STATS *sds_create_stats(void) sUU` nacint sds_free(SDS *sdsptr) UU` nLi$int sds_free_attr(ATTRIBUTES *attr) liUU` nts!int sds_free_dim(DIMENSION *dim) eUU` nta'ATTRIBUTES *sds_malloc_attribute(void) o pUU` nto%char *sds_malloc_data(int numobytes) cUU` n&DIMENSION *sds_malloc_dimension(void) ͪUU` n e!int *sds_malloc_length(int rank) aܪUU` n'char *sds_malloc_string(int numochars) 6` w)Utilities for creating complete datasets UU` nHSDS *sds_construct (int rank, int *length, int datatype, void *fillval) ruUU` nbe-int sds_copy_attrs(SDS *sdsin, SDS *sdsout); b!UU` nta!SDS *sds_dup_header (SDS *sdsin) f0UU` nedDSDS *sds_make_sds (int rank, int *length, int datatype, void *data) a?UU` noi SDS *sds_replicate (SDS *sdsin) SDNUU` noc%SDS *sds_short_template (SDS *sdsin) ce` wUUData conversion utility reuUU` n-int sds_convert (SDS *sds_in, int type_out)0 UU` nin1int sds_fill_data (SDS *sdsptr, void *fillvalue) UU` n_d0SDS *sds_slice(SDS *sds, int *start, int *end); ESUU` nbu4SDS *sds_slice_file(FILE *fp, int *start, int *end) a(` wC++ style access functions sdsɪUU` nvo double sds_bscale (SDS *sdsptr) _mتUU` nandouble sds_bzero (SDS *sdsptr) ds_窐UU` nnuvoid *sds_data (SDS *sdsptr) UU` nea"long sds_data_length (SDS *sdsin) UU` n_cint sds_datatype (SDS *sdsptr) intUU` nil#int sds_dim_n (SDS *sdsptr, int n) _co#UU` nn,int sds_dim0 (SDS *sdsptr) ` 2UU` n_hint sds_dim1 (SDS *sdsptr) UUAUU` n_mint sds_dim2 (SDS *sdsptr) h, PUU` n *"void *sds_fillvalue (SDS *sdsptr) d_sHh\V0 Hh\V0D &UUUU` ncoint *sds_length (SDS *sdsptr) UU` n int sds_numbytes (SDS *sdsptr) ptr$UU` n int sds_rank (SDS *sdsptr) s_s3UU` n *int sds_sizeof (int datatype) BUU` n_s(SDS_STATS * sds_stats_ptr (SDS *sdsptr) a(Y` w'Routines for setting structure members UUiUU` nds(int sds_set_data (SDS *sds, void *data) anxUU` n .int sds_set_datatype (SDS *sds, int datatype) UU` n 2int sds_set_fillvalue (SDS *sds, void *fillvalue) UU` n +int sds_set_length (SDS *sds, int *length) UU` nsd.int sds_set_numbytes (SDS *sds, int numbytes) UU` n (&int sds_set_rank (SDS *sds, int rank) ` wds Attribute manipulation routines sd۪UU` (nr),char *sds_attrcomment (ATTRIBUTES *attrptr) (SꪞUU` n&ATTRIBUTES *sds_attributes (SDS *sds) UU` 'n\)char *sds_attrname (ATTRIBUTES *attrptr) 0UU` n0int sds_attribute_type (SDS *sdsptr, char *key) gtUU` +n'int sds_attrtype (ATTRIBUTES *attrptr) sds&UU` )nUU*void *sds_attrvalue (ATTRIBUTES *attrptr) 5UU` *nin.char *sds_attrvalue_str (ATTRIBUTES *attrptr) DUU` !nst&ATTRIBUTES *sds_first_attr (SDS *sds) SUU` "n s%ATTRIBUTES *sds_last_attr (SDS *sds) UbUU` #nse-ATTRIBUTES *sds_next_attr (ATTRIBUTES *attr) qUU` nda0int sds_remove_attribute (SDS *sds, char *name) UU` nva2ATTRIBUTES *sds_search_attr (SDS *sds, char *key) UU` %nth1void *sds_search_attrvalue (SDS *sds, char *key) nUU` $n (5char *sds_search_attrvalue_str (SDS *sds, char *key) eUU` ,ninHint sds_set_attribute (SDS *sds, char *name, void *value, int attrtype, UUUU` 0ns_char *comment) BU˪UU` &n8int sds_set_attrname (ATTRIBUTES *attr, char *attrname) ڪUU` -nch6int sds_set_attrtype (ATTRIBUTES *attr, int datatype) 骍UU` nibHint sds_set_attrvalue (ATTRIBUTES *attr, void *attrvalue, int datatype) (UU` .nr)6int sds_set_comment (ATTRIBUTES *attr, char *comment) ` wFile I/O routines UU` n(A'SDS *sds_get_one_fits (char *filename) &AT.UU` nt_.SDS * sds_in (char *infile, int sds_datatype) =UU` /nDS)int sds_out (SDS *sdsptr, char *outfile) dLUU` 2nBU2int sds_put_one_fits (SDS *sdsptr, char *outfile) 6h\V0_ 6h\V0^ tt0 *h |u  module.h hUU` }q_a/* lue+UU` ~qke1 * module.h~soi/(version)/include/module.h e7UU` qar * ) eCUU` qinN * Data structures used in 4-level model for SSSC compute modules, described OUU` qcG * in "Programming in the SOI Analysis Environment", SOI TN-93-107. ttr[UU` qM * Levels are: use (interface), strategy, function, and library (support). gUU` qin * _sesUU` qBU> * Responsible: Kay LeibrandKLeibrand@solar.Stanford.EDU UU` qen * TRIUU` q*c * Bugs: UU` qFi< * There are no unsigned fixed-point types for arguments haUU` q * UUUU` qs_0 * Revision history is at the end of the file. /UU` q(S */ spǪUU` q d#ifndef __MODULE_TYPES__ dӪUU` q sߪUU` q) O/****************************************************************************/ 몙UU` q |O/************************** INCLUDE STATEMENTS ****************************/ hUU` qinO/****************************************************************************/ ureUU` qmo UU` qod#include UU` q #include S'UU` qnm#include [3UU` q *#include fac?UU` qti KUU` qrtO/****************************************************************************/ andWUU` q.SO/**************************** DEFINE STATEMENTS ***************************/ UUcUU` qerO/****************************************************************************/ oUU` q * e{UU` qat"/* kinds of module arguments */ UU` q#define ARG_END(0) UU` q d#define ARG_DATASET(1) UU` q/*#define ARG_FLAG(2) ***UU` q**#define ARG_TIME(3) **/UU` q #define ARG_INT(4) êUU` q S#define ARG_FLOAT(5) **ϪUU` q#define ARG_STRING(6) *۪UU` q**#define ARG_FILEPTR(7) 窄UU` q*/#define ARG_DATASET_IN(8) UU` q#i#define ARG_DATASET_OUT(9) UU` q <#define MODULE_ERROR(-1) nm UU` qme#define MODULE_OK(0) *UU` qro%#define MODULES_VERSION_NUM(0.8) #UU` q**#define __MODULE_TYPES__ */~UU` q** *;}UU` q*/O/****************************************************************************/ ***G|UU` q*/O/******************************* TYPEDEFS *********************************/ ***dUUUUHh\V0 meHh\V0 EN) UU` q dO/****************************************************************************/ UU` qin _TIUU` qO /* form of entry in table of arguments needed by strategy level function */ ***UU` qtypedef struct ARG { (6UU` q  int kind; _FIBUU` q char *key; NUU` qIN char *default_value; #iZUU` qSE char *minvalid; UUfUU` qMO char *maxvalid; rUU` q#d } argument; K~UU` qUU UU` qLEO/****************************************************************************/ UUUU` qO/********************* GLOBAL & EXTERN DECLARATIONS ***********************/ ***UU` qO/****************************************************************************/ ***UU` q UU` q, /* strategy level function */ ƪUU` qextern int (*DoIt)(); ҪUU` q) A /* table of arguments needed by strategy level function */ *ުUU` q**extern argument arguments[]; ꪗUU` qA /* table of arguments created by strategy level function */ rUU` qon!extern argument outarguments[]; eUU` q UU` qnt#endif _FIUU` q/* cha&UU` qUU * Revision History u2UU` qI * V 0.8 94.02.08 Kay Leibranddefined version number ;>UU` q  */ } JUU` q Ud/***6h\V0 **6h\V0 /*0**h uAL( Pipeline Interface {main_svcu **UU` LqUUP/*----------------------------------------------------------------------------- **+UU` MqUU4 * /home/soi/new/src/pipe/main_svc.c PVM3 Version te7UU` Rq *P *----------------------------------------------------------------------------- taCUU` SqUU * y sOUU` Tqti> * INPUTS: Messages of various types from Pipeline Execution [UU` UqP * OUTPUTS: Files according to the strategy level module that it's linked with. ongUU` Vq o5 * A log file /tmp/"strategy_name"_svc.log. sUU` Wq) * RETURNS: Response messages back to PE UUU` XqtoA * EXTERNALLY READ: strategy_name from the strategy level module aUU` Zqrs * EXTERNALLY MODIFIED: None UU` [qUU * qUU` \q * DESCRIPTION: /*UU` ]qJ * Wrapper to make pipe interface level server when linked to a strategy UU` ^q * level module. ǪUU` `qce/ * Each server is started by PE as a pvm task. ---ӪUU` aq--> * PE and each server exchange messages to effect processing. ߪUU` bq/sG * Each server type must have a unique message number that PE uses to ---몙UU` cq--M * identify that server type. This message number is given to the server in sUU` dqti * the first msg that PE sends. tyUU` eqExP * The major action is to receive a keylist from PE and call the strategy level duUU` fqd N * module with this keylist which will then transform the input files to the UU` gq W * output files. e'UU` hqck * E U3UU` iqto*/ EXT?UU` jqte nKUU` kqegmain() oduWUU` lq Z{ cUU` mqDI int parent, msgtag, status; oUU` nqUU KEY *list; S{UU` oq KEY *outlist = newkeylist(); pipUU` pqse rUU` qqst7 parent=setup();/* preliminaries & reg with pvm */ UUUU` rqse rUU` sqas while(1) { -UU` tq-- busy = 0; êUU` uqes< if((msgtag=getmsg(parent)) == -1)/* get any message */ erϪUU` vqun+ continue;/* error, loop again */ ۪UU` wqde busy = 1; 窄UU` xqge8 alarm(SLAVE_TIMEOUT);/* reset the idle timeout */ *UU` yqt  sUU` zqUU< if(msgtag == msgid) {/* normal file processing msg */ an UU` {qy ? if(!(list=unpackmsg(list))) /* get the key list sent */ illUU` |qe , continue;/* top of while loop */ ut#UU` }q U/~UU` ~qM status=DoIt(list, &outlist, write_log, write_log); /* strategy code */ u;}UU` q Z G|UU` qDI if(verbose) { , 'm ̔Y  =Gtimes[power[indexes[0,1,char[Y],char[l]],char[m]],id[cos[char[theta]]]]Q:)m̔I;J egU<)m̔IseJ as'm ̔-- =; Gtimes[power[indexes[0,1,char[Y],char[l]],char[m]],id[cos[char[theta]]]]ssa)@ Ǵ #o* :leq[num[0,"0"],char[l],indexes[0,1,char[l],string["max"]]]Q8)m̔IAVJ th~m3+@ ǴI yEJ  z'm ̔*  =ocGtimes[power[indexes[0,1,char[Y],char[l]],char[m]],id[cos[char[theta]]]]/*  a0#o leq[num[0,"0"],char[m],char[l]] lo 1 ~ =power[num[2,"2"],char[n]]o~m3"a IstEJ Q6)m̔IDIJ , 'm ̔Y  =Gtimes[power[indexes[0,1,char[Y],char[l]],char[m]],id[cos[char[theta]]]]7%{; RJcos[char[theta]]mo 1 GEH mmZ7% {I)J xe 1 G[cEH  1 \ =le:cross[power[num[2,"2"],char[n]],power[num[2,"2"],char[m]]]dUUmHh\V0 Hh\V0 UU` qocG write_log("The keylist output by %s_svc is:\n",strategy_name); /* UU` q% keyiterate(logkey, outlist); uUU` qha } *UU` qG sendresult(parent, status, outlist);/* send the results to PE */ 6UU` q } BUU` q69 else if(msgtag == MSGARGS) {/* send the arg list */ NUU` q sendargs(parent); tiZUU` q0, } fUU` q],H else if(msgtag == MSGMSG) {/* msg # for normal file processing */ JrUU` qm pvm_upkint(&msgid, 1, 1); ~UU` q" pvm_upkint(&verbose, 1, 1); UU` qJ } UU` q else { [cUU` qN write_log("Illegal msg type %d sent to %s_svc\n",msgtag,strategy_name); UU` qm[ } UU` q }/* end while(1) */ ƪUU` q} ҪUU` Jq dALeftdBRightocdlheFirsttutdttr Reference;* d TOC dstIXd FirstdnddlidC PdEdG6dIGAdKt dM dO dQ dS idU msdW sidYmd[ 1d]d_e,dJddUU i?~;f HQm  u ~/*1Heading 1Heading Rule H:\t\t FirstBodyUf SE heut 1Step Step Numbere S:.\tStep_Rf HQ  ~  2HeadingH:\t.\t FirstBody_R f HQA  ~  3HeadingH:\t..\t FirstBodyf vHQW  u[~ 12HeadingH:\t.\t FirstBody_ffufz ffBullet Bullet Symbol\tmffufa  FiffBullet Bullet Symbol\t~ fwHQ  tuR~3HeadingH:\t..\t FirstBodyf@H dyAbstract1Headingf 3HCellBodyf  CellHeadingf CStep fEl uEquationEquation Number E:(EQ )f \tExtract fFA ~ea gFigure Table Top. Step NumberdF:FIGURE .\tBody~~ f Bodyf CeFootnote.f@   CePurpose FirstBodyfS  Step Step Number S:.\tfq n+> TableFootnoteffT  TableTitle Table Top Step NumberT:TABLE .\tf @ < ~TitleAuthorf!y  CellHeadingf"xe .CellBodyf#Te  TableTitle Table Top Step NumberT:TABLE .\t~;f$uAQ  u~ AppendixHead 1Heading RuleA:\tAppendix \tAppendixf%q@ 0aG TaeTTae % epVQrAppendixAppendix_R f&wHQ  le~Au r 3HeadingH:\t..\t FirstBody~;f'uHQ  u~x1Heading 1Heading Rule H:\t\t FirstBodyf(w  headerf)w\   footer leftf*wx  x pe x footer rightf+w   header firstf,w   footer firstf-ni dy  f 3HeadingTOCf.m RulvHQ   ~f  2HeadingH:\t.\t FirstBody~;f?AQ  8xu~ AppendixHead 1Heading RuleA:\tAppendix \tAppendixfCn stBCBulletfffffEn CBulletffF CBulletfIn@ Abstract1Heading~~fKnD  FirstBodyBody~~ fLnn Body$ fQ@   AuthorTNTagdfTo@< TitleAuthor$ fYp@  AuthorTNTag$ f\@   TNTagAbstract$ f^v@  TNTagAbstractm m ~ n n<o  p  Bo q r  Bullet SymbolsCallout= t Emphasis u  v  w  x  y  z  Bullet Symbol {  EmphasisAu| Equation Number }  Run-In Heading ~ Ab Step Number=   Subscript=   Superscript   Step Number  Emphasis         Emphasis    Default Bold@@5E:5Thin6Medium7Double8Thick@9 Very Thin ) 9 )#6!"!6!"!6!"!n6!"!Format A9#6!"!6!"!6!"!6!"!eFormat B a q a  EmComment Courier Helvetica Symbol Times-RegularRegular BoldRegularObliqueItalicl/s5:P]G&g>U.&2z7}##i~$8!w lo3IchnL>1 WU7nCl86lۜS/8ιzQJ߻I$+ X{6cfS`9}R򁂐)'E>O( Rܾy4픕q- s:*,'4$s7W<ڊJfN jПu 4R]2;MUG]hA:$.TD@땼oA^y*BN/u e$w?ZE38XfM71<32M