Open GoogleCodeExporter opened 9 years ago
Right now output that prints scalar measurements works in such a manner:
Everything is defined in the file dqmc_phy0.F90
----
There are variables:
P0_N_NO_SAF - which defines number of variables that can be defined for both
bipartite and frustrated lattice.
P0_N - total number of scalar variables.
where
P0_N should be >= P0_N_NO_SAF
P0%compSAF - True if lattice is bipartite
False if lattice is frustrated
P0%nMeas - number of scalar variables that will go to the output
If P0%compSAF == True:
P0%nMeas = P0_N
if P0%compSAF == False:
P0%nMeas = P0_N_NO_SAF
Which means that if lattice is frustrated we print only first P0_N_NO_SAF
variables,
if not we will print all P0_N variables.
This can look fine because it works, but this is really crappy code. Problem
that it is
hard to scale. And reason for this is that if you need to add new ferromagnetic
variables you need:
change variables:
integer, parameter :: P0_SAF
integer, parameter :: P0_SAFSQ
integer, parameter :: P0_SAF2
integer, parameter :: P0_SAF2SQ
integer, parameter :: P0_N_NO_SAF
integer, parameter :: P0_N
and add label for the variable that you want to add in character(len=*),
parameter :: P0_STR(P0_N) in proper space.
So you have number of ways to create a bug from nowhere.
I do not know how wrote this "amazing" code but it should be changed at some
point.
I am changing this from defect to enhancement but it is still not ok.
Original comment by iglovi...@gmail.com
on 13 Apr 2014 at 4:57
Vlad,
this is not so bad. I am also unhappy about it but I don't think that this is
in any way serious: it is too simple of a piece of code for
people to get confused or introduce bugs that are hard to track.
We could and should definitely make this better. What do you have in mind?
I am thinking linked list but there may be better/simpler ways.
For everyone's benefit, I am copying below an email I sent Vlad on how
to add a new scalar measurement but mended with a new paragraph to
avoid what Vlad is seeing.
----
I am going to assume the property is just a single number like
the double occupancy.
At the very beginning of DQMC_Phy0 you see a bunch of parameter
definition (P0_NUP, P0_DN...) which is just an emulation of C/C++ enum.
So the first step in adding an observable is adding an entry here. Note that the
number of variables is either P0_N or P0_N_NO_SAF depending on the
value of P0%compSAF (see DQMC_Phy0_Init). These constants will both need
to be incremented. Something like this will do
! Parameter for the index of scalar variables (IMEAS)
integer, parameter :: P0_NUP = 1
integer, parameter :: P0_NDN = 2
integer, parameter :: P0_NUD = 3
integer, parameter :: P0_KE = 4
integer, parameter :: P0_ENERGY = 5
integer, parameter :: P0_DENSITY = 6
integer, parameter :: P0_CHIT = 7
integer, parameter :: P0_CV = 8
integer, parameter :: P0_VLAD = 9
integer, parameter :: P0_SFERRO = 10
integer, parameter :: P0_SFER2 = 11
integer, parameter :: P0_SAF = 12
integer, parameter :: P0_SAFSQ = 13
integer, parameter :: P0_SAF2 = 14
integer, parameter :: P0_SAF2SQ = 15
integer, parameter :: P0_N_NO_SAF = 11
integer, parameter :: P0_N = 15
-->Note that the new property (P0_VLAD) will *need* to be added before
the "P0_SAF" properties. Here I add it at number 9 which means that anything
after will need its index incremented by one. There's certainly a better way
to do this.<--
Then add the corresponding "label" for printing like so
! Name of scalar variables
character(len=*), parameter :: P0_STR(P0_N) = (/&
" Up spin occupancy : ", &
" Down spin occupancy : ", &
" <U*N_up*N_dn> : ", &
" Kinetic energy : ", &
" Total Energy : ", &
" Density : ", &
" Chi_thermal : ", &
" Specific heat : ", &
" Vlad new property:",&
" XX Ferro structure factor : ", &
" ZZ Ferro structure factor : ", &
" XX AF structure factor : ", &
" Root Mean Square of XX AF : ", &
" ZZ AF structure factor : ", &
" Root Mean Square of ZZ AF : "/)
Finally code up the actual measurement in DQMC_Phy0_Meas
P0%meas(P0_VLAD,tmp) = "some product/sum of G's"
----
Simone
Original comment by simone.c...@gmail.com
on 13 Apr 2014 at 11:18
Original issue reported on code.google.com by
iglovi...@gmail.com
on 13 Apr 2014 at 3:34Attachments: