diff --git a/regtest/sizeshape/Makefile b/regtest/sizeshape/Makefile
new file mode 100644
index 0000000000..42480767ae
--- /dev/null
+++ b/regtest/sizeshape/Makefile
@@ -0,0 +1,2 @@
+include ../scripts/module.make
+
diff --git a/regtest/sizeshape/rt-mahadist/Makefile b/regtest/sizeshape/rt-mahadist/Makefile
new file mode 100644
index 0000000000..3703b27cea
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/sizeshape/rt-mahadist/config b/regtest/sizeshape/rt-mahadist/config
new file mode 100644
index 0000000000..f2c2f7b285
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/config
@@ -0,0 +1,3 @@
+type=driver
+plumed_modules=sizeshape
+arg="--plumed plumed.dat --itrr test_traj.trr"
diff --git a/regtest/sizeshape/rt-mahadist/deriv.reference b/regtest/sizeshape/rt-mahadist/deriv.reference
new file mode 100644
index 0000000000..ed340f8946
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/deriv.reference
@@ -0,0 +1,391 @@
+#! FIELDS time parameter d
+ 0.000000 0 0.073
+ 0.000000 1 0.152
+ 0.000000 2 -0.299
+ 0.000000 3 0.128
+ 0.000000 4 -0.403
+ 0.000000 5 0.630
+ 0.000000 6 -1.717
+ 0.000000 7 2.577
+ 0.000000 8 -0.466
+ 0.000000 9 1.793
+ 0.000000 10 -2.024
+ 0.000000 11 0.019
+ 0.000000 12 0.672
+ 0.000000 13 -3.252
+ 0.000000 14 0.580
+ 0.000000 15 -1.216
+ 0.000000 16 2.568
+ 0.000000 17 -0.813
+ 0.000000 18 -0.865
+ 0.000000 19 -1.512
+ 0.000000 20 -0.051
+ 0.000000 21 2.083
+ 0.000000 22 3.175
+ 0.000000 23 1.265
+ 0.000000 24 -2.147
+ 0.000000 25 -0.827
+ 0.000000 26 0.672
+ 0.000000 27 1.087
+ 0.000000 28 -0.619
+ 0.000000 29 -0.977
+ 0.000000 30 0.887
+ 0.000000 31 -0.591
+ 0.000000 32 -1.649
+ 0.000000 33 -2.266
+ 0.000000 34 -2.066
+ 0.000000 35 0.291
+ 0.000000 36 1.479
+ 0.000000 37 2.678
+ 0.000000 38 -1.886
+ 0.000000 39 0.924
+ 0.000000 40 0.730
+ 0.000000 41 3.040
+ 0.000000 42 -2.052
+ 0.000000 43 0.043
+ 0.000000 44 1.569
+ 0.000000 45 2.054
+ 0.000000 46 -1.377
+ 0.000000 47 -4.637
+ 0.000000 48 -2.290
+ 0.000000 49 1.402
+ 0.000000 50 1.496
+ 0.000000 51 0.425
+ 0.000000 52 -0.488
+ 0.000000 53 5.286
+ 0.000000 54 2.387
+ 0.000000 55 1.137
+ 0.000000 56 -2.983
+ 0.000000 57 -2.033
+ 0.000000 58 -5.916
+ 0.000000 59 2.411
+ 0.000000 60 1.649
+ 0.000000 61 4.954
+ 0.000000 62 -3.420
+ 0.000000 63 -1.986
+ 0.000000 64 -0.851
+ 0.000000 65 0.515
+ 0.000000 66 0.930
+ 0.000000 67 0.512
+ 0.000000 68 -0.595
+ 0.000000 69 2.692
+ 0.000000 70 0.575
+ 0.000000 71 3.468
+ 0.000000 72 0.575
+ 0.000000 73 -4.199
+ 0.000000 74 4.022
+ 0.000000 75 3.468
+ 0.000000 76 4.022
+ 0.000000 77 -18.669
+ 1.000000 0 0.484
+ 1.000000 1 0.093
+ 1.000000 2 -0.455
+ 1.000000 3 -1.082
+ 1.000000 4 -0.345
+ 1.000000 5 1.037
+ 1.000000 6 0.900
+ 1.000000 7 1.688
+ 1.000000 8 -0.555
+ 1.000000 9 -0.976
+ 1.000000 10 -1.503
+ 1.000000 11 -0.367
+ 1.000000 12 1.359
+ 1.000000 13 -1.997
+ 1.000000 14 0.144
+ 1.000000 15 -0.158
+ 1.000000 16 4.747
+ 1.000000 17 -1.600
+ 1.000000 18 0.011
+ 1.000000 19 -2.663
+ 1.000000 20 0.513
+ 1.000000 21 -1.477
+ 1.000000 22 -2.846
+ 1.000000 23 3.938
+ 1.000000 24 2.165
+ 1.000000 25 1.594
+ 1.000000 26 -4.052
+ 1.000000 27 -0.637
+ 1.000000 28 1.258
+ 1.000000 29 0.686
+ 1.000000 30 -2.156
+ 1.000000 31 0.128
+ 1.000000 32 1.837
+ 1.000000 33 2.777
+ 1.000000 34 -0.183
+ 1.000000 35 -2.703
+ 1.000000 36 -4.607
+ 1.000000 37 -2.879
+ 1.000000 38 1.985
+ 1.000000 39 4.088
+ 1.000000 40 4.293
+ 1.000000 41 1.664
+ 1.000000 42 -1.597
+ 1.000000 43 -1.907
+ 1.000000 44 0.133
+ 1.000000 45 1.347
+ 1.000000 46 0.062
+ 1.000000 47 -1.966
+ 1.000000 48 -1.623
+ 1.000000 49 1.593
+ 1.000000 50 -0.433
+ 1.000000 51 1.843
+ 1.000000 52 -0.277
+ 1.000000 53 -0.251
+ 1.000000 54 0.647
+ 1.000000 55 1.340
+ 1.000000 56 -2.888
+ 1.000000 57 -0.229
+ 1.000000 58 -4.507
+ 1.000000 59 4.897
+ 1.000000 60 0.495
+ 1.000000 61 2.792
+ 1.000000 62 -1.925
+ 1.000000 63 -2.629
+ 1.000000 64 -0.631
+ 1.000000 65 0.410
+ 1.000000 66 1.053
+ 1.000000 67 0.149
+ 1.000000 68 -0.051
+ 1.000000 69 2.078
+ 1.000000 70 1.930
+ 1.000000 71 -6.979
+ 1.000000 72 1.930
+ 1.000000 73 -1.450
+ 1.000000 74 -1.751
+ 1.000000 75 -6.979
+ 1.000000 76 -1.751
+ 1.000000 77 -1.923
+ 2.000000 0 -0.259
+ 2.000000 1 0.217
+ 2.000000 2 -0.027
+ 2.000000 3 0.413
+ 2.000000 4 -0.461
+ 2.000000 5 -0.096
+ 2.000000 6 0.302
+ 2.000000 7 0.629
+ 2.000000 8 -1.096
+ 2.000000 9 -1.509
+ 2.000000 10 0.249
+ 2.000000 11 1.141
+ 2.000000 12 1.119
+ 2.000000 13 -0.211
+ 2.000000 14 1.538
+ 2.000000 15 -2.266
+ 2.000000 16 -0.915
+ 2.000000 17 -0.134
+ 2.000000 18 1.495
+ 2.000000 19 0.585
+ 2.000000 20 -0.715
+ 2.000000 21 1.914
+ 2.000000 22 0.404
+ 2.000000 23 -0.638
+ 2.000000 24 -2.092
+ 2.000000 25 0.939
+ 2.000000 26 1.288
+ 2.000000 27 -1.100
+ 2.000000 28 -0.123
+ 2.000000 29 0.958
+ 2.000000 30 3.093
+ 2.000000 31 -2.066
+ 2.000000 32 -3.391
+ 2.000000 33 -3.433
+ 2.000000 34 -0.783
+ 2.000000 35 2.963
+ 2.000000 36 6.051
+ 2.000000 37 2.725
+ 2.000000 38 -6.009
+ 2.000000 39 -3.825
+ 2.000000 40 -2.038
+ 2.000000 41 5.326
+ 2.000000 42 1.159
+ 2.000000 43 0.994
+ 2.000000 44 -2.187
+ 2.000000 45 -0.322
+ 2.000000 46 -0.138
+ 2.000000 47 -1.123
+ 2.000000 48 -1.114
+ 2.000000 49 1.470
+ 2.000000 50 2.194
+ 2.000000 51 -0.371
+ 2.000000 52 -2.130
+ 2.000000 53 6.053
+ 2.000000 54 -0.849
+ 2.000000 55 -1.105
+ 2.000000 56 -1.620
+ 2.000000 57 1.027
+ 2.000000 58 -2.146
+ 2.000000 59 -0.858
+ 2.000000 60 0.206
+ 2.000000 61 3.559
+ 2.000000 62 -2.421
+ 2.000000 63 0.784
+ 2.000000 64 -0.097
+ 2.000000 65 -1.587
+ 2.000000 66 -0.425
+ 2.000000 67 0.442
+ 2.000000 68 0.441
+ 2.000000 69 -5.569
+ 2.000000 70 -2.247
+ 2.000000 71 8.952
+ 2.000000 72 -2.247
+ 2.000000 73 -4.776
+ 2.000000 74 7.667
+ 2.000000 75 8.952
+ 2.000000 76 7.667
+ 2.000000 77 -26.507
+ 3.000000 0 0.068
+ 3.000000 1 0.700
+ 3.000000 2 -0.427
+ 3.000000 3 -0.091
+ 3.000000 4 -1.269
+ 3.000000 5 0.587
+ 3.000000 6 0.911
+ 3.000000 7 0.334
+ 3.000000 8 -2.507
+ 3.000000 9 -1.199
+ 3.000000 10 -0.323
+ 3.000000 11 1.455
+ 3.000000 12 0.112
+ 3.000000 13 1.878
+ 3.000000 14 3.936
+ 3.000000 15 -1.360
+ 3.000000 16 -2.231
+ 3.000000 17 -4.126
+ 3.000000 18 2.599
+ 3.000000 19 3.163
+ 3.000000 20 0.524
+ 3.000000 21 -1.154
+ 3.000000 22 -2.645
+ 3.000000 23 2.368
+ 3.000000 24 -0.228
+ 3.000000 25 2.462
+ 3.000000 26 -1.045
+ 3.000000 27 -1.090
+ 3.000000 28 -1.703
+ 3.000000 29 -0.717
+ 3.000000 30 2.890
+ 3.000000 31 -1.979
+ 3.000000 32 -1.998
+ 3.000000 33 -2.846
+ 3.000000 34 0.814
+ 3.000000 35 2.418
+ 3.000000 36 2.685
+ 3.000000 37 2.818
+ 3.000000 38 -0.797
+ 3.000000 39 -1.149
+ 3.000000 40 -1.608
+ 3.000000 41 -0.757
+ 3.000000 42 -1.048
+ 3.000000 43 0.879
+ 3.000000 44 1.609
+ 3.000000 45 0.994
+ 3.000000 46 -2.378
+ 3.000000 47 -1.511
+ 3.000000 48 -0.332
+ 3.000000 49 1.778
+ 3.000000 50 -1.192
+ 3.000000 51 0.477
+ 3.000000 52 -1.921
+ 3.000000 53 3.006
+ 3.000000 54 -0.187
+ 3.000000 55 2.121
+ 3.000000 56 -0.063
+ 3.000000 57 1.103
+ 3.000000 58 0.664
+ 3.000000 59 -0.606
+ 3.000000 60 -2.488
+ 3.000000 61 -2.232
+ 3.000000 62 0.087
+ 3.000000 63 3.094
+ 3.000000 64 0.971
+ 3.000000 65 -0.556
+ 3.000000 66 -1.759
+ 3.000000 67 -0.292
+ 3.000000 68 0.313
+ 3.000000 69 1.322
+ 3.000000 70 -0.060
+ 3.000000 71 3.191
+ 3.000000 72 -0.060
+ 3.000000 73 -2.330
+ 3.000000 74 0.666
+ 3.000000 75 3.191
+ 3.000000 76 0.666
+ 3.000000 77 -3.863
+ 4.000000 0 0.172
+ 4.000000 1 -0.097
+ 4.000000 2 -0.027
+ 4.000000 3 -0.339
+ 4.000000 4 0.132
+ 4.000000 5 0.133
+ 4.000000 6 1.060
+ 4.000000 7 -0.226
+ 4.000000 8 -0.224
+ 4.000000 9 -0.158
+ 4.000000 10 -0.046
+ 4.000000 11 -0.069
+ 4.000000 12 -1.393
+ 4.000000 13 -0.455
+ 4.000000 14 -0.335
+ 4.000000 15 2.032
+ 4.000000 16 2.215
+ 4.000000 17 0.346
+ 4.000000 18 -1.129
+ 4.000000 19 -0.408
+ 4.000000 20 0.120
+ 4.000000 21 1.362
+ 4.000000 22 -2.677
+ 4.000000 23 0.978
+ 4.000000 24 -1.485
+ 4.000000 25 2.101
+ 4.000000 26 -0.197
+ 4.000000 27 2.096
+ 4.000000 28 -0.645
+ 4.000000 29 -1.466
+ 4.000000 30 -3.881
+ 4.000000 31 -1.356
+ 4.000000 32 -0.126
+ 4.000000 33 2.639
+ 4.000000 34 0.931
+ 4.000000 35 2.695
+ 4.000000 36 -1.438
+ 4.000000 37 -1.618
+ 4.000000 38 -1.701
+ 4.000000 39 1.900
+ 4.000000 40 6.712
+ 4.000000 41 0.583
+ 4.000000 42 -0.214
+ 4.000000 43 -6.084
+ 4.000000 44 1.579
+ 4.000000 45 -2.135
+ 4.000000 46 2.667
+ 4.000000 47 -2.042
+ 4.000000 48 0.728
+ 4.000000 49 0.167
+ 4.000000 50 0.479
+ 4.000000 51 1.249
+ 4.000000 52 0.120
+ 4.000000 53 0.647
+ 4.000000 54 -3.243
+ 4.000000 55 -0.523
+ 4.000000 56 -5.153
+ 4.000000 57 4.809
+ 4.000000 58 -1.885
+ 4.000000 59 4.914
+ 4.000000 60 -1.390
+ 4.000000 61 1.190
+ 4.000000 62 -0.789
+ 4.000000 63 -2.277
+ 4.000000 64 -0.160
+ 4.000000 65 -0.867
+ 4.000000 66 1.034
+ 4.000000 67 -0.054
+ 4.000000 68 0.520
+ 4.000000 69 -6.832
+ 4.000000 70 -0.198
+ 4.000000 71 -10.388
+ 4.000000 72 -0.198
+ 4.000000 73 -2.674
+ 4.000000 74 -3.229
+ 4.000000 75 -10.388
+ 4.000000 76 -3.229
+ 4.000000 77 -7.698
diff --git a/regtest/sizeshape/rt-mahadist/global_avg.txt b/regtest/sizeshape/rt-mahadist/global_avg.txt
new file mode 100644
index 0000000000..3fe06fc8dd
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/global_avg.txt
@@ -0,0 +1,23 @@
+4.265825962982551012e+00 2.336690414907679203e-01 3.662809312682036023e+00
+4.214057267340745483e+00 1.072049513718947578e-01 4.314804999781733486e+00
+3.671228981308725103e+00 1.274792340073149510e-01 3.977231205572313577e+00
+2.343698812761148886e+00 -2.841411661146072132e-01 3.478414401687389024e+00
+1.686436487941495699e+00 -8.665088225218358087e-01 4.100811861077803044e+00
+4.360230108844224128e-01 -1.347015411672896512e+00 3.844097514796287030e+00
+3.117457174800847969e-02 -1.024227536411313366e+00 2.585940217022081988e+00
+6.808808862178362675e-01 -5.870202775664047357e-01 2.290245252111865248e+00
+4.586351396567848737e-01 -2.433497671270518359e-01 1.192357902655695634e+00
+4.931328549364416558e-01 2.515992483355074527e-01 2.956934483804412803e-02
+1.406321673638208702e+00 6.682431861735423917e-01 7.908513055476143472e-02
+1.646908036369386430e+00 1.186975749838515615e+00 -8.956858825186609918e-01
+5.912530303131902087e-01 8.617407774506029572e-01 -1.344660953846545715e+00
+8.530666038486142688e-02 2.536604398394486926e-01 -4.506541385680229994e-01
+-8.727821507437001358e-01 -1.296438909175296195e-01 -6.398328611456164383e-01
+-2.067478377458112249e+00 -3.906550201962756819e-01 -1.401863559473397691e+00
+-2.408455843196946056e+00 -6.754022773093291132e-01 -1.106090740276666429e+00
+-3.499742687863982127e+00 -9.747491888605476218e-01 -1.653484266030961436e+00
+-3.548593077032900389e+00 -4.204563480815317056e-01 -3.070014906890367268e+00
+-2.499045339091049645e+00 2.342840846507300567e-01 -3.442979964675248805e+00
+-2.331926055743990922e+00 8.142912721692037170e-01 -4.695739761431558357e+00
+-2.568879301577981611e+00 1.091951813009595762e+00 -5.625053366993444826e+00
+-2.213980543775061705e+00 1.112069908442180788e+00 -5.229306740929514419e+00
diff --git a/regtest/sizeshape/rt-mahadist/global_precision.txt b/regtest/sizeshape/rt-mahadist/global_precision.txt
new file mode 100644
index 0000000000..6cd0c4b4ec
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/global_precision.txt
@@ -0,0 +1,23 @@
+1.341060592612849689e+01 -2.432209892648744542e+01 1.533381940780554942e+01 -7.657303908462504083e+00 1.776037152155568455e+00 4.338540983771763671e+00 -3.609963145053606937e+00 2.810411955027056319e+00 -1.043671268084174208e+00 -1.475196332213428052e+00 5.759621172324607130e-01 -8.527089597052168735e-01 9.644241803601940610e-01 -7.723571031369950157e-01 -9.902209008702838045e-01 1.137035356431496114e+00 -7.992059372693161023e-01 -2.078782440990323555e-01 3.883776323509380735e+00 -3.312986073939271581e+00 3.260580287172311076e-01 -2.407079734553001227e-01 7.276273416339069655e-01
+-2.432209892648744542e+01 5.224657127170035409e+01 -4.184495643299391787e+01 2.691929890881726450e+01 -1.133485157950145350e+01 -4.581368136551017045e+00 5.418668441607914055e+00 -4.721462749988712737e+00 7.612938084579194686e-02 3.416864986007456029e+00 -1.915387904627712246e+00 1.300900115134859814e+00 -9.304157403410605598e-01 6.940752221505136488e-01 1.446934261540284483e+00 -1.833895730955714232e+00 1.069137481710279447e+00 7.471315977387903429e-01 -5.206532972119772396e+00 4.646086172638097977e+00 -9.512588298321154046e-01 4.764495021104730443e-01 -8.160183386215708046e-01
+1.533381940780554942e+01 -4.184495643299391787e+01 1.006909570680676609e+02 -9.001875555992035061e+01 -3.451475916336282523e+01 4.163490105870881308e+01 1.599032505888508560e+01 -1.109541021072212708e+01 5.753834304617886808e+00 -5.207568591756271958e-01 -4.504124622286217239e+00 4.467889138659089987e+00 -1.979451375310257388e+00 1.428207880391368700e+00 2.455983409910902082e-01 -3.661844077828322330e-01 1.301366752271428284e+00 1.865718345450012861e-01 -5.661336629183209013e+00 4.110320821833330029e+00 -4.436445385268852210e-02 -9.273163347354730357e-01 3.336243824700811378e-01
+-7.657303908462504083e+00 2.691929890881726450e+01 -9.001875555992035061e+01 1.219943530037234609e+02 -1.755683353726008988e+01 -1.486034955695616766e+01 -3.364530734833785885e+01 1.815403977068739394e+01 5.330083239917091653e+00 -5.787673063672293949e+00 8.949916505352897289e+00 -1.337407792820569874e+01 5.626279540052188999e+00 -3.353587794831017099e+00 -1.939256656091284045e-02 2.049939558614113921e-02 1.365089261756972094e+00 -8.149336646290846531e+00 -1.593034705295243825e+00 2.922427496009236236e+00 2.418471544653607364e+00 1.735086438573440581e+00 5.801075102971581243e-01
+1.776037152155568455e+00 -1.133485157950145350e+01 -3.451475916336282523e+01 -1.755683353726008988e+01 1.576310085514577395e+02 -1.169557595696256698e+02 4.104142155819025817e+01 -1.993810599591465405e+01 -9.199632220440848940e+00 5.609782974523333188e+00 -8.606957001656226902e-01 4.352603470334472924e+00 2.000397845332385627e-01 -2.935281317572900339e-01 6.386731800524242386e-01 -5.216545146993613047e-01 -9.531848586959631997e-02 1.488251394396544747e+00 -4.845847551417503118e-01 8.827391178444837783e-01 -2.003420141528640397e-01 -1.571162986767073333e+00 -9.332852800342261723e-02
+4.338540983771763671e+00 -4.581368136551017045e+00 4.163490105870881308e+01 -1.486034955695616766e+01 -1.169557595696256698e+02 1.788850067984545547e+02 -1.161726175113718540e+02 -1.824155088149085913e+01 3.722951336234645225e+01 1.822089554504272613e+01 -1.822518186211086544e+01 2.062249842740017414e+01 -2.513081540730243901e+01 1.287044852717752264e+01 5.701441320158269654e+00 -1.053843438992904424e+01 4.429603780088037013e+00 2.474040595293856626e+01 -1.978639881137895529e+01 1.263968084842567130e+01 -1.061985799126625452e+01 -5.387113217480632876e+00 -8.134892698422866442e-01
+-3.609963145053606937e+00 5.418668441607914055e+00 1.599032505888508560e+01 -3.364530734833785885e+01 4.104142155819025817e+01 -1.161726175113718540e+02 1.694295840575620389e+02 -5.437639055615947115e+01 2.623850990846575915e+00 -3.516723107832262230e+01 1.435451051172955950e+01 3.222162989559810842e-01 -1.842212594999670827e+01 2.189731127507590713e+01 -1.902181569285956542e+01 3.228461102714651698e+00 -4.863952497098324557e+00 2.030310554237381027e+01 2.060639289458460510e+01 -1.956583996346799736e+01 -6.462280445941964935e+00 -1.842331321362554952e+00 -2.065992221782699811e+00
+2.810411955027056319e+00 -4.721462749988712737e+00 -1.109541021072212708e+01 1.815403977068739394e+01 -1.993810599591465405e+01 -1.824155088149085913e+01 -5.437639055615947115e+01 2.012346773701846985e+02 -1.433541271828811432e+02 4.653186371227659635e+01 -1.956748341724615514e+01 -1.634725695145779811e+00 8.039707591790719476e+00 -3.267442313649244756e+00 8.227736047692134846e+00 -3.724004024363516852e+00 5.781830775284857893e+00 -9.284359805331549254e+00 -2.654749576699840574e+01 2.268517800068569201e+01 1.861784076616177952e+00 -1.086057555055923052e+00 1.511386856157765468e+00
+-1.043671268084174208e+00 7.612938084579194686e-02 5.753834304617886808e+00 5.330083239917091653e+00 -9.199632220440848940e+00 3.722951336234645225e+01 2.623850990846575915e+00 -1.433541271828811432e+02 1.996795924035413066e+02 -1.309616133199795343e+02 -1.259115312344027870e+01 4.068068951966531444e+01 8.652590509943264507e+00 -7.261756692588662077e+00 1.155589151733675202e+01 -3.228134443858557301e+00 -4.085784906015216933e+00 5.498844145142581574e+00 -1.472529623873179538e+01 1.212553585632562303e+01 -2.619725312876233669e+00 6.554258795806483517e-01 -7.910864037361950984e-01
+-1.475196332213428052e+00 3.416864986007456029e+00 -5.207568591756271958e-01 -5.787673063672293949e+00 5.609782974523333188e+00 1.822089554504272613e+01 -3.516723107832262230e+01 4.653186371227659635e+01 -1.309616133199795343e+02 2.050231620923374862e+02 -7.832272719934573502e+01 -1.766817048680164248e+01 -2.523801962490263406e+01 5.604515342927428811e+00 -2.903829488250302848e+00 1.337127124864552741e+01 -9.018253000914876694e+00 -4.537565087179325829e+00 7.267839671918275712e+01 -6.048117285047313629e+01 8.332814408542049689e-01 2.913611038688055821e+00 -2.121436706560488439e+00
+5.759621172324607130e-01 -1.915387904627712246e+00 -4.504124622286217239e+00 8.949916505352897289e+00 -8.606957001656226902e-01 -1.822518186211086544e+01 1.435451051172955950e+01 -1.956748341724615514e+01 -1.259115312344027870e+01 -7.832272719934573502e+01 2.255353366533649933e+02 -1.439515471076909705e+02 7.531020566839718811e+01 -4.167059763260684946e+01 -3.788221335436109616e+00 6.749467480930080754e+00 4.450810630543437618e+00 -3.510936740882865337e+01 -2.067928130108034779e+01 2.200436634778799672e+01 1.435784250738115198e+01 5.897940047881299996e+00 2.999410141876153624e+00
+-8.527089597052168735e-01 1.300900115134859814e+00 4.467889138659089987e+00 -1.337407792820569874e+01 4.352603470334472924e+00 2.062249842740017414e+01 3.222162989559810842e-01 -1.634725695145779811e+00 4.068068951966531444e+01 -1.766817048680164248e+01 -1.439515471076909705e+02 2.620094439724968538e+02 -2.689027245307896692e+02 1.016191451925127325e+02 4.640171585384572950e+01 -4.830056188387580818e+01 2.830546078080061889e+01 1.267562362513533429e+02 -1.748406454372760663e+02 1.236547165154022565e+02 -5.288020624787915125e+01 -3.703333668761484176e+01 -1.054810568719527941e+00
+9.644241803601940610e-01 -9.304157403410605598e-01 -1.979451375310257388e+00 5.626279540052188999e+00 2.000397845332385627e-01 -2.513081540730243901e+01 -1.842212594999670827e+01 8.039707591790719476e+00 8.652590509943264507e+00 -2.523801962490263406e+01 7.531020566839718811e+01 -2.689027245307896692e+02 5.839023592146512556e+02 -3.894294442433576364e+02 -9.173356538671294302e+00 1.081568782887882350e+02 -6.181982179848619552e+01 -3.444185111762555493e+02 3.311311821450776165e+02 -2.214088698492690810e+02 1.412525470264524756e+02 8.807560198206526536e+01 1.554174029562684467e+01
+-7.723571031369950157e-01 6.940752221505136488e-01 1.428207880391368700e+00 -3.353587794831017099e+00 -2.935281317572900339e-01 1.287044852717752264e+01 2.189731127507590713e+01 -3.267442313649244756e+00 -7.261756692588662077e+00 5.604515342927428811e+00 -4.167059763260684946e+01 1.016191451925127325e+02 -3.894294442433576364e+02 4.755931108838578325e+02 -1.425057023424922704e+02 -5.886350932625035881e+01 3.452077327022928444e+01 2.741529622474283201e+02 -2.596681594940621380e+02 1.811159982832207618e+02 -1.209752078734303211e+02 -6.791623844252907816e+01 -1.351901672842707747e+01
+-9.902209008702838045e-01 1.446934261540284483e+00 2.455983409910902082e-01 -1.939256656091284045e-02 6.386731800524242386e-01 5.701441320158269654e+00 -1.902181569285956542e+01 8.227736047692134846e+00 1.155589151733675202e+01 -2.903829488250302848e+00 -3.788221335436109616e+00 4.640171585384572950e+01 -9.173356538671294302e+00 -1.425057023424922704e+02 2.400794701823535888e+02 -1.792956792626917490e+02 3.138582984045448754e+01 2.515489335475258414e+01 -6.417006226891290055e+01 5.501930999130374289e+01 2.834210966776290253e+00 -5.661727157052321324e+00 -1.161697304761181604e+00
+1.137035356431496114e+00 -1.833895730955714232e+00 -3.661844077828322330e-01 2.049939558614113921e-02 -5.216545146993613047e-01 -1.053843438992904424e+01 3.228461102714651698e+00 -3.724004024363516852e+00 -3.228134443858557301e+00 1.337127124864552741e+01 6.749467480930080754e+00 -4.830056188387580818e+01 1.081568782887882350e+02 -5.886350932625035881e+01 -1.792956792626917490e+02 2.983596837029729727e+02 -1.505787385408951025e+02 -1.007539282739960811e+02 1.817399408509938894e+02 -1.524500322663519967e+02 6.872035320031325512e+01 3.215537051004270808e+01 -3.184204072141046726e+00
+-7.992059372693161023e-01 1.069137481710279447e+00 1.301366752271428284e+00 1.365089261756972094e+00 -9.531848586959631997e-02 4.429603780088037013e+00 -4.863952497098324557e+00 5.781830775284857893e+00 -4.085784906015216933e+00 -9.018253000914876694e+00 4.450810630543437618e+00 2.830546078080061889e+01 -6.181982179848619552e+01 3.452077327022928444e+01 3.138582984045448754e+01 -1.505787385408951025e+02 2.834361801812467547e+02 -1.103742556523487934e+02 -1.133915422380968607e+02 1.084268925701416748e+02 -3.713437396884358321e+01 -1.732989764142075018e+01 5.018169342462520000e+00
+-2.078782440990323555e-01 7.471315977387903429e-01 1.865718345450012861e-01 -8.149336646290846531e+00 1.488251394396544747e+00 2.474040595293856626e+01 2.030310554237381027e+01 -9.284359805331549254e+00 5.498844145142581574e+00 -4.537565087179325829e+00 -3.510936740882865337e+01 1.267562362513533429e+02 -3.444185111762555493e+02 2.741529622474283201e+02 2.515489335475258414e+01 -1.007539282739960811e+02 -1.103742556523487934e+02 5.533027818891989682e+02 -3.612519277674758769e+02 1.456607310201988810e+02 -1.200889435095781153e+02 -6.822817263798721399e+01 -1.558766901584039388e+01
+3.883776323509380735e+00 -5.206532972119772396e+00 -5.661336629183209013e+00 -1.593034705295243825e+00 -4.845847551417503118e-01 -1.978639881137895529e+01 2.060639289458460510e+01 -2.654749576699840574e+01 -1.472529623873179538e+01 7.267839671918275712e+01 -2.067928130108034779e+01 -1.748406454372760663e+02 3.311311821450776165e+02 -2.596681594940621380e+02 -6.417006226891290055e+01 1.817399408509938894e+02 -1.133915422380968607e+02 -3.612519277674758769e+02 8.227661540145846857e+02 -5.889251881384034277e+02 1.505009903985806829e+02 7.459360068624346241e+01 -9.689475113469024903e-01
+-3.312986073939271581e+00 4.646086172638097977e+00 4.110320821833330029e+00 2.922427496009236236e+00 8.827391178444837783e-01 1.263968084842567130e+01 -1.956583996346799736e+01 2.268517800068569201e+01 1.212553585632562303e+01 -6.048117285047313629e+01 2.200436634778799672e+01 1.236547165154022565e+02 -2.214088698492690810e+02 1.811159982832207618e+02 5.501930999130374289e+01 -1.524500322663519967e+02 1.084268925701416748e+02 1.456607310201988810e+02 -5.889251881384034277e+02 6.281297406866601705e+02 -2.360284378048359315e+02 -3.788478747503720001e+01 -3.966409304890950338e+00
+3.260580287172311076e-01 -9.512588298321154046e-01 -4.436445385268852210e-02 2.418471544653607364e+00 -2.003420141528640397e-01 -1.061985799126625452e+01 -6.462280445941964935e+00 1.861784076616177952e+00 -2.619725312876233669e+00 8.332814408542049689e-01 1.435784250738115198e+01 -5.288020624787915125e+01 1.412525470264524756e+02 -1.209752078734303211e+02 2.834210966776290253e+00 6.872035320031325512e+01 -3.713437396884358321e+01 -1.200889435095781153e+02 1.505009903985806829e+02 -2.360284378048359315e+02 1.984952390410417138e+02 -1.726639859088383133e+01 2.367061880986858213e+01
+-2.407079734553001227e-01 4.764495021104730443e-01 -9.273163347354730357e-01 1.735086438573440581e+00 -1.571162986767073333e+00 -5.387113217480632876e+00 -1.842331321362554952e+00 -1.086057555055923052e+00 6.554258795806483517e-01 2.913611038688055821e+00 5.897940047881299996e+00 -3.703333668761484176e+01 8.807560198206526536e+01 -6.791623844252907816e+01 -5.661727157052321324e+00 3.215537051004270808e+01 -1.732989764142075018e+01 -6.822817263798721399e+01 7.459360068624346241e+01 -3.788478747503720001e+01 -1.726639859088383133e+01 8.664655681400094522e+01 -3.077439487873002122e+01
+7.276273416339069655e-01 -8.160183386215708046e-01 3.336243824700811378e-01 5.801075102971581243e-01 -9.332852800342261723e-02 -8.134892698422866442e-01 -2.065992221782699811e+00 1.511386856157765468e+00 -7.910864037361950984e-01 -2.121436706560488439e+00 2.999410141876153624e+00 -1.054810568719527941e+00 1.554174029562684467e+01 -1.351901672842707747e+01 -1.161697304761181604e+00 -3.184204072141046726e+00 5.018169342462520000e+00 -1.558766901584039388e+01 -9.689475113469024903e-01 -3.966409304890950338e+00 2.367061880986858213e+01 -3.077439487873002122e+01 2.653581617274004500e+01
diff --git a/regtest/sizeshape/rt-mahadist/output.reference b/regtest/sizeshape/rt-mahadist/output.reference
new file mode 100644
index 0000000000..4458c2b895
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/output.reference
@@ -0,0 +1,6 @@
+#! FIELDS time d
+ 0.000000 6.59472498
+ 1.000000 5.04830502
+ 2.000000 6.38109182
+ 3.000000 5.63516600
+ 4.000000 6.20313896
diff --git a/regtest/sizeshape/rt-mahadist/plumed.dat b/regtest/sizeshape/rt-mahadist/plumed.dat
new file mode 100644
index 0000000000..fdfb926223
--- /dev/null
+++ b/regtest/sizeshape/rt-mahadist/plumed.dat
@@ -0,0 +1,15 @@
+# units
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+
+# make a group of atoms
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+
+# mahadist
+d: SIZESHAPE_POSITION_MAHA_DIST REFERENCE=global_avg.txt PRECISION=global_precision.txt GROUP=ga_list
+
+#print
+PRINT ARG=d STRIDE=1 FILE=output FMT=%8.8f
+
+# dump derivatives
+DUMPDERIVATIVES ARG=d STRIDE=1 FILE=deriv FMT=%8.3f
+
diff --git a/regtest/sizeshape/rt-mahadist/test_traj.trr b/regtest/sizeshape/rt-mahadist/test_traj.trr
new file mode 100644
index 0000000000..6698336cbe
Binary files /dev/null and b/regtest/sizeshape/rt-mahadist/test_traj.trr differ
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/COLVAR.reference b/regtest/sizeshape/rt-sizeshape-mpi/COLVAR.reference
new file mode 100644
index 0000000000..d8dc94d277
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/COLVAR.reference
@@ -0,0 +1,6 @@
+#! FIELDS time ld1
+ 0.000000 -53.42214977
+ 1.000000 -53.56701954
+ 2.000000 -51.75886201
+ 3.000000 -53.01109644
+ 4.000000 -52.57399786
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/Makefile b/regtest/sizeshape/rt-sizeshape-mpi/Makefile
new file mode 100644
index 0000000000..3703b27cea
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/config b/regtest/sizeshape/rt-sizeshape-mpi/config
new file mode 100644
index 0000000000..ae37970300
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/config
@@ -0,0 +1,4 @@
+type=driver
+mpiprocs=4
+plumed_modules=sizeshape
+arg="--plumed plumed.dat --itrr test_traj.trr"
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/deriv.reference b/regtest/sizeshape/rt-sizeshape-mpi/deriv.reference
new file mode 100644
index 0000000000..b6e896896b
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/deriv.reference
@@ -0,0 +1,391 @@
+#! FIELDS time parameter ld1
+ 0.000000 0 -0.747
+ 0.000000 1 1.806
+ 0.000000 2 0.181
+ 0.000000 3 -0.521
+ 0.000000 4 0.961
+ 0.000000 5 0.216
+ 0.000000 6 0.976
+ 0.000000 7 -3.388
+ 0.000000 8 -0.749
+ 0.000000 9 -0.276
+ 0.000000 10 -0.621
+ 0.000000 11 -0.502
+ 0.000000 12 -0.191
+ 0.000000 13 1.000
+ 0.000000 14 0.094
+ 0.000000 15 -0.061
+ 0.000000 16 -0.675
+ 0.000000 17 -0.042
+ 0.000000 18 0.213
+ 0.000000 19 -1.567
+ 0.000000 20 -0.747
+ 0.000000 21 -0.166
+ 0.000000 22 -0.023
+ 0.000000 23 -0.045
+ 0.000000 24 -1.457
+ 0.000000 25 4.729
+ 0.000000 26 0.969
+ 0.000000 27 -0.074
+ 0.000000 28 0.093
+ 0.000000 29 -0.142
+ 0.000000 30 -0.143
+ 0.000000 31 -0.891
+ 0.000000 32 -0.319
+ 0.000000 33 -0.299
+ 0.000000 34 0.502
+ 0.000000 35 0.094
+ 0.000000 36 -0.463
+ 0.000000 37 0.642
+ 0.000000 38 0.019
+ 0.000000 39 -0.248
+ 0.000000 40 0.298
+ 0.000000 41 0.036
+ 0.000000 42 1.153
+ 0.000000 43 -4.986
+ 0.000000 44 -1.449
+ 0.000000 45 1.493
+ 0.000000 46 -5.907
+ 0.000000 47 -1.102
+ 0.000000 48 -1.910
+ 0.000000 49 6.659
+ 0.000000 50 1.163
+ 0.000000 51 0.044
+ 0.000000 52 -0.831
+ 0.000000 53 -0.406
+ 0.000000 54 -0.373
+ 0.000000 55 0.760
+ 0.000000 56 0.136
+ 0.000000 57 0.263
+ 0.000000 58 -1.311
+ 0.000000 59 -0.510
+ 0.000000 60 -2.336
+ 0.000000 61 7.304
+ 0.000000 62 1.589
+ 0.000000 63 -0.525
+ 0.000000 64 1.138
+ 0.000000 65 0.051
+ 0.000000 66 1.655
+ 0.000000 67 -6.270
+ 0.000000 68 -1.306
+ 0.000000 69 50.236
+ 0.000000 70 -6.694
+ 0.000000 71 28.810
+ 0.000000 72 111.741
+ 0.000000 73 66.389
+ 0.000000 74 96.952
+ 0.000000 75 101.422
+ 0.000000 76 25.227
+ 0.000000 77 75.637
+ 1.000000 0 -0.775
+ 1.000000 1 1.792
+ 1.000000 2 0.036
+ 1.000000 3 -0.547
+ 1.000000 4 0.974
+ 1.000000 5 0.134
+ 1.000000 6 1.054
+ 1.000000 7 -3.398
+ 1.000000 8 -0.497
+ 1.000000 9 -0.240
+ 1.000000 10 -0.660
+ 1.000000 11 -0.479
+ 1.000000 12 -0.210
+ 1.000000 13 1.006
+ 1.000000 14 0.026
+ 1.000000 15 -0.069
+ 1.000000 16 -0.612
+ 1.000000 17 0.004
+ 1.000000 18 0.278
+ 1.000000 19 -1.623
+ 1.000000 20 -0.643
+ 1.000000 21 -0.177
+ 1.000000 22 0.016
+ 1.000000 23 -0.047
+ 1.000000 24 -1.575
+ 1.000000 25 4.785
+ 1.000000 26 0.618
+ 1.000000 27 -0.028
+ 1.000000 28 -0.050
+ 1.000000 29 -0.167
+ 1.000000 30 -0.116
+ 1.000000 31 -0.910
+ 1.000000 32 -0.275
+ 1.000000 33 -0.449
+ 1.000000 34 0.987
+ 1.000000 35 0.114
+ 1.000000 36 -0.171
+ 1.000000 37 -0.431
+ 1.000000 38 -0.189
+ 1.000000 39 -0.492
+ 1.000000 40 1.143
+ 1.000000 41 0.123
+ 1.000000 42 1.239
+ 1.000000 43 -4.870
+ 1.000000 44 -1.072
+ 1.000000 45 1.793
+ 1.000000 46 -6.522
+ 1.000000 47 -0.753
+ 1.000000 48 -2.172
+ 1.000000 49 7.088
+ 1.000000 50 0.723
+ 1.000000 51 -0.153
+ 1.000000 52 -0.032
+ 1.000000 53 -0.237
+ 1.000000 54 0.064
+ 1.000000 55 -0.799
+ 1.000000 56 -0.130
+ 1.000000 57 -0.046
+ 1.000000 58 -0.131
+ 1.000000 59 -0.264
+ 1.000000 60 -2.385
+ 1.000000 61 6.906
+ 1.000000 62 0.977
+ 1.000000 63 -0.463
+ 1.000000 64 0.855
+ 1.000000 65 -0.080
+ 1.000000 66 1.804
+ 1.000000 67 -6.318
+ 1.000000 68 -0.852
+ 1.000000 69 49.076
+ 1.000000 70 -5.373
+ 1.000000 71 31.440
+ 1.000000 72 106.043
+ 1.000000 73 74.308
+ 1.000000 74 98.783
+ 1.000000 75 98.604
+ 1.000000 76 27.784
+ 1.000000 77 78.844
+ 2.000000 0 -0.705
+ 2.000000 1 1.815
+ 2.000000 2 0.221
+ 2.000000 3 -0.500
+ 2.000000 4 0.970
+ 2.000000 5 0.239
+ 2.000000 6 0.899
+ 2.000000 7 -3.387
+ 2.000000 8 -0.825
+ 2.000000 9 -0.294
+ 2.000000 10 -0.586
+ 2.000000 11 -0.510
+ 2.000000 12 -0.168
+ 2.000000 13 0.998
+ 2.000000 14 0.115
+ 2.000000 15 -0.070
+ 2.000000 16 -0.703
+ 2.000000 17 -0.064
+ 2.000000 18 0.192
+ 2.000000 19 -1.613
+ 2.000000 20 -0.797
+ 2.000000 21 -0.177
+ 2.000000 22 0.021
+ 2.000000 23 -0.035
+ 2.000000 24 -1.354
+ 2.000000 25 4.748
+ 2.000000 26 1.078
+ 2.000000 27 -0.050
+ 2.000000 28 0.015
+ 2.000000 29 -0.161
+ 2.000000 30 -0.188
+ 2.000000 31 -0.779
+ 2.000000 32 -0.313
+ 2.000000 33 -0.272
+ 2.000000 34 0.420
+ 2.000000 35 0.087
+ 2.000000 36 -0.539
+ 2.000000 37 1.069
+ 2.000000 38 0.131
+ 2.000000 39 -0.168
+ 2.000000 40 -0.035
+ 2.000000 41 -0.036
+ 2.000000 42 1.024
+ 2.000000 43 -4.917
+ 2.000000 44 -1.545
+ 2.000000 45 1.354
+ 2.000000 46 -5.859
+ 2.000000 47 -1.225
+ 2.000000 48 -1.775
+ 2.000000 49 6.708
+ 2.000000 50 1.324
+ 2.000000 51 0.134
+ 2.000000 52 -1.305
+ 2.000000 53 -0.539
+ 2.000000 54 -0.323
+ 2.000000 55 0.704
+ 2.000000 56 0.127
+ 2.000000 57 0.189
+ 2.000000 58 -1.181
+ 2.000000 59 -0.499
+ 2.000000 60 -2.209
+ 2.000000 61 7.488
+ 2.000000 62 1.793
+ 2.000000 63 -0.513
+ 2.000000 64 1.217
+ 2.000000 65 0.093
+ 2.000000 66 1.506
+ 2.000000 67 -6.235
+ 2.000000 68 -1.437
+ 2.000000 69 49.950
+ 2.000000 70 -7.018
+ 2.000000 71 29.008
+ 2.000000 72 113.611
+ 2.000000 73 60.279
+ 2.000000 74 97.937
+ 2.000000 75 102.101
+ 2.000000 76 22.165
+ 2.000000 77 76.321
+ 3.000000 0 -0.619
+ 3.000000 1 1.869
+ 3.000000 2 0.035
+ 3.000000 3 -0.453
+ 3.000000 4 1.001
+ 3.000000 5 0.132
+ 3.000000 6 0.749
+ 3.000000 7 -3.503
+ 3.000000 8 -0.488
+ 3.000000 9 -0.294
+ 3.000000 10 -0.685
+ 3.000000 11 -0.475
+ 3.000000 12 -0.122
+ 3.000000 13 1.025
+ 3.000000 14 0.021
+ 3.000000 15 -0.131
+ 3.000000 16 -0.576
+ 3.000000 17 0.013
+ 3.000000 18 0.082
+ 3.000000 19 -1.454
+ 3.000000 20 -0.611
+ 3.000000 21 -0.141
+ 3.000000 22 -0.127
+ 3.000000 23 -0.064
+ 3.000000 24 -1.128
+ 3.000000 25 4.851
+ 3.000000 26 0.596
+ 3.000000 27 -0.110
+ 3.000000 28 0.321
+ 3.000000 29 -0.123
+ 3.000000 30 -0.135
+ 3.000000 31 -1.194
+ 3.000000 32 -0.300
+ 3.000000 33 -0.333
+ 3.000000 34 0.817
+ 3.000000 35 0.090
+ 3.000000 36 -0.117
+ 3.000000 37 -0.639
+ 3.000000 38 -0.213
+ 3.000000 39 -0.467
+ 3.000000 40 1.377
+ 3.000000 41 0.147
+ 3.000000 42 0.858
+ 3.000000 43 -5.307
+ 3.000000 44 -1.090
+ 3.000000 45 1.140
+ 3.000000 46 -6.267
+ 3.000000 47 -0.683
+ 3.000000 48 -1.440
+ 3.000000 49 6.772
+ 3.000000 50 0.642
+ 3.000000 51 -0.337
+ 3.000000 52 0.624
+ 3.000000 53 -0.155
+ 3.000000 54 -0.308
+ 3.000000 55 0.848
+ 3.000000 56 0.064
+ 3.000000 57 0.223
+ 3.000000 58 -1.629
+ 3.000000 59 -0.435
+ 3.000000 60 -1.719
+ 3.000000 61 7.007
+ 3.000000 62 0.944
+ 3.000000 63 -0.389
+ 3.000000 64 0.950
+ 3.000000 65 -0.074
+ 3.000000 66 1.253
+ 3.000000 67 -6.564
+ 3.000000 68 -0.839
+ 3.000000 69 47.697
+ 3.000000 70 -4.767
+ 3.000000 71 31.173
+ 3.000000 72 113.561
+ 3.000000 73 65.919
+ 3.000000 74 96.862
+ 3.000000 75 102.521
+ 3.000000 76 19.515
+ 3.000000 77 77.509
+ 4.000000 0 -0.873
+ 4.000000 1 1.741
+ 4.000000 2 -0.004
+ 4.000000 3 -0.614
+ 4.000000 4 0.945
+ 4.000000 5 0.102
+ 4.000000 6 1.283
+ 4.000000 7 -3.315
+ 4.000000 8 -0.459
+ 4.000000 9 -0.162
+ 4.000000 10 -0.648
+ 4.000000 11 -0.509
+ 4.000000 12 -0.267
+ 4.000000 13 0.990
+ 4.000000 14 0.025
+ 4.000000 15 -0.032
+ 4.000000 16 -0.622
+ 4.000000 17 -0.015
+ 4.000000 18 0.449
+ 4.000000 19 -1.645
+ 4.000000 20 -0.652
+ 4.000000 21 -0.190
+ 4.000000 22 0.053
+ 4.000000 23 -0.057
+ 4.000000 24 -1.901
+ 4.000000 25 4.692
+ 4.000000 26 0.560
+ 4.000000 27 0.031
+ 4.000000 28 -0.154
+ 4.000000 29 -0.185
+ 4.000000 30 -0.070
+ 4.000000 31 -0.823
+ 4.000000 32 -0.289
+ 4.000000 33 -0.541
+ 4.000000 34 1.018
+ 4.000000 35 0.098
+ 4.000000 36 -0.137
+ 4.000000 37 -0.372
+ 4.000000 38 -0.203
+ 4.000000 39 -0.556
+ 4.000000 40 1.057
+ 4.000000 41 0.090
+ 4.000000 42 1.568
+ 4.000000 43 -4.670
+ 4.000000 44 -1.028
+ 4.000000 45 2.270
+ 4.000000 46 -6.508
+ 4.000000 47 -0.721
+ 4.000000 48 -2.684
+ 4.000000 49 7.080
+ 4.000000 50 0.671
+ 4.000000 51 -0.071
+ 4.000000 52 -0.219
+ 4.000000 53 -0.277
+ 4.000000 54 0.316
+ 4.000000 55 -1.269
+ 4.000000 56 -0.208
+ 4.000000 57 -0.190
+ 4.000000 58 0.308
+ 4.000000 59 -0.206
+ 4.000000 60 -2.854
+ 4.000000 61 6.764
+ 4.000000 62 0.883
+ 4.000000 63 -0.492
+ 4.000000 64 0.812
+ 4.000000 65 -0.109
+ 4.000000 66 2.219
+ 4.000000 67 -6.157
+ 4.000000 68 -0.793
+ 4.000000 69 47.095
+ 4.000000 70 -6.360
+ 4.000000 71 35.143
+ 4.000000 72 93.172
+ 4.000000 73 75.817
+ 4.000000 74 109.531
+ 4.000000 75 89.571
+ 4.000000 76 30.716
+ 4.000000 77 88.099
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/global_avg.txt b/regtest/sizeshape/rt-sizeshape-mpi/global_avg.txt
new file mode 100644
index 0000000000..3fe06fc8dd
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/global_avg.txt
@@ -0,0 +1,23 @@
+4.265825962982551012e+00 2.336690414907679203e-01 3.662809312682036023e+00
+4.214057267340745483e+00 1.072049513718947578e-01 4.314804999781733486e+00
+3.671228981308725103e+00 1.274792340073149510e-01 3.977231205572313577e+00
+2.343698812761148886e+00 -2.841411661146072132e-01 3.478414401687389024e+00
+1.686436487941495699e+00 -8.665088225218358087e-01 4.100811861077803044e+00
+4.360230108844224128e-01 -1.347015411672896512e+00 3.844097514796287030e+00
+3.117457174800847969e-02 -1.024227536411313366e+00 2.585940217022081988e+00
+6.808808862178362675e-01 -5.870202775664047357e-01 2.290245252111865248e+00
+4.586351396567848737e-01 -2.433497671270518359e-01 1.192357902655695634e+00
+4.931328549364416558e-01 2.515992483355074527e-01 2.956934483804412803e-02
+1.406321673638208702e+00 6.682431861735423917e-01 7.908513055476143472e-02
+1.646908036369386430e+00 1.186975749838515615e+00 -8.956858825186609918e-01
+5.912530303131902087e-01 8.617407774506029572e-01 -1.344660953846545715e+00
+8.530666038486142688e-02 2.536604398394486926e-01 -4.506541385680229994e-01
+-8.727821507437001358e-01 -1.296438909175296195e-01 -6.398328611456164383e-01
+-2.067478377458112249e+00 -3.906550201962756819e-01 -1.401863559473397691e+00
+-2.408455843196946056e+00 -6.754022773093291132e-01 -1.106090740276666429e+00
+-3.499742687863982127e+00 -9.747491888605476218e-01 -1.653484266030961436e+00
+-3.548593077032900389e+00 -4.204563480815317056e-01 -3.070014906890367268e+00
+-2.499045339091049645e+00 2.342840846507300567e-01 -3.442979964675248805e+00
+-2.331926055743990922e+00 8.142912721692037170e-01 -4.695739761431558357e+00
+-2.568879301577981611e+00 1.091951813009595762e+00 -5.625053366993444826e+00
+-2.213980543775061705e+00 1.112069908442180788e+00 -5.229306740929514419e+00
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/global_precision.txt b/regtest/sizeshape/rt-sizeshape-mpi/global_precision.txt
new file mode 100644
index 0000000000..6cd0c4b4ec
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/global_precision.txt
@@ -0,0 +1,23 @@
+1.341060592612849689e+01 -2.432209892648744542e+01 1.533381940780554942e+01 -7.657303908462504083e+00 1.776037152155568455e+00 4.338540983771763671e+00 -3.609963145053606937e+00 2.810411955027056319e+00 -1.043671268084174208e+00 -1.475196332213428052e+00 5.759621172324607130e-01 -8.527089597052168735e-01 9.644241803601940610e-01 -7.723571031369950157e-01 -9.902209008702838045e-01 1.137035356431496114e+00 -7.992059372693161023e-01 -2.078782440990323555e-01 3.883776323509380735e+00 -3.312986073939271581e+00 3.260580287172311076e-01 -2.407079734553001227e-01 7.276273416339069655e-01
+-2.432209892648744542e+01 5.224657127170035409e+01 -4.184495643299391787e+01 2.691929890881726450e+01 -1.133485157950145350e+01 -4.581368136551017045e+00 5.418668441607914055e+00 -4.721462749988712737e+00 7.612938084579194686e-02 3.416864986007456029e+00 -1.915387904627712246e+00 1.300900115134859814e+00 -9.304157403410605598e-01 6.940752221505136488e-01 1.446934261540284483e+00 -1.833895730955714232e+00 1.069137481710279447e+00 7.471315977387903429e-01 -5.206532972119772396e+00 4.646086172638097977e+00 -9.512588298321154046e-01 4.764495021104730443e-01 -8.160183386215708046e-01
+1.533381940780554942e+01 -4.184495643299391787e+01 1.006909570680676609e+02 -9.001875555992035061e+01 -3.451475916336282523e+01 4.163490105870881308e+01 1.599032505888508560e+01 -1.109541021072212708e+01 5.753834304617886808e+00 -5.207568591756271958e-01 -4.504124622286217239e+00 4.467889138659089987e+00 -1.979451375310257388e+00 1.428207880391368700e+00 2.455983409910902082e-01 -3.661844077828322330e-01 1.301366752271428284e+00 1.865718345450012861e-01 -5.661336629183209013e+00 4.110320821833330029e+00 -4.436445385268852210e-02 -9.273163347354730357e-01 3.336243824700811378e-01
+-7.657303908462504083e+00 2.691929890881726450e+01 -9.001875555992035061e+01 1.219943530037234609e+02 -1.755683353726008988e+01 -1.486034955695616766e+01 -3.364530734833785885e+01 1.815403977068739394e+01 5.330083239917091653e+00 -5.787673063672293949e+00 8.949916505352897289e+00 -1.337407792820569874e+01 5.626279540052188999e+00 -3.353587794831017099e+00 -1.939256656091284045e-02 2.049939558614113921e-02 1.365089261756972094e+00 -8.149336646290846531e+00 -1.593034705295243825e+00 2.922427496009236236e+00 2.418471544653607364e+00 1.735086438573440581e+00 5.801075102971581243e-01
+1.776037152155568455e+00 -1.133485157950145350e+01 -3.451475916336282523e+01 -1.755683353726008988e+01 1.576310085514577395e+02 -1.169557595696256698e+02 4.104142155819025817e+01 -1.993810599591465405e+01 -9.199632220440848940e+00 5.609782974523333188e+00 -8.606957001656226902e-01 4.352603470334472924e+00 2.000397845332385627e-01 -2.935281317572900339e-01 6.386731800524242386e-01 -5.216545146993613047e-01 -9.531848586959631997e-02 1.488251394396544747e+00 -4.845847551417503118e-01 8.827391178444837783e-01 -2.003420141528640397e-01 -1.571162986767073333e+00 -9.332852800342261723e-02
+4.338540983771763671e+00 -4.581368136551017045e+00 4.163490105870881308e+01 -1.486034955695616766e+01 -1.169557595696256698e+02 1.788850067984545547e+02 -1.161726175113718540e+02 -1.824155088149085913e+01 3.722951336234645225e+01 1.822089554504272613e+01 -1.822518186211086544e+01 2.062249842740017414e+01 -2.513081540730243901e+01 1.287044852717752264e+01 5.701441320158269654e+00 -1.053843438992904424e+01 4.429603780088037013e+00 2.474040595293856626e+01 -1.978639881137895529e+01 1.263968084842567130e+01 -1.061985799126625452e+01 -5.387113217480632876e+00 -8.134892698422866442e-01
+-3.609963145053606937e+00 5.418668441607914055e+00 1.599032505888508560e+01 -3.364530734833785885e+01 4.104142155819025817e+01 -1.161726175113718540e+02 1.694295840575620389e+02 -5.437639055615947115e+01 2.623850990846575915e+00 -3.516723107832262230e+01 1.435451051172955950e+01 3.222162989559810842e-01 -1.842212594999670827e+01 2.189731127507590713e+01 -1.902181569285956542e+01 3.228461102714651698e+00 -4.863952497098324557e+00 2.030310554237381027e+01 2.060639289458460510e+01 -1.956583996346799736e+01 -6.462280445941964935e+00 -1.842331321362554952e+00 -2.065992221782699811e+00
+2.810411955027056319e+00 -4.721462749988712737e+00 -1.109541021072212708e+01 1.815403977068739394e+01 -1.993810599591465405e+01 -1.824155088149085913e+01 -5.437639055615947115e+01 2.012346773701846985e+02 -1.433541271828811432e+02 4.653186371227659635e+01 -1.956748341724615514e+01 -1.634725695145779811e+00 8.039707591790719476e+00 -3.267442313649244756e+00 8.227736047692134846e+00 -3.724004024363516852e+00 5.781830775284857893e+00 -9.284359805331549254e+00 -2.654749576699840574e+01 2.268517800068569201e+01 1.861784076616177952e+00 -1.086057555055923052e+00 1.511386856157765468e+00
+-1.043671268084174208e+00 7.612938084579194686e-02 5.753834304617886808e+00 5.330083239917091653e+00 -9.199632220440848940e+00 3.722951336234645225e+01 2.623850990846575915e+00 -1.433541271828811432e+02 1.996795924035413066e+02 -1.309616133199795343e+02 -1.259115312344027870e+01 4.068068951966531444e+01 8.652590509943264507e+00 -7.261756692588662077e+00 1.155589151733675202e+01 -3.228134443858557301e+00 -4.085784906015216933e+00 5.498844145142581574e+00 -1.472529623873179538e+01 1.212553585632562303e+01 -2.619725312876233669e+00 6.554258795806483517e-01 -7.910864037361950984e-01
+-1.475196332213428052e+00 3.416864986007456029e+00 -5.207568591756271958e-01 -5.787673063672293949e+00 5.609782974523333188e+00 1.822089554504272613e+01 -3.516723107832262230e+01 4.653186371227659635e+01 -1.309616133199795343e+02 2.050231620923374862e+02 -7.832272719934573502e+01 -1.766817048680164248e+01 -2.523801962490263406e+01 5.604515342927428811e+00 -2.903829488250302848e+00 1.337127124864552741e+01 -9.018253000914876694e+00 -4.537565087179325829e+00 7.267839671918275712e+01 -6.048117285047313629e+01 8.332814408542049689e-01 2.913611038688055821e+00 -2.121436706560488439e+00
+5.759621172324607130e-01 -1.915387904627712246e+00 -4.504124622286217239e+00 8.949916505352897289e+00 -8.606957001656226902e-01 -1.822518186211086544e+01 1.435451051172955950e+01 -1.956748341724615514e+01 -1.259115312344027870e+01 -7.832272719934573502e+01 2.255353366533649933e+02 -1.439515471076909705e+02 7.531020566839718811e+01 -4.167059763260684946e+01 -3.788221335436109616e+00 6.749467480930080754e+00 4.450810630543437618e+00 -3.510936740882865337e+01 -2.067928130108034779e+01 2.200436634778799672e+01 1.435784250738115198e+01 5.897940047881299996e+00 2.999410141876153624e+00
+-8.527089597052168735e-01 1.300900115134859814e+00 4.467889138659089987e+00 -1.337407792820569874e+01 4.352603470334472924e+00 2.062249842740017414e+01 3.222162989559810842e-01 -1.634725695145779811e+00 4.068068951966531444e+01 -1.766817048680164248e+01 -1.439515471076909705e+02 2.620094439724968538e+02 -2.689027245307896692e+02 1.016191451925127325e+02 4.640171585384572950e+01 -4.830056188387580818e+01 2.830546078080061889e+01 1.267562362513533429e+02 -1.748406454372760663e+02 1.236547165154022565e+02 -5.288020624787915125e+01 -3.703333668761484176e+01 -1.054810568719527941e+00
+9.644241803601940610e-01 -9.304157403410605598e-01 -1.979451375310257388e+00 5.626279540052188999e+00 2.000397845332385627e-01 -2.513081540730243901e+01 -1.842212594999670827e+01 8.039707591790719476e+00 8.652590509943264507e+00 -2.523801962490263406e+01 7.531020566839718811e+01 -2.689027245307896692e+02 5.839023592146512556e+02 -3.894294442433576364e+02 -9.173356538671294302e+00 1.081568782887882350e+02 -6.181982179848619552e+01 -3.444185111762555493e+02 3.311311821450776165e+02 -2.214088698492690810e+02 1.412525470264524756e+02 8.807560198206526536e+01 1.554174029562684467e+01
+-7.723571031369950157e-01 6.940752221505136488e-01 1.428207880391368700e+00 -3.353587794831017099e+00 -2.935281317572900339e-01 1.287044852717752264e+01 2.189731127507590713e+01 -3.267442313649244756e+00 -7.261756692588662077e+00 5.604515342927428811e+00 -4.167059763260684946e+01 1.016191451925127325e+02 -3.894294442433576364e+02 4.755931108838578325e+02 -1.425057023424922704e+02 -5.886350932625035881e+01 3.452077327022928444e+01 2.741529622474283201e+02 -2.596681594940621380e+02 1.811159982832207618e+02 -1.209752078734303211e+02 -6.791623844252907816e+01 -1.351901672842707747e+01
+-9.902209008702838045e-01 1.446934261540284483e+00 2.455983409910902082e-01 -1.939256656091284045e-02 6.386731800524242386e-01 5.701441320158269654e+00 -1.902181569285956542e+01 8.227736047692134846e+00 1.155589151733675202e+01 -2.903829488250302848e+00 -3.788221335436109616e+00 4.640171585384572950e+01 -9.173356538671294302e+00 -1.425057023424922704e+02 2.400794701823535888e+02 -1.792956792626917490e+02 3.138582984045448754e+01 2.515489335475258414e+01 -6.417006226891290055e+01 5.501930999130374289e+01 2.834210966776290253e+00 -5.661727157052321324e+00 -1.161697304761181604e+00
+1.137035356431496114e+00 -1.833895730955714232e+00 -3.661844077828322330e-01 2.049939558614113921e-02 -5.216545146993613047e-01 -1.053843438992904424e+01 3.228461102714651698e+00 -3.724004024363516852e+00 -3.228134443858557301e+00 1.337127124864552741e+01 6.749467480930080754e+00 -4.830056188387580818e+01 1.081568782887882350e+02 -5.886350932625035881e+01 -1.792956792626917490e+02 2.983596837029729727e+02 -1.505787385408951025e+02 -1.007539282739960811e+02 1.817399408509938894e+02 -1.524500322663519967e+02 6.872035320031325512e+01 3.215537051004270808e+01 -3.184204072141046726e+00
+-7.992059372693161023e-01 1.069137481710279447e+00 1.301366752271428284e+00 1.365089261756972094e+00 -9.531848586959631997e-02 4.429603780088037013e+00 -4.863952497098324557e+00 5.781830775284857893e+00 -4.085784906015216933e+00 -9.018253000914876694e+00 4.450810630543437618e+00 2.830546078080061889e+01 -6.181982179848619552e+01 3.452077327022928444e+01 3.138582984045448754e+01 -1.505787385408951025e+02 2.834361801812467547e+02 -1.103742556523487934e+02 -1.133915422380968607e+02 1.084268925701416748e+02 -3.713437396884358321e+01 -1.732989764142075018e+01 5.018169342462520000e+00
+-2.078782440990323555e-01 7.471315977387903429e-01 1.865718345450012861e-01 -8.149336646290846531e+00 1.488251394396544747e+00 2.474040595293856626e+01 2.030310554237381027e+01 -9.284359805331549254e+00 5.498844145142581574e+00 -4.537565087179325829e+00 -3.510936740882865337e+01 1.267562362513533429e+02 -3.444185111762555493e+02 2.741529622474283201e+02 2.515489335475258414e+01 -1.007539282739960811e+02 -1.103742556523487934e+02 5.533027818891989682e+02 -3.612519277674758769e+02 1.456607310201988810e+02 -1.200889435095781153e+02 -6.822817263798721399e+01 -1.558766901584039388e+01
+3.883776323509380735e+00 -5.206532972119772396e+00 -5.661336629183209013e+00 -1.593034705295243825e+00 -4.845847551417503118e-01 -1.978639881137895529e+01 2.060639289458460510e+01 -2.654749576699840574e+01 -1.472529623873179538e+01 7.267839671918275712e+01 -2.067928130108034779e+01 -1.748406454372760663e+02 3.311311821450776165e+02 -2.596681594940621380e+02 -6.417006226891290055e+01 1.817399408509938894e+02 -1.133915422380968607e+02 -3.612519277674758769e+02 8.227661540145846857e+02 -5.889251881384034277e+02 1.505009903985806829e+02 7.459360068624346241e+01 -9.689475113469024903e-01
+-3.312986073939271581e+00 4.646086172638097977e+00 4.110320821833330029e+00 2.922427496009236236e+00 8.827391178444837783e-01 1.263968084842567130e+01 -1.956583996346799736e+01 2.268517800068569201e+01 1.212553585632562303e+01 -6.048117285047313629e+01 2.200436634778799672e+01 1.236547165154022565e+02 -2.214088698492690810e+02 1.811159982832207618e+02 5.501930999130374289e+01 -1.524500322663519967e+02 1.084268925701416748e+02 1.456607310201988810e+02 -5.889251881384034277e+02 6.281297406866601705e+02 -2.360284378048359315e+02 -3.788478747503720001e+01 -3.966409304890950338e+00
+3.260580287172311076e-01 -9.512588298321154046e-01 -4.436445385268852210e-02 2.418471544653607364e+00 -2.003420141528640397e-01 -1.061985799126625452e+01 -6.462280445941964935e+00 1.861784076616177952e+00 -2.619725312876233669e+00 8.332814408542049689e-01 1.435784250738115198e+01 -5.288020624787915125e+01 1.412525470264524756e+02 -1.209752078734303211e+02 2.834210966776290253e+00 6.872035320031325512e+01 -3.713437396884358321e+01 -1.200889435095781153e+02 1.505009903985806829e+02 -2.360284378048359315e+02 1.984952390410417138e+02 -1.726639859088383133e+01 2.367061880986858213e+01
+-2.407079734553001227e-01 4.764495021104730443e-01 -9.273163347354730357e-01 1.735086438573440581e+00 -1.571162986767073333e+00 -5.387113217480632876e+00 -1.842331321362554952e+00 -1.086057555055923052e+00 6.554258795806483517e-01 2.913611038688055821e+00 5.897940047881299996e+00 -3.703333668761484176e+01 8.807560198206526536e+01 -6.791623844252907816e+01 -5.661727157052321324e+00 3.215537051004270808e+01 -1.732989764142075018e+01 -6.822817263798721399e+01 7.459360068624346241e+01 -3.788478747503720001e+01 -1.726639859088383133e+01 8.664655681400094522e+01 -3.077439487873002122e+01
+7.276273416339069655e-01 -8.160183386215708046e-01 3.336243824700811378e-01 5.801075102971581243e-01 -9.332852800342261723e-02 -8.134892698422866442e-01 -2.065992221782699811e+00 1.511386856157765468e+00 -7.910864037361950984e-01 -2.121436706560488439e+00 2.999410141876153624e+00 -1.054810568719527941e+00 1.554174029562684467e+01 -1.351901672842707747e+01 -1.161697304761181604e+00 -3.184204072141046726e+00 5.018169342462520000e+00 -1.558766901584039388e+01 -9.689475113469024903e-01 -3.966409304890950338e+00 2.367061880986858213e+01 -3.077439487873002122e+01 2.653581617274004500e+01
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/ld1_scalings.txt b/regtest/sizeshape/rt-sizeshape-mpi/ld1_scalings.txt
new file mode 100644
index 0000000000..0d6d305798
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/ld1_scalings.txt
@@ -0,0 +1,69 @@
+-1.008123761803866980e+00
+1.626510375189665680e+00
+4.491793750288705644e-01
+-6.586147643691930842e-01
+8.235017815364878979e-01
+3.478980458875061688e-01
+1.481264411141690829e+00
+-3.038312014911420000e+00
+-1.267599717071444143e+00
+-1.585188804951326025e-01
+-5.817395001067517946e-01
+-6.260861234524053298e-01
+-3.387375174876071648e-01
+9.372083330539093815e-01
+2.554555712335253581e-01
+2.167666577399882111e-02
+-6.051555596404274429e-01
+-1.380047808122754072e-01
+4.218768793816384255e-01
+-1.281803232189904440e+00
+-9.491404066182579369e-01
+-1.339507084104512580e-01
+-8.935651980303346842e-02
+-8.508449794582281789e-02
+-2.148524234383437648e+00
+4.226170448258242729e+00
+1.677729266602153713e+00
+-1.357153299731779228e-01
+2.085836564032336471e-01
+-7.003628642152187611e-02
+5.765462050962143897e-02
+-9.802581922121870184e-01
+-5.445968486733449021e-01
+-4.132029558223072052e-01
+6.261097028889341942e-01
+2.257791572712143091e-01
+-3.200628724867338182e-01
+-2.087169662443416895e-01
+-1.977133624004201451e-01
+-4.769408025188121014e-01
+8.678530538596880284e-01
+3.176011660686111626e-01
+1.944520543315805039e+00
+-4.508400989736514042e+00
+-2.258083990712280276e+00
+2.386745619994993017e+00
+-5.518894174386804963e+00
+-2.056655748999836497e+00
+-2.860416065666450347e+00
+6.025099475452838860e+00
+2.158730933826262799e+00
+-1.008140655250909096e-01
+9.449132130777106175e-02
+-1.921879735818581014e-01
+-5.517552129726168708e-01
+5.344767556698636346e-01
+2.778728406758145253e-01
+5.657267029451286122e-01
+-1.164396506907206197e+00
+-7.932515522656270468e-01
+-3.322057545545195278e+00
+6.199518797075218579e+00
+2.565033662356621669e+00
+-6.500590254132574408e-01
+8.874930491073512728e-01
+1.671230651011225421e-01
+2.608378228283110278e+00
+-5.709980861399765573e+00
+-2.296414790623169999e+00
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/plumed.dat b/regtest/sizeshape/rt-sizeshape-mpi/plumed.dat
new file mode 100644
index 0000000000..635da1dcf8
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/plumed.dat
@@ -0,0 +1,14 @@
+# units
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+
+# make a group of atoms
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+
+# ld1
+ld1: SIZESHAPE_POSITION_LINEAR_PROJ REFERENCE=global_avg.txt PRECISION=global_precision.txt COEFFS=ld1_scalings.txt GROUP=ga_list
+
+#print
+PRINT ARG=ld1 STRIDE=1 FILE=COLVAR FMT=%8.8f
+
+# dump derivatives
+DUMPDERIVATIVES ARG=ld1 STRIDE=1 FILE=deriv FMT=%8.3f
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/report.txt b/regtest/sizeshape/rt-sizeshape-mpi/report.txt
new file mode 100644
index 0000000000..4eba530597
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/report.txt
@@ -0,0 +1,7 @@
+Tue May 7 17:13:00 EDT 2024
+Running regtest in /home/subarna/plumed2-sizeshape/regtest/sizeshape/rt-sizeshape-mpi
+++ Test type: driver
+++ Arguments: --plumed plumed.dat --itrr test_traj.trr
+++ Processors: 4
+/home/subarna/plumed2-sizeshape/regtest/sizeshape/rt-sizeshape-mpi/tmp
+NOT_APPLICABLE (MPI NOT INSTALLED)
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/test_traj.trr b/regtest/sizeshape/rt-sizeshape-mpi/test_traj.trr
new file mode 100644
index 0000000000..6698336cbe
Binary files /dev/null and b/regtest/sizeshape/rt-sizeshape-mpi/test_traj.trr differ
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/COLVAR.reference b/regtest/sizeshape/rt-sizeshape-mpi/tmp/COLVAR.reference
new file mode 100644
index 0000000000..d8dc94d277
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/COLVAR.reference
@@ -0,0 +1,6 @@
+#! FIELDS time ld1
+ 0.000000 -53.42214977
+ 1.000000 -53.56701954
+ 2.000000 -51.75886201
+ 3.000000 -53.01109644
+ 4.000000 -52.57399786
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/Makefile b/regtest/sizeshape/rt-sizeshape-mpi/tmp/Makefile
new file mode 100644
index 0000000000..3703b27cea
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/config b/regtest/sizeshape/rt-sizeshape-mpi/tmp/config
new file mode 100644
index 0000000000..ae37970300
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/config
@@ -0,0 +1,4 @@
+type=driver
+mpiprocs=4
+plumed_modules=sizeshape
+arg="--plumed plumed.dat --itrr test_traj.trr"
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/deriv.reference b/regtest/sizeshape/rt-sizeshape-mpi/tmp/deriv.reference
new file mode 100644
index 0000000000..5ac798a64a
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/deriv.reference
@@ -0,0 +1,391 @@
+#! FIELDS time parameter ld1
+ 0.000000 0 -0.7465037939
+ 0.000000 1 1.8058080784
+ 0.000000 2 0.1806327248
+ 0.000000 3 -0.5209154224
+ 0.000000 4 0.9607693215
+ 0.000000 5 0.2164921646
+ 0.000000 6 0.9760679639
+ 0.000000 7 -3.3880242995
+ 0.000000 8 -0.7494042038
+ 0.000000 9 -0.2757943278
+ 0.000000 10 -0.6212341177
+ 0.000000 11 -0.5016006632
+ 0.000000 12 -0.1907059719
+ 0.000000 13 1.0000372605
+ 0.000000 14 0.0937873381
+ 0.000000 15 -0.0614433191
+ 0.000000 16 -0.6754772826
+ 0.000000 17 -0.0422200053
+ 0.000000 18 0.2129071405
+ 0.000000 19 -1.5665352471
+ 0.000000 20 -0.7468818026
+ 0.000000 21 -0.1656536320
+ 0.000000 22 -0.0234855690
+ 0.000000 23 -0.0453223542
+ 0.000000 24 -1.4568328943
+ 0.000000 25 4.7293672466
+ 0.000000 26 0.9686497535
+ 0.000000 27 -0.0739811860
+ 0.000000 28 0.0928309674
+ 0.000000 29 -0.1420965702
+ 0.000000 30 -0.1429928233
+ 0.000000 31 -0.8905229315
+ 0.000000 32 -0.3192321920
+ 0.000000 33 -0.2990691229
+ 0.000000 34 0.5016669682
+ 0.000000 35 0.0936904854
+ 0.000000 36 -0.4627987266
+ 0.000000 37 0.6419541613
+ 0.000000 38 0.0191613083
+ 0.000000 39 -0.2476678084
+ 0.000000 40 0.2980038367
+ 0.000000 41 0.0357759674
+ 0.000000 42 1.1528645423
+ 0.000000 43 -4.9863341495
+ 0.000000 44 -1.4489906796
+ 0.000000 45 1.4925953053
+ 0.000000 46 -5.9074267590
+ 0.000000 47 -1.1018027344
+ 0.000000 48 -1.9104834756
+ 0.000000 49 6.6593190944
+ 0.000000 50 1.1627779649
+ 0.000000 51 0.0438803177
+ 0.000000 52 -0.8313684482
+ 0.000000 53 -0.4058261609
+ 0.000000 54 -0.3727672450
+ 0.000000 55 0.7604417689
+ 0.000000 56 0.1356918844
+ 0.000000 57 0.2633403739
+ 0.000000 58 -1.3114889789
+ 0.000000 59 -0.5098225905
+ 0.000000 60 -2.3361243173
+ 0.000000 61 7.3041077819
+ 0.000000 62 1.5885888530
+ 0.000000 63 -0.5248772602
+ 0.000000 64 1.1383742141
+ 0.000000 65 0.0512168853
+ 0.000000 66 1.6554002357
+ 0.000000 67 -6.2698840019
+ 0.000000 68 -1.3056211394
+ 0.000000 69 50.2355411744
+ 0.000000 70 -6.6941564591
+ 0.000000 71 28.8095270592
+ 0.000000 72 111.7410217451
+ 0.000000 73 66.3891323287
+ 0.000000 74 96.9521335448
+ 0.000000 75 101.4215580999
+ 0.000000 76 25.2271332480
+ 0.000000 77 75.6369535069
+ 1.000000 0 -0.7753207584
+ 1.000000 1 1.7921155376
+ 1.000000 2 0.0356870196
+ 1.000000 3 -0.5473867922
+ 1.000000 4 0.9743979625
+ 1.000000 5 0.1342936301
+ 1.000000 6 1.0536467705
+ 1.000000 7 -3.3975531380
+ 1.000000 8 -0.4973107480
+ 1.000000 9 -0.2403247976
+ 1.000000 10 -0.6598967992
+ 1.000000 11 -0.4785140227
+ 1.000000 12 -0.2096313267
+ 1.000000 13 1.0055465879
+ 1.000000 14 0.0258456929
+ 1.000000 15 -0.0689153133
+ 1.000000 16 -0.6118316271
+ 1.000000 17 0.0037224687
+ 1.000000 18 0.2784715434
+ 1.000000 19 -1.6233315321
+ 1.000000 20 -0.6426126291
+ 1.000000 21 -0.1769381818
+ 1.000000 22 0.0159656899
+ 1.000000 23 -0.0474945210
+ 1.000000 24 -1.5754363247
+ 1.000000 25 4.7847020781
+ 1.000000 26 0.6180385483
+ 1.000000 27 -0.0279585507
+ 1.000000 28 -0.0496915618
+ 1.000000 29 -0.1666834429
+ 1.000000 30 -0.1164721439
+ 1.000000 31 -0.9099545814
+ 1.000000 32 -0.2747310099
+ 1.000000 33 -0.4491756840
+ 1.000000 34 0.9868005094
+ 1.000000 35 0.1135952516
+ 1.000000 36 -0.1708242422
+ 1.000000 37 -0.4309165263
+ 1.000000 38 -0.1887707747
+ 1.000000 39 -0.4921455400
+ 1.000000 40 1.1429888524
+ 1.000000 41 0.1226990243
+ 1.000000 42 1.2393999000
+ 1.000000 43 -4.8698796959
+ 1.000000 44 -1.0716528003
+ 1.000000 45 1.7925315440
+ 1.000000 46 -6.5218595040
+ 1.000000 47 -0.7531634189
+ 1.000000 48 -2.1720336591
+ 1.000000 49 7.0879150968
+ 1.000000 50 0.7233449480
+ 1.000000 51 -0.1530769445
+ 1.000000 52 -0.0318216223
+ 1.000000 53 -0.2368546291
+ 1.000000 54 0.0637095297
+ 1.000000 55 -0.7989108944
+ 1.000000 56 -0.1302381527
+ 1.000000 57 -0.0455275512
+ 1.000000 58 -0.1307244887
+ 1.000000 59 -0.2641923039
+ 1.000000 60 -2.3847966091
+ 1.000000 61 6.9055664135
+ 1.000000 62 0.9766132102
+ 1.000000 63 -0.4632063472
+ 1.000000 64 0.8546463881
+ 1.000000 65 -0.0797933133
+ 1.000000 66 1.8041121137
+ 1.000000 67 -6.3178431290
+ 1.000000 68 -0.8515336745
+ 1.000000 69 49.0757825540
+ 1.000000 70 -5.3731019185
+ 1.000000 71 31.4396033403
+ 1.000000 72 106.0429881109
+ 1.000000 73 74.3078142961
+ 1.000000 74 98.7834739652
+ 1.000000 75 98.6041278407
+ 1.000000 76 27.7844190617
+ 1.000000 77 78.8442473916
+ 2.000000 0 -0.7052451330
+ 2.000000 1 1.8150155370
+ 2.000000 2 0.2208900774
+ 2.000000 3 -0.5003223372
+ 2.000000 4 0.9697526963
+ 2.000000 5 0.2394547764
+ 2.000000 6 0.8989572748
+ 2.000000 7 -3.3874214481
+ 2.000000 8 -0.8245792685
+ 2.000000 9 -0.2943111269
+ 2.000000 10 -0.5864385678
+ 2.000000 11 -0.5103636354
+ 2.000000 12 -0.1676483130
+ 2.000000 13 0.9983253456
+ 2.000000 14 0.1153158685
+ 2.000000 15 -0.0697149630
+ 2.000000 16 -0.7033001488
+ 2.000000 17 -0.0641136729
+ 2.000000 18 0.1923279974
+ 2.000000 19 -1.6127951312
+ 2.000000 20 -0.7966933723
+ 2.000000 21 -0.1766586905
+ 2.000000 22 0.0205009457
+ 2.000000 23 -0.0351875251
+ 2.000000 24 -1.3536756796
+ 2.000000 25 4.7475514620
+ 2.000000 26 1.0779992380
+ 2.000000 27 -0.0504259773
+ 2.000000 28 0.0146696273
+ 2.000000 29 -0.1614451705
+ 2.000000 30 -0.1875604646
+ 2.000000 31 -0.7789855353
+ 2.000000 32 -0.3134289855
+ 2.000000 33 -0.2723518811
+ 2.000000 34 0.4201918493
+ 2.000000 35 0.0872779843
+ 2.000000 36 -0.5389705407
+ 2.000000 37 1.0692379675
+ 2.000000 38 0.1311880304
+ 2.000000 39 -0.1676361620
+ 2.000000 40 -0.0354262795
+ 2.000000 41 -0.0358216212
+ 2.000000 42 1.0241730273
+ 2.000000 43 -4.9171106028
+ 2.000000 44 -1.5445107557
+ 2.000000 45 1.3536146710
+ 2.000000 46 -5.8586949429
+ 2.000000 47 -1.2248857807
+ 2.000000 48 -1.7747122747
+ 2.000000 49 6.7077424987
+ 2.000000 50 1.3243485810
+ 2.000000 51 0.1342071457
+ 2.000000 52 -1.3053584922
+ 2.000000 53 -0.5391307717
+ 2.000000 54 -0.3234418088
+ 2.000000 55 0.7041374879
+ 2.000000 56 0.1270823986
+ 2.000000 57 0.1892627765
+ 2.000000 58 -1.1809091937
+ 2.000000 59 -0.4993478186
+ 2.000000 60 -2.2089047441
+ 2.000000 61 7.4879759339
+ 2.000000 62 1.7928743333
+ 2.000000 63 -0.5134399935
+ 2.000000 64 1.2167683209
+ 2.000000 65 0.0925620242
+ 2.000000 66 1.5055100796
+ 2.000000 67 -6.2351220748
+ 2.000000 68 -1.4367964788
+ 2.000000 69 49.9503224202
+ 2.000000 70 -7.0182122942
+ 2.000000 71 29.0078497492
+ 2.000000 72 113.6108218838
+ 2.000000 73 60.2787883064
+ 2.000000 74 97.9368511388
+ 2.000000 75 102.1013974790
+ 2.000000 76 22.1648009236
+ 2.000000 77 76.3211888896
+ 3.000000 0 -0.6188945832
+ 3.000000 1 1.8689478715
+ 3.000000 2 0.0345407472
+ 3.000000 3 -0.4531505503
+ 3.000000 4 1.0008762331
+ 3.000000 5 0.1322454274
+ 3.000000 6 0.7486273724
+ 3.000000 7 -3.5032309853
+ 3.000000 8 -0.4879441228
+ 3.000000 9 -0.2942259670
+ 3.000000 10 -0.6846226775
+ 3.000000 11 -0.4748601178
+ 3.000000 12 -0.1218263073
+ 3.000000 13 1.0254412544
+ 3.000000 14 0.0214332211
+ 3.000000 15 -0.1308317835
+ 3.000000 16 -0.5760577181
+ 3.000000 17 0.0131848758
+ 3.000000 18 0.0819305534
+ 3.000000 19 -1.4543600969
+ 3.000000 20 -0.6108163156
+ 3.000000 21 -0.1411347732
+ 3.000000 22 -0.1266982387
+ 3.000000 23 -0.0635377233
+ 3.000000 24 -1.1282417780
+ 3.000000 25 4.8506044905
+ 3.000000 26 0.5957038773
+ 3.000000 27 -0.1104557384
+ 3.000000 28 0.3205626328
+ 3.000000 29 -0.1229388957
+ 3.000000 30 -0.1351672637
+ 3.000000 31 -1.1942657125
+ 3.000000 32 -0.3003983188
+ 3.000000 33 -0.3332766674
+ 3.000000 34 0.8174752928
+ 3.000000 35 0.0898270351
+ 3.000000 36 -0.1168805582
+ 3.000000 37 -0.6387881037
+ 3.000000 38 -0.2131654483
+ 3.000000 39 -0.4665228182
+ 3.000000 40 1.3766377172
+ 3.000000 41 0.1468823541
+ 3.000000 42 0.8582115974
+ 3.000000 43 -5.3070276067
+ 3.000000 44 -1.0896328533
+ 3.000000 45 1.1397359103
+ 3.000000 46 -6.2673164123
+ 3.000000 47 -0.6827733600
+ 3.000000 48 -1.4403401323
+ 3.000000 49 6.7717520395
+ 3.000000 50 0.6423701763
+ 3.000000 51 -0.3365506316
+ 3.000000 52 0.6235800797
+ 3.000000 53 -0.1551699839
+ 3.000000 54 -0.3084860701
+ 3.000000 55 0.8477422014
+ 3.000000 56 0.0636917072
+ 3.000000 57 0.2231165581
+ 3.000000 58 -1.6287066465
+ 3.000000 59 -0.4347773420
+ 3.000000 60 -1.7185768826
+ 3.000000 61 7.0072439627
+ 3.000000 62 0.9438750638
+ 3.000000 63 -0.3885055314
+ 3.000000 64 0.9504401817
+ 3.000000 65 -0.0740351261
+ 3.000000 66 1.2533739124
+ 3.000000 67 -6.5635602937
+ 3.000000 68 -0.8393451409
+ 3.000000 69 47.6966305609
+ 3.000000 70 -4.7673792276
+ 3.000000 71 31.1730050619
+ 3.000000 72 113.5605068787
+ 3.000000 73 65.9189332575
+ 3.000000 74 96.8622929525
+ 3.000000 75 102.5211981396
+ 3.000000 76 19.5147926116
+ 3.000000 77 77.5087229738
+ 4.000000 0 -0.8734634839
+ 4.000000 1 1.7412499467
+ 4.000000 2 -0.0038133699
+ 4.000000 3 -0.6141074422
+ 4.000000 4 0.9449101071
+ 4.000000 5 0.1017555284
+ 4.000000 6 1.2829156304
+ 4.000000 7 -3.3154423448
+ 4.000000 8 -0.4593863622
+ 4.000000 9 -0.1624425970
+ 4.000000 10 -0.6475301092
+ 4.000000 11 -0.5090292845
+ 4.000000 12 -0.2671931114
+ 4.000000 13 0.9901919391
+ 4.000000 14 0.0247236422
+ 4.000000 15 -0.0322460529
+ 4.000000 16 -0.6223725144
+ 4.000000 17 -0.0151854493
+ 4.000000 18 0.4487420988
+ 4.000000 19 -1.6451232320
+ 4.000000 20 -0.6520692018
+ 4.000000 21 -0.1902053924
+ 4.000000 22 0.0528842207
+ 4.000000 23 -0.0567671862
+ 4.000000 24 -1.9006368277
+ 4.000000 25 4.6921211762
+ 4.000000 26 0.5603084766
+ 4.000000 27 0.0310541303
+ 4.000000 28 -0.1536970345
+ 4.000000 29 -0.1850019359
+ 4.000000 30 -0.0702503272
+ 4.000000 31 -0.8227929669
+ 4.000000 32 -0.2887376944
+ 4.000000 33 -0.5414239766
+ 4.000000 34 1.0178630532
+ 4.000000 35 0.0984832148
+ 4.000000 36 -0.1373751807
+ 4.000000 37 -0.3724803811
+ 4.000000 38 -0.2026525898
+ 4.000000 39 -0.5561543546
+ 4.000000 40 1.0566389150
+ 4.000000 41 0.0897332356
+ 4.000000 42 1.5681218265
+ 4.000000 43 -4.6697014774
+ 4.000000 44 -1.0278621872
+ 4.000000 45 2.2700212007
+ 4.000000 46 -6.5082337017
+ 4.000000 47 -0.7211068443
+ 4.000000 48 -2.6840555002
+ 4.000000 49 7.0795853340
+ 4.000000 50 0.6705517279
+ 4.000000 51 -0.0713202489
+ 4.000000 52 -0.2185402941
+ 4.000000 53 -0.2774533620
+ 4.000000 54 0.3164785625
+ 4.000000 55 -1.2691278513
+ 4.000000 56 -0.2083820263
+ 4.000000 57 -0.1896378620
+ 4.000000 58 0.3077414299
+ 4.000000 59 -0.2062385157
+ 4.000000 60 -2.8544753256
+ 4.000000 61 6.7642185300
+ 4.000000 62 0.8826579929
+ 4.000000 63 -0.4918334142
+ 4.000000 64 0.8121816762
+ 4.000000 65 -0.1091184252
+ 4.000000 66 2.2185732327
+ 4.000000 67 -6.1571544812
+ 4.000000 68 -0.7930843360
+ 4.000000 69 47.0946987303
+ 4.000000 70 -6.3597579684
+ 4.000000 71 35.1428007585
+ 4.000000 72 93.1724550557
+ 4.000000 73 75.8170113735
+ 4.000000 74 109.5310246398
+ 4.000000 75 89.5712004998
+ 4.000000 76 30.7160098188
+ 4.000000 77 88.0994881784
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_avg.txt b/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_avg.txt
new file mode 100644
index 0000000000..3fe06fc8dd
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_avg.txt
@@ -0,0 +1,23 @@
+4.265825962982551012e+00 2.336690414907679203e-01 3.662809312682036023e+00
+4.214057267340745483e+00 1.072049513718947578e-01 4.314804999781733486e+00
+3.671228981308725103e+00 1.274792340073149510e-01 3.977231205572313577e+00
+2.343698812761148886e+00 -2.841411661146072132e-01 3.478414401687389024e+00
+1.686436487941495699e+00 -8.665088225218358087e-01 4.100811861077803044e+00
+4.360230108844224128e-01 -1.347015411672896512e+00 3.844097514796287030e+00
+3.117457174800847969e-02 -1.024227536411313366e+00 2.585940217022081988e+00
+6.808808862178362675e-01 -5.870202775664047357e-01 2.290245252111865248e+00
+4.586351396567848737e-01 -2.433497671270518359e-01 1.192357902655695634e+00
+4.931328549364416558e-01 2.515992483355074527e-01 2.956934483804412803e-02
+1.406321673638208702e+00 6.682431861735423917e-01 7.908513055476143472e-02
+1.646908036369386430e+00 1.186975749838515615e+00 -8.956858825186609918e-01
+5.912530303131902087e-01 8.617407774506029572e-01 -1.344660953846545715e+00
+8.530666038486142688e-02 2.536604398394486926e-01 -4.506541385680229994e-01
+-8.727821507437001358e-01 -1.296438909175296195e-01 -6.398328611456164383e-01
+-2.067478377458112249e+00 -3.906550201962756819e-01 -1.401863559473397691e+00
+-2.408455843196946056e+00 -6.754022773093291132e-01 -1.106090740276666429e+00
+-3.499742687863982127e+00 -9.747491888605476218e-01 -1.653484266030961436e+00
+-3.548593077032900389e+00 -4.204563480815317056e-01 -3.070014906890367268e+00
+-2.499045339091049645e+00 2.342840846507300567e-01 -3.442979964675248805e+00
+-2.331926055743990922e+00 8.142912721692037170e-01 -4.695739761431558357e+00
+-2.568879301577981611e+00 1.091951813009595762e+00 -5.625053366993444826e+00
+-2.213980543775061705e+00 1.112069908442180788e+00 -5.229306740929514419e+00
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_precision.txt b/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_precision.txt
new file mode 100644
index 0000000000..6cd0c4b4ec
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/global_precision.txt
@@ -0,0 +1,23 @@
+1.341060592612849689e+01 -2.432209892648744542e+01 1.533381940780554942e+01 -7.657303908462504083e+00 1.776037152155568455e+00 4.338540983771763671e+00 -3.609963145053606937e+00 2.810411955027056319e+00 -1.043671268084174208e+00 -1.475196332213428052e+00 5.759621172324607130e-01 -8.527089597052168735e-01 9.644241803601940610e-01 -7.723571031369950157e-01 -9.902209008702838045e-01 1.137035356431496114e+00 -7.992059372693161023e-01 -2.078782440990323555e-01 3.883776323509380735e+00 -3.312986073939271581e+00 3.260580287172311076e-01 -2.407079734553001227e-01 7.276273416339069655e-01
+-2.432209892648744542e+01 5.224657127170035409e+01 -4.184495643299391787e+01 2.691929890881726450e+01 -1.133485157950145350e+01 -4.581368136551017045e+00 5.418668441607914055e+00 -4.721462749988712737e+00 7.612938084579194686e-02 3.416864986007456029e+00 -1.915387904627712246e+00 1.300900115134859814e+00 -9.304157403410605598e-01 6.940752221505136488e-01 1.446934261540284483e+00 -1.833895730955714232e+00 1.069137481710279447e+00 7.471315977387903429e-01 -5.206532972119772396e+00 4.646086172638097977e+00 -9.512588298321154046e-01 4.764495021104730443e-01 -8.160183386215708046e-01
+1.533381940780554942e+01 -4.184495643299391787e+01 1.006909570680676609e+02 -9.001875555992035061e+01 -3.451475916336282523e+01 4.163490105870881308e+01 1.599032505888508560e+01 -1.109541021072212708e+01 5.753834304617886808e+00 -5.207568591756271958e-01 -4.504124622286217239e+00 4.467889138659089987e+00 -1.979451375310257388e+00 1.428207880391368700e+00 2.455983409910902082e-01 -3.661844077828322330e-01 1.301366752271428284e+00 1.865718345450012861e-01 -5.661336629183209013e+00 4.110320821833330029e+00 -4.436445385268852210e-02 -9.273163347354730357e-01 3.336243824700811378e-01
+-7.657303908462504083e+00 2.691929890881726450e+01 -9.001875555992035061e+01 1.219943530037234609e+02 -1.755683353726008988e+01 -1.486034955695616766e+01 -3.364530734833785885e+01 1.815403977068739394e+01 5.330083239917091653e+00 -5.787673063672293949e+00 8.949916505352897289e+00 -1.337407792820569874e+01 5.626279540052188999e+00 -3.353587794831017099e+00 -1.939256656091284045e-02 2.049939558614113921e-02 1.365089261756972094e+00 -8.149336646290846531e+00 -1.593034705295243825e+00 2.922427496009236236e+00 2.418471544653607364e+00 1.735086438573440581e+00 5.801075102971581243e-01
+1.776037152155568455e+00 -1.133485157950145350e+01 -3.451475916336282523e+01 -1.755683353726008988e+01 1.576310085514577395e+02 -1.169557595696256698e+02 4.104142155819025817e+01 -1.993810599591465405e+01 -9.199632220440848940e+00 5.609782974523333188e+00 -8.606957001656226902e-01 4.352603470334472924e+00 2.000397845332385627e-01 -2.935281317572900339e-01 6.386731800524242386e-01 -5.216545146993613047e-01 -9.531848586959631997e-02 1.488251394396544747e+00 -4.845847551417503118e-01 8.827391178444837783e-01 -2.003420141528640397e-01 -1.571162986767073333e+00 -9.332852800342261723e-02
+4.338540983771763671e+00 -4.581368136551017045e+00 4.163490105870881308e+01 -1.486034955695616766e+01 -1.169557595696256698e+02 1.788850067984545547e+02 -1.161726175113718540e+02 -1.824155088149085913e+01 3.722951336234645225e+01 1.822089554504272613e+01 -1.822518186211086544e+01 2.062249842740017414e+01 -2.513081540730243901e+01 1.287044852717752264e+01 5.701441320158269654e+00 -1.053843438992904424e+01 4.429603780088037013e+00 2.474040595293856626e+01 -1.978639881137895529e+01 1.263968084842567130e+01 -1.061985799126625452e+01 -5.387113217480632876e+00 -8.134892698422866442e-01
+-3.609963145053606937e+00 5.418668441607914055e+00 1.599032505888508560e+01 -3.364530734833785885e+01 4.104142155819025817e+01 -1.161726175113718540e+02 1.694295840575620389e+02 -5.437639055615947115e+01 2.623850990846575915e+00 -3.516723107832262230e+01 1.435451051172955950e+01 3.222162989559810842e-01 -1.842212594999670827e+01 2.189731127507590713e+01 -1.902181569285956542e+01 3.228461102714651698e+00 -4.863952497098324557e+00 2.030310554237381027e+01 2.060639289458460510e+01 -1.956583996346799736e+01 -6.462280445941964935e+00 -1.842331321362554952e+00 -2.065992221782699811e+00
+2.810411955027056319e+00 -4.721462749988712737e+00 -1.109541021072212708e+01 1.815403977068739394e+01 -1.993810599591465405e+01 -1.824155088149085913e+01 -5.437639055615947115e+01 2.012346773701846985e+02 -1.433541271828811432e+02 4.653186371227659635e+01 -1.956748341724615514e+01 -1.634725695145779811e+00 8.039707591790719476e+00 -3.267442313649244756e+00 8.227736047692134846e+00 -3.724004024363516852e+00 5.781830775284857893e+00 -9.284359805331549254e+00 -2.654749576699840574e+01 2.268517800068569201e+01 1.861784076616177952e+00 -1.086057555055923052e+00 1.511386856157765468e+00
+-1.043671268084174208e+00 7.612938084579194686e-02 5.753834304617886808e+00 5.330083239917091653e+00 -9.199632220440848940e+00 3.722951336234645225e+01 2.623850990846575915e+00 -1.433541271828811432e+02 1.996795924035413066e+02 -1.309616133199795343e+02 -1.259115312344027870e+01 4.068068951966531444e+01 8.652590509943264507e+00 -7.261756692588662077e+00 1.155589151733675202e+01 -3.228134443858557301e+00 -4.085784906015216933e+00 5.498844145142581574e+00 -1.472529623873179538e+01 1.212553585632562303e+01 -2.619725312876233669e+00 6.554258795806483517e-01 -7.910864037361950984e-01
+-1.475196332213428052e+00 3.416864986007456029e+00 -5.207568591756271958e-01 -5.787673063672293949e+00 5.609782974523333188e+00 1.822089554504272613e+01 -3.516723107832262230e+01 4.653186371227659635e+01 -1.309616133199795343e+02 2.050231620923374862e+02 -7.832272719934573502e+01 -1.766817048680164248e+01 -2.523801962490263406e+01 5.604515342927428811e+00 -2.903829488250302848e+00 1.337127124864552741e+01 -9.018253000914876694e+00 -4.537565087179325829e+00 7.267839671918275712e+01 -6.048117285047313629e+01 8.332814408542049689e-01 2.913611038688055821e+00 -2.121436706560488439e+00
+5.759621172324607130e-01 -1.915387904627712246e+00 -4.504124622286217239e+00 8.949916505352897289e+00 -8.606957001656226902e-01 -1.822518186211086544e+01 1.435451051172955950e+01 -1.956748341724615514e+01 -1.259115312344027870e+01 -7.832272719934573502e+01 2.255353366533649933e+02 -1.439515471076909705e+02 7.531020566839718811e+01 -4.167059763260684946e+01 -3.788221335436109616e+00 6.749467480930080754e+00 4.450810630543437618e+00 -3.510936740882865337e+01 -2.067928130108034779e+01 2.200436634778799672e+01 1.435784250738115198e+01 5.897940047881299996e+00 2.999410141876153624e+00
+-8.527089597052168735e-01 1.300900115134859814e+00 4.467889138659089987e+00 -1.337407792820569874e+01 4.352603470334472924e+00 2.062249842740017414e+01 3.222162989559810842e-01 -1.634725695145779811e+00 4.068068951966531444e+01 -1.766817048680164248e+01 -1.439515471076909705e+02 2.620094439724968538e+02 -2.689027245307896692e+02 1.016191451925127325e+02 4.640171585384572950e+01 -4.830056188387580818e+01 2.830546078080061889e+01 1.267562362513533429e+02 -1.748406454372760663e+02 1.236547165154022565e+02 -5.288020624787915125e+01 -3.703333668761484176e+01 -1.054810568719527941e+00
+9.644241803601940610e-01 -9.304157403410605598e-01 -1.979451375310257388e+00 5.626279540052188999e+00 2.000397845332385627e-01 -2.513081540730243901e+01 -1.842212594999670827e+01 8.039707591790719476e+00 8.652590509943264507e+00 -2.523801962490263406e+01 7.531020566839718811e+01 -2.689027245307896692e+02 5.839023592146512556e+02 -3.894294442433576364e+02 -9.173356538671294302e+00 1.081568782887882350e+02 -6.181982179848619552e+01 -3.444185111762555493e+02 3.311311821450776165e+02 -2.214088698492690810e+02 1.412525470264524756e+02 8.807560198206526536e+01 1.554174029562684467e+01
+-7.723571031369950157e-01 6.940752221505136488e-01 1.428207880391368700e+00 -3.353587794831017099e+00 -2.935281317572900339e-01 1.287044852717752264e+01 2.189731127507590713e+01 -3.267442313649244756e+00 -7.261756692588662077e+00 5.604515342927428811e+00 -4.167059763260684946e+01 1.016191451925127325e+02 -3.894294442433576364e+02 4.755931108838578325e+02 -1.425057023424922704e+02 -5.886350932625035881e+01 3.452077327022928444e+01 2.741529622474283201e+02 -2.596681594940621380e+02 1.811159982832207618e+02 -1.209752078734303211e+02 -6.791623844252907816e+01 -1.351901672842707747e+01
+-9.902209008702838045e-01 1.446934261540284483e+00 2.455983409910902082e-01 -1.939256656091284045e-02 6.386731800524242386e-01 5.701441320158269654e+00 -1.902181569285956542e+01 8.227736047692134846e+00 1.155589151733675202e+01 -2.903829488250302848e+00 -3.788221335436109616e+00 4.640171585384572950e+01 -9.173356538671294302e+00 -1.425057023424922704e+02 2.400794701823535888e+02 -1.792956792626917490e+02 3.138582984045448754e+01 2.515489335475258414e+01 -6.417006226891290055e+01 5.501930999130374289e+01 2.834210966776290253e+00 -5.661727157052321324e+00 -1.161697304761181604e+00
+1.137035356431496114e+00 -1.833895730955714232e+00 -3.661844077828322330e-01 2.049939558614113921e-02 -5.216545146993613047e-01 -1.053843438992904424e+01 3.228461102714651698e+00 -3.724004024363516852e+00 -3.228134443858557301e+00 1.337127124864552741e+01 6.749467480930080754e+00 -4.830056188387580818e+01 1.081568782887882350e+02 -5.886350932625035881e+01 -1.792956792626917490e+02 2.983596837029729727e+02 -1.505787385408951025e+02 -1.007539282739960811e+02 1.817399408509938894e+02 -1.524500322663519967e+02 6.872035320031325512e+01 3.215537051004270808e+01 -3.184204072141046726e+00
+-7.992059372693161023e-01 1.069137481710279447e+00 1.301366752271428284e+00 1.365089261756972094e+00 -9.531848586959631997e-02 4.429603780088037013e+00 -4.863952497098324557e+00 5.781830775284857893e+00 -4.085784906015216933e+00 -9.018253000914876694e+00 4.450810630543437618e+00 2.830546078080061889e+01 -6.181982179848619552e+01 3.452077327022928444e+01 3.138582984045448754e+01 -1.505787385408951025e+02 2.834361801812467547e+02 -1.103742556523487934e+02 -1.133915422380968607e+02 1.084268925701416748e+02 -3.713437396884358321e+01 -1.732989764142075018e+01 5.018169342462520000e+00
+-2.078782440990323555e-01 7.471315977387903429e-01 1.865718345450012861e-01 -8.149336646290846531e+00 1.488251394396544747e+00 2.474040595293856626e+01 2.030310554237381027e+01 -9.284359805331549254e+00 5.498844145142581574e+00 -4.537565087179325829e+00 -3.510936740882865337e+01 1.267562362513533429e+02 -3.444185111762555493e+02 2.741529622474283201e+02 2.515489335475258414e+01 -1.007539282739960811e+02 -1.103742556523487934e+02 5.533027818891989682e+02 -3.612519277674758769e+02 1.456607310201988810e+02 -1.200889435095781153e+02 -6.822817263798721399e+01 -1.558766901584039388e+01
+3.883776323509380735e+00 -5.206532972119772396e+00 -5.661336629183209013e+00 -1.593034705295243825e+00 -4.845847551417503118e-01 -1.978639881137895529e+01 2.060639289458460510e+01 -2.654749576699840574e+01 -1.472529623873179538e+01 7.267839671918275712e+01 -2.067928130108034779e+01 -1.748406454372760663e+02 3.311311821450776165e+02 -2.596681594940621380e+02 -6.417006226891290055e+01 1.817399408509938894e+02 -1.133915422380968607e+02 -3.612519277674758769e+02 8.227661540145846857e+02 -5.889251881384034277e+02 1.505009903985806829e+02 7.459360068624346241e+01 -9.689475113469024903e-01
+-3.312986073939271581e+00 4.646086172638097977e+00 4.110320821833330029e+00 2.922427496009236236e+00 8.827391178444837783e-01 1.263968084842567130e+01 -1.956583996346799736e+01 2.268517800068569201e+01 1.212553585632562303e+01 -6.048117285047313629e+01 2.200436634778799672e+01 1.236547165154022565e+02 -2.214088698492690810e+02 1.811159982832207618e+02 5.501930999130374289e+01 -1.524500322663519967e+02 1.084268925701416748e+02 1.456607310201988810e+02 -5.889251881384034277e+02 6.281297406866601705e+02 -2.360284378048359315e+02 -3.788478747503720001e+01 -3.966409304890950338e+00
+3.260580287172311076e-01 -9.512588298321154046e-01 -4.436445385268852210e-02 2.418471544653607364e+00 -2.003420141528640397e-01 -1.061985799126625452e+01 -6.462280445941964935e+00 1.861784076616177952e+00 -2.619725312876233669e+00 8.332814408542049689e-01 1.435784250738115198e+01 -5.288020624787915125e+01 1.412525470264524756e+02 -1.209752078734303211e+02 2.834210966776290253e+00 6.872035320031325512e+01 -3.713437396884358321e+01 -1.200889435095781153e+02 1.505009903985806829e+02 -2.360284378048359315e+02 1.984952390410417138e+02 -1.726639859088383133e+01 2.367061880986858213e+01
+-2.407079734553001227e-01 4.764495021104730443e-01 -9.273163347354730357e-01 1.735086438573440581e+00 -1.571162986767073333e+00 -5.387113217480632876e+00 -1.842331321362554952e+00 -1.086057555055923052e+00 6.554258795806483517e-01 2.913611038688055821e+00 5.897940047881299996e+00 -3.703333668761484176e+01 8.807560198206526536e+01 -6.791623844252907816e+01 -5.661727157052321324e+00 3.215537051004270808e+01 -1.732989764142075018e+01 -6.822817263798721399e+01 7.459360068624346241e+01 -3.788478747503720001e+01 -1.726639859088383133e+01 8.664655681400094522e+01 -3.077439487873002122e+01
+7.276273416339069655e-01 -8.160183386215708046e-01 3.336243824700811378e-01 5.801075102971581243e-01 -9.332852800342261723e-02 -8.134892698422866442e-01 -2.065992221782699811e+00 1.511386856157765468e+00 -7.910864037361950984e-01 -2.121436706560488439e+00 2.999410141876153624e+00 -1.054810568719527941e+00 1.554174029562684467e+01 -1.351901672842707747e+01 -1.161697304761181604e+00 -3.184204072141046726e+00 5.018169342462520000e+00 -1.558766901584039388e+01 -9.689475113469024903e-01 -3.966409304890950338e+00 2.367061880986858213e+01 -3.077439487873002122e+01 2.653581617274004500e+01
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/ld1_scalings.txt b/regtest/sizeshape/rt-sizeshape-mpi/tmp/ld1_scalings.txt
new file mode 100644
index 0000000000..0d6d305798
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/ld1_scalings.txt
@@ -0,0 +1,69 @@
+-1.008123761803866980e+00
+1.626510375189665680e+00
+4.491793750288705644e-01
+-6.586147643691930842e-01
+8.235017815364878979e-01
+3.478980458875061688e-01
+1.481264411141690829e+00
+-3.038312014911420000e+00
+-1.267599717071444143e+00
+-1.585188804951326025e-01
+-5.817395001067517946e-01
+-6.260861234524053298e-01
+-3.387375174876071648e-01
+9.372083330539093815e-01
+2.554555712335253581e-01
+2.167666577399882111e-02
+-6.051555596404274429e-01
+-1.380047808122754072e-01
+4.218768793816384255e-01
+-1.281803232189904440e+00
+-9.491404066182579369e-01
+-1.339507084104512580e-01
+-8.935651980303346842e-02
+-8.508449794582281789e-02
+-2.148524234383437648e+00
+4.226170448258242729e+00
+1.677729266602153713e+00
+-1.357153299731779228e-01
+2.085836564032336471e-01
+-7.003628642152187611e-02
+5.765462050962143897e-02
+-9.802581922121870184e-01
+-5.445968486733449021e-01
+-4.132029558223072052e-01
+6.261097028889341942e-01
+2.257791572712143091e-01
+-3.200628724867338182e-01
+-2.087169662443416895e-01
+-1.977133624004201451e-01
+-4.769408025188121014e-01
+8.678530538596880284e-01
+3.176011660686111626e-01
+1.944520543315805039e+00
+-4.508400989736514042e+00
+-2.258083990712280276e+00
+2.386745619994993017e+00
+-5.518894174386804963e+00
+-2.056655748999836497e+00
+-2.860416065666450347e+00
+6.025099475452838860e+00
+2.158730933826262799e+00
+-1.008140655250909096e-01
+9.449132130777106175e-02
+-1.921879735818581014e-01
+-5.517552129726168708e-01
+5.344767556698636346e-01
+2.778728406758145253e-01
+5.657267029451286122e-01
+-1.164396506907206197e+00
+-7.932515522656270468e-01
+-3.322057545545195278e+00
+6.199518797075218579e+00
+2.565033662356621669e+00
+-6.500590254132574408e-01
+8.874930491073512728e-01
+1.671230651011225421e-01
+2.608378228283110278e+00
+-5.709980861399765573e+00
+-2.296414790623169999e+00
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/plumed.dat b/regtest/sizeshape/rt-sizeshape-mpi/tmp/plumed.dat
new file mode 100644
index 0000000000..d2da872af6
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/plumed.dat
@@ -0,0 +1,14 @@
+# units
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+
+# make a group of atoms
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+
+# ld1
+ld1: SIZESHAPE_POSITION_LINEAR_PROJ REFERENCE=global_avg.txt PRECISION=global_precision.txt COEFFS=ld1_scalings.txt GROUP=ga_list
+
+#print
+PRINT ARG=ld1 STRIDE=1 FILE=COLVAR FMT=%8.8f
+
+# dump derivatives
+DUMPDERIVATIVES ARG=ld1 STRIDE=1 FILE=deriv
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/report.txt b/regtest/sizeshape/rt-sizeshape-mpi/tmp/report.txt
new file mode 100644
index 0000000000..3c2ecd79bf
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape-mpi/tmp/report.txt
@@ -0,0 +1,2 @@
+Tue May 7 17:13:00 EDT 2024
+Running regtest in /home/subarna/plumed2-sizeshape/regtest/sizeshape/rt-sizeshape-mpi
diff --git a/regtest/sizeshape/rt-sizeshape-mpi/tmp/test_traj.trr b/regtest/sizeshape/rt-sizeshape-mpi/tmp/test_traj.trr
new file mode 100644
index 0000000000..6698336cbe
Binary files /dev/null and b/regtest/sizeshape/rt-sizeshape-mpi/tmp/test_traj.trr differ
diff --git a/regtest/sizeshape/rt-sizeshape/COLVAR.reference b/regtest/sizeshape/rt-sizeshape/COLVAR.reference
new file mode 100644
index 0000000000..d8dc94d277
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/COLVAR.reference
@@ -0,0 +1,6 @@
+#! FIELDS time ld1
+ 0.000000 -53.42214977
+ 1.000000 -53.56701954
+ 2.000000 -51.75886201
+ 3.000000 -53.01109644
+ 4.000000 -52.57399786
diff --git a/regtest/sizeshape/rt-sizeshape/Makefile b/regtest/sizeshape/rt-sizeshape/Makefile
new file mode 100644
index 0000000000..3703b27cea
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/sizeshape/rt-sizeshape/config b/regtest/sizeshape/rt-sizeshape/config
new file mode 100644
index 0000000000..f2c2f7b285
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/config
@@ -0,0 +1,3 @@
+type=driver
+plumed_modules=sizeshape
+arg="--plumed plumed.dat --itrr test_traj.trr"
diff --git a/regtest/sizeshape/rt-sizeshape/deriv.reference b/regtest/sizeshape/rt-sizeshape/deriv.reference
new file mode 100644
index 0000000000..b6e896896b
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/deriv.reference
@@ -0,0 +1,391 @@
+#! FIELDS time parameter ld1
+ 0.000000 0 -0.747
+ 0.000000 1 1.806
+ 0.000000 2 0.181
+ 0.000000 3 -0.521
+ 0.000000 4 0.961
+ 0.000000 5 0.216
+ 0.000000 6 0.976
+ 0.000000 7 -3.388
+ 0.000000 8 -0.749
+ 0.000000 9 -0.276
+ 0.000000 10 -0.621
+ 0.000000 11 -0.502
+ 0.000000 12 -0.191
+ 0.000000 13 1.000
+ 0.000000 14 0.094
+ 0.000000 15 -0.061
+ 0.000000 16 -0.675
+ 0.000000 17 -0.042
+ 0.000000 18 0.213
+ 0.000000 19 -1.567
+ 0.000000 20 -0.747
+ 0.000000 21 -0.166
+ 0.000000 22 -0.023
+ 0.000000 23 -0.045
+ 0.000000 24 -1.457
+ 0.000000 25 4.729
+ 0.000000 26 0.969
+ 0.000000 27 -0.074
+ 0.000000 28 0.093
+ 0.000000 29 -0.142
+ 0.000000 30 -0.143
+ 0.000000 31 -0.891
+ 0.000000 32 -0.319
+ 0.000000 33 -0.299
+ 0.000000 34 0.502
+ 0.000000 35 0.094
+ 0.000000 36 -0.463
+ 0.000000 37 0.642
+ 0.000000 38 0.019
+ 0.000000 39 -0.248
+ 0.000000 40 0.298
+ 0.000000 41 0.036
+ 0.000000 42 1.153
+ 0.000000 43 -4.986
+ 0.000000 44 -1.449
+ 0.000000 45 1.493
+ 0.000000 46 -5.907
+ 0.000000 47 -1.102
+ 0.000000 48 -1.910
+ 0.000000 49 6.659
+ 0.000000 50 1.163
+ 0.000000 51 0.044
+ 0.000000 52 -0.831
+ 0.000000 53 -0.406
+ 0.000000 54 -0.373
+ 0.000000 55 0.760
+ 0.000000 56 0.136
+ 0.000000 57 0.263
+ 0.000000 58 -1.311
+ 0.000000 59 -0.510
+ 0.000000 60 -2.336
+ 0.000000 61 7.304
+ 0.000000 62 1.589
+ 0.000000 63 -0.525
+ 0.000000 64 1.138
+ 0.000000 65 0.051
+ 0.000000 66 1.655
+ 0.000000 67 -6.270
+ 0.000000 68 -1.306
+ 0.000000 69 50.236
+ 0.000000 70 -6.694
+ 0.000000 71 28.810
+ 0.000000 72 111.741
+ 0.000000 73 66.389
+ 0.000000 74 96.952
+ 0.000000 75 101.422
+ 0.000000 76 25.227
+ 0.000000 77 75.637
+ 1.000000 0 -0.775
+ 1.000000 1 1.792
+ 1.000000 2 0.036
+ 1.000000 3 -0.547
+ 1.000000 4 0.974
+ 1.000000 5 0.134
+ 1.000000 6 1.054
+ 1.000000 7 -3.398
+ 1.000000 8 -0.497
+ 1.000000 9 -0.240
+ 1.000000 10 -0.660
+ 1.000000 11 -0.479
+ 1.000000 12 -0.210
+ 1.000000 13 1.006
+ 1.000000 14 0.026
+ 1.000000 15 -0.069
+ 1.000000 16 -0.612
+ 1.000000 17 0.004
+ 1.000000 18 0.278
+ 1.000000 19 -1.623
+ 1.000000 20 -0.643
+ 1.000000 21 -0.177
+ 1.000000 22 0.016
+ 1.000000 23 -0.047
+ 1.000000 24 -1.575
+ 1.000000 25 4.785
+ 1.000000 26 0.618
+ 1.000000 27 -0.028
+ 1.000000 28 -0.050
+ 1.000000 29 -0.167
+ 1.000000 30 -0.116
+ 1.000000 31 -0.910
+ 1.000000 32 -0.275
+ 1.000000 33 -0.449
+ 1.000000 34 0.987
+ 1.000000 35 0.114
+ 1.000000 36 -0.171
+ 1.000000 37 -0.431
+ 1.000000 38 -0.189
+ 1.000000 39 -0.492
+ 1.000000 40 1.143
+ 1.000000 41 0.123
+ 1.000000 42 1.239
+ 1.000000 43 -4.870
+ 1.000000 44 -1.072
+ 1.000000 45 1.793
+ 1.000000 46 -6.522
+ 1.000000 47 -0.753
+ 1.000000 48 -2.172
+ 1.000000 49 7.088
+ 1.000000 50 0.723
+ 1.000000 51 -0.153
+ 1.000000 52 -0.032
+ 1.000000 53 -0.237
+ 1.000000 54 0.064
+ 1.000000 55 -0.799
+ 1.000000 56 -0.130
+ 1.000000 57 -0.046
+ 1.000000 58 -0.131
+ 1.000000 59 -0.264
+ 1.000000 60 -2.385
+ 1.000000 61 6.906
+ 1.000000 62 0.977
+ 1.000000 63 -0.463
+ 1.000000 64 0.855
+ 1.000000 65 -0.080
+ 1.000000 66 1.804
+ 1.000000 67 -6.318
+ 1.000000 68 -0.852
+ 1.000000 69 49.076
+ 1.000000 70 -5.373
+ 1.000000 71 31.440
+ 1.000000 72 106.043
+ 1.000000 73 74.308
+ 1.000000 74 98.783
+ 1.000000 75 98.604
+ 1.000000 76 27.784
+ 1.000000 77 78.844
+ 2.000000 0 -0.705
+ 2.000000 1 1.815
+ 2.000000 2 0.221
+ 2.000000 3 -0.500
+ 2.000000 4 0.970
+ 2.000000 5 0.239
+ 2.000000 6 0.899
+ 2.000000 7 -3.387
+ 2.000000 8 -0.825
+ 2.000000 9 -0.294
+ 2.000000 10 -0.586
+ 2.000000 11 -0.510
+ 2.000000 12 -0.168
+ 2.000000 13 0.998
+ 2.000000 14 0.115
+ 2.000000 15 -0.070
+ 2.000000 16 -0.703
+ 2.000000 17 -0.064
+ 2.000000 18 0.192
+ 2.000000 19 -1.613
+ 2.000000 20 -0.797
+ 2.000000 21 -0.177
+ 2.000000 22 0.021
+ 2.000000 23 -0.035
+ 2.000000 24 -1.354
+ 2.000000 25 4.748
+ 2.000000 26 1.078
+ 2.000000 27 -0.050
+ 2.000000 28 0.015
+ 2.000000 29 -0.161
+ 2.000000 30 -0.188
+ 2.000000 31 -0.779
+ 2.000000 32 -0.313
+ 2.000000 33 -0.272
+ 2.000000 34 0.420
+ 2.000000 35 0.087
+ 2.000000 36 -0.539
+ 2.000000 37 1.069
+ 2.000000 38 0.131
+ 2.000000 39 -0.168
+ 2.000000 40 -0.035
+ 2.000000 41 -0.036
+ 2.000000 42 1.024
+ 2.000000 43 -4.917
+ 2.000000 44 -1.545
+ 2.000000 45 1.354
+ 2.000000 46 -5.859
+ 2.000000 47 -1.225
+ 2.000000 48 -1.775
+ 2.000000 49 6.708
+ 2.000000 50 1.324
+ 2.000000 51 0.134
+ 2.000000 52 -1.305
+ 2.000000 53 -0.539
+ 2.000000 54 -0.323
+ 2.000000 55 0.704
+ 2.000000 56 0.127
+ 2.000000 57 0.189
+ 2.000000 58 -1.181
+ 2.000000 59 -0.499
+ 2.000000 60 -2.209
+ 2.000000 61 7.488
+ 2.000000 62 1.793
+ 2.000000 63 -0.513
+ 2.000000 64 1.217
+ 2.000000 65 0.093
+ 2.000000 66 1.506
+ 2.000000 67 -6.235
+ 2.000000 68 -1.437
+ 2.000000 69 49.950
+ 2.000000 70 -7.018
+ 2.000000 71 29.008
+ 2.000000 72 113.611
+ 2.000000 73 60.279
+ 2.000000 74 97.937
+ 2.000000 75 102.101
+ 2.000000 76 22.165
+ 2.000000 77 76.321
+ 3.000000 0 -0.619
+ 3.000000 1 1.869
+ 3.000000 2 0.035
+ 3.000000 3 -0.453
+ 3.000000 4 1.001
+ 3.000000 5 0.132
+ 3.000000 6 0.749
+ 3.000000 7 -3.503
+ 3.000000 8 -0.488
+ 3.000000 9 -0.294
+ 3.000000 10 -0.685
+ 3.000000 11 -0.475
+ 3.000000 12 -0.122
+ 3.000000 13 1.025
+ 3.000000 14 0.021
+ 3.000000 15 -0.131
+ 3.000000 16 -0.576
+ 3.000000 17 0.013
+ 3.000000 18 0.082
+ 3.000000 19 -1.454
+ 3.000000 20 -0.611
+ 3.000000 21 -0.141
+ 3.000000 22 -0.127
+ 3.000000 23 -0.064
+ 3.000000 24 -1.128
+ 3.000000 25 4.851
+ 3.000000 26 0.596
+ 3.000000 27 -0.110
+ 3.000000 28 0.321
+ 3.000000 29 -0.123
+ 3.000000 30 -0.135
+ 3.000000 31 -1.194
+ 3.000000 32 -0.300
+ 3.000000 33 -0.333
+ 3.000000 34 0.817
+ 3.000000 35 0.090
+ 3.000000 36 -0.117
+ 3.000000 37 -0.639
+ 3.000000 38 -0.213
+ 3.000000 39 -0.467
+ 3.000000 40 1.377
+ 3.000000 41 0.147
+ 3.000000 42 0.858
+ 3.000000 43 -5.307
+ 3.000000 44 -1.090
+ 3.000000 45 1.140
+ 3.000000 46 -6.267
+ 3.000000 47 -0.683
+ 3.000000 48 -1.440
+ 3.000000 49 6.772
+ 3.000000 50 0.642
+ 3.000000 51 -0.337
+ 3.000000 52 0.624
+ 3.000000 53 -0.155
+ 3.000000 54 -0.308
+ 3.000000 55 0.848
+ 3.000000 56 0.064
+ 3.000000 57 0.223
+ 3.000000 58 -1.629
+ 3.000000 59 -0.435
+ 3.000000 60 -1.719
+ 3.000000 61 7.007
+ 3.000000 62 0.944
+ 3.000000 63 -0.389
+ 3.000000 64 0.950
+ 3.000000 65 -0.074
+ 3.000000 66 1.253
+ 3.000000 67 -6.564
+ 3.000000 68 -0.839
+ 3.000000 69 47.697
+ 3.000000 70 -4.767
+ 3.000000 71 31.173
+ 3.000000 72 113.561
+ 3.000000 73 65.919
+ 3.000000 74 96.862
+ 3.000000 75 102.521
+ 3.000000 76 19.515
+ 3.000000 77 77.509
+ 4.000000 0 -0.873
+ 4.000000 1 1.741
+ 4.000000 2 -0.004
+ 4.000000 3 -0.614
+ 4.000000 4 0.945
+ 4.000000 5 0.102
+ 4.000000 6 1.283
+ 4.000000 7 -3.315
+ 4.000000 8 -0.459
+ 4.000000 9 -0.162
+ 4.000000 10 -0.648
+ 4.000000 11 -0.509
+ 4.000000 12 -0.267
+ 4.000000 13 0.990
+ 4.000000 14 0.025
+ 4.000000 15 -0.032
+ 4.000000 16 -0.622
+ 4.000000 17 -0.015
+ 4.000000 18 0.449
+ 4.000000 19 -1.645
+ 4.000000 20 -0.652
+ 4.000000 21 -0.190
+ 4.000000 22 0.053
+ 4.000000 23 -0.057
+ 4.000000 24 -1.901
+ 4.000000 25 4.692
+ 4.000000 26 0.560
+ 4.000000 27 0.031
+ 4.000000 28 -0.154
+ 4.000000 29 -0.185
+ 4.000000 30 -0.070
+ 4.000000 31 -0.823
+ 4.000000 32 -0.289
+ 4.000000 33 -0.541
+ 4.000000 34 1.018
+ 4.000000 35 0.098
+ 4.000000 36 -0.137
+ 4.000000 37 -0.372
+ 4.000000 38 -0.203
+ 4.000000 39 -0.556
+ 4.000000 40 1.057
+ 4.000000 41 0.090
+ 4.000000 42 1.568
+ 4.000000 43 -4.670
+ 4.000000 44 -1.028
+ 4.000000 45 2.270
+ 4.000000 46 -6.508
+ 4.000000 47 -0.721
+ 4.000000 48 -2.684
+ 4.000000 49 7.080
+ 4.000000 50 0.671
+ 4.000000 51 -0.071
+ 4.000000 52 -0.219
+ 4.000000 53 -0.277
+ 4.000000 54 0.316
+ 4.000000 55 -1.269
+ 4.000000 56 -0.208
+ 4.000000 57 -0.190
+ 4.000000 58 0.308
+ 4.000000 59 -0.206
+ 4.000000 60 -2.854
+ 4.000000 61 6.764
+ 4.000000 62 0.883
+ 4.000000 63 -0.492
+ 4.000000 64 0.812
+ 4.000000 65 -0.109
+ 4.000000 66 2.219
+ 4.000000 67 -6.157
+ 4.000000 68 -0.793
+ 4.000000 69 47.095
+ 4.000000 70 -6.360
+ 4.000000 71 35.143
+ 4.000000 72 93.172
+ 4.000000 73 75.817
+ 4.000000 74 109.531
+ 4.000000 75 89.571
+ 4.000000 76 30.716
+ 4.000000 77 88.099
diff --git a/regtest/sizeshape/rt-sizeshape/global_avg.txt b/regtest/sizeshape/rt-sizeshape/global_avg.txt
new file mode 100644
index 0000000000..3fe06fc8dd
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/global_avg.txt
@@ -0,0 +1,23 @@
+4.265825962982551012e+00 2.336690414907679203e-01 3.662809312682036023e+00
+4.214057267340745483e+00 1.072049513718947578e-01 4.314804999781733486e+00
+3.671228981308725103e+00 1.274792340073149510e-01 3.977231205572313577e+00
+2.343698812761148886e+00 -2.841411661146072132e-01 3.478414401687389024e+00
+1.686436487941495699e+00 -8.665088225218358087e-01 4.100811861077803044e+00
+4.360230108844224128e-01 -1.347015411672896512e+00 3.844097514796287030e+00
+3.117457174800847969e-02 -1.024227536411313366e+00 2.585940217022081988e+00
+6.808808862178362675e-01 -5.870202775664047357e-01 2.290245252111865248e+00
+4.586351396567848737e-01 -2.433497671270518359e-01 1.192357902655695634e+00
+4.931328549364416558e-01 2.515992483355074527e-01 2.956934483804412803e-02
+1.406321673638208702e+00 6.682431861735423917e-01 7.908513055476143472e-02
+1.646908036369386430e+00 1.186975749838515615e+00 -8.956858825186609918e-01
+5.912530303131902087e-01 8.617407774506029572e-01 -1.344660953846545715e+00
+8.530666038486142688e-02 2.536604398394486926e-01 -4.506541385680229994e-01
+-8.727821507437001358e-01 -1.296438909175296195e-01 -6.398328611456164383e-01
+-2.067478377458112249e+00 -3.906550201962756819e-01 -1.401863559473397691e+00
+-2.408455843196946056e+00 -6.754022773093291132e-01 -1.106090740276666429e+00
+-3.499742687863982127e+00 -9.747491888605476218e-01 -1.653484266030961436e+00
+-3.548593077032900389e+00 -4.204563480815317056e-01 -3.070014906890367268e+00
+-2.499045339091049645e+00 2.342840846507300567e-01 -3.442979964675248805e+00
+-2.331926055743990922e+00 8.142912721692037170e-01 -4.695739761431558357e+00
+-2.568879301577981611e+00 1.091951813009595762e+00 -5.625053366993444826e+00
+-2.213980543775061705e+00 1.112069908442180788e+00 -5.229306740929514419e+00
diff --git a/regtest/sizeshape/rt-sizeshape/global_precision.txt b/regtest/sizeshape/rt-sizeshape/global_precision.txt
new file mode 100644
index 0000000000..6cd0c4b4ec
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/global_precision.txt
@@ -0,0 +1,23 @@
+1.341060592612849689e+01 -2.432209892648744542e+01 1.533381940780554942e+01 -7.657303908462504083e+00 1.776037152155568455e+00 4.338540983771763671e+00 -3.609963145053606937e+00 2.810411955027056319e+00 -1.043671268084174208e+00 -1.475196332213428052e+00 5.759621172324607130e-01 -8.527089597052168735e-01 9.644241803601940610e-01 -7.723571031369950157e-01 -9.902209008702838045e-01 1.137035356431496114e+00 -7.992059372693161023e-01 -2.078782440990323555e-01 3.883776323509380735e+00 -3.312986073939271581e+00 3.260580287172311076e-01 -2.407079734553001227e-01 7.276273416339069655e-01
+-2.432209892648744542e+01 5.224657127170035409e+01 -4.184495643299391787e+01 2.691929890881726450e+01 -1.133485157950145350e+01 -4.581368136551017045e+00 5.418668441607914055e+00 -4.721462749988712737e+00 7.612938084579194686e-02 3.416864986007456029e+00 -1.915387904627712246e+00 1.300900115134859814e+00 -9.304157403410605598e-01 6.940752221505136488e-01 1.446934261540284483e+00 -1.833895730955714232e+00 1.069137481710279447e+00 7.471315977387903429e-01 -5.206532972119772396e+00 4.646086172638097977e+00 -9.512588298321154046e-01 4.764495021104730443e-01 -8.160183386215708046e-01
+1.533381940780554942e+01 -4.184495643299391787e+01 1.006909570680676609e+02 -9.001875555992035061e+01 -3.451475916336282523e+01 4.163490105870881308e+01 1.599032505888508560e+01 -1.109541021072212708e+01 5.753834304617886808e+00 -5.207568591756271958e-01 -4.504124622286217239e+00 4.467889138659089987e+00 -1.979451375310257388e+00 1.428207880391368700e+00 2.455983409910902082e-01 -3.661844077828322330e-01 1.301366752271428284e+00 1.865718345450012861e-01 -5.661336629183209013e+00 4.110320821833330029e+00 -4.436445385268852210e-02 -9.273163347354730357e-01 3.336243824700811378e-01
+-7.657303908462504083e+00 2.691929890881726450e+01 -9.001875555992035061e+01 1.219943530037234609e+02 -1.755683353726008988e+01 -1.486034955695616766e+01 -3.364530734833785885e+01 1.815403977068739394e+01 5.330083239917091653e+00 -5.787673063672293949e+00 8.949916505352897289e+00 -1.337407792820569874e+01 5.626279540052188999e+00 -3.353587794831017099e+00 -1.939256656091284045e-02 2.049939558614113921e-02 1.365089261756972094e+00 -8.149336646290846531e+00 -1.593034705295243825e+00 2.922427496009236236e+00 2.418471544653607364e+00 1.735086438573440581e+00 5.801075102971581243e-01
+1.776037152155568455e+00 -1.133485157950145350e+01 -3.451475916336282523e+01 -1.755683353726008988e+01 1.576310085514577395e+02 -1.169557595696256698e+02 4.104142155819025817e+01 -1.993810599591465405e+01 -9.199632220440848940e+00 5.609782974523333188e+00 -8.606957001656226902e-01 4.352603470334472924e+00 2.000397845332385627e-01 -2.935281317572900339e-01 6.386731800524242386e-01 -5.216545146993613047e-01 -9.531848586959631997e-02 1.488251394396544747e+00 -4.845847551417503118e-01 8.827391178444837783e-01 -2.003420141528640397e-01 -1.571162986767073333e+00 -9.332852800342261723e-02
+4.338540983771763671e+00 -4.581368136551017045e+00 4.163490105870881308e+01 -1.486034955695616766e+01 -1.169557595696256698e+02 1.788850067984545547e+02 -1.161726175113718540e+02 -1.824155088149085913e+01 3.722951336234645225e+01 1.822089554504272613e+01 -1.822518186211086544e+01 2.062249842740017414e+01 -2.513081540730243901e+01 1.287044852717752264e+01 5.701441320158269654e+00 -1.053843438992904424e+01 4.429603780088037013e+00 2.474040595293856626e+01 -1.978639881137895529e+01 1.263968084842567130e+01 -1.061985799126625452e+01 -5.387113217480632876e+00 -8.134892698422866442e-01
+-3.609963145053606937e+00 5.418668441607914055e+00 1.599032505888508560e+01 -3.364530734833785885e+01 4.104142155819025817e+01 -1.161726175113718540e+02 1.694295840575620389e+02 -5.437639055615947115e+01 2.623850990846575915e+00 -3.516723107832262230e+01 1.435451051172955950e+01 3.222162989559810842e-01 -1.842212594999670827e+01 2.189731127507590713e+01 -1.902181569285956542e+01 3.228461102714651698e+00 -4.863952497098324557e+00 2.030310554237381027e+01 2.060639289458460510e+01 -1.956583996346799736e+01 -6.462280445941964935e+00 -1.842331321362554952e+00 -2.065992221782699811e+00
+2.810411955027056319e+00 -4.721462749988712737e+00 -1.109541021072212708e+01 1.815403977068739394e+01 -1.993810599591465405e+01 -1.824155088149085913e+01 -5.437639055615947115e+01 2.012346773701846985e+02 -1.433541271828811432e+02 4.653186371227659635e+01 -1.956748341724615514e+01 -1.634725695145779811e+00 8.039707591790719476e+00 -3.267442313649244756e+00 8.227736047692134846e+00 -3.724004024363516852e+00 5.781830775284857893e+00 -9.284359805331549254e+00 -2.654749576699840574e+01 2.268517800068569201e+01 1.861784076616177952e+00 -1.086057555055923052e+00 1.511386856157765468e+00
+-1.043671268084174208e+00 7.612938084579194686e-02 5.753834304617886808e+00 5.330083239917091653e+00 -9.199632220440848940e+00 3.722951336234645225e+01 2.623850990846575915e+00 -1.433541271828811432e+02 1.996795924035413066e+02 -1.309616133199795343e+02 -1.259115312344027870e+01 4.068068951966531444e+01 8.652590509943264507e+00 -7.261756692588662077e+00 1.155589151733675202e+01 -3.228134443858557301e+00 -4.085784906015216933e+00 5.498844145142581574e+00 -1.472529623873179538e+01 1.212553585632562303e+01 -2.619725312876233669e+00 6.554258795806483517e-01 -7.910864037361950984e-01
+-1.475196332213428052e+00 3.416864986007456029e+00 -5.207568591756271958e-01 -5.787673063672293949e+00 5.609782974523333188e+00 1.822089554504272613e+01 -3.516723107832262230e+01 4.653186371227659635e+01 -1.309616133199795343e+02 2.050231620923374862e+02 -7.832272719934573502e+01 -1.766817048680164248e+01 -2.523801962490263406e+01 5.604515342927428811e+00 -2.903829488250302848e+00 1.337127124864552741e+01 -9.018253000914876694e+00 -4.537565087179325829e+00 7.267839671918275712e+01 -6.048117285047313629e+01 8.332814408542049689e-01 2.913611038688055821e+00 -2.121436706560488439e+00
+5.759621172324607130e-01 -1.915387904627712246e+00 -4.504124622286217239e+00 8.949916505352897289e+00 -8.606957001656226902e-01 -1.822518186211086544e+01 1.435451051172955950e+01 -1.956748341724615514e+01 -1.259115312344027870e+01 -7.832272719934573502e+01 2.255353366533649933e+02 -1.439515471076909705e+02 7.531020566839718811e+01 -4.167059763260684946e+01 -3.788221335436109616e+00 6.749467480930080754e+00 4.450810630543437618e+00 -3.510936740882865337e+01 -2.067928130108034779e+01 2.200436634778799672e+01 1.435784250738115198e+01 5.897940047881299996e+00 2.999410141876153624e+00
+-8.527089597052168735e-01 1.300900115134859814e+00 4.467889138659089987e+00 -1.337407792820569874e+01 4.352603470334472924e+00 2.062249842740017414e+01 3.222162989559810842e-01 -1.634725695145779811e+00 4.068068951966531444e+01 -1.766817048680164248e+01 -1.439515471076909705e+02 2.620094439724968538e+02 -2.689027245307896692e+02 1.016191451925127325e+02 4.640171585384572950e+01 -4.830056188387580818e+01 2.830546078080061889e+01 1.267562362513533429e+02 -1.748406454372760663e+02 1.236547165154022565e+02 -5.288020624787915125e+01 -3.703333668761484176e+01 -1.054810568719527941e+00
+9.644241803601940610e-01 -9.304157403410605598e-01 -1.979451375310257388e+00 5.626279540052188999e+00 2.000397845332385627e-01 -2.513081540730243901e+01 -1.842212594999670827e+01 8.039707591790719476e+00 8.652590509943264507e+00 -2.523801962490263406e+01 7.531020566839718811e+01 -2.689027245307896692e+02 5.839023592146512556e+02 -3.894294442433576364e+02 -9.173356538671294302e+00 1.081568782887882350e+02 -6.181982179848619552e+01 -3.444185111762555493e+02 3.311311821450776165e+02 -2.214088698492690810e+02 1.412525470264524756e+02 8.807560198206526536e+01 1.554174029562684467e+01
+-7.723571031369950157e-01 6.940752221505136488e-01 1.428207880391368700e+00 -3.353587794831017099e+00 -2.935281317572900339e-01 1.287044852717752264e+01 2.189731127507590713e+01 -3.267442313649244756e+00 -7.261756692588662077e+00 5.604515342927428811e+00 -4.167059763260684946e+01 1.016191451925127325e+02 -3.894294442433576364e+02 4.755931108838578325e+02 -1.425057023424922704e+02 -5.886350932625035881e+01 3.452077327022928444e+01 2.741529622474283201e+02 -2.596681594940621380e+02 1.811159982832207618e+02 -1.209752078734303211e+02 -6.791623844252907816e+01 -1.351901672842707747e+01
+-9.902209008702838045e-01 1.446934261540284483e+00 2.455983409910902082e-01 -1.939256656091284045e-02 6.386731800524242386e-01 5.701441320158269654e+00 -1.902181569285956542e+01 8.227736047692134846e+00 1.155589151733675202e+01 -2.903829488250302848e+00 -3.788221335436109616e+00 4.640171585384572950e+01 -9.173356538671294302e+00 -1.425057023424922704e+02 2.400794701823535888e+02 -1.792956792626917490e+02 3.138582984045448754e+01 2.515489335475258414e+01 -6.417006226891290055e+01 5.501930999130374289e+01 2.834210966776290253e+00 -5.661727157052321324e+00 -1.161697304761181604e+00
+1.137035356431496114e+00 -1.833895730955714232e+00 -3.661844077828322330e-01 2.049939558614113921e-02 -5.216545146993613047e-01 -1.053843438992904424e+01 3.228461102714651698e+00 -3.724004024363516852e+00 -3.228134443858557301e+00 1.337127124864552741e+01 6.749467480930080754e+00 -4.830056188387580818e+01 1.081568782887882350e+02 -5.886350932625035881e+01 -1.792956792626917490e+02 2.983596837029729727e+02 -1.505787385408951025e+02 -1.007539282739960811e+02 1.817399408509938894e+02 -1.524500322663519967e+02 6.872035320031325512e+01 3.215537051004270808e+01 -3.184204072141046726e+00
+-7.992059372693161023e-01 1.069137481710279447e+00 1.301366752271428284e+00 1.365089261756972094e+00 -9.531848586959631997e-02 4.429603780088037013e+00 -4.863952497098324557e+00 5.781830775284857893e+00 -4.085784906015216933e+00 -9.018253000914876694e+00 4.450810630543437618e+00 2.830546078080061889e+01 -6.181982179848619552e+01 3.452077327022928444e+01 3.138582984045448754e+01 -1.505787385408951025e+02 2.834361801812467547e+02 -1.103742556523487934e+02 -1.133915422380968607e+02 1.084268925701416748e+02 -3.713437396884358321e+01 -1.732989764142075018e+01 5.018169342462520000e+00
+-2.078782440990323555e-01 7.471315977387903429e-01 1.865718345450012861e-01 -8.149336646290846531e+00 1.488251394396544747e+00 2.474040595293856626e+01 2.030310554237381027e+01 -9.284359805331549254e+00 5.498844145142581574e+00 -4.537565087179325829e+00 -3.510936740882865337e+01 1.267562362513533429e+02 -3.444185111762555493e+02 2.741529622474283201e+02 2.515489335475258414e+01 -1.007539282739960811e+02 -1.103742556523487934e+02 5.533027818891989682e+02 -3.612519277674758769e+02 1.456607310201988810e+02 -1.200889435095781153e+02 -6.822817263798721399e+01 -1.558766901584039388e+01
+3.883776323509380735e+00 -5.206532972119772396e+00 -5.661336629183209013e+00 -1.593034705295243825e+00 -4.845847551417503118e-01 -1.978639881137895529e+01 2.060639289458460510e+01 -2.654749576699840574e+01 -1.472529623873179538e+01 7.267839671918275712e+01 -2.067928130108034779e+01 -1.748406454372760663e+02 3.311311821450776165e+02 -2.596681594940621380e+02 -6.417006226891290055e+01 1.817399408509938894e+02 -1.133915422380968607e+02 -3.612519277674758769e+02 8.227661540145846857e+02 -5.889251881384034277e+02 1.505009903985806829e+02 7.459360068624346241e+01 -9.689475113469024903e-01
+-3.312986073939271581e+00 4.646086172638097977e+00 4.110320821833330029e+00 2.922427496009236236e+00 8.827391178444837783e-01 1.263968084842567130e+01 -1.956583996346799736e+01 2.268517800068569201e+01 1.212553585632562303e+01 -6.048117285047313629e+01 2.200436634778799672e+01 1.236547165154022565e+02 -2.214088698492690810e+02 1.811159982832207618e+02 5.501930999130374289e+01 -1.524500322663519967e+02 1.084268925701416748e+02 1.456607310201988810e+02 -5.889251881384034277e+02 6.281297406866601705e+02 -2.360284378048359315e+02 -3.788478747503720001e+01 -3.966409304890950338e+00
+3.260580287172311076e-01 -9.512588298321154046e-01 -4.436445385268852210e-02 2.418471544653607364e+00 -2.003420141528640397e-01 -1.061985799126625452e+01 -6.462280445941964935e+00 1.861784076616177952e+00 -2.619725312876233669e+00 8.332814408542049689e-01 1.435784250738115198e+01 -5.288020624787915125e+01 1.412525470264524756e+02 -1.209752078734303211e+02 2.834210966776290253e+00 6.872035320031325512e+01 -3.713437396884358321e+01 -1.200889435095781153e+02 1.505009903985806829e+02 -2.360284378048359315e+02 1.984952390410417138e+02 -1.726639859088383133e+01 2.367061880986858213e+01
+-2.407079734553001227e-01 4.764495021104730443e-01 -9.273163347354730357e-01 1.735086438573440581e+00 -1.571162986767073333e+00 -5.387113217480632876e+00 -1.842331321362554952e+00 -1.086057555055923052e+00 6.554258795806483517e-01 2.913611038688055821e+00 5.897940047881299996e+00 -3.703333668761484176e+01 8.807560198206526536e+01 -6.791623844252907816e+01 -5.661727157052321324e+00 3.215537051004270808e+01 -1.732989764142075018e+01 -6.822817263798721399e+01 7.459360068624346241e+01 -3.788478747503720001e+01 -1.726639859088383133e+01 8.664655681400094522e+01 -3.077439487873002122e+01
+7.276273416339069655e-01 -8.160183386215708046e-01 3.336243824700811378e-01 5.801075102971581243e-01 -9.332852800342261723e-02 -8.134892698422866442e-01 -2.065992221782699811e+00 1.511386856157765468e+00 -7.910864037361950984e-01 -2.121436706560488439e+00 2.999410141876153624e+00 -1.054810568719527941e+00 1.554174029562684467e+01 -1.351901672842707747e+01 -1.161697304761181604e+00 -3.184204072141046726e+00 5.018169342462520000e+00 -1.558766901584039388e+01 -9.689475113469024903e-01 -3.966409304890950338e+00 2.367061880986858213e+01 -3.077439487873002122e+01 2.653581617274004500e+01
diff --git a/regtest/sizeshape/rt-sizeshape/ld1_scalings.txt b/regtest/sizeshape/rt-sizeshape/ld1_scalings.txt
new file mode 100644
index 0000000000..0d6d305798
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/ld1_scalings.txt
@@ -0,0 +1,69 @@
+-1.008123761803866980e+00
+1.626510375189665680e+00
+4.491793750288705644e-01
+-6.586147643691930842e-01
+8.235017815364878979e-01
+3.478980458875061688e-01
+1.481264411141690829e+00
+-3.038312014911420000e+00
+-1.267599717071444143e+00
+-1.585188804951326025e-01
+-5.817395001067517946e-01
+-6.260861234524053298e-01
+-3.387375174876071648e-01
+9.372083330539093815e-01
+2.554555712335253581e-01
+2.167666577399882111e-02
+-6.051555596404274429e-01
+-1.380047808122754072e-01
+4.218768793816384255e-01
+-1.281803232189904440e+00
+-9.491404066182579369e-01
+-1.339507084104512580e-01
+-8.935651980303346842e-02
+-8.508449794582281789e-02
+-2.148524234383437648e+00
+4.226170448258242729e+00
+1.677729266602153713e+00
+-1.357153299731779228e-01
+2.085836564032336471e-01
+-7.003628642152187611e-02
+5.765462050962143897e-02
+-9.802581922121870184e-01
+-5.445968486733449021e-01
+-4.132029558223072052e-01
+6.261097028889341942e-01
+2.257791572712143091e-01
+-3.200628724867338182e-01
+-2.087169662443416895e-01
+-1.977133624004201451e-01
+-4.769408025188121014e-01
+8.678530538596880284e-01
+3.176011660686111626e-01
+1.944520543315805039e+00
+-4.508400989736514042e+00
+-2.258083990712280276e+00
+2.386745619994993017e+00
+-5.518894174386804963e+00
+-2.056655748999836497e+00
+-2.860416065666450347e+00
+6.025099475452838860e+00
+2.158730933826262799e+00
+-1.008140655250909096e-01
+9.449132130777106175e-02
+-1.921879735818581014e-01
+-5.517552129726168708e-01
+5.344767556698636346e-01
+2.778728406758145253e-01
+5.657267029451286122e-01
+-1.164396506907206197e+00
+-7.932515522656270468e-01
+-3.322057545545195278e+00
+6.199518797075218579e+00
+2.565033662356621669e+00
+-6.500590254132574408e-01
+8.874930491073512728e-01
+1.671230651011225421e-01
+2.608378228283110278e+00
+-5.709980861399765573e+00
+-2.296414790623169999e+00
diff --git a/regtest/sizeshape/rt-sizeshape/plumed.dat b/regtest/sizeshape/rt-sizeshape/plumed.dat
new file mode 100644
index 0000000000..635da1dcf8
--- /dev/null
+++ b/regtest/sizeshape/rt-sizeshape/plumed.dat
@@ -0,0 +1,14 @@
+# units
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+
+# make a group of atoms
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+
+# ld1
+ld1: SIZESHAPE_POSITION_LINEAR_PROJ REFERENCE=global_avg.txt PRECISION=global_precision.txt COEFFS=ld1_scalings.txt GROUP=ga_list
+
+#print
+PRINT ARG=ld1 STRIDE=1 FILE=COLVAR FMT=%8.8f
+
+# dump derivatives
+DUMPDERIVATIVES ARG=ld1 STRIDE=1 FILE=deriv FMT=%8.3f
diff --git a/regtest/sizeshape/rt-sizeshape/test_traj.trr b/regtest/sizeshape/rt-sizeshape/test_traj.trr
new file mode 100644
index 0000000000..6698336cbe
Binary files /dev/null and b/regtest/sizeshape/rt-sizeshape/test_traj.trr differ
diff --git a/src/sizeshape/COPYRIGHT b/src/sizeshape/COPYRIGHT
new file mode 100644
index 0000000000..c748bf6906
--- /dev/null
+++ b/src/sizeshape/COPYRIGHT
@@ -0,0 +1,14 @@
+Copyright (c) 2024 by Glen Hocky, New York University on behalf of authors
+
+The sizeshape module 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.
+
+The sizeshape module 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 .
diff --git a/src/sizeshape/Makefile b/src/sizeshape/Makefile
new file mode 100644
index 0000000000..d9e15607a6
--- /dev/null
+++ b/src/sizeshape/Makefile
@@ -0,0 +1,3 @@
+USE=core tools colvar
+# generic makefile
+include ../maketools/make.module
diff --git a/src/sizeshape/mahadist.cpp b/src/sizeshape/mahadist.cpp
new file mode 100644
index 0000000000..550fcf1474
--- /dev/null
+++ b/src/sizeshape/mahadist.cpp
@@ -0,0 +1,448 @@
+/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Copyright (c) 2024 by Glen Hocky, New York University on behalf of authors
+
+The sizeshape module 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.
+
+The sizeshape module 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 .
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "colvar/Colvar.h"
+#include "core/ActionRegister.h"
+#include "tools/Pbc.h"
+#include "tools/File.h" // Input and output from files
+#include "tools/Matrix.h" // Linear Algebra operations
+#include
+#include
+
+namespace PLMD {
+namespace sizeshape {
+
+//+PLUMEDOC sizeshapeMOD_COLVAR SIZESHAPE_POSITION_MAHA_DIST
+/*
+Calculates Mahalanobis distance of a current configuration from a given reference configurational distribution in size-and-shape space.
+
+The Mahalanobis distance is given as:
+
+\f[
+d(\mathbf{x}, \mathbf{\mu}, \mathbf{\Sigma}) = \sqrt{(\mathbf{x}-\mathbf{\mu})^T \mathbf{\Sigma}^{-1} (\mathbf{x}-\mathbf{\mu})}
+\f]
+
+Here \f$\mathbf{x}\f$ is the configuration at time t, \f$\mathbf{\mu}\f$ is the reference and \f$\mathbf{\Sigma}^{-1}\f$ is the \f$N \times N\f$ precision matrix.
+
+Size-and-shape Gaussian Mixture Model (shapeGMM) \cite Heidi-shapeGMM-2022 is a probabilistic clustering technique that is used to perform structural clusteing on ensemble of molecular configurations and to obtain reference \f$(\mathbf{\mu})\f$ and precision \f$(\mathbf{\Sigma}^{-1})\f$ corresponding to each of the cluster centers. Please chcek out shapeGMMTorch-GitHub and shapeGMMTorch-PyPI for examples and informations on preforming shapeGMM clustering.
+
+\par Examples
+In the following example, a group is defined with atom indices of selected atoms and then Mahalanobis distance is calculated with respect to the given reference and precision. Each file is a space separated list of 3N floating point numbers.
+
+\plumedfile
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+#SETTINGS AUXFILE=regtest/sizeshape/rt-mahadist/global_avg.txt
+#SETTINGS AUXFILE=regtest/sizeshape/rt-mahadist/global_precision.txt
+d: SIZESHAPE_POSITION_MAHA_DIST REFERENCE=global_avg.txt PRECISION=global_precision.txt GROUP=ga_list
+PRINT ARG=d STRIDE=1 FILE=output FMT=%8.8f
+\endplumedfile
+
+*/
+//+ENDPLUMEDOC
+
+class position_maha_dist : public Colvar {
+
+private:
+ bool pbc, squared;
+ std::string prec_f_name; // precision file name
+ std::string ref_f_name; // reference file name
+ IFile in_; // create an object of class IFile
+ //Log out_;
+ Matrix ref_str; // coords of reference
+ Matrix mobile_str; // coords of mobile
+ Matrix prec; // precision data
+ Matrix rotation;
+ Matrix derv_;
+ Matrix derv_numeric;
+ void readinputs(); // reads the input data
+ double dist;
+ std::vector atom_list; // list of atoms
+ const double SMALL = 1.0E-30;
+ const double delta = 0.00001;
+public:
+ static void registerKeywords( Keywords& keys );
+ explicit position_maha_dist(const ActionOptions&);
+ double determinant(int n, const std::vector>* B);
+ void kabsch_rot_mat(); // gives rotation matrix
+ double cal_maha_dist(); // calculates the mahalanobis distance
+ void grad_maha(double); // calculates the gradient
+ void numeric_maha(); // calculates the numeric gradient
+ // active methods:
+ void calculate() override;
+};
+
+PLUMED_REGISTER_ACTION(position_maha_dist,"SIZESHAPE_POSITION_MAHA_DIST")
+
+void position_maha_dist::registerKeywords( Keywords& keys ) {
+ Colvar::registerKeywords( keys );
+ keys.add("compulsory", "PRECISION", "Precision Matrix (inverse of covariance)" );
+ keys.add("compulsory", "REFERENCE", "Reference structure.");
+ keys.add("atoms","GROUP","The group of atoms being used");
+ keys.addFlag("SQUARED",false,"Returns the square of distance.");
+}
+
+// constructor function
+position_maha_dist::position_maha_dist(const ActionOptions&ao):
+ PLUMED_COLVAR_INIT(ao),
+ pbc(true),
+ squared(false),
+ dist(0),
+ prec_f_name(""),
+ ref_f_name("") // Note! no comma here in the last line.
+{
+ parseAtomList("GROUP",atom_list);
+ parse("REFERENCE", ref_f_name);
+ parse("PRECISION", prec_f_name);
+
+ bool nopbc=!pbc;
+ parseFlag("NOPBC",nopbc);
+ parseFlag("SQUARED",squared);
+ pbc=!nopbc;
+
+ checkRead();
+
+ log.printf(" of %u atoms\n",static_cast(atom_list.size()));
+ for(unsigned int i=0; i items_;
+ std::stringstream check_(line_);
+
+ while(std::getline(check_, val_, ' ')) { items_.push_back(val_); }
+ for(int i=0; i<3; ++i) { ref_str(c_,i) = std::stold(items_[i]); }
+ c_ += 1;
+ }
+ in_.close();
+
+ //read precision
+ in_.open(prec_f_name);
+
+ std::string line, val;
+ unsigned int c = 0;
+
+ while(c < N)
+ {
+ in_.getline(line);
+
+ // vector for storing the objects
+ std::vector items;
+
+ // stringstream helps to treat a string like an ifstream!
+ std::stringstream check(line);
+
+ while (std::getline(check, val, ' '))
+ {
+ items.push_back(val);
+ }
+
+ for(unsigned int i=0; i>* B)
+{
+
+ std::vector> A(n, std::vector(n, 0));
+ // make a copy first!
+ for(int i=0; i maxA )
+ {
+ r = k;
+ maxA = val;
+ }
+ }
+ if ( r != i )
+ {
+ for ( int j = i; j < n; j++ ) std::swap( A[i][j], A[r][j] );
+ det = -det;
+ }
+
+ // Row operations to make upper-triangular
+ double pivot = A[i][i];
+ if (std::abs( pivot ) < SMALL ) return 0.0; // Singular matrix
+
+ for ( int r = i + 1; r < n; r++ ) // On lower rows
+ {
+ double multiple = A[r][i] / pivot; // Multiple of row i to clear element in ith column
+ for ( int j = i; j < n; j++ ) A[r][j] -= multiple * A[i][j];
+ }
+ det *= pivot; // Determinant is product of diagonal
+ }
+
+ det *= A[n-1][n-1];
+
+ return det;
+}
+
+// kabsch rotation
+void position_maha_dist::kabsch_rot_mat() {
+
+ unsigned N=getNumberOfAtoms();
+
+ Matrix mobile_str_T(3,N);
+ Matrix prec_dot_ref_str(N,3);
+ Matrix correlation(3,3);
+
+
+ transpose(mobile_str, mobile_str_T);
+ mult(prec, ref_str, prec_dot_ref_str);
+ mult(mobile_str_T, prec_dot_ref_str, correlation);
+
+
+ int rw = correlation.nrows();
+ int cl = correlation.ncols();
+ int sz = rw*cl;
+
+ // SVD part (taking from plu2/src/tools/Matrix.h: pseudoInvert function)
+
+ std::vector da(sz);
+ unsigned k=0;
+
+ // Transfer the matrix to the local array
+ for (int i=0; i( correlation(j,i) ); // note! its [j][i] not [i][j]
+
+ int nsv, info, nrows=rw, ncols=cl;
+ if(rw>cl) {nsv=cl;} else {nsv=rw;}
+
+ // Create some containers for stuff from single value decomposition
+ std::vector S(nsv);
+ std::vector U(nrows*nrows);
+ std::vector VT(ncols*ncols);
+ std::vector iwork(8*nsv);
+
+ // This optimizes the size of the work array used in lapack singular value decomposition
+ int lwork=-1;
+ std::vector work(1);
+ plumed_lapack_dgesdd( "A", &nrows, &ncols, da.data(), &nrows, S.data(), U.data(), &nrows, VT.data(), &ncols, work.data(), &lwork, iwork.data(), &info );
+ //if(info!=0) return info;
+ if(info!=0) log.printf("info:", info);
+
+ // Retrieve correct sizes for work and rellocate
+ lwork=(int) work[0]; work.resize(lwork);
+
+ // This does the singular value decomposition
+ plumed_lapack_dgesdd( "A", &nrows, &ncols, da.data(), &nrows, S.data(), U.data(), &nrows, VT.data(), &ncols, work.data(), &lwork, iwork.data(), &info );
+ //if(info!=0) return info;
+ if(info!=0) log.printf("info:", info);
+
+
+ // get U and VT in form of 2D vector (U_, VT_)
+ std::vector> U_(nrows, std::vector(nrows,0));
+ std::vector> VT_(ncols, std::vector(ncols,0));
+
+ int c=0;
+
+ for(int i=0; i rotation(3,3);
+ rotation.resize(3,3);
+ Matrix u(3,3), vt(3,3);
+ for(int i=0; i<3; ++i) { for(int j=0; j<3; ++j) { u(i,j)=U_[i][j]; vt(i,j)=VT_[i][j]; } }
+
+ // get rotation matrix
+ mult(u, vt, rotation);
+
+}
+
+
+// calculates maha dist
+double position_maha_dist::cal_maha_dist() {
+
+ unsigned N=getNumberOfAtoms();
+
+ Matrix rotated_obj(N,3);
+ // rotate the object
+ mult(mobile_str, rotation, rotated_obj);
+
+ // compute the displacement
+ Matrix disp(N,3);
+ for(unsigned int i=0; i prec_dot_disp(N,3);
+ Matrix disp_T(3,N);
+ Matrix out(3,3);
+
+ mult(prec, disp, prec_dot_disp);
+ transpose(disp, disp_T);
+ mult(disp_T, prec_dot_disp, out);
+
+
+
+ double maha_d=0.0;
+ for(int i=0; i<3; ++i) { maha_d += out(i,i);}
+
+ if (!squared) maha_d = std::sqrt(maha_d);
+
+ return maha_d;
+}
+
+// gradient function
+void position_maha_dist::grad_maha(double d) {
+
+ unsigned N=getNumberOfAtoms();
+
+ derv_.resize(N,3);
+
+ Matrix ref_str_rot_T(N,3);
+ Matrix rot_T(3,3);
+ Matrix diff_(N,3);
+
+ transpose(rotation, rot_T);
+ mult(ref_str, rot_T, ref_str_rot_T);
+
+ for(unsigned i=0; i.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "colvar/Colvar.h"
+#include "core/ActionRegister.h"
+#include "tools/Pbc.h"
+#include "tools/File.h" // Input and output from files
+#include "tools/Matrix.h" // Linear Algebra operations
+#include
+#include
+#include "tools/Communicator.h" // All the MPI related stuffs
+
+namespace PLMD {
+namespace sizeshape {
+
+//+PLUMEDOC sizeshapeMOD_COLVAR SIZESHAPE_POSITION_LINEAR_PROJ
+/*
+Calculates a linear projection in the space of a given reference configurational distribution in size-and-shape space.
+
+This method is described in \cite Sasmal-poslda-2023.
+
+The linear projection is given by:
+\f[
+ l(\mathbf{x}) = \mathbf{v}\cdot(\mathbf{R}\cdot(\mathbf{x}(t) - \vec{{\zeta}}(t)) - \mathbf{\mu}),
+\f]
+Where \f$\mathbf{v}\f$ is a vector of linear coefficients, \f$\mathbf{x}(t)\f$ is the configuration at time t, \f$\vec{\zeta}(t)\f$ is the difference in the geometric mean of the current configuration and that of the reference configuration \f$\mathbf{\mu}\f$. \f$\vec{\zeta}(t) = \frac{1}{N} \sum_{i=1}^N \vec{x_{i}}(t) - \frac{1}{N} \sum_{i=1}^N \vec{\mu_{i}}(t)\f$, for N atoms.
+
+\f$\mathbf{R}\f$ is an optimal rotation matrix that minimizes the Mahalanobis distance between the current configuration and reference. \f$\mathbf{R}\f$ is obtained by using Kabsch algorithm within the code. The Mahalanobis distance is given as:
+
+\f[
+d(\mathbf{x}, \mathbf{\mu}, \mathbf{\Sigma}) = \sqrt{(\mathbf{x}-\mathbf{\mu})^T \mathbf{\Sigma}^{-1} (\mathbf{x}-\mathbf{\mu})}
+\f]
+
+where, \f$\mathbf{\Sigma}^{-1}\f$ is the \f$N\times N\f$ precision matrix. See also \ref POSITION_MAHA_DIST for information about calculating Mahalanobis distance in size-and-shape space.
+
+Size-and-shape Gaussian Mixture Model (shapeGMM) \cite Heidi-shapeGMM-2022 is a probabilistic clustering technique that is used to perform structural clusteing on ensemble of molecular configurations and to obtain reference \f$(\mathbf{\mu})\f$ and precision \f$(\mathbf{\Sigma}^{-1})\f$ corresponding to each of the cluster centers. Please chcek out shapeGMMTorch-GitHub and shapeGMMTorch-PyPI for examples and informations on preforming shapeGMM clustering.
+
+\par Examples
+In the following example, a group is defined with atom indices of selected atoms and then linear projection is calculated for the given reference, precision and coefficients. Each file is a space separated list of 3N floating point numbers.
+
+\plumedfile
+UNITS LENGTH=A TIME=ps ENERGY=kcal/mol
+GROUP ATOMS=18,20,22,31,33,35,44,46,48,57,59,61,70,72,74,83,85,87,96,98,100,109,111 LABEL=ga_list
+#SETTINGS AUXFILE=regtest/sizeshape/rt-sizeshape/global_avg.txt
+#SETTINGS AUXFILE=regtest/sizeshape/rt-sizeshape/global_precision.txt
+#SETTINGS AUXFILE=regtest/sizeshape/rt-sizeshape/ld1_scalings.txt
+proj: SIZESHAPE_POSITION_LINEAR_PROJ REFERENCE=global_avg.txt PRECISION=global_precision.txt COEFFS=ld1_scalings.txt GROUP=ga_list
+PRINT ARG=proj STRIDE=1 FILE=COLVAR FMT=%8.8f
+\endplumedfile
+
+*/
+//+ENDPLUMEDOC
+
+
+class position_linear_proj : public Colvar {
+
+private:
+ bool pbc, serial;
+ std::string prec_f_name; // precision file name
+ std::string ref_f_name; // reference file name
+ std::string coeffs_f_name; // file containing linear coeffs
+ IFile in_; // create an object of class IFile
+ Log out_;
+ Matrix ref_str; // coords of reference
+ Matrix mobile_str; // coords of mobile
+ Matrix prec; // precision data
+ Matrix rotation;
+ std::vector linear_coeffs; // Linear Coefficients
+ Matrix derv_numeric;
+ void readinputs(); // reads the input data
+ double proj; // projection value
+ std::vector atom_list; // list of atoms
+ const double SMALL = 1.0E-30;
+ const double delta = 0.00001;
+public:
+ static void registerKeywords( Keywords& keys );
+ explicit position_linear_proj(const ActionOptions&);
+ double determinant(int n, const std::vector>* B);
+ void kabsch_rot_mat(); // gives rotation matrix
+ double cal_position_linear_proj(); // calculates the linear projection
+ void numeric_grad(); // calculates the numeric gradient
+ // active methods:
+ void calculate() override;
+};
+
+PLUMED_REGISTER_ACTION(position_linear_proj, "SIZESHAPE_POSITION_LINEAR_PROJ")
+
+// register keywords function
+void position_linear_proj::registerKeywords( Keywords& keys ) {
+ Colvar::registerKeywords( keys );
+ keys.add("compulsory", "PRECISION", "Precision Matrix (inverse of covariance)." );
+ keys.add("compulsory", "REFERENCE", "Coordinates of the reference structure.");
+ keys.add("atoms","GROUP","Group of atoms being used");
+ keys.add("compulsory", "COEFFS", "Vector of linear coefficients.");
+ keys.addFlag("SERIAL",false,"Perform the calculation in serial, for debug purposes only.");
+}
+
+// constructor function
+position_linear_proj::position_linear_proj(const ActionOptions&ao):
+ PLUMED_COLVAR_INIT(ao),
+ pbc(true),
+ serial(false),
+ proj(0),
+ prec_f_name(""),
+ ref_f_name(""),
+ coeffs_f_name("") // Note! no comma here in the last line.
+{
+ parseFlag("SERIAL",serial);
+ parseAtomList("GROUP",atom_list);
+ parse("REFERENCE", ref_f_name);
+ parse("PRECISION", prec_f_name);
+ parse("COEFFS", coeffs_f_name);
+ bool nopbc=!pbc;
+ parseFlag("NOPBC",nopbc);
+ pbc=!nopbc;
+
+ checkRead();
+
+ log.printf(" of %u atoms\n",static_cast(atom_list.size()));
+ for(unsigned int i=0; i items_;
+ std::stringstream check_(line_);
+
+ while(std::getline(check_, val_, ' ')) { items_.push_back(val_); }
+ for(int i=0; i<3; ++i) { ref_str(c_,i) = std::stold(items_[i]); }
+ c_ += 1;
+ }
+ in_.close();
+
+ //read precision
+ in_.open(prec_f_name);
+
+ std::string line, val;
+ unsigned int c = 0;
+
+ while(c < N)
+ {
+ in_.getline(line);
+
+ // vector for storing the objects
+ std::vector items;
+
+ // stringstream helps to treat a string like an ifstream!
+ std::stringstream check(line);
+
+ while (std::getline(check, val, ' '))
+ {
+ items.push_back(val);
+ }
+
+ for(unsigned int i=0; i>* B)
+{
+
+ std::vector> A(n, std::vector(n, 0));
+ // make a copy first!
+ for(int i=0; i maxA )
+ {
+ r = k;
+ maxA = val;
+ }
+ }
+ if ( r != i )
+ {
+ for ( int j = i; j < n; j++ ) std::swap( A[i][j], A[r][j] );
+ det = -det;
+ }
+
+ // Row operations to make upper-triangular
+ double pivot = A[i][i];
+ if (std::abs( pivot ) < SMALL ) return 0.0; // Singular matrix
+
+ for ( int r = i + 1; r < n; r++ ) // On lower rows
+ {
+ double multiple = A[r][i] / pivot; // Multiple of row i to clear element in ith column
+ for ( int j = i; j < n; j++ ) A[r][j] -= multiple * A[i][j];
+ }
+ det *= pivot; // Determinant is product of diagonal
+ }
+
+ det *= A[n-1][n-1];
+
+ return det;
+}
+
+// kabsch rotation
+void position_linear_proj::kabsch_rot_mat() {
+
+ unsigned N=getNumberOfAtoms();
+
+ Matrix mobile_str_T(3,N);
+ Matrix prec_dot_ref_str(N,3);
+ Matrix correlation(3,3);
+
+
+ transpose(mobile_str, mobile_str_T);
+ mult(prec, ref_str, prec_dot_ref_str);
+ mult(mobile_str_T, prec_dot_ref_str, correlation);
+
+
+ int rw = correlation.nrows();
+ int cl = correlation.ncols();
+ int sz = rw*cl;
+
+ // SVD part (taking from plu2/src/tools/Matrix.h: pseudoInvert function)
+
+ std::vector da(sz);
+ unsigned k=0;
+
+ // Transfer the matrix to the local array
+ for (int i=0; i( correlation(j,i) ); // note! its [j][i] not [i][j]
+
+ int nsv, info, nrows=rw, ncols=cl;
+ if(rw>cl) {nsv=cl;} else {nsv=rw;}
+
+ // Create some containers for stuff from single value decomposition
+ std::vector S(nsv);
+ std::vector U(nrows*nrows);
+ std::vector VT(ncols*ncols);
+ std::vector iwork(8*nsv);
+
+ // This optimizes the size of the work array used in lapack singular value decomposition
+ int lwork=-1;
+ std::vector work(1);
+ plumed_lapack_dgesdd( "A", &nrows, &ncols, da.data(), &nrows, S.data(), U.data(), &nrows, VT.data(), &ncols, work.data(), &lwork, iwork.data(), &info );
+ //if(info!=0) return info;
+ if(info!=0) log.printf("info:", info);
+
+ // Retrieve correct sizes for work and rellocate
+ lwork=(int) work[0]; work.resize(lwork);
+
+ // This does the singular value decomposition
+ plumed_lapack_dgesdd( "A", &nrows, &ncols, da.data(), &nrows, S.data(), U.data(), &nrows, VT.data(), &ncols, work.data(), &lwork, iwork.data(), &info );
+ //if(info!=0) return info;
+ if(info!=0) log.printf("info:", info);
+
+
+ // get U and VT in form of 2D vector (U_, VT_)
+ std::vector> U_(nrows, std::vector(nrows,0));
+ std::vector> VT_(ncols, std::vector(ncols,0));
+
+ int c=0;
+
+ for(int i=0; i rotation(3,3);
+ rotation.resize(3,3);
+ Matrix u(3,3), vt(3,3);
+ for(int i=0; i<3; ++i) { for(int j=0; j<3; ++j) { u(i,j)=U_[i][j]; vt(i,j)=VT_[i][j]; } }
+
+ // get rotation matrix
+ mult(u, vt, rotation);
+
+}
+
+
+// calculates linear projection
+double position_linear_proj::cal_position_linear_proj() {
+
+ unsigned N=getNumberOfAtoms();
+
+ Matrix rotated_obj(N,3);
+ // rotate the object
+ mult(mobile_str, rotation, rotated_obj);
+
+ // compute the displacement
+ std::vector disp(N*3);
+ unsigned c=0;
+ for(unsigned int i=0; i
+
+\section Overview
+
+This sizeshape module contains method for calculating a 1D linear projection and the Mahalanobis distance in size and shape space for a given reference configurational distribution, as described in \cite Sasmal-poslda-2023.
+
+\section Installation
+This module is not installed by default. Add '\-\-enable-modules=sizeshape' to your './configure' command when building PLUMED to enable these features.
+
+\section Usage
+Currently, all features of the sizeshape module are included in a single sizeshape collective variable: \ref POSITION_LINEAR_PROJ \ref POSITION_MAHA_DIST
+
+\section Module Contents
+- \subpage sizeshapeMODColvar
+
+\page sizeshapeMODColvar CVs Documentation
+
+The following list contains descriptions of collective variable developed for the PLUMED-sizeshape module. They can be used in combination with other actions outside of the sizeshape module.
+
+@sizeshapeMOD_COLVAR@