diff --git a/CHANGES/Unreleased.txt b/CHANGES/Unreleased.txt
index 6737c1bec938ab8e6dff39aaa4adde1407b446e9..86b7bb8201a2557c7cc01eb1bb973e26e5e41825 100644
--- a/CHANGES/Unreleased.txt
+++ b/CHANGES/Unreleased.txt
@@ -32,6 +32,7 @@ Changes from version 2.2 which are relevant for users:
   - \ref ROWSUMS
   - \ref COLUMNSUMS
   - \ref UPDATE_IF
+  - \ref PCA
 - New features in MD patches (require repatch):
   - Patch for amber 14 now passes charges with appropriate units (fixes \issue{165}). Notice that
     the patch is still backward compatible with older PLUMED version, but the charges will only be passed
diff --git a/CHANGES/v2.2.txt b/CHANGES/v2.2.txt
index 5543cf015edaa947f39c2e899c9ab5545c1ecc6a..5c1b836c5f5cbd45e76e27e35955c8f651dfee57 100644
--- a/CHANGES/v2.2.txt
+++ b/CHANGES/v2.2.txt
@@ -105,7 +105,7 @@ For developers:
 - ./configure is automatically relaunched when changing ./configure or Makefile.conf. This makes it more robust
   to switch between branches.
 
-Unreleased changes (will be included in 2.2.2)
+Version 2.2.2 (coming soon)
 ----------------------------------------------
 
 For users:
@@ -119,7 +119,8 @@ For users:
 - Fixed a bug in the normalization of kernel functions (relevant for \ref HISTOGRAM).
 - Fixed a regression introduced in v2.2 that was making \ref METAD with non-MPI multiple walkers crash
   if reading frequently. See \issue{190}
-- Updated patch for gromacs 5.1
+- Updated patch for gromacs 5.x. Patches for gromacs 5.0 and 5.1 have been fixed so as to allow
+  patching in runtime mode.
 - Possibility to control manual generation (including pdf) from ./configure. Pdf manual is now off
   by default. Notice that on travis CI it is still generated.
 
diff --git a/regtest/analysis/rt-pca-2/Makefile b/regtest/analysis/rt-pca-2/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee
--- /dev/null
+++ b/regtest/analysis/rt-pca-2/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/analysis/rt-pca-2/colvar.in b/regtest/analysis/rt-pca-2/colvar.in
new file mode 100644
index 0000000000000000000000000000000000000000..3c1a6d4ff8bbca15ba5cc7bc12587585b89d3cbb
--- /dev/null
+++ b/regtest/analysis/rt-pca-2/colvar.in
@@ -0,0 +1,1001 @@
+#! FIELDS time cv1 cv2
+0 0.775540714036 0.114424044242
+1 0.875241253264 1.26867389701
+2 1.5823516279 0.605481219611
+3 -1.96997844317 -3.19169418421
+4 1.46732571381 0.768488126284
+5 0.666346341751 -0.470501561902
+6 0.860037532851 -0.407265735903
+7 0.356107752262 0.578949081633
+8 1.29856933615 0.877672309318
+9 -1.91795493292 -1.06303227781
+10 0.503769991835 -1.60084848817
+11 0.654256109546 0.897859999363
+12 1.02289470749 0.298766057397
+13 0.513653990173 -0.828578832591
+14 0.728689851987 0.386875652092
+15 0.897535288431 -0.102913855511
+16 3.05937675092 2.06078844086
+17 -0.250090711503 0.97082781137
+18 0.767548438193 0.9917571357
+19 3.04721203027 1.95327665343
+20 0.883247152601 1.42758236937
+21 -0.0440969219802 0.175247477206
+22 -0.584719212221 -1.27184824226
+23 3.41759109718 0.796329037698
+24 3.13938674369 1.26821644297
+25 1.2190377829 0.103134012441
+26 1.0466239386 0.986404889943
+27 0.180082423161 -1.47317617169
+28 1.70132536395 1.57912581146
+29 -1.67316758635 0.457524118724
+30 0.419583577658 0.419002131786
+31 2.08908425542 1.74820816361
+32 0.365257968572 1.96793840588
+33 -0.0497651715967 0.381983401933
+34 -0.236074748852 -0.187896968959
+35 1.55492737247 -0.439098734545
+36 1.5383684657 1.17171100139
+37 -0.139897090906 -0.23738519017
+38 0.770989321462 -0.938496396415
+39 0.451017119855 0.842232510705
+40 1.91640601869 0.832057382667
+41 -0.594572922964 -0.733158693988
+42 0.444401447116 0.244228800796
+43 1.38590200976 1.83739003623
+44 0.663913596737 0.127638758917
+45 -0.500647526898 -1.6570969453
+46 0.706239344415 2.05086674122
+47 0.578127400432 0.787921845244
+48 2.2275525669 0.368161450454
+49 0.906842668518 0.95581995319
+50 -1.22571853845 -1.32136949323
+51 -0.275089607594 -0.308775809186
+52 0.432543013028 0.352939734773
+53 -0.265613356155 0.685579682129
+54 -0.026500469991 -1.46371851512
+55 -2.25635311888 -0.159184803471
+56 -1.05132726639 -2.40098362963
+57 2.89640541158 0.547566861808
+58 -1.14344481238 -1.68926858478
+59 1.45238235659 1.25365664484
+60 3.08497160853 1.7120033581
+61 1.65205641262 0.0870512387052
+62 1.96225185285 1.2023227004
+63 2.12967824398 1.54646668897
+64 -1.05958054818 -1.64242634245
+65 1.58963629316 1.12989953507
+66 1.32938987432 0.0211976858831
+67 0.802707269487 -0.735851517591
+68 1.44968642067 -1.12289769058
+69 1.59035697882 2.28786735322
+70 2.53014104202 1.24813646371
+71 -1.53570128588 -1.92600970779
+72 1.08745452242 -1.27355083636
+73 1.30117182562 0.787026441902
+74 -0.77975601089 -0.330799732548
+75 0.409944088865 -0.619570646354
+76 0.271191647328 -0.327035449609
+77 1.55707575036 1.27106691454
+78 -0.29521951328 -0.918247433415
+79 0.738422452017 -0.0639102857288
+80 1.75945417231 -0.806567559302
+81 1.30944276799 0.490682166354
+82 -1.32208025015 -1.9741189554
+83 -0.983868566041 -0.675037269068
+84 -2.41155796614 0.0106880240482
+85 1.59584562215 1.04628176079
+86 1.24299574254 -0.156556771096
+87 -0.349106141641 0.343122029732
+88 3.42302650979 1.83306682365
+89 2.09504205893 0.715062412482
+90 1.3864990786 -0.848122023448
+91 0.114438193308 0.838407668496
+92 0.359234528506 0.473327864691
+93 2.72262347992 2.13341275326
+94 1.29480801872 0.223921347775
+95 -1.44095653035 -2.78622391763
+96 1.82885082976 0.465991778531
+97 0.0650202816573 -0.52176986029
+98 1.4826449428 -0.531661924194
+99 2.91669366438 1.1533975579
+100 -2.27351051187 -3.54020281492
+101 -0.934723496529 1.00579340162
+102 0.373440323787 1.80485887534
+103 0.0703649761202 0.831433338352
+104 2.81895503432 0.0675261343631
+105 1.00076332094 -0.426258776056
+106 1.48402135963 2.19476881944
+107 2.88990012631 2.88047328603
+108 1.70043111576 -0.0604897530187
+109 3.91193812988 2.41620634795
+110 2.86834529622 2.32988866475
+111 1.72788726525 2.59407176217
+112 2.37246624358 0.930990165063
+113 0.147200669425 -1.81465080644
+114 0.263554041463 2.1627959981
+115 0.754048313019 1.46810596294
+116 1.59864025054 0.140166238336
+117 -0.695358343263 -0.881988413021
+118 3.3029529571 1.36885697998
+119 -0.023437088948 0.82956505666
+120 1.56563256871 1.01221804778
+121 0.0629390870554 -0.257050993644
+122 2.36875663895 1.15524606522
+123 2.11926689893 2.18682127227
+124 1.37724243614 0.618075497951
+125 1.16567400959 2.42530403584
+126 0.612519978649 -0.21893524974
+127 -0.35248272377 -0.0975479513445
+128 1.01140013077 0.342684499755
+129 1.62422907251 1.75542981328
+130 0.0914719882537 -0.910093617506
+131 2.69028058582 1.90389142139
+132 0.519176583588 -1.04607407774
+133 1.91520164602 -0.115862015663
+134 -0.414102159498 -1.23710080445
+135 1.86430676851 -0.0376822598894
+136 3.63132905991 2.46736311543
+137 1.24714839944 1.11904957832
+138 1.7283696712 1.1531693112
+139 -0.115520894051 -1.80600638047
+140 1.57671760911 2.99955859278
+141 2.12997222413 1.78612083307
+142 0.111351590629 0.405688932784
+143 -0.0645354718478 0.841667853091
+144 0.217233517861 0.350182424433
+145 -0.0146872312086 0.323894416193
+146 0.0394414239506 -0.946620767282
+147 -0.411764311248 -0.311196782931
+148 -0.863345411069 -1.01756205589
+149 0.684865768077 -0.367923621622
+150 0.21353493243 -0.0956576402036
+151 1.50416321319 1.14379539237
+152 2.88703332958 1.31051490726
+153 -0.960338043351 -1.66814020872
+154 -0.492284025077 0.0832615150324
+155 -0.928634693707 -1.16821407272
+156 -2.59191513331 -1.28544171723
+157 0.515602333124 0.272054532867
+158 4.25028349028 3.507667131
+159 0.0594299650903 0.818673971616
+160 2.63074099874 2.03620436428
+161 -1.0640535519 -1.92207789074
+162 3.1125293201 1.54259626731
+163 -0.49110917227 -2.17484935256
+164 1.70815957187 -0.100510436263
+165 0.682852254931 0.749829411678
+166 -0.681280359108 1.31300620317
+167 1.61670909287 0.784707727399
+168 1.14411540609 -0.0348052682116
+169 -0.0395965296065 0.142132112801
+170 0.983407074316 0.106888185229
+171 1.42370381706 -0.106199787771
+172 1.90055022213 1.45027686125
+173 4.6825676146 4.11270684163
+174 0.967944326868 1.29911582792
+175 1.62626113517 1.01357338884
+176 0.0250152151991 -0.635262684752
+177 2.70172666648 0.888489811227
+178 0.118916736713 0.413707288397
+179 -1.47129462582 -0.906153358896
+180 -0.929868777077 -0.29650049668
+181 0.713734440172 1.38545704433
+182 0.766609751549 0.599607761343
+183 0.755861919229 0.281242589585
+184 2.1581814869 1.52885299632
+185 1.54265937091 -0.996915709267
+186 -0.780607032956 -0.826969158462
+187 1.90833389883 0.457936075481
+188 0.74029790498 0.94103411897
+189 0.751299096605 -1.02883865917
+190 0.30213713357 -0.647657246138
+191 2.95921076522 0.694306578014
+192 3.00214453898 4.30361069765
+193 1.54660838906 2.3341555745
+194 0.340172194022 -0.0671323466137
+195 -0.874633904713 -1.07707508057
+196 4.04204484772 3.28872412068
+197 0.806915838458 -0.889212545126
+198 1.46230502674 0.950701059737
+199 2.13747966684 0.455682207011
+200 3.55919802275 2.51430238161
+201 -0.0144887733885 0.183480222719
+202 0.0324546538771 -0.72689453247
+203 3.40995509673 1.28101054183
+204 -0.763179246749 -0.492505206305
+205 1.96493800998 0.796615448806
+206 -0.704944271664 -1.27478887289
+207 0.690556750936 -0.708097082348
+208 0.773782607187 0.875528859869
+209 1.52765916482 0.0635660795492
+210 0.845377777251 0.203497019752
+211 -0.715523545915 0.589160981226
+212 1.51612287539 0.971050552539
+213 1.89593266002 -1.37143406738
+214 -1.4741800175 -1.16928816375
+215 -0.0647886701305 0.550125130952
+216 0.697289652694 -0.157679017555
+217 0.0573342236867 -0.819722294706
+218 0.799558305331 1.24347126912
+219 -2.05302682887 -1.29844246328
+220 -0.733310704173 0.242551002071
+221 2.12169970999 0.457606862708
+222 -0.0869489875983 -0.888846788791
+223 1.16539020143 -0.0506299817686
+224 2.04883289186 2.03628119297
+225 2.05378286147 1.96428637793
+226 0.352549173391 -0.736571699667
+227 -0.0958917366564 0.0130708628444
+228 0.869629669038 0.496611243565
+229 -0.0343217404299 1.63218101958
+230 0.523833306155 1.98300708493
+231 2.14575171275 2.1022971365
+232 1.39241877451 1.84694428478
+233 0.274934047958 0.853363558047
+234 -1.08474602359 -1.54638874523
+235 0.70245904624 0.293021841089
+236 2.59761330718 1.77132101732
+237 1.86539692206 0.218117830318
+238 0.249393244623 -1.1544026902
+239 0.530293489218 1.0598013229
+240 0.452134860455 -0.303388650397
+241 0.131995203315 1.26492684015
+242 1.78184112625 1.66568150653
+243 0.505786940864 -1.92771995867
+244 1.23278487459 -0.676747348331
+245 2.4462262619 0.316113766592
+246 1.86667900797 -0.206230891226
+247 0.0698985002469 -0.0745302107041
+248 -1.0493115203 -1.73601638326
+249 1.32908950397 -0.480643862775
+250 2.584215445 -1.40886078758
+251 0.0934909066951 -0.213251283186
+252 0.81161839983 0.199604526541
+253 3.26141584822 3.49545625188
+254 -0.0225541598693 -1.08322805373
+255 2.84096921521 2.73595573635
+256 0.951381899166 -0.012846413267
+257 0.289076285186 0.296471327373
+258 0.201232559406 -0.284346060192
+259 0.259305343806 0.0229188879366
+260 0.903024005931 0.403651085692
+261 -0.136681526264 -0.418468534663
+262 1.83514473355 1.01072132381
+263 -0.236933132897 0.203188325015
+264 -1.42682510598 -0.0604871537797
+265 1.0990673161 0.549232799254
+266 1.00717608158 1.11046306959
+267 1.70528012477 1.315990044
+268 1.52158082967 1.70578848698
+269 1.75839111063 -0.0778391452926
+270 -0.671478012149 -1.12574361467
+271 0.365565862885 0.160546255789
+272 1.50215652036 1.44263078376
+273 -0.887036436076 -1.03585563721
+274 2.21695335334 3.81710888486
+275 1.13684346944 0.215697352326
+276 2.52481319476 2.55195149733
+277 1.13953692191 1.06636430846
+278 2.38514883977 0.762612566466
+279 -0.687484433714 -0.319608372001
+280 0.63593618339 -1.24079753909
+281 0.597706891687 0.258529950414
+282 4.01619056311 3.03951102339
+283 0.550505169525 -0.0688245535789
+284 4.28776205841 2.61114736721
+285 1.51197738334 0.0264910003122
+286 2.60870913293 2.13476564203
+287 1.61813007624 0.147874947905
+288 2.29463984573 0.778094612308
+289 -0.682858381366 -0.325895661707
+290 0.306487376882 1.59827744577
+291 2.4888497043 1.00790786632
+292 -0.359365104705 -1.05866143453
+293 0.581951540681 -0.455290021178
+294 0.714536330703 0.197380961064
+295 2.30643681046 0.691396150557
+296 1.04922924132 0.650134453588
+297 2.43584493409 1.16613113311
+298 2.64308549025 2.44286689195
+299 2.61152475015 1.21441329604
+300 1.9218105291 1.23289871385
+301 0.0948256352664 -1.75567976615
+302 -1.36984642979 -2.73882963234
+303 1.73787895669 -0.193187577553
+304 1.39168118344 -0.295159570309
+305 0.431920647433 -0.618871013126
+306 1.8344545771 0.214550409659
+307 3.66171946394 0.655669486125
+308 1.71687723612 1.77025752681
+309 0.684362512946 1.95018476561
+310 1.84432520827 2.43309311701
+311 1.1549195534 0.298463033981
+312 2.80056988796 1.89346749203
+313 0.466838169967 -1.22778215326
+314 0.186882003361 0.516035379124
+315 -0.0188114444643 -0.385504513194
+316 2.29633686482 0.763966204079
+317 0.185988474554 0.26290054327
+318 2.44497169506 3.67677629428
+319 -1.15246316348 -0.244220510524
+320 0.379827367145 0.721125265413
+321 -0.419585909823 -1.57231431368
+322 1.59984981343 0.212070869
+323 2.20663417997 2.39787858999
+324 0.599290451168 -0.426016374591
+325 -0.462885658275 -1.72029218
+326 0.895693633802 0.26861909088
+327 4.08522032128 1.78769715523
+328 2.47036356352 1.68808652941
+329 0.661135471044 3.07792849049
+330 2.39914987553 4.03450837073
+331 -0.902698794621 -0.0395743503755
+332 -0.234888091242 0.429935582538
+333 -1.24229668302 -0.891571315585
+334 2.38682363243 0.952680035706
+335 0.778988620514 -1.04764437369
+336 0.0290530737073 1.00037697255
+337 1.82948502843 -0.973601280486
+338 -0.255441771728 -0.0501472018501
+339 2.67981170401 2.00559795819
+340 2.82370753257 1.8894652539
+341 -0.727352458306 -3.34205907279
+342 0.0399296755205 0.27238308227
+343 1.71565955182 1.34259391332
+344 2.29197898238 2.50454593216
+345 -0.34239303414 -2.04174483763
+346 0.225520446188 -1.07967124149
+347 -0.174673652103 -1.37336504242
+348 -0.977031664524 0.272318038884
+349 1.87134448544 1.32560334521
+350 1.15539065529 -0.830321942086
+351 0.0291670744791 -2.81384199247
+352 2.98864734291 2.55108846992
+353 0.331970195453 -0.0610323768683
+354 3.03755118164 2.60885420458
+355 1.99226624173 0.99676428002
+356 2.49564151498 2.66230277701
+357 3.53016735288 5.00087780226
+358 0.644262344443 -0.271604962087
+359 0.464189914596 0.576690004603
+360 -1.36138805793 -1.32071875517
+361 1.29463133072 -0.391123429176
+362 3.1874582637 2.62609357278
+363 3.36561298952 0.760355037001
+364 2.8239778861 -0.0144977767168
+365 -0.805577270066 -1.65749263448
+366 1.77114879553 1.70910899824
+367 1.28974044756 1.78068487179
+368 2.29139078531 1.21095725493
+369 0.736334280684 -0.22582516837
+370 2.92700684628 0.184354011636
+371 3.09600365675 3.15873192246
+372 1.99012314199 2.03230399847
+373 2.27876026089 1.52105851734
+374 0.243532378114 -0.664500626984
+375 2.13394143755 -0.445420021546
+376 0.682435215644 0.667472063454
+377 -0.174154686481 1.1077888367
+378 0.245848877399 0.752188547185
+379 -1.95414834123 -1.93478329794
+380 0.251503935402 0.673738731109
+381 1.54317732422 -0.0307492473901
+382 0.744299213055 -0.0679565163054
+383 -0.395810359248 -0.905837428034
+384 -0.92708482271 -0.231525221758
+385 3.45637818675 1.99712897273
+386 -0.624102147725 -1.05414151336
+387 1.84520828541 1.37325304257
+388 0.843144657515 2.80414378921
+389 1.92235471974 0.381194425255
+390 0.410698414571 1.13648779995
+391 3.46436056176 2.71531155103
+392 -0.346913750807 0.0814298700551
+393 0.364803420117 1.57444479004
+394 1.22972839265 0.0854847505351
+395 -1.96011721992 -2.11998060065
+396 -1.13613897562 -0.248986899577
+397 -0.926968731246 -0.774034703661
+398 2.93061369164 3.76228736345
+399 0.96993588573 1.02171222345
+400 -0.534853957736 1.94888525811
+401 0.207986390589 -0.258386537038
+402 1.21754239578 -0.622209647106
+403 3.28534669792 1.45763349464
+404 2.57696834036 0.041225437598
+405 1.66756917118 0.965454385545
+406 0.877947610383 1.11357709835
+407 -2.2692456298 -1.83432562541
+408 1.85945181218 -0.40660686344
+409 -0.345670495056 -0.286242232426
+410 0.19138792386 0.703556123658
+411 4.25313428896 2.57935763904
+412 1.64211901151 1.44565939308
+413 1.71346169688 0.141115442134
+414 1.0514561521 -0.575111556836
+415 0.644952149657 -0.516172606824
+416 0.60506162459 -0.806113441249
+417 2.82764297873 1.50021468229
+418 -0.762532449738 -1.39823173826
+419 1.43953479773 0.43759344655
+420 1.34824576782 -0.200239271406
+421 1.51143952548 2.14181366538
+422 0.483653577551 1.24884626406
+423 0.862375521711 -0.570754184564
+424 -0.82201458081 -2.07352531411
+425 -0.371354712305 0.325447869576
+426 0.705807360286 1.34887472459
+427 1.80620156233 0.103760291976
+428 -0.0274758346697 -0.0290690802303
+429 2.60629663962 2.10933530411
+430 1.84391671156 2.26838590812
+431 -0.396012416076 -0.62002102807
+432 1.19240643007 2.51716590762
+433 0.13990422317 -0.299778153456
+434 3.32238171317 0.480689006118
+435 0.568193328783 -0.501474047425
+436 0.78021865519 0.999992150985
+437 2.83729819379 0.33413407313
+438 1.62920157569 0.176620377991
+439 1.03258924164 0.0290451161013
+440 1.34686580298 0.647663294761
+441 1.82677101754 0.499687315021
+442 2.79261671698 1.92174825068
+443 0.873279177187 0.810097275589
+444 -1.17134258798 -1.74790954386
+445 2.43554616397 1.43966546244
+446 0.047036205671 1.69195510925
+447 1.15202840653 1.06267393051
+448 0.858636668649 2.75250354782
+449 3.39530736739 1.35297509084
+450 2.1960357862 2.59220931043
+451 -1.25435547981 -1.04701839973
+452 0.587753199293 0.0822737714978
+453 2.46760803988 1.71022042776
+454 1.04072684401 1.11879124654
+455 -0.0218070356976 -0.730600301405
+456 -0.11315979219 -1.31631320683
+457 -0.621332309939 0.275285390091
+458 1.01946475309 1.17782403869
+459 -0.940323720693 -1.48185090181
+460 0.323321328974 1.33081581377
+461 0.429284793469 1.76354059365
+462 3.92528553786 3.26992136254
+463 -0.0897120393174 1.22141796103
+464 2.55876575761 2.755719467
+465 0.851624935406 0.288519968642
+466 -1.15309276021 -1.04478568405
+467 1.66651784418 1.00594295195
+468 1.7757136274 0.826137737493
+469 1.65539339468 1.6101025123
+470 -1.28125059035 0.3599539084
+471 1.5159002697 0.55641244575
+472 1.14402298659 -0.473152923088
+473 1.64364305 2.74534262956
+474 0.882148663566 0.00169098851953
+475 -1.42519755646 -1.61400363179
+476 0.593136177159 -0.304645628883
+477 0.763859990243 -0.423708319046
+478 0.582661864364 1.42354130823
+479 1.52747146156 0.767945115182
+480 -1.10531031111 -0.859119636195
+481 1.85044799071 2.34978938125
+482 1.64812398249 0.719158803895
+483 1.40850004304 1.61896989769
+484 -0.242335192278 0.828057832308
+485 1.78240263841 0.0225420336733
+486 -0.867548653409 -0.705582492794
+487 1.07899857083 -0.481520580757
+488 1.19030356659 -1.08759008376
+489 2.32217880207 0.575578544355
+490 4.50152856693 4.14448214823
+491 -0.549818033247 -0.294384714167
+492 -1.41599664799 -0.691971590616
+493 3.32473542845 3.65436524573
+494 0.319243402948 1.02641745853
+495 2.64602276722 1.72260225656
+496 0.581459350573 0.0875056586848
+497 1.48337545557 1.17593955
+498 1.43791364658 2.20321783934
+499 -0.054951309901 0.617746198574
+500 -2.51524804756 -1.65299793719
+501 0.707706570489 0.238416177496
+502 -0.210507387918 0.561471152066
+503 3.34935005849 1.55626857936
+504 2.25893159947 0.883418788758
+505 -0.551856362605 -1.20940721054
+506 -0.357111657339 -0.541731397327
+507 2.69030398946 2.32539649814
+508 2.76738728951 2.22466542296
+509 -0.0230502241641 -0.656042299005
+510 -0.559643435022 -1.92328237899
+511 3.70631218241 2.46866405907
+512 2.5760832061 0.666310723278
+513 3.34139342964 2.03986043458
+514 -1.19637019354 -0.914641322775
+515 0.913680249488 1.3183361458
+516 2.47553136862 1.54688063319
+517 2.57755716189 1.32148058779
+518 2.69408305654 3.17577759616
+519 -0.132640659626 1.34209836103
+520 0.347079135085 -0.397664145488
+521 -0.149620886717 -0.221275807952
+522 -0.104307961184 -1.96629590581
+523 1.02309047193 1.36510346255
+524 1.53457091702 2.3319960714
+525 1.17223268984 1.49616353811
+526 0.722838162556 -0.533783365431
+527 0.0732270712633 0.147895172698
+528 1.75949109451 1.82673523045
+529 3.71205711579 3.0187327817
+530 2.85598870175 2.58854685483
+531 1.48283278082 1.40508708391
+532 3.70047669102 1.76006423213
+533 0.95723262243 -0.889632371204
+534 -0.620924854674 -0.575456287154
+535 0.771403500439 0.0880467124265
+536 0.252818270631 -1.89798671743
+537 -1.30004750181 -1.67430856051
+538 2.72099994964 -0.0695310563377
+539 0.188298270224 -0.781884521008
+540 -0.731548591235 -0.1512938988
+541 -0.162548527384 -0.106372991796
+542 1.94785012869 2.7657596283
+543 0.181244683279 1.57753466484
+544 1.63483407561 0.901427099611
+545 0.680990798372 1.7030152873
+546 0.176065482226 -0.628176004173
+547 -0.0973629697773 -0.311209903318
+548 2.51647892386 1.46073963097
+549 1.1359491635 1.85307726829
+550 0.501595471304 1.20100862138
+551 3.13513313186 0.867108935057
+552 0.483185477534 -1.20929156422
+553 1.41188481789 0.648962724409
+554 0.848795114658 0.921145817252
+555 0.455717542005 -0.323887951802
+556 1.05739986464 1.92966375801
+557 0.209009551163 -0.134139566032
+558 2.69889928814 1.9781607324
+559 2.7021539095 1.02421957709
+560 -0.0499762852346 1.06698372385
+561 0.954853162243 -0.994572239192
+562 0.862081396971 -0.33928579314
+563 -1.04389260722 0.0625005203764
+564 2.07959809531 1.89522527184
+565 -0.354455731839 -0.459654396053
+566 1.33289002318 -0.258409491406
+567 1.22664362358 -0.538422790006
+568 1.85319098534 2.46894472251
+569 -0.773593443763 0.760304214909
+570 1.26886212145 1.01553396799
+571 0.600288942806 -0.695384004503
+572 -0.558720368167 -0.144849184108
+573 2.56041675691 0.422204406765
+574 0.621531842267 -0.694718260905
+575 1.96381746508 1.37604102859
+576 2.36639403121 0.910706437437
+577 0.745495746681 0.51358312913
+578 1.51790546593 0.794246272017
+579 0.389018556536 1.55586522426
+580 0.433758147035 0.528897074213
+581 -1.55256303032 -2.3754293018
+582 0.184450867512 -0.15905721576
+583 2.54948109095 3.1254875726
+584 1.14828618691 -0.0843092632523
+585 2.33209323664 1.66402366494
+586 -0.0800109018387 -1.75838637268
+587 -1.00844915938 -0.896658080855
+588 2.44823145777 2.14441460999
+589 1.93791785974 1.05446297094
+590 0.699543633024 1.14524105932
+591 2.39983569247 0.404477511844
+592 1.06224023399 1.7535587029
+593 0.449649937011 0.604164300585
+594 2.16381281371 2.52871632163
+595 0.202556124432 0.659684476728
+596 2.04442187104 2.82750827022
+597 1.05163557156 0.793426866761
+598 0.756306843977 0.364035049703
+599 1.29372392653 1.53808833406
+600 0.107768664125 0.229392992968
+601 -0.024931023902 -0.109322429324
+602 -1.31647048544 -1.27102598751
+603 -1.82261536085 -1.53173913738
+604 2.43390637638 0.901979140647
+605 1.18739929034 1.58844755905
+606 0.682575412605 0.942356211445
+607 1.72661132706 1.54228771268
+608 1.09784500572 0.203670021065
+609 0.135745558019 0.342522546785
+610 -1.26983741674 -2.38814247677
+611 3.13900684267 1.88692666516
+612 0.582074615507 -0.397992306911
+613 0.398458058796 0.56804059781
+614 0.46932455806 3.4971371696
+615 0.0189051768259 -0.469971970375
+616 -1.73663542449 -1.82888091158
+617 2.39126944327 1.75614054714
+618 2.330704119 0.497628422207
+619 0.860243338672 -0.173432445718
+620 -0.82922662282 0.0377160091238
+621 0.81323034143 0.903578825373
+622 1.78655855429 2.08634115414
+623 2.53386201781 2.72907842797
+624 1.6595624772 1.68631110703
+625 1.01274922899 -0.924392514626
+626 1.55235360179 1.93135760231
+627 1.26986028743 3.01424240634
+628 -0.0818235126635 0.264194227246
+629 2.34427274803 0.422640768676
+630 0.704434142455 -0.381521808242
+631 -0.080373023695 -1.608530912
+632 2.98137648224 2.22977769074
+633 1.11048720698 1.7384621194
+634 0.473409960962 0.771341610389
+635 1.92848421628 -0.0358306458715
+636 1.27128444858 0.295774496882
+637 0.742460032623 1.00754812606
+638 2.54472403068 -0.117012094572
+639 1.64023134703 0.191446380975
+640 0.108242555083 0.402774596948
+641 1.34129338843 0.875822419311
+642 2.59365469374 1.15739225165
+643 2.38238502982 1.26201370577
+644 3.21605932534 2.25069346915
+645 -0.257191878061 -0.635794769293
+646 1.58120925084 1.93382930661
+647 0.196338196368 1.19819467207
+648 -0.0702928909198 0.814300383707
+649 2.90247651766 1.61171211116
+650 -0.795427816172 -0.334436514489
+651 -0.629413482366 -0.632207380878
+652 -0.144084499749 0.268961248025
+653 -0.218517105267 0.18090866134
+654 1.85504616389 0.53778176331
+655 0.31802429935 1.28324726681
+656 1.71662212823 1.39989361292
+657 1.31079937308 1.75203449282
+658 0.121256610451 -0.739908189767
+659 0.872820977551 0.00786030110003
+660 -2.17112267381 -1.19569712895
+661 1.78386403001 1.68310930688
+662 4.13563491156 3.62949830987
+663 1.55872947975 1.47601648782
+664 -1.30704425209 0.130223272766
+665 1.32529528201 0.849696753453
+666 1.90129032489 0.166695068933
+667 0.076235502795 -0.367090988023
+668 2.19672153365 1.82760888294
+669 0.941627988147 1.37958941224
+670 0.919497036965 0.785202218094
+671 0.771242580381 -1.13983331474
+672 2.06072210209 1.33052071981
+673 1.10244358328 1.57313731438
+674 -0.518351681232 -0.949343060309
+675 -0.285158070242 -1.14517304978
+676 0.412628834613 0.552094092824
+677 1.74530137233 0.777303741217
+678 -1.4224740359 -1.87510635769
+679 1.7987846836 1.13845291772
+680 0.347638099719 -1.12462301637
+681 0.0423545317715 1.11703720277
+682 0.47931520382 1.16174150339
+683 2.5182846848 2.8430338799
+684 -0.53291880548 -0.691754899762
+685 2.00792387483 1.52563103564
+686 1.14757033437 -0.582790146871
+687 1.23890784888 0.26758176499
+688 1.07185137023 -0.251913873566
+689 -0.521422466757 -1.06512000548
+690 -1.16627435725 -1.61838207345
+691 2.62582470673 -0.708647647917
+692 0.927083088507 0.303194726658
+693 1.89149893164 0.871389589822
+694 2.78545761048 2.21607723079
+695 2.24167346642 2.23458216656
+696 1.63806622857 2.24039408661
+697 -1.22283458191 -0.640019667177
+698 0.672886103152 -0.962509253367
+699 0.873633700786 -0.54571343013
+700 -0.802528020974 0.461416284531
+701 1.49223590923 1.74535373436
+702 1.03515292342 0.482168735426
+703 3.06804396866 0.941427966364
+704 0.117450757972 0.999379672059
+705 0.794262222462 -0.576695555004
+706 0.578981865972 0.30219121373
+707 0.781115803816 -0.164624472457
+708 1.23349345717 -0.29006323419
+709 -0.968659832993 0.0187354829897
+710 1.93045915012 0.940992209236
+711 -0.122949763517 0.773706898298
+712 -0.679865989972 -0.803755215284
+713 1.99127854928 2.19108721572
+714 0.770188966715 0.181234133761
+715 1.04894360789 0.629784906484
+716 -1.50777312772 -1.90315356357
+717 2.08072610849 0.241125531301
+718 0.516566417523 0.601677120115
+719 2.48915162628 1.40798804137
+720 -0.0810499763129 -1.49750921116
+721 0.423565134594 1.19052891122
+722 1.01729208108 1.48895714018
+723 1.97395382212 2.37853447506
+724 1.16172158107 0.501419445567
+725 1.74636873968 0.202404415846
+726 2.76098806811 1.24594676229
+727 0.702350501588 3.04336364422
+728 0.381198427648 1.39123779182
+729 2.20063972477 0.253352528355
+730 0.719136996913 0.195250256714
+731 1.69135392323 2.44520086316
+732 1.27488343113 0.428048876532
+733 2.63889134813 1.98492284507
+734 3.65405903105 3.95915048069
+735 0.345857655669 -1.29313018738
+736 1.54513482748 1.49321278305
+737 1.546346945 0.168920489752
+738 0.473136534464 -0.11495000625
+739 2.85501489758 1.51218407092
+740 1.08513832229 -0.297152256315
+741 2.14250508117 1.38144408018
+742 -0.64248501234 0.604219434669
+743 3.1930042928 2.62975785536
+744 2.14268100963 0.790411366877
+745 0.478476679674 1.12517549527
+746 0.881922915425 -0.0105471539547
+747 0.207762867153 -0.354017351578
+748 0.5512203494 0.699690801314
+749 2.53940394049 0.439553899412
+750 0.689095197985 -0.11417235544
+751 0.368738470934 1.39502234069
+752 1.56853514551 -0.0986904654701
+753 1.47725061734 -0.302153692792
+754 3.95431553622 3.32403631499
+755 -0.593928919808 -1.0870508988
+756 2.47617110499 0.208571088906
+757 1.21173003226 1.0169652282
+758 1.79966699581 -0.118926947449
+759 -1.95603723125 -2.66031635992
+760 1.6364408415 0.369168540587
+761 3.68733003563 1.65079487875
+762 0.910651399587 -1.51764411049
+763 0.498347922546 0.864412387165
+764 2.64005783357 1.85007911092
+765 -0.921641622345 -1.68214715581
+766 1.48622970844 0.865787462035
+767 4.10914523665 2.83205801212
+768 1.16894979758 -0.0419499265835
+769 1.10454460668 -0.280781157321
+770 3.09848288591 2.91336556876
+771 0.0205280911318 0.585216428684
+772 2.25195468355 2.47138111513
+773 -0.393785540589 1.31237658657
+774 2.44987615939 1.50871122351
+775 -1.42290539727 -0.543922714866
+776 0.264522068134 -0.393013424724
+777 1.27337073874 0.99285439127
+778 0.284958276437 2.18866703366
+779 -1.35688598311 -1.75831106473
+780 0.883624518491 1.9268230796
+781 0.658539500773 0.308340424885
+782 1.97650319329 1.35358898197
+783 2.78642704003 0.76260729985
+784 0.303003797663 0.609165640586
+785 0.846870288716 1.37905688263
+786 0.439755999879 0.589612157318
+787 0.77369067662 0.663375025549
+788 2.11135316664 1.63859008624
+789 2.48738092959 1.67675770364
+790 -0.147201424882 -0.95510908649
+791 3.11996702224 1.38384976649
+792 -0.949101712279 0.341171178239
+793 -0.49976552277 -0.585618939724
+794 -0.575694326033 -0.998780146074
+795 0.388075696638 -0.499659057571
+796 1.33288157367 0.280856025717
+797 0.182759647577 -0.805879895855
+798 1.04670623936 2.14891308835
+799 3.50164708714 2.26032748567
+800 0.314301935466 -1.2098833698
+801 -0.16303592247 -0.761875177208
+802 0.333932712592 -0.0573072574812
+803 -0.193940291302 0.0813898381062
+804 -0.425833712589 -2.97063981936
+805 0.958612622287 1.37662721098
+806 0.86046295315 -0.227812705577
+807 1.74545789191 1.61407938645
+808 0.17095271104 -0.416615895056
+809 0.414826568371 -1.0751635932
+810 0.179262304392 -0.849578286863
+811 1.36997523195 0.860590139708
+812 0.954451295335 1.56464965595
+813 3.75661089471 2.4074840736
+814 -0.141398924648 -2.31974269819
+815 -0.463086999609 -2.60191803028
+816 3.04971309137 0.981371683431
+817 -0.853289156873 -0.911262472072
+818 0.532007842028 -0.250193592559
+819 1.62731498622 0.735740744244
+820 0.91741152559 1.59476352315
+821 1.78562998584 0.9712274179
+822 1.22284984049 0.787769708278
+823 -0.498598906454 -0.263356381842
+824 3.13959578933 0.950426953037
+825 1.87587066587 1.21642617458
+826 1.15759839629 0.223120257653
+827 2.66375323143 2.21839752102
+828 0.773248041353 -0.741366534795
+829 2.57979307424 1.79543039298
+830 0.955745314921 2.8131791742
+831 -0.73406604712 0.193723639099
+832 1.17838621491 2.2287375112
+833 0.244070473952 0.305975143643
+834 -0.455082520621 -0.445735495187
+835 1.06082269156 0.344762814998
+836 1.38638278887 1.26187721367
+837 0.800177289425 0.589589221976
+838 -0.679473810377 0.149150897477
+839 0.745925905627 -0.00516350633378
+840 -0.63894935311 1.35534736522
+841 0.821658724263 0.831925413546
+842 0.217720386297 0.541045629592
+843 1.38191189765 0.836283402612
+844 -0.938073227963 -1.6416755797
+845 1.7594205273 -0.680239387468
+846 1.32591092739 -0.244877204286
+847 0.100768421929 -1.56796817086
+848 0.844922840698 0.30584695745
+849 -1.58099536056 -2.62627452209
+850 1.76622026799 0.698100700844
+851 1.24214718355 0.965692674522
+852 2.24960634507 2.0170367204
+853 0.374345340997 -0.0627748990537
+854 1.23739327985 0.905745201082
+855 -0.0152489177331 -0.208323033525
+856 0.0412648598923 0.0296510634187
+857 -0.907963876031 0.210880386575
+858 -1.03979333341 0.542812908539
+859 1.30593025654 -0.180957133017
+860 2.33774502024 2.97141976196
+861 -1.00528625619 -0.285059737178
+862 0.336404926328 -0.322909569595
+863 -1.18774788343 -0.248907334337
+864 0.690607293025 1.29529974786
+865 1.83733232837 0.778739706292
+866 2.47233172863 2.85257529304
+867 2.26775201989 1.20141923313
+868 -0.605536648361 -0.853580241723
+869 1.95321163726 1.1069951393
+870 -0.847670557405 -0.0376837670101
+871 2.64481472334 2.37832784947
+872 1.62552294377 0.665024634253
+873 0.909541491134 -0.27001129735
+874 1.76279998016 1.5396929052
+875 1.8863608414 1.64966199293
+876 1.28910788772 -0.679628494136
+877 1.32521922443 0.735643704301
+878 1.94993363559 1.06525179066
+879 -0.56442660719 -1.29379541158
+880 0.592008072002 1.88961991423
+881 1.19303821282 2.3024598091
+882 -0.924424821381 0.376912066102
+883 0.576964556025 0.0790701184954
+884 2.66837357916 1.47118397571
+885 1.39964009578 -1.00292327956
+886 -0.117619929023 -1.20732307332
+887 2.54762431737 2.19768496347
+888 3.25757915342 0.5666592764
+889 0.748920377805 -0.315329662266
+890 -1.34068440362 -2.24910172069
+891 -0.505745582142 -1.42927801828
+892 1.20211089992 -0.0881234698419
+893 1.78394851583 1.09896641282
+894 2.88490147738 0.0272246780127
+895 1.36697230567 -0.0805015655804
+896 -0.84193533413 0.254075787589
+897 0.5762762599 -0.589706236766
+898 0.698698198074 0.144302062831
+899 1.00395105878 0.0828954089461
+900 0.283279737141 0.0461786274254
+901 0.336761658583 -0.519875647444
+902 2.98398502725 0.897923709223
+903 1.50054355717 1.34169503427
+904 2.72336962172 1.0934303171
+905 1.04386747176 -0.259867944844
+906 2.26636034462 2.34290355893
+907 1.06783566934 -0.271804958053
+908 0.870769551483 -0.565458859058
+909 -0.355020161729 -0.0465272569999
+910 1.47792780553 2.20457016093
+911 2.3213067274 3.48508785754
+912 2.22647376583 1.60059264483
+913 -2.56553794385 -1.50609738648
+914 -1.86276295813 -0.162042653801
+915 0.996847460844 1.04251234985
+916 0.237811244321 -1.40828452583
+917 2.29532044329 2.26795430785
+918 -1.42058277927 -0.139976660562
+919 -1.14982270238 -0.940401009527
+920 1.29488330811 0.625097008703
+921 1.75669056948 0.774900325832
+922 1.58638974075 1.62323828463
+923 2.24184259658 1.66172380299
+924 1.25555724841 0.703039346719
+925 -0.375004313818 -0.287342136508
+926 1.15123529 2.32815302898
+927 1.04939658961 1.57645783759
+928 -0.111237564066 -0.575666981136
+929 1.11648290176 0.0839548085496
+930 0.896401504196 -0.591658487194
+931 -1.54828369019 -2.09130174917
+932 -2.10210444811 -1.00953307381
+933 0.578744043015 1.06812809264
+934 1.9031494339 2.58891974662
+935 0.650688410389 -0.333344575395
+936 1.45490884712 -1.07890749401
+937 -2.29271663116 -1.02590301386
+938 -0.553520580323 -0.876623533905
+939 0.295435790386 0.154151106451
+940 0.739552197854 -1.45056938461
+941 0.550596269191 -0.211490309288
+942 2.06617139015 1.68357498934
+943 1.37009335914 0.248966043502
+944 -0.779723180082 1.04185667777
+945 0.657346131671 0.395013846374
+946 1.35793985771 1.23005653641
+947 0.346675905403 0.350476402606
+948 1.90143214681 -1.15790392208
+949 1.53755048835 1.16322562472
+950 1.79676676874 0.215953081403
+951 -0.653794703493 -1.25304663149
+952 3.22998948681 2.83965358638
+953 1.38852441013 1.0349202775
+954 0.6407225295 -0.148904121116
+955 4.85000442842 2.46644798213
+956 -0.571640043081 0.243693414108
+957 -0.854429704873 -1.20906016632
+958 -0.874078069668 -0.222990486174
+959 2.77410991574 3.23952664504
+960 0.276074094834 0.439327093322
+961 1.54579862229 1.1440556871
+962 2.23366155194 -0.359657105833
+963 2.21934095707 1.79156902781
+964 2.86300126621 1.96212364234
+965 0.00486634868158 0.669181762001
+966 0.539941607917 -0.504574984575
+967 1.1309972889 0.885170985788
+968 1.6692167276 1.33735722262
+969 -0.0137451416733 0.553616395605
+970 2.13229368105 1.28967806398
+971 1.0500030028 0.509911061302
+972 1.5058172904 0.0852260723227
+973 0.325847822973 0.186023614173
+974 -0.245039097176 0.337306470895
+975 2.16487426907 1.32405596035
+976 4.19696845179 1.75410942942
+977 2.06140151241 2.8798802773
+978 2.61222166917 0.851089587134
+979 -0.714530716835 -1.46320620395
+980 1.32899995942 1.55150260174
+981 -0.394233621705 -0.856512866842
+982 1.81059648553 0.714173342419
+983 1.12703896172 1.24851248903
+984 2.95556810589 1.94860146185
+985 1.70187203768 -1.00603168336
+986 3.43828180843 1.80565165287
+987 2.11199388028 1.28652551778
+988 0.335427288053 0.406678273009
+989 -1.72386638965 -1.70394842507
+990 1.22086004787 0.708041438911
+991 -1.03093269869 -0.121198424122
+992 1.14306483245 -0.520134639627
+993 1.21535477617 0.362732243366
+994 0.793234640358 -0.356093010693
+995 2.41023312707 1.5279948071
+996 1.14798568608 0.905693333918
+997 1.13789136769 1.25958660988
+998 1.1508991036 0.767507215707
+999 1.34103725484 1.00348213522
diff --git a/regtest/analysis/rt-pca-2/config b/regtest/analysis/rt-pca-2/config
new file mode 100644
index 0000000000000000000000000000000000000000..58f0b8893460c32a1c9a774c2f8e59d2d9761a08
--- /dev/null
+++ b/regtest/analysis/rt-pca-2/config
@@ -0,0 +1,3 @@
+type=driver
+arg="--plumed plumed.dat --ixyz diala_traj_nm.xyz"
+extra_files="../../trajectories/diala_traj_nm.xyz"
diff --git a/regtest/analysis/rt-pca-2/pca-comp.pdb.reference b/regtest/analysis/rt-pca-2/pca-comp.pdb.reference
new file mode 100644
index 0000000000000000000000000000000000000000..4a7972a92b559a3d72825fe6b206e96622e2a667
--- /dev/null
+++ b/regtest/analysis/rt-pca-2/pca-comp.pdb.reference
@@ -0,0 +1,12 @@
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=c1,c2
+REMARK c1=0.9663   c2=0.4730   
+END
+REMARK TYPE=DIRECTION
+REMARK ARG=c1,c2
+REMARK c1=0.7142   c2=0.6999   
+END
+REMARK TYPE=DIRECTION
+REMARK ARG=c1,c2
+REMARK c1=0.6999   c2=-0.7142  
+END
diff --git a/regtest/analysis/rt-pca-2/plumed.dat b/regtest/analysis/rt-pca-2/plumed.dat
new file mode 100644
index 0000000000000000000000000000000000000000..aa6a39f97daf852438292389b69aa52ef43389da
--- /dev/null
+++ b/regtest/analysis/rt-pca-2/plumed.dat
@@ -0,0 +1,4 @@
+c1: READ FILE=colvar.in VALUES=cv1
+c2: READ FILE=colvar.in VALUES=cv2
+
+PCA METRIC=EUCLIDEAN ARG=c1,c2 USE_ALL_DATA NLOW_DIM=2 OFILE=pca-comp.pdb FMT=%8.4f
diff --git a/regtest/analysis/rt-pca/Makefile b/regtest/analysis/rt-pca/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee
--- /dev/null
+++ b/regtest/analysis/rt-pca/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/analysis/rt-pca/config b/regtest/analysis/rt-pca/config
new file mode 100644
index 0000000000000000000000000000000000000000..58f0b8893460c32a1c9a774c2f8e59d2d9761a08
--- /dev/null
+++ b/regtest/analysis/rt-pca/config
@@ -0,0 +1,3 @@
+type=driver
+arg="--plumed plumed.dat --ixyz diala_traj_nm.xyz"
+extra_files="../../trajectories/diala_traj_nm.xyz"
diff --git a/regtest/analysis/rt-pca/pca-comp.pdb.reference b/regtest/analysis/rt-pca/pca-comp.pdb.reference
new file mode 100644
index 0000000000000000000000000000000000000000..fc22670a085813745bf312a3803ddbea39367c40
--- /dev/null
+++ b/regtest/analysis/rt-pca/pca-comp.pdb.reference
@@ -0,0 +1,72 @@
+REMARK TYPE=OPTIMAL
+ATOM     1  X    RES     0    -3.002  -0.303   1.042  0.05  0.05
+ATOM     2  X    RES     1    -3.375  -0.131   1.046  0.05  0.05
+ATOM     3  X    RES     2    -3.376  -0.402   1.084  0.05  0.05
+ATOM     4  X    RES     3    -3.326  -0.239   1.294  0.05  0.05
+ATOM     5  X    RES     4    -1.625  -0.479   0.681  0.05  0.05
+ATOM     6  X    RES     5    -1.001  -0.681   1.355  0.05  0.05
+ATOM     7  X    RES     6    -1.117  -0.412  -0.407  0.05  0.05
+ATOM     8  X    RES     7    -1.688  -0.225  -0.895  0.05  0.05
+ATOM     9  X    RES     8     0.167  -0.648  -0.993  0.05  0.05
+ATOM    10  X    RES     9     0.264  -1.677  -1.119  0.05  0.05
+ATOM    11  X    RES    10     0.199  -0.014  -2.349  0.05  0.05
+ATOM    12  X    RES    11     0.278   0.101  -2.643  0.05  0.05
+ATOM    13  X    RES    12     0.168   0.098  -2.737  0.05  0.05
+ATOM    14  X    RES    13     0.174   0.229  -2.704  0.05  0.05
+ATOM    15  X    RES    14     1.392  -0.272  -0.203  0.05  0.05
+ATOM    16  X    RES    15     2.259  -0.716  -0.363  0.05  0.05
+ATOM    17  X    RES    16     1.500   0.569   0.661  0.05  0.05
+ATOM    18  X    RES    17     0.762   0.889   0.785  0.05  0.05
+ATOM    19  X    RES    18     2.611   0.994   1.452  0.05  0.05
+ATOM    20  X    RES    19     2.964   1.128   1.574  0.05  0.05
+ATOM    21  X    RES    20     2.843   1.185   1.726  0.05  0.05
+ATOM    22  X    RES    21     2.928   1.006   1.713  0.05  0.05
+END
+REMARK TYPE=DIRECTION
+ATOM     1  X    RES     0     0.354   0.171   0.229  1.00  1.00
+ATOM     2  X    RES     1     0.585   0.567   0.558  1.00  1.00
+ATOM     3  X    RES     2     0.205   0.793   0.037  1.00  1.00
+ATOM     4  X    RES     3     0.320   0.180   0.111  1.00  1.00
+ATOM     5  X    RES     4     0.255  -1.235   0.169  1.00  1.00
+ATOM     6  X    RES     5     0.252  -4.529   0.304  1.00  1.00
+ATOM     7  X    RES     6     0.252   1.215  -0.073  1.00  1.00
+ATOM     8  X    RES     7     0.435   3.800  -0.249  1.00  1.00
+ATOM     9  X    RES     8     0.107   0.313  -0.066  1.00  1.00
+ATOM    10  X    RES     9     0.093   0.161   1.087  1.00  1.00
+ATOM    11  X    RES    10    -0.089  -1.113  -0.746  1.00  1.00
+ATOM    12  X    RES    11     0.480  -3.066  -1.776  1.00  1.00
+ATOM    13  X    RES    12    -2.025  -1.152  -0.684  1.00  1.00
+ATOM    14  X    RES    13     1.185  -0.261  -0.272  1.00  1.00
+ATOM    15  X    RES    14     0.099   1.372  -0.666  1.00  1.00
+ATOM    16  X    RES    15     0.492   3.830  -2.307  1.00  1.00
+ATOM    17  X    RES    16    -0.394  -0.438   0.775  1.00  1.00
+ATOM    18  X    RES    17    -0.608  -2.369   1.984  1.00  1.00
+ATOM    19  X    RES    18    -0.479   0.302   0.455  1.00  1.00
+ATOM    20  X    RES    19    -0.662   0.700   0.477  1.00  1.00
+ATOM    21  X    RES    20    -0.547   0.209   0.491  1.00  1.00
+ATOM    22  X    RES    21    -0.309   0.548   0.162  1.00  1.00
+END
+REMARK TYPE=DIRECTION
+ATOM     1  X    RES     0     0.040  -0.180   0.140  1.00  1.00
+ATOM     2  X    RES     1     0.469  -1.519   2.216  1.00  1.00
+ATOM     3  X    RES     2     0.337   2.166   0.164  1.00  1.00
+ATOM     4  X    RES     3    -0.723  -1.344  -1.892  1.00  1.00
+ATOM     5  X    RES     4     0.011  -0.017   0.057  1.00  1.00
+ATOM     6  X    RES     5     0.044   0.234  -0.008  1.00  1.00
+ATOM     7  X    RES     6    -0.006  -0.149   0.077  1.00  1.00
+ATOM     8  X    RES     7    -0.009  -0.335   0.106  1.00  1.00
+ATOM     9  X    RES     8    -0.007  -0.045   0.002  1.00  1.00
+ATOM    10  X    RES     9     0.008  -0.058  -0.089  1.00  1.00
+ATOM    11  X    RES    10    -0.099   0.067   0.048  1.00  1.00
+ATOM    12  X    RES    11     2.890  -0.426  -0.116  1.00  1.00
+ATOM    13  X    RES    12    -2.066  -1.963  -0.898  1.00  1.00
+ATOM    14  X    RES    13    -1.117   2.728   1.157  1.00  1.00
+ATOM    15  X    RES    14     0.018  -0.063   0.016  1.00  1.00
+ATOM    16  X    RES    15     0.077  -0.275   0.135  1.00  1.00
+ATOM    17  X    RES    16    -0.013   0.160  -0.129  1.00  1.00
+ATOM    18  X    RES    17    -0.037   0.355  -0.233  1.00  1.00
+ATOM    19  X    RES    18     0.046   0.169  -0.200  1.00  1.00
+ATOM    20  X    RES    19     2.278  -3.179  -1.474  1.00  1.00
+ATOM    21  X    RES    20     0.240   3.803  -2.326  1.00  1.00
+ATOM    22  X    RES    21    -2.383  -0.130   3.246  1.00  1.00
+END
diff --git a/regtest/analysis/rt-pca/plumed.dat b/regtest/analysis/rt-pca/plumed.dat
new file mode 100644
index 0000000000000000000000000000000000000000..3bb806c3ad6fc770728daf3c1325763aefb4a55f
--- /dev/null
+++ b/regtest/analysis/rt-pca/plumed.dat
@@ -0,0 +1 @@
+PCA METRIC=OPTIMAL ATOMS=1-22 STRIDE=1 USE_ALL_DATA NLOW_DIM=2 OFILE=pca-comp.pdb
diff --git a/src/analysis/PCA.cpp b/src/analysis/PCA.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..624d2609164fa2ef6e80ad580350bdb349554d5f
--- /dev/null
+++ b/src/analysis/PCA.cpp
@@ -0,0 +1,237 @@
+/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+   Copyright (c) 2012-2015 The plumed team
+   (see the PEOPLE file at the root of the distribution for a list of names)
+
+   See http://www.plumed-code.org for more information.
+
+   This file is part of plumed, version 2.
+
+   plumed is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   plumed is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with plumed.  If not, see <http://www.gnu.org/licenses/>.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "Analysis.h"
+#include "tools/Matrix.h"
+#include "reference/Direction.h"
+#include "reference/MetricRegister.h"
+#include "reference/ReferenceConfiguration.h"
+#include "reference/ReferenceValuePack.h"
+#include "core/ActionRegister.h"
+
+//+PLUMEDOC ANALYSIS PCA
+/* 
+Perform principal component analysis (PCA) using either the positions of the atoms a large number of collective variables as input.
+
+Principal component analysis is a statistical technique that uses an orthogonal transformation to convert a set of observations of 
+poorly correlated variables into a set of linearly uncorrelated variables.  You can read more about the specifics of this technique
+here: https://en.wikipedia.org/wiki/Principal_component_analysis
+
+When used in context with molecular dynamics simulations a set of frames taken from the trajectory, \f$\{X_i\}\f$, or the values of 
+a number of collective variables which are calculated from the trajectory frames are used as input.  In this second instance your 
+input to the PCA analysis algorithm is thus a set of high-dimensional vectors of collective variables.  However, if
+collective variables are calculated from the positions of the atoms or if the positions are used directly the assumption is that 
+this input trajectory is a set of poorly correlated (high-dimensional) vectors.  After principal component analysis has been 
+performed the output is a set of orthogonal vectors that describe the directions in which the largest motions have been seen.  
+In other words, principal component analysis provides a method for lowering the dimensionality of the data contained in a trajectory.
+These output directions are some linear combination of the \f$x\f$, \f$y\f$ and \f$z\f$ positions if the positions were used as input 
+or some linear combination of the input collective variables if a high-dimensional vector of collective variables was used as input.
+
+As explained on the Wikipedia page you must calculate the average and covariance for each of the input coordinates.  In other words, you must 
+calculate the average structure and the amount the system fluctuates around this average structure.  The problem in doing so when the 
+\f$x\f$, \f$y\f$ and \f$z\f$ coordinates of a molecule are used as input is that the majority of the changes in the positions of the 
+atoms comes from the translational and rotational degrees of freedom of the molecule.  The first six principal components will thus, most likely,
+be uninteresting.  Consequently, to remedy this problem PLUMED provides the functionality to perform an RMSD alignment of the all the structures 
+to be analysed to the first frame in the trajectory.  This can be used to effectively remove translational and/or rotational motions from 
+consideration.  The resulting principal components thus describe vibrational motions of the molecule. 
+
+If you wish to calculate the projection of a trajectory on a set of principal components calculated from this PCA action then the output can be 
+used as input for the \ref PCAVARS action.
+
+\par Examples
+
+The following input instructs PLUMED to perform a principal component analysis in which the covariance matrix is calculated from changes in the positions
+of the first 22 atoms.  The TYPE=OPTIMAL instruction ensures that translational and rotational degrees of freedom are removed from consideration.
+The first two principal components will be output to a file called pca-comp.pdb.  Trajectory frames will be collected on every step and the PCA calculation
+will be performed at the end of the simulation.
+
+\verbatim
+PCA METRIC=OPTIMAL ATOMS=1-22 STRIDE=1 USE_ALL_DATA NLOW_DIM=2 OFILE=pca-comp.pdb
+\endverbatim
+
+The following input instructs PLUMED to perform a principal component analysis in which the covariance matrix is calculated from chnages in the six distances
+seen in the previous lines.  Notice that here the TYPE=EUCLIDEAN keyword is used to indicate that no alighment has to be done when calculating the various
+elements of the covariance matrix from the input vectors.  In this calculation the first two principal components will be output to a file called pca-comp.pdb.
+Trajectory frames will be collected every five steps and the PCA calculation is performed every 1000 steps.  Consequently, if you run a 2000 step simulation the 
+PCA analysis will be performed twice.  The REWEIGHT_BIAS keyword in this input tells PLUMED that rather that ascribing a weight of one to each of the frames
+when calculating averages and covariances a reweighting should be performed based and each frames' weight in these calculations should be determined based on 
+the current value of the instantaneous bias (see \ref reweighting).  
+
+\verbatim
+d1: DISTANCE ATOMS=1,2
+d2: DISTANCE ATOMS=1,3
+d3: DISTANCE ATOMS=1,4
+d4: DISTNACE ATOMS=2,3
+d5: DISTANCE ATOMS=2,4
+d6: DISTANCE ATOMS=3,4
+
+PCA ARG=d1,d2,d3,d4,d5,d6 METRIC=EUCLIDEAN STRIDE=5 RUN=1000 NLOW_DIM=2 REWEIGHT_BIAS OFILE=pca-comp.pdb
+\endverbatim
+
+*/
+//+ENDPLUMEDOC
+
+namespace PLMD {
+namespace analysis {
+
+class PCA : public Analysis {
+private:
+  unsigned ndim;
+/// The position of the reference configuration (the one we align to)
+  ReferenceConfiguration* myref;
+/// The eigenvectors for the atomic displacements
+  Matrix<Vector> atom_eigv;
+/// The eigenvectors for the displacements in argument space
+  Matrix<double> arg_eigv;
+  std::string ofilename;
+public:
+  static void registerKeywords( Keywords& keys );
+  explicit PCA(const ActionOptions&ao);
+  ~PCA();
+  void performAnalysis();
+  void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); }
+};
+
+PLUMED_REGISTER_ACTION(PCA,"PCA")
+
+void PCA::registerKeywords( Keywords& keys ){
+  Analysis::registerKeywords( keys );
+  keys.add("compulsory","NLOW_DIM","number of PCA coordinates required");
+  keys.add("compulsory","OFILE","the file on which to output the eigenvectors");
+}
+
+PCA::PCA(const ActionOptions&ao):
+PLUMED_ANALYSIS_INIT(ao)
+{
+  // Setup reference configuration
+  log.printf("  performing PCA analysis using %s metric \n", getMetricName().c_str() );
+  myref = metricRegister().create<ReferenceConfiguration>( getMetricName() );
+  std::vector<std::string> argnames( getNumberOfArguments() );
+  for(unsigned i=0;i<argnames.size();++i){
+     if( getArguments()[i]->isPeriodic() ) error("cannot run PCA with periodic variables");
+     argnames[i] = getArguments()[i]->getName();
+  }
+  myref->setNamesAndAtomNumbers( getAbsoluteIndexes(), argnames );
+
+  parse("NLOW_DIM",ndim);
+  if( getNumberOfAtoms()>0 ) atom_eigv.resize( ndim, getNumberOfAtoms() );
+  if( getNumberOfArguments()>0 ) arg_eigv.resize( ndim, getNumberOfArguments() );
+
+  // Read stuff for output file
+  parseOutputFile("OFILE",ofilename); 
+  checkRead();
+}
+
+PCA::~PCA(){
+  delete myref;
+}
+
+void PCA::performAnalysis(){
+  // Align everything to the first frame
+  MultiValue myval( 1, getNumberOfArguments() + 3*getNumberOfAtoms() + 9 );
+  ReferenceValuePack mypack( getNumberOfArguments(), getNumberOfAtoms(), myval );
+  for(unsigned i=0;i<getNumberOfAtoms();++i) mypack.setAtomIndex( i, i );
+  // Setup some PCA storage 
+  data[0]->setupPCAStorage ( mypack );
+
+  // Create some arrays to store the average position
+  std::vector<double> sarg( getNumberOfArguments(), 0 );
+  std::vector<Vector> spos( getNumberOfAtoms() );
+  for(unsigned i=0;i<getNumberOfAtoms();++i) spos[i].zero();  
+ 
+  // Calculate the average displacement from the first frame 
+  for(unsigned i=1;i<getNumberOfDataPoints();++i){
+      double d = data[0]->calc( data[i]->getReferencePositions(), getPbc(), getArguments(), data[i]->getReferenceArguments(), mypack, true );
+      // Accumulate average displacement of arguments (Here PBC could do fucked up things - really needs Berry Phase ) GAT
+      for(unsigned j=0;j<getNumberOfArguments();++j) sarg[j] += 0.5*getWeight(i)*mypack.getArgumentDerivative(j); 
+      // Accumulate average displacement of position
+      for(unsigned j=0;j<getNumberOfAtoms();++j) spos[j] += getWeight(i)*mypack.getAtomsDisplacementVector()[j];
+  }
+  // Now normalise the displacements to get the average and add these to the first frame
+  double inorm = 1.0 / getNormalization(); 
+  for(unsigned j=0;j<getNumberOfArguments();++j) sarg[j] = inorm*sarg[j] + data[0]->getReferenceArguments()[j];
+  for(unsigned j=0;j<getNumberOfAtoms();++j) spos[j] = inorm*spos[j] + data[0]->getReferencePositions()[j]; 
+  // And set the reference configuration
+  std::vector<double> empty( getNumberOfArguments(), 1.0 ); myref->setReferenceConfig( spos, sarg, empty ); 
+
+  // Now accumulate the covariance
+  unsigned narg=getNumberOfArguments();
+  Matrix<double> covar( getNumberOfArguments()+3*getNumberOfAtoms(), getNumberOfArguments()+3*getNumberOfAtoms() ); covar=0;
+  for(unsigned i=0;i<getNumberOfDataPoints();++i){
+      // double d = data[i]->calc( spos, getPbc(), getArguments(), sarg, mypack, true );
+      double d = data[0]->calc( data[i]->getReferencePositions(), getPbc(), getArguments(), data[i]->getReferenceArguments(), mypack, true );
+      for(unsigned jarg=0;jarg<getNumberOfArguments();++jarg){
+         // Need sorting for PBC with GAT 
+         double jarg_d = 0.5*mypack.getArgumentDerivative(jarg) + data[0]->getReferenceArguments()[jarg] - sarg[jarg];
+         for(unsigned karg=0;karg<getNumberOfArguments();++karg){
+            // Need sorting for PBC with GAT 
+            double karg_d = 0.5*mypack.getArgumentDerivative(karg) + data[0]->getReferenceArguments()[karg] - sarg[karg];
+            covar( jarg, karg ) += 0.25*getWeight(i)*jarg_d*karg_d; // mypack.getArgumentDerivative(jarg)*mypack.getArgumentDerivative(karg); 
+         }
+      }
+      for(unsigned jat=0;jat<getNumberOfAtoms();++jat){ 
+        for(unsigned jc=0;jc<3;++jc){
+             double jdisplace = mypack.getAtomsDisplacementVector()[jat][jc] + data[0]->getReferencePositions()[jat][jc] - spos[jat][jc];
+             for(unsigned kat=0;kat<getNumberOfAtoms();++kat){ 
+                 for(unsigned kc=0;kc<3;++kc){
+                    double kdisplace = mypack.getAtomsDisplacementVector()[kat][kc] + data[0]->getReferencePositions()[kat][kc] - spos[kat][kc];
+                    covar( narg+3*jat + jc, narg+3*kat + kc ) += getWeight(i)*jdisplace*kdisplace; 
+                 }
+             }
+         }
+      }
+  }
+  // Normalise
+  for(unsigned i=0;i<covar.nrows();++i){
+      for(unsigned j=0;j<covar.ncols();++j) covar(i,j) *= inorm; 
+  }
+
+  // Diagonalise the covariance
+  std::vector<double> eigval( getNumberOfArguments()+3*getNumberOfAtoms() );
+  Matrix<double> eigvec( getNumberOfArguments()+3*getNumberOfAtoms(), getNumberOfArguments()+3*getNumberOfAtoms() );
+  diagMat( covar, eigval, eigvec );
+
+  // Open an output file
+  OFile ofile; ofile.link(*this); ofile.setBackupString("analysis");
+  ofile.open( ofilename ); 
+  // Output the reference configuration
+  myref->print( ofile, getOutputFormat(), atoms.getUnits().getLength()/0.1 );   
+
+  // Store and print the eigenvectors
+  std::vector<Vector> tmp_atoms( getNumberOfAtoms() );
+  std::vector<double> tmp_args( getNumberOfArguments() );
+  Direction* tref = metricRegister().create<Direction>( "DIRECTION" );
+  tref->setNamesAndAtomNumbers( getAbsoluteIndexes(), argument_names );
+  for(unsigned dim=0;dim<ndim;++dim){
+     unsigned idim = covar.ncols() - 1 - dim;
+     for(unsigned i=0;i<getNumberOfArguments();++i) tmp_args[i]=arg_eigv(dim,i)=eigvec(idim,i);
+     for(unsigned i=0;i<getNumberOfAtoms();++i){
+         for(unsigned k=0;k<3;++k) tmp_atoms[i][k]=atom_eigv(dim,i)[k]=eigvec(idim,narg+3*i+k);
+     }  
+     tref->setDirection( tmp_atoms, tmp_args );
+     tref->print( ofile, getOutputFormat(), atoms.getUnits().getLength()/0.1 ); 
+  } 
+  // Close the output file   
+  delete tref; ofile.close();
+}
+
+}
+}
diff --git a/src/bias/External.cpp b/src/bias/External.cpp
index 0a8193466426b2588940e6d34a6e52cdde3b73a2..b01c47fc642d7aeadcdfdd6f07dd19fa1c5e6a28 100644
--- a/src/bias/External.cpp
+++ b/src/bias/External.cpp
@@ -41,7 +41,7 @@ The following is an input for a calculation with an external potential that is
 defined in the file bias.dat and that acts on the distance between atoms 3 and 5.
 \verbatim
 DISTANCE ATOMS=3,5 LABEL=d1
-EXTERNAL ARG=d1 FILENAME=bias.dat LABEL=external 
+EXTERNAL ARG=d1 FILE=bias.dat LABEL=external 
 \endverbatim
 (See also \ref DISTANCE \ref PRINT).
 
@@ -64,7 +64,7 @@ potential acting on two torsional angles:
 \verbatim
 TORSION ATOMS=4,5,6,7 LABEL=t1
 TORSION ATOMS=6,7,8,9 LABEL=t2
-EXTERNAL ARG=t1,t2 FILENAME=bias.dat LABEL=ext
+EXTERNAL ARG=t1,t2 FILE=bias.dat LABEL=ext
 \endverbatim
 
 The header in the file bias.dat for this calculation would read:
diff --git a/src/mapping/Path.cpp b/src/mapping/Path.cpp
index 56fac268c68cf4a48367fcdf000cd42375b2e665..00b1596c692d3a2af7949793dc98b081e47a8349 100644
--- a/src/mapping/Path.cpp
+++ b/src/mapping/Path.cpp
@@ -66,12 +66,14 @@ PLUMED_REGISTER_ACTION(Path,"PATH")
 void Path::registerKeywords( Keywords& keys ){
   PathBase::registerKeywords( keys ); keys.remove("PROPERTY");
   keys.addFlag("NOSPATH",false,"do not calculate the spath position");
+  keys.remove("LOWMEM");
 }
 
 Path::Path(const ActionOptions& ao):
 Action(ao),
 PathBase(ao)
 {
+  setLowMemOption( true ); 
   bool nos; parseFlag("NOSPATH",nos);
 
   std::string empty;