<div dir="ltr">Thanks! The separate files mapping approach seems to be working.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 10, 2014 at 4:16 PM, Michael Wilde <span dir="ltr"><<a href="mailto:wilde@anl.gov" target="_blank">wilde@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here's a few more examples of simpler approaches. These *should* work<br>
correctly for both relative and absolute filename mappings, even with<br>
the __root__ convention.<br>
<br>
- Mike<br>
<br>
$ cat regexpmap1.swift<br>
<br>
type file;<br>
<br>
file data[]<filesys_mapper; prefix="f", suffix=".dat">;<br>
<br>
file image[] <structured_regexp_mapper;<br>
source=data,<br>
match="^(.*)dat$",<br>
transform="\\1img">;<br>
<br>
foreach j, i in data {<br>
<span class=""> tracef(" data[%i] = %s\nimage[%i] = %s\n",<br>
</span> i, filename(data[i]),<br>
i, filename(image[i]));<br>
}<br>
<br>
$ swift ./regexpmap1.swift<br>
<span class="">Swift 0.95 RC5 swift-r7605 cog-r3874<br>
</span>RunID: run077<br>
Progress: Wed, 10 Dec 2014 22:10:29+0000<br>
data[0] = f1.dat<br>
image[0] = f1.img<br>
data[3] = f4.dat<br>
image[3] = f4.img<br>
data[1] = f2.dat<br>
image[1] = f2.img<br>
data[2] = f3.dat<br>
image[2] = f3.img<br>
Final status:Wed, 10 Dec 2014 22:10:29+0000<br>
<br>
The simplest approach is to just map one array to each file suffix. The<br>
filesys mapper will return the files in the same lexicographic order for<br>
each pattern:<br>
<br>
$ cat ./regexpmap3.swift<br>
<br>
type file;<br>
<br>
file data[] <filesys_mapper; prefix="f", suffix=".dat">;<br>
file image[] <filesys_mapper; prefix="f", suffix=".img">;<br>
<br>
foreach j, i in data {<br>
<span class=""> tracef(" data[%i] = %s\nimage[%i] = %s\n",<br>
</span> i, filename(data[i]),<br>
i, filename(image[i]));<br>
}<br>
<br>
$ swift ./regexpmap3.swift<br>
<span class="">Swift 0.95 RC5 swift-r7605 cog-r3874<br>
</span>RunID: run078<br>
Progress: Wed, 10 Dec 2014 22:10:56+0000<br>
data[2] = f3.dat<br>
image[2] = f3.img<br>
data[3] = f4.dat<br>
image[3] = f4.img<br>
data[0] = f1.dat<br>
image[0] = f1.img<br>
data[1] = f2.dat<br>
image[1] = f2.img<br>
Final status:Wed, 10 Dec 2014 22:10:56+0000<br>
swift$<br>
<div class="HOEnZb"><div class="h5"><br>
On 12/10/14 3:52 PM, Michael Wilde wrote:<br>
> This example may be helpful:<br>
><br>
> $ cat -n regexpmap.swift<br>
> 1 type file;<br>
> 2<br>
> 3 string fnames[] = [<br>
> 4 "/data/dir/000001/f01.dat",<br>
> 5 "/data/dir/000001/f02.dat",<br>
> 6 "/data/dir/000002/f03.dat",<br>
> 7 "/data/dir/000002/f04.dat",<br>
> 8 "/data/dir/000003/f05.dat",<br>
> 9 "/data/dir/000003/f06.dat"];<br>
> 10<br>
> 11 file data[]<array_mapper; files=fnames>;<br>
> 12<br>
> 13 file image[] <structured_regexp_mapper;<br>
> 14 source=data,<br>
> 15 match="(/data/dir/[0-9][0-9]*/.*?)dat$",<br>
> 16 transform="\\1img">;<br>
> 17<br>
> 18 iterate i {<br>
> 19 tracef(" data[%i] = %s\nimage[%i] = %s\n",<br>
> 20 i, filename(data[i]),<br>
> 21 i, filename(image[i]));<br>
> 22 } until (i==6);<br>
><br>
> $ swift regexpmap.swift<br>
><br>
> Swift 0.95 RC5 swift-r7605 cog-r3874<br>
> RunID: run067<br>
> Progress: Wed, 10 Dec 2014 21:50:42+0000<br>
> data[0] = __root__/data/dir/000001/f01.dat<br>
> image[0] = __root__/data/dir/000001/f01.img<br>
> data[1] = __root__/data/dir/000001/f02.dat<br>
> image[1] = __root__/data/dir/000001/f02.img<br>
> data[2] = __root__/data/dir/000002/f03.dat<br>
> image[2] = __root__/data/dir/000002/f03.img<br>
> data[3] = __root__/data/dir/000002/f04.dat<br>
> image[3] = __root__/data/dir/000002/f04.img<br>
> data[4] = __root__/data/dir/000003/f05.dat<br>
> image[4] = __root__/data/dir/000003/f05.img<br>
> data[5] = __root__/data/dir/000003/f06.dat<br>
> image[5] = __root__/data/dir/000003/f06.img<br>
> Final status:Wed, 10 Dec 2014 21:50:42+0000<br>
><br>
><br>
><br>
> On 12/10/14 3:21 PM, Mihael Hategan wrote:<br>
>> Hi,<br>
>><br>
>> In 0.95 this is a bit of a known problem. This should be fixed in trunk.<br>
>> A backport of the fix may be possible and should probably be done. Can<br>
>> you easily switch to trunk? If not, I'll try to do the backport sooner.<br>
>><br>
>> Mihael<br>
>><br>
>> On Wed, 2014-12-10 at 15:11 -0600, Ketan Maheshwari wrote:<br>
>>> Hi,<br>
>>><br>
>>> In an app that needs input files with same name but different extension, I<br>
>>> am trying to use regexp on the filename() of a mapped file. However, Swift<br>
>>> adds '__root__' to the path of file which cause the file to be not found in<br>
>>> the new location resulting in error as:<br>
>>><br>
>>> org.griphyn.vdl.mapping.MissingDataException: File not found for<br>
>>> variable 'in_sto':<br>
>>> file://localhost/__root__/lcrc/project/NEXTGENOPT/DSP_old/examples/smps/dcap/dcap332_500.sto<br>
>>><br>
>>> Relevant code is:<br>
>>><br>
>>> file timfiles[]<filesys_mapper;<br>
>>> location="/lcrc/project/NEXTGENOPT/DSP_old/examples/smps/dcap",<br>
>>> pattern="*.tim">;<br>
>>> file in_sto <single_file_mapper; file=regexp(filename(timfiles[0]), "tim",<br>
>>> "sto")>;<br>
>>><br>
>>> Thanks for any workaround suggestions for this,<br>
>>> Ketan<br>
>>> _______________________________________________<br>
>>> Swift-user mailing list<br>
>>> <a href="mailto:Swift-user@ci.uchicago.edu">Swift-user@ci.uchicago.edu</a><br>
>>> <a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user</a><br>
>> _______________________________________________<br>
>> Swift-user mailing list<br>
>> <a href="mailto:Swift-user@ci.uchicago.edu">Swift-user@ci.uchicago.edu</a><br>
>> <a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user</a><br>
<br>
--<br>
Michael Wilde<br>
Mathematics and Computer Science Computation Institute<br>
Argonne National Laboratory The University of Chicago<br>
<br>
_______________________________________________<br>
Swift-user mailing list<br>
<a href="mailto:Swift-user@ci.uchicago.edu">Swift-user@ci.uchicago.edu</a><br>
<a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user</a><br>
</div></div></blockquote></div><br></div>