[Swift-user] mapping variables on the fly

Justin M Wozniak wozniak at mcs.anl.gov
Thu Mar 25 15:45:48 CDT 2010


Is rups[] getting filled correctly?

On Thu, 25 Mar 2010, Allan Espinosa wrote:

> When my rups array contains more than one element, my script doesn't
> seem to progress in executing.  the workdirectory for the extract()
> job isn't even being prepared. My logfile says something like
> "variable already closed".  its attached in this email.
>
>
> below is the script, i swapped the "main" part of the program with the
> type and app() declarations
> /* TODO: data management zip jobs */
> int run_id = 644;
> Station site = get_site(run_id);
>
> Sgt sgt_var <ext; exec="getsgtvar.rb", r=run_id, s=site.name,
>    l="gsiftp://ff-grid.unl.edu//panfs/panasas/CMS/data/engage/scec/data/SgtFiles/TEST">;
>
> Rupture rups[] = get_ruptures(run_id);
>
> foreach rup in rups {
>  string datadir =
>      "gsiftp://ff-grid.unl.edu//panfs/panasas/CMS/data/engage/swift";
>  string loc_sub = @strcat(datadir, ",", rup.index, "/", rup.source);
>  Sgt sub <ext; exec="getsub.rb", l=loc_sub, n=site.name, s=rup.source,
>      r=rup.index>;
>  Variation vars[] <ext; exec="variation_mapper.rb", e=site.erf,
>      v=site.variation_scenario, s=rup.source, r=rup.index>;
>
>  sub = extract(sgt_var,  site, vars[rup.size-1]);
>
>  foreach var,i in vars {
>    Seismogram seis <single_file_mapper; file=@strcat(loc_sub, "/Seismogram_",
>        site.name, "_", rup.source, "_", rup.index, "_", i,".grm")>;
>    PeakValue peak <single_file_mapper; file=@strcat(loc_sub, "/PeakVals_",
>        site.name, "_", rup.source, "_", rup.index, "_", i, ".bsa")>;
>
>    seis = seismogram(sub, var, site);
>    peak = peak_calc(seis, var);
>  }
> }
>
>
> type SgtDim;
> type Variation;
> type Seismogram;
> type PeakValue;
>
> type Station {
>  string name;
>  float lat;
>  float lon;
>  int erf;
>  int variation_scenario;
> }
>
> type Sgt {
>  SgtDim x;
>  SgtDim y;
> }
>
> type Rupture {
>  int source;
>  int index;
>  int size;
> }
>
> /* some constants used by the apps*/
> global int num_time_steps = 3000;
> global string spectra_period1 = "all";
> global float filter_highhz = 5.0;
> global float simulation_timeskip = 0.1;
>
> app (Sgt _ext) extract(Sgt _sgt, Station _stat, Variation _var) {
>  jbsim3d @strcat("stat=", _stat.name) "extract_sgt=1"
>      @strcat("slon=", _stat.lon) @strcat("slat=", _stat.lat)
>
>      @strcat("rupmodfile=", @filename(_var))
>      @strcat("sgt_xfile=", @filename(_sgt.x))
>      @strcat("sgt_yfile=", @filename(_sgt.y))
>      @strcat("extract_sgt_xfile=", @filename(_ext.x))
>      @strcat("extract_sgt_yfile=", @filename(_ext.y));
> }
>
> app (Seismogram _seis) seismogram(Sgt _sgt, Variation _var, Station _stat) {
>  jbsim3d @strcat("stat=", _stat.name) "extract_sgt=0"
>      @strcat("slon=", _stat.lon) @strcat("slat=", _stat.lat)
>      "outputBinary=1" "mergeOutput=1" @strcat("ntout=", num_time_steps)
>
>      @strcat("rupmodfile=", @filename(_var))
>      @strcat("sgt_xfile=", @filename(_sgt.x))
>      @strcat("sgt_yfile=", @filename(_sgt.y))
>      @strcat("seis_file=", @filename(_seis));
> }
>
> app (PeakValue _peak) peak_calc(Seismogram _seis, Variation _var) {
> //  touch @_peak;
>  surfeis_rspectra "simulation_out_pointsX=2" "simulation_out_pointsY=1"
>      "surfseis_rspectra_seismogram_units=cmpersec"
>      "surfseis_rspectra_output_units=cmpersec2"
>      "surfseis_rspectra_output_type=aa"
>      "surfseis_rspectra_apply_byteswap=no"
>
>      @strcat("simulation_out_timesamples=", num_time_steps)
>      @strcat("simulation_out_timeskip=", simulation_timeskip)
>      @strcat("surfseis_rspectra_period=", spectra_period1)
>      @strcat(" surfseis_rspectra_apply_filter_highHZ=", filter_highhz)
>      @strcat("in=", @filename(_seis))
>      @strcat("out=", @filename(_peak));
> }
>
> // Auxillary functions for the mappers
> type StationFile;
> app (StationFile _stat) getsite_file(int _run_id) {
>  getsite _run_id stdout=@filename(_stat);
> }
> (Station _stat) get_site(int _run_id) {
>  StationFile file<"site_tmp">;
>  file = getsite_file(_run_id);
>  _stat = readData(file);
> }
>
> type RuptureFile;
> app (RuptureFile _rup) getrupture_file(int _run_id) {
>  getrupture _run_id stdout=@filename(_rup);
> }
> (Rupture _rup[]) get_ruptures(int _run_id) {
>  RuptureFile file<"rup_tmp">;
>  file = getrupture_file(_run_id);
>  _rup = readData(file);
> }
>
>
> --
> Allan M. Espinosa <http://amespinosa.wordpress.com>
> PhD student, Computer Science
> University of Chicago <http://people.cs.uchicago.edu/~aespinosa>
>

-- 
Justin M Wozniak



More information about the Swift-user mailing list