Fenòmens p4: allow to save final configuration

Change-Id: I9f14110403a8313357ab04df624373789de47233
diff --git a/quad10/fenomens/lab/p4/MC-2.f90 b/quad10/fenomens/lab/p4/MC-2.f90
index 8398997..554890d 100644
--- a/quad10/fenomens/lab/p4/MC-2.f90
+++ b/quad10/fenomens/lab/p4/MC-2.f90
@@ -7,6 +7,7 @@
   integer*4 :: I, J, IMC, MCTOT, MCINI, MCD, IPAS, N, SEED, NSEED, SEED0, pbc
   integer :: genrand_int31
   character(100) :: NOM
+  logical :: SAVEFINALCONF
 
   integer :: SUMI
   real(dp) :: SUME, SUME2, SUMM, SUMAM, SUMM2, VARE, VARM, CV, CHI
@@ -16,7 +17,7 @@
   integer*2 :: S(1:64, 1:64)
 
   ! Inicialitzem algunes variables sobre el problema
-  namelist /DADES/ L, NOM, TEMP, NSEED, SEED0, MCTOT, MCINI, MCD
+  namelist /DADES/ L, NOM, TEMP, NSEED, SEED0, MCTOT, MCINI, MCD, SAVEFINALCONF
   read(nml = DADES, unit = 5)
 
   N = L*L
@@ -95,9 +96,13 @@
 
   ! Guardem a un fiter els promitjos
   open(unit = 13, file = "data_out/" // trim(NOM) // ".res")
-  !write(13, *) "L,     T,     <E>,     <E**2>,     Var(E),     <M>,     <|M|>,     <M**2>,     Var(M),     C_V,     CHI"
+  ! Valors: L, T, <E>, <E**2>, Var(E), <M>, <|M|>, <M**2>, Var(M), C_V, CHI
   write(13, *) L, TEMP, SUME, SUME2, VARE, SUMM, SUMAM, SUMM2, VARM, CV, CHI
 
+  if (SAVEFINALCONF) then
+    call writeConfig(S, L, "data_out/" // trim(NOM) // ".conf")
+  endif
+
   ! Tanquem els fitxers de sortida
   close(13)
 endprogram main