Merge lp:~albertog/siesta/gridxc-integration into lp:siesta/psml-support

Proposed by Alberto Garcia
Status: Merged
Merged at revision: 533
Proposed branch: lp:~albertog/siesta/gridxc-integration
Merge into: lp:siesta/psml-support
Diff against target: 3682 lines (+1534/-1037) (has conflicts)
48 files modified
Docs/gridxc-insert.CHANGES (+83/-0)
Src/MPI/Makefile (+2/-6)
Src/MPI/mpi__type_s.f90 (+0/-2)
Src/MPI/mpi__type_sv.f90 (+0/-2)
Src/MPI/mpi__type_v.f90 (+0/-2)
Src/MPI/mpi__type_vs.f90 (+0/-2)
Src/MPI/mpi_siesta.f90 (+0/-2)
Src/MPI/timer_mpi.F90 (+0/-26)
Src/Makefile (+58/-24)
Src/SiestaXC/makefile (+3/-2)
Src/SiestaXC/siestaxc.F90 (+5/-5)
Src/Sys/GRIDXC.make (+55/-0)
Src/alloc.F90 (+147/-567)
Src/alloc_error_report.F (+55/-0)
Src/alloc_memory_event.F (+30/-0)
Src/atom.F (+2/-2)
Src/broyden_optim.F (+1/-1)
Src/cell_fire_optim.F (+1/-1)
Src/cellxc_mod.F (+2/-2)
Src/dhscf.F (+4/-4)
Src/diagmemory.F (+0/-45)
Src/diagon.F (+1/-1)
Src/fft.F (+2/-2)
Src/forhar.F (+3/-3)
Src/ldau_specs.f (+2/-2)
Src/m_memory.F (+0/-134)
Src/m_timer.F90 (+47/-21)
Src/memory.F (+6/-143)
Src/memory_log.F90 (+587/-0)
Src/meshsubs.F (+2/-2)
Src/moreParallelSubs.F90 (+2/-2)
Src/obj_setup.sh (+9/-0)
Src/read_xc_info.F (+1/-1)
Src/siesta_end.F (+2/-2)
Src/siesta_init.F (+20/-10)
Src/siesta_options.F90 (+0/-2)
Src/state_init.F (+1/-1)
Src/timer.F90 (+32/-1)
Src/timer_tree.f90 (+13/-1)
Util/Denchar/Src/Makefile (+8/-5)
Util/Denchar/Src/alloc_handlers.f90 (+14/-0)
Util/Gen-basis/Makefile (+57/-6)
Util/Gen-basis/handlers.f (+114/-0)
Util/SiestaSubroutine/ProtoNEB/Src/Makefile (+5/-0)
Util/SiestaSubroutine/SimpleTest/Src/Makefile (+5/-0)
Util/VCA/Makefile (+33/-3)
Util/VCA/handlers.f (+114/-0)
version.info (+6/-0)
Text conflict in Src/Makefile
Text conflict in Util/Denchar/Src/Makefile
Text conflict in Util/Gen-basis/Makefile
Contents conflict in Util/Gen-basis/local_die.F
Text conflict in Util/SiestaSubroutine/ProtoNEB/Src/Makefile
Text conflict in Util/SiestaSubroutine/SimpleTest/Src/Makefile
Text conflict in Util/VCA/Makefile
Text conflict in version.info
To merge this branch: bzr merge lp:~albertog/siesta/gridxc-integration
Reviewer Review Type Date Requested Status
Nick Papior Approve
Alberto Garcia Approve
Review via email: mp+300428@code.launchpad.net

Description of the change

Basic changes to interface to libGridXC:

- Abstraction of alloc interface, with callbacks for logging.
- Similar abstraction of timer interface
- Hooks for libGridXC, including libxc interface.

To post a comment you must log in.
Revision history for this message
Alberto Garcia (albertog) wrote :

Nick:

I think that this should be merged into the psml work to take advantage of the infrastructure for small libs there. Also, it would streamline the compilation of ATOM, which also uses libGridXC.

Revision history for this message
Nick Papior (nickpapior) wrote :

Yes, good idea.

I will take a look at it :)

2016-07-19 10:22 GMT+02:00 Alberto Garcia <email address hidden>:

> Nick:
>
> I think that this should be merged into the psml work to take advantage of
> the infrastructure for small libs there. Also, it would streamline the
> compilation of ATOM, which also uses libGridXC.
>
>
> --
>
> https://code.launchpad.net/~albertog/siesta/gridxc-integration/+merge/300428
> You are requested to review the proposed merge of
> lp:~albertog/siesta/gridxc-integration into
> lp:~siesta-pseudos-bases/siesta/trunk-psml.
>

--
Kind regards Nick

Revision history for this message
Alberto Garcia (albertog) wrote :

I am now ready to merge this branch into trunk-psml, which has been brought in sync to the tip of the trunk. Actually, the PSML work does need libgridxc for its support of libxc (still to be strengthened).

Revision history for this message
Alberto Garcia (albertog) wrote :

I will merge it. The first commit (533) is the bulk of the merge. Later commits will fine-tune
missing bits and defaults.

review: Approve
Revision history for this message
Nick Papior (nickpapior) wrote :

I think it looks good.

However, it seems that there is going to be needed "tons" of handlers.f in all utilities.
Wouldn't it be cleaner to add the handlers.f in the Src directory to not have the code dublicated.
We may then call it handlers_utils.f (or just handlers) to make it accessible for all the utilities?

Revision history for this message
Alberto Garcia (albertog) wrote :

Hi Nick,

Indeed, this is a non-pretty side-effect of my scheme for back-communication from the small libraries.

Regarding your proposal: It is good, but note that there should be a few distintct "handlers" files for different uses. Some utilities (such as some in TS) work in parallel, so, say, "die" has to be the parallel version. Then, in some cases you might be interested in enabling detailed memory reports or error messages, so the simple stubs will not do.

I still need to carry out a second iteration of the Makefiles to rationalize the use of the handler idea (currently there are different mixes of "psml_die, die", etc, files, and "handlers"), so it would be a good opportunity to prepare a few common ones.

Note that I will not be merging trunk-psml for a while. I need to implement a few more things in gridxc and atom.F.

  Thank you for the review!

   Alberto

On 28 Oct 2016, at 20:39, Nick Papior <email address hidden> wrote:

> I think it looks good.
>
> However, it seems that there is going to be needed "tons" of handlers.f in all utilities.
> Wouldn't it be cleaner to add the handlers.f in the Src directory to not have the code dublicated.
> We may then call it handlers_utils.f (or just handlers) to make it accessible for all the utilities?
> --
> https://code.launchpad.net/~albertog/siesta/gridxc-integration/+merge/300428
> You are the owner of lp:~albertog/siesta/gridxc-integration.

Revision history for this message
Nick Papior (nickpapior) wrote :

Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Docs/gridxc-insert.CHANGES'
2--- Docs/gridxc-insert.CHANGES 1970-01-01 00:00:00 +0000
3+++ Docs/gridxc-insert.CHANGES 2016-07-19 08:21:24 +0000
4@@ -0,0 +1,83 @@
5+-----------------------------------------------------------------------
6+2016-07-07 Alberto Garcia siesta-trunk-503--gridxc-12
7+Use external gridxc library
8+
9+The arch.make must now define the GRIDXC_ROOT variable
10+(See Src/Sys/GRIDXC.make for the whole story, including
11+parallel makes for Siesta and serial for Utils).
12+
13+See Src/Makefile and Util/Gen-basis/Makefile for new idioms.
14+
15+Src/SiestaXC is kept to facilitate updates.
16+
17+-----------------------------------------------------------------------
18+2016-05-29 Alberto Garcia siesta-trunk-503--gridxc-11
19+Sync with trunk-503
20+
21+Note that the libGridXC code is kept in the Siesta tree for now.
22+Also, Src/SiestaXC is kept to facilitate updates.
23+
24+-----------------------------------------------------------------------
25+2015-06-12 Alberto Garcia siesta-trunk-470--memory-accounting-10
26+Revamped timer interface in gridxc. Build fixes
27+
28+* Revamped the timer interface in gridxc
29+
30+ Removed the internal timer framework, as it was not really needed
31+ in its full glory. If cellxc timing information is needed in the
32+ future to fine-tune the load-balancing mechanism, it should be
33+ handled in a more light-weight manner.
34+
35+ Internal timings are passed over to the calling program through
36+ the 'gridxc_timer_*' calls.
37+
38+ The MPI subsystem is instrumented for timing also. It calls
39+ also the gridxc_timer_* routines if 'time_mpi_calls' is set
40+ in 'gridxc_init'.
41+
42+* Use package-specific module names in MPI_instr
43+
44+ If a program uses several versions of the MPI interfaces,
45+ the first appearing in the linking list will be used for
46+ everything. This causes problems for package-specific
47+ functionality.
48+
49+ The modules in MPI_instr are now renamed at the time
50+ the 'generate.sh' script is run.
51+
52+* Bring in needed fixes in Util and elsewhere
53+
54+removed:
55+ Src/gridxc/m_timer.F90
56+ Util/Gen-basis/local_die.F
57+added:
58+ Util/Gen-basis/handlers.f
59+ Util/VCA/handlers.f
60+modified:
61+ Src/gridxc/MPI_instr/Makefile
62+ Src/gridxc/MPI_instr/generate.sh
63+ Src/gridxc/MPI_instr/mpi__type_s.f90
64+ Src/gridxc/MPI_instr/mpi__type_sv.f90
65+ Src/gridxc/MPI_instr/mpi__type_v.f90
66+ Src/gridxc/MPI_instr/mpi__type_vs.f90
67+ Src/gridxc/MPI_instr/mpi_instr.f90
68+ Src/gridxc/MPI_instr/mpi_interfaces.F
69+ Src/gridxc/Testers/handlers.f90
70+ Src/gridxc/Testers/test3.F90
71+ Src/gridxc/atomxc.F90
72+ Src/gridxc/cellxc.F90
73+ Src/gridxc/fft3d.F90
74+ Src/gridxc/gridxc.F90
75+ Src/gridxc/gridxc_config.F90
76+ Src/gridxc/makefile
77+ Src/gridxc/radfft.f
78+ Src/obj_setup.sh
79+ Src/siesta_init.F
80+ Util/Gen-basis/Makefile
81+ Util/VCA/Makefile
82+
83+
84+
85+
86+
87+
88
89=== modified file 'Src/MPI/Makefile'
90--- Src/MPI/Makefile 2016-06-29 04:07:55 +0000
91+++ Src/MPI/Makefile 2016-07-19 08:21:24 +0000
92@@ -38,8 +38,8 @@
93 @cp *.mod ..
94 @touch module_built
95 #
96-libmpi_f90.a: mpi.o mpi__include.o Interfaces.o mpi_siesta.o timer_mpi.o
97- @$(AR) $(ARFLAGS_EXTRA) cru libmpi_f90.a mpi.o mpi_siesta.o mpi__include.o Interfaces.o timer_mpi.o
98+libmpi_f90.a: mpi.o mpi__include.o Interfaces.o mpi_siesta.o
99+ @$(AR) $(ARFLAGS_EXTRA) cru libmpi_f90.a mpi.o mpi_siesta.o mpi__include.o Interfaces.o
100 -$(RANLIB) libmpi_f90.a
101 #
102 clean:
103@@ -47,7 +47,3 @@
104 @rm -f module_built *.uses kind_explorer
105 @rm -f libmpi_f90.a
106
107-mpi_siesta.o: timer_mpi.o
108-Interfaces.o: timer_mpi.o
109-
110-
111
112=== modified file 'Src/MPI/mpi__type_s.f90'
113--- Src/MPI/mpi__type_s.f90 2009-07-09 15:35:11 +0000
114+++ Src/MPI/mpi__type_s.f90 2016-07-19 08:21:24 +0000
115@@ -17,8 +17,6 @@
116 ! (C) 1996 Michael Hennecke, RZ Universitaet Karlsruhe
117 !
118 !
119- USE TIMER_MPI_M, only: timer_mpi
120-
121 IMPLICIT NONE
122 PRIVATE
123
124
125=== modified file 'Src/MPI/mpi__type_sv.f90'
126--- Src/MPI/mpi__type_sv.f90 2009-07-09 15:35:11 +0000
127+++ Src/MPI/mpi__type_sv.f90 2016-07-19 08:21:24 +0000
128@@ -17,8 +17,6 @@
129 ! (C) 1996 Michael Hennecke, RZ Universitaet Karlsruhe
130 !
131 !
132- USE TIMER_MPI_M, only: timer_mpi
133-
134 IMPLICIT NONE
135 PRIVATE
136
137
138=== modified file 'Src/MPI/mpi__type_v.f90'
139--- Src/MPI/mpi__type_v.f90 2009-07-09 15:35:11 +0000
140+++ Src/MPI/mpi__type_v.f90 2016-07-19 08:21:24 +0000
141@@ -17,8 +17,6 @@
142 ! (C) 1996 Michael Hennecke, RZ Universitaet Karlsruhe
143 !
144 !
145- USE TIMER_MPI_M, only: timer_mpi
146-
147 IMPLICIT NONE
148 PRIVATE
149
150
151=== modified file 'Src/MPI/mpi__type_vs.f90'
152--- Src/MPI/mpi__type_vs.f90 2009-07-09 15:35:11 +0000
153+++ Src/MPI/mpi__type_vs.f90 2016-07-19 08:21:24 +0000
154@@ -17,8 +17,6 @@
155 ! (C) 1996 Michael Hennecke, RZ Universitaet Karlsruhe
156 !
157 !
158- USE TIMER_MPI_M, only: timer_mpi
159-
160 IMPLICIT NONE
161 PRIVATE
162
163
164=== modified file 'Src/MPI/mpi_siesta.f90'
165--- Src/MPI/mpi_siesta.f90 2016-01-25 16:00:16 +0000
166+++ Src/MPI/mpi_siesta.f90 2016-07-19 08:21:24 +0000
167@@ -20,8 +20,6 @@
168 trueMPI_WAIT => MPI_WAIT, &
169 trueMPI_WAITALL => MPI_WAITALL
170
171- USE TIMER_MPI_M, only: timer_mpi
172-
173 ! The following construction allows to supplant MPI_Comm_World within SIESTA,
174 ! and to use it as a subroutine with its own internal MPI communicator.
175 ! JMS. Oct.2010
176
177=== removed file 'Src/MPI/timer_mpi.F90'
178--- Src/MPI/timer_mpi.F90 2016-01-25 16:00:16 +0000
179+++ Src/MPI/timer_mpi.F90 1970-01-01 00:00:00 +0000
180@@ -1,26 +0,0 @@
181-! ---
182-! Copyright (C) 1996-2016 The SIESTA group
183-! This file is distributed under the terms of the
184-! GNU General Public License: see COPYING in the top directory
185-! or http://www.gnu.org/copyleft/gpl.txt .
186-! See Docs/Contributors.txt for a list of contributors.
187-! ---
188-MODULE timer_mpi_m
189-
190-! Disconnectable interface to siesta's timer routine.
191-! J.M.Soler. May.2009
192-
193-CONTAINS
194-
195- SUBROUTINE timer_mpi( name, opt )
196- character(len=*), intent(in):: name
197- integer, intent(in):: opt
198-
199-#ifdef MPI_TIMING
200- external timer
201- call timer( name, opt )
202-#endif
203-
204- END SUBROUTINE timer_mpi
205-
206-END MODULE timer_mpi_m
207
208=== modified file 'Src/Makefile'
209--- Src/Makefile 2016-07-08 00:16:48 +0000
210+++ Src/Makefile 2016-07-19 08:21:24 +0000
211@@ -44,6 +44,7 @@
212 /^m_ts_io.o:/s/m_tbt_kpoints.o//" Makefile > tmp.Makefile
213 @mv tmp.Makefile Makefile
214 #
215+<<<<<<< TREE
216 ARCH_MAKE?=$(MAIN_OBJDIR)/arch.make
217 include $(ARCH_MAKE)
218 #
219@@ -57,6 +58,10 @@
220 INCFLAGS:= $(NETCDF_INCFLAGS) $(PSML_INCFLAGS) $(NCPS_INCFLAGS) \
221 $(PSOP_INCFLAGS) $(XMLF90_INCFLAGS) $(INCFLAGS)
222 #
223+=======
224+include arch.make
225+INCFLAGS:= -I. $(NETCDF_INCFLAGS) $(INCFLAGS)
226+>>>>>>> MERGE-SOURCE
227 # For removing any -ipo compilation in sub directories...
228 # Later compilers are also having this enabled, and it lets you
229 # specify what to not be used in libraries.
230@@ -96,7 +101,7 @@
231 chempot.o coceri.o coxmol.o cross.o compute_norm.o\
232 denmat.o denmatlomem.o detover.o dfscf.o m_diagon.o diagon.o digcel.o \
233 fft.o dhscf.o constr.o diagk_file.o \
234- diagg.o diagk.o diagkp.o diag2g.o diag2k.o diagpol.o \
235+ diagg.o diagk.o diagkp.o diag2g.o diag2k.o diagmemory.o diagpol.o \
236 diagsprl.o dipole.o dismin.o dnaefs.o doping_uniform.o dot.o \
237 m_efield.o egandd.o ener3.o ener3lomem.o errorf.o extrapolon.o \
238 fixed.o interpolation.o gradient.o gradientlomem.o grdsam.o \
239@@ -130,7 +135,7 @@
240 precision.o sys.o m_cell.o files.o \
241 spatial.o parallel.o parallelsubs.o parsing.o chemical.o atom.o atmparams.o \
242 m_mpi_utils.o m_fdf_global.o m_history.o m_iorho.o \
243- atmfuncs.o listsc.o memoryinfo.o m_memory.o sorting.o \
244+ atmfuncs.o listsc.o memory_log.o sorting.o \
245 atomlist.o atm_types.o old_atmfuncs.o radial.o \
246 alloc.o spher_harm.o periodic_table.o version.o timestamp.o \
247 basis_types.o xml.o basis_specs.o basis_io.o\
248@@ -164,7 +169,8 @@
249 write_orb_indx.o \
250 m_hs_matrix.o kpoint_convert.o m_glob_sparse.o\
251 die.o m_dminim.o m_zminim.o m_svd.o compute_max_diff.o \
252- save_density_matrix.o \
253+ save_density_matrix.o alloc_error_report.o\
254+ alloc_memory_event.o\
255 m_rhog.o rhofft.o m_diis.o compute_energies.o \
256 class_Vector.o class_Pair_Vectors.o class_Fstack_Pair_Vectors.o\
257 m_target_stress.o\
258@@ -179,8 +185,26 @@
259 OBJS += m_cite.o
260
261 #--------------------------------------------------------------
262+<<<<<<< TREE
263
264 INCFLAGS:=$(INCFLAGS) $(NETCDF_INCFLAGS)
265+=======
266+# FoX whatnot
267+#
268+# FoX build targets:
269+FoX_configured=FoX/.config
270+FoX_built=FoX/.FoX
271+#
272+# This is how we pick up modules and libraries for FoX:
273+FoX_FCFLAGS=`FoX/FoX-config --fcflags`
274+FoX_LIBS=`FoX/FoX-config --libs --wcml`
275+#
276+# And add them to global compiler flags:
277+INCFLAGS:=$(INCFLAGS) $(FoX_FCFLAGS)
278+#
279+# First, it needs to be configured. This may have been done
280+# by the main SIESTA configure, but in case not:
281+>>>>>>> MERGE-SOURCE
282 #
283 FC_DEFAULT:=$(FC)
284 FC_SERIAL?=$(FC_DEFAULT)
285@@ -200,6 +224,7 @@
286 FFFLAGS="$(FFLAGS:$(IPO_FLAG)=)" module)
287 #
288 #--------------------------------------------------------------
289+<<<<<<< TREE
290 XC=libSiestaXC.a
291 $(XC):
292 (cd SiestaXC ; $(MAKE) \
293@@ -207,6 +232,11 @@
294 "VPATH_ROOT=$(VPATH)" \
295 "INCFLAGS=-I../MPI" \
296 "FFLAGS=$(FFLAGS:$(IPO_FLAG)=)" module )
297+=======
298+include $(GRIDXC_ROOT)/gridxc.mk
299+XC=$(GRIDXC_LIBS)
300+INCFLAGS:= $(INCFLAGS) $(GRIDXC_INCFLAGS)
301+>>>>>>> MERGE-SOURCE
302 #--------------------------------------------------------------
303 FDF=libfdf.a
304 $(FDF):
305@@ -355,10 +385,10 @@
306 (cd psoplib/src ; $(MAKE) ARCH_MAKE=$(ARCH_MAKE) clean)
307 @if [ -d MPI ] ; then (cd MPI && $(MAKE) clean ) ; fi
308 (cd Libs ; $(MAKE) clean )
309- (cd SiestaXC ; $(MAKE) clean )
310
311 # DO NOT DELETE THIS LINE - used by make depend
312-alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
313+alloc_error_report.o: parallel.o
314+alloc_memory_event.o: memory_log.o
315 amn.o: alloc.o atmfuncs.o atomlist.o m_orderbands.o m_trialorbitalclass.o
316 amn.o: matel_registry.o mneighb.o new_matel.o parallel.o parallelsubs.o
317 amn.o: precision.o siesta2wannier90.o siesta_geom.o sys.o
318@@ -389,16 +419,16 @@
319 born_charge.o: siesta_geom.o siesta_options.o sparse_matrices.o
320 broadcast_basis.o: atm_types.o ldau_specs.o m_mpi_utils.o parallel.o radial.o
321 broadcast_projections.o: m_trialorbitalclass.o parallel.o siesta2wannier90.o
322-broyden_optim.o: m_broyddj_nocomm.o m_memory.o parallel.o precision.o
323+broyden_optim.o: m_broyddj_nocomm.o memory_log.o parallel.o precision.o
324 broyden_optim.o: siesta_options.o sys.o units.o
325 bsc_cellxc.o: alloc.o bsc_xcmod.o cellxc_mod.o mesh.o moremeshsubs.o parallel.o
326 bsc_cellxc.o: parallelsubs.o precision.o sys.o
327 bsc_xcmod.o: parallel.o precision.o sys.o
328 cart2frac.o: sys.o
329-cdiag.o: alloc.o m_spin.o memoryinfo.o parallel.o precision.o sys.o
330+cdiag.o: alloc.o diagmemory.o m_spin.o parallel.o precision.o sys.o
331 cell_broyden_optim.o: m_broyddj_nocomm.o parallel.o precision.o sys.o units.o
332 cell_broyden_optim.o: zmatrix.o
333-cell_fire_optim.o: alloc.o m_fdf_global.o m_fire.o m_memory.o parallel.o
334+cell_fire_optim.o: alloc.o m_fdf_global.o m_fire.o memory_log.o parallel.o
335 cell_fire_optim.o: precision.o siesta_options.o sys.o zmatrix.o
336 cellsubs.o: precision.o
337 cellxc_mod.o: bsc_xcmod.o sys.o
338@@ -463,8 +493,9 @@
339 diagk_file.o: fermid.o iowfs_netcdf.o parallel.o parallelsubs.o precision.o
340 diagk_file.o: sys.o writewave.o
341 diagkp.o: alloc.o fermid.o parallel.o parallelsubs.o precision.o sys.o
342-diagon.o: alloc.o densematrix.o m_diagon.o m_memory.o parallel.o parallelsubs.o
343-diagon.o: precision.o siesta_options.o sys.o
344+diagmemory.o: precision.o
345+diagon.o: alloc.o densematrix.o m_diagon.o memory_log.o parallel.o
346+diagon.o: parallelsubs.o precision.o siesta_options.o sys.o
347 diagonalizeHk.o: alloc.o atomlist.o densematrix.o m_orderbands.o m_spin.o
348 diagonalizeHk.o: parallel.o parallelsubs.o precision.o siesta2wannier90.o
349 diagonalizeHk.o: sparse_matrices.o units.o
350@@ -488,8 +519,8 @@
351 ener3lomem.o: alloc.o globalise.o m_mpi_utils.o onmod.o precision.o
352 extrapolon.o: parallel.o precision.o sys.o
353 fermid.o: errorf.o parallel.o precision.o sys.o
354-fft.o: alloc.o fft1d.o m_timer.o mesh.o parallel.o parallelsubs.o precision.o
355-fft.o: sys.o
356+fft.o: alloc.o m_fft_gpfa.o m_timer.o mesh.o parallel.o parallelsubs.o
357+fft.o: precision.o sys.o
358 fft1d.o: parallel.o precision.o sys.o
359 final_H_f_stress.o: alloc.o atomlist.o dnaefs.o files.o grdsam.o kinefsm.o
360 final_H_f_stress.o: ldau.o ldau_specs.o m_dipol.o m_energies.o m_forces.o
361@@ -600,7 +631,6 @@
362 m_iostruct.o: alloc.o files.o m_mpi_utils.o parallel.o precision.o
363 m_iostruct.o: siesta_geom.o sys.o units.o
364 m_kinetic.o: precision.o
365-m_memory.o: memoryinfo.o parallel.o sys.o
366 m_mpi_utils.o: precision.o sys.o
367 m_noccbands.o: alloc.o atmfuncs.o m_spin.o parallel.o precision.o siesta_geom.o
368 m_noccbands.o: sys.o
369@@ -656,16 +686,21 @@
370 matel_registry.o: m_trialorbitalclass.o precision.o radial.o spher_harm.o sys.o
371 md_out.o: files.o m_energies.o precision.o sys.o units.o
372 md_utils.o: precision.o
373-memory.o: alloc.o memoryinfo.o parallel.o precision.o
374-memoryinfo.o: precision.o
375+memory.o: memory_log.o parallel.o
376+memory_log.o: m_io.o parallel.o precision.o
377 mesh.o: precision.o
378 meshcomm.o: mesh.o precision.o
379 meshdscf.o: alloc.o atomlist.o m_dscfcomm.o meshphi.o parallel.o parallelsubs.o
380 meshdscf.o: precision.o
381 meshphi.o: alloc.o precision.o
382 meshsubs.o: alloc.o atm_types.o atmfuncs.o cellsubs.o cellxc_mod.o chkgmx.o
383+<<<<<<< TREE
384 meshsubs.o: fft1d.o mesh.o meshphi.o moremeshsubs.o parallel.o parallelsubs.o
385 meshsubs.o: precision.o siesta_cml.o sys.o
386+=======
387+meshsubs.o: m_fft_gpfa.o mesh.o meshphi.o moremeshsubs.o parallel.o
388+meshsubs.o: parallelsubs.o precision.o radial.o siesta_cml.o sys.o
389+>>>>>>> MERGE-SOURCE
390 metaforce.o: alloc.o parallel.o precision.o sys.o
391 minvec.o: cellsubs.o precision.o sorting.o sys.o
392 mixer.o: atomlist.o m_broyden_mixing.o m_fire_mixing.o m_pulay.o m_spin.o
393@@ -734,8 +769,8 @@
394 proximity_check.o: siesta_geom.o siesta_options.o units.o
395 radfft.o: alloc.o bessph.o m_fft_gpfa.o precision.o
396 radial.o: alloc.o interpolation.o precision.o xml.o
397-rdiag.o: alloc.o m_diagon.o memoryinfo.o parallel.o precision.o sys.o
398-read_options.o: files.o m_target_stress.o memoryinfo.o parallel.o precision.o
399+rdiag.o: alloc.o diagmemory.o m_diagon.o parallel.o precision.o sys.o
400+read_options.o: diagmemory.o files.o m_target_stress.o parallel.o precision.o
401 read_options.o: siesta_cml.o siesta_options.o sys.o units.o
402 read_xc_info.o: parallel.o precision.o sys.o
403 readsp.o: parallel.o precision.o sys.o
404@@ -789,8 +824,8 @@
405 siesta_analysis.o: siesta_geom.o siesta_options.o sparse_matrices.o units.o
406 siesta_analysis.o: write_subs.o writewave.o zmatrix.o
407 siesta_cmlsubs.o: files.o parallel.o siesta_cml.o timestamp.o
408-siesta_end.o: alloc.o bands.o densematrix.o fixed.o m_dscfcomm.o m_pulay.o
409-siesta_end.o: m_rhog.o m_wallclock.o meshdscf.o meshphi.o moremeshsubs.o
410+siesta_end.o: bands.o densematrix.o fixed.o m_dscfcomm.o m_pulay.o m_rhog.o
411+siesta_end.o: m_wallclock.o memory_log.o meshdscf.o meshphi.o moremeshsubs.o
412 siesta_end.o: parallel.o siesta_cml.o siesta_cmlsubs.o siesta_master.o
413 siesta_end.o: sparse_matrices.o timestamp.o
414 siesta_forces.o: compute_dm.o compute_energies.o compute_max_diff.o
415@@ -806,10 +841,10 @@
416 siesta_init.o: ioxv.o kpoint_grid.o kpoint_pdos.o ksvinit.o m_check_supercell.o
417 siesta_init.o: m_cite.o m_energies.o m_eo.o m_forces.o m_gamma.o m_iostruct.o
418 siesta_init.o: m_mpi_utils.o m_rmaxh.o m_spin.o m_steps.o m_timer.o
419-siesta_init.o: m_wallclock.o metaforce.o molecularmechanics.o parallel.o
420-siesta_init.o: parallelsubs.o projected_DOS.o siesta_cmlsubs.o siesta_geom.o
421-siesta_init.o: siesta_options.o sparse_matrices.o struct_init.o sys.o timer.o
422-siesta_init.o: timestamp.o ts_init.o writewave.o zmatrix.o
423+siesta_init.o: m_wallclock.o memory_log.o metaforce.o molecularmechanics.o
424+siesta_init.o: parallel.o parallelsubs.o projected_DOS.o siesta_cmlsubs.o
425+siesta_init.o: siesta_geom.o siesta_options.o sparse_matrices.o struct_init.o
426+siesta_init.o: sys.o timer.o timestamp.o ts_init.o writewave.o zmatrix.o
427 siesta_master.o: iopipes.o iosockets.o m_fdf_global.o precision.o sys.o
428 siesta_move.o: atomlist.o broyden_optim.o cell_broyden_optim.o
429 siesta_move.o: cell_fire_optim.o dynamics.o fire_optim.o ioxv.o m_energies.o
430@@ -873,7 +908,6 @@
431 zmatrix.o: alloc.o m_cell.o parallel.o precision.o siesta_geom.o sys.o units.o
432 aux_proj.o: atom.o
433 band.o: bands.o
434-diagmemory.o: memoryinfo.o
435 f90sockets.o: fsockets.o
436 fsiesta.o: fsiesta_sockets.o
437 listsc_module.o: listsc.o
438
439=== modified file 'Src/SiestaXC/makefile'
440--- Src/SiestaXC/makefile 2015-07-19 05:13:23 +0000
441+++ Src/SiestaXC/makefile 2016-07-19 08:21:24 +0000
442@@ -17,7 +17,7 @@
443 module: libSiestaXC.a
444 cp *.mod *.a ..
445 #
446-SIESTA_SRCS= alloc.F90 bessph.f cellsubs.f debugmpi.F \
447+SIESTA_SRCS= alloc.F90 memory_log.F90 bessph.f cellsubs.f debugmpi.F \
448 chkgmx.f fft1d.F interpolation.f90 \
449 minvec.f m_io.f moreParallelSubs.F90 \
450 m_timer.F90 timer_tree.F90 m_walltime.f90 parallel.F \
451@@ -71,7 +71,7 @@
452 rm -fr *.o *.*d *.a siestaXC.tgz
453 #
454 # DO NOT DELETE THIS LINE - used by make depend
455-alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
456+alloc.o: memory_log.o
457 am05.o: precision.o sys.o
458 atomxc.o: alloc.o ggaxc.o ldaxc.o mesh1d.o precision.o radfft.o
459 atomxc.o: sys.o vdwxc.o xcmod.o
460@@ -91,6 +91,7 @@
461 ldaxc.o: precision.o sys.o
462 m_io.o: sys.o
463 m_timer.o: m_io.o m_walltime.o moreParallelSubs.o parallel.o precision.o sys.o
464+memory_log.o: precision.o parallel.o m_io.o
465 mesh1d.o: precision.o
466 mesh3d.o: alloc.o debugxc.o parallel.o precision.o sorting.o sys.o
467 minvec.o: cellsubs.o precision.o sorting.o sys.o
468
469=== modified file 'Src/SiestaXC/siestaxc.F90'
470--- Src/SiestaXC/siestaxc.F90 2015-06-09 13:34:25 +0000
471+++ Src/SiestaXC/siestaxc.F90 2016-07-19 08:21:24 +0000
472@@ -20,7 +20,7 @@
473 ! Extra utilities placed here for non-siesta users
474 ! See correspondig modules for usage documentation
475 ! nfft ! Get allowed sizes for FFTs
476-! alloc_report ! Set and print allocation report
477+! memory_report ! Set and print allocation report
478 ! setDebugOutputUnit ! Initialize debug report
479 ! closeDebugOutputFile ! Print debug report
480 ! timer_report ! Print report of CPU times
481@@ -429,7 +429,7 @@
482 !
483 !******************************************************************************
484 !
485-! SUBROUTINE alloc_report( level, unit, file, printNow, threshold )
486+! SUBROUTINE memory_report( level, unit, file, printNow, threshold )
487 ! Sets the output file for the allocation report
488 ! INPUT (optional):
489 ! integer :: level : Level (detail) of report
490@@ -445,14 +445,14 @@
491 ! level=2 : detailed report created but printed only upon request
492 ! level=3 : detailed report printed at every new memory peak
493 ! level=4 : print every individual reallocation or deallocation
494-! If unit is present, alloc_report merely takes note of it for
495+! If unit is present, memory_report merely takes note of it for
496 ! future use, assuming that it has been already open outside.
497 ! In this case, file is not used.
498 ! If unit is absent, and file is present, a file with that
499 ! name is open for future use.
500 ! If both arguments are absent, a file named 'alloc_report'
501 ! is open for future use.
502-! If alloc_report is called with printNow=.true. several times in
503+! If memory_report is called with printNow=.true. several times in
504 ! a program, with the same unit or file argument, the subsequent
505 ! reports are written consecutively in the same file, each with a
506 ! time stamp header.
507@@ -712,7 +712,7 @@
508 ! Extra utilities placed here for non-siesta users
509 ! See correspondig modules for usage documentation
510 USE fft1d, only: nfft ! Get allowed sizes for FFTs
511- USE alloc, only: alloc_report ! Set and print allocation report
512+ USE memory_log, only: memory_report ! Set and print allocation report
513 #ifdef DEBUG_XC
514 USE debugXC, only: setDebugOutputUnit ! Set debug report
515 USE debugXC, only: closeDebugOutputFile ! Print debug report
516
517=== added file 'Src/Sys/GRIDXC.make'
518--- Src/Sys/GRIDXC.make 1970-01-01 00:00:00 +0000
519+++ Src/Sys/GRIDXC.make 2016-07-19 08:21:24 +0000
520@@ -0,0 +1,55 @@
521+#
522+# This file is part of the SIESTA package.
523+#
524+# Copyright (c) Fundacion General Universidad Autonoma de Madrid:
525+# E.Artacho, J.Gale, A.Garcia, J.Junquera, P.Ordejon, D.Sanchez-Portal
526+# and J.M.Soler, 1996- .
527+#
528+# Use of this software constitutes agreement with the full conditions
529+# given in the SIESTA license, as signed by all legitimate users.
530+#
531+SIESTA_ARCH=gfortran-macosx64-openmpi
532+# The only thing you should change is the location of the libraries
533+# on your computer
534+#
535+FC=mpif90
536+FC_SERIAL=gfortran
537+#
538+GRIDXC_ROOT=$(HOME)/lib/gfortran/gridxc-mpi
539+GRIDXC_SERIAL_ROOT=$(HOME)/lib/gfortran/gridxc
540+#
541+FC_ASIS=$(FC)
542+#
543+###FFLAGS= -g -O2 # -Wall
544+FFLAGS_CHECKS= -O0 -g -fcheck=all
545+FFLAGS= -O0 -g -fcheck=all
546+FFLAGS_DEBUG= -g -O0
547+RANLIB=echo
548+COMP_LIBS=
549+#
550+NETCDF_ROOT=/usr/local
551+NETCDF_INCFLAGS=-I$(NETCDF_ROOT)/include
552+FPPFLAGS_CDF=-DCDF
553+NETCDF_LIBS= -L$(NETCDF_ROOT)/lib -lnetcdff
554+#
555+MPI_INTERFACE=libmpi_f90.a
556+MPI_INCLUDE=. # Note . for no-op
557+FPPFLAGS_MPI=-DMPI
558+
559+LIBS=-L/opt/scalapack/openmpi-1.6.1-gfortran/lib \
560+ -lscalapack -ltmg -lreflapack -lrefblas \
561+ $(NETCDF_LIBS)
562+
563+SYS=nag
564+FPPFLAGS= $(FPPFLAGS_CDF) $(FPPFLAGS_MPI) -DF2003
565+#
566+#
567+.F.o:
568+ $(FC) -c $(FFLAGS) $(INCFLAGS) $(FPPFLAGS) $<
569+.f.o:
570+ $(FC) -c $(FFLAGS) $(INCFLAGS) $<
571+.F90.o:
572+ $(FC) -c $(FFLAGS) $(INCFLAGS) $(FPPFLAGS) $<
573+.f90.o:
574+ $(FC) -c $(FFLAGS) $(INCFLAGS) $<
575+#
576
577=== modified file 'Src/alloc.F90'
578--- Src/alloc.F90 2016-01-28 13:41:07 +0000
579+++ Src/alloc.F90 2016-07-19 08:21:24 +0000
580@@ -9,7 +9,10 @@
581 !
582 ! ==================================================================
583 ! Allocation, reallocation, and deallocation utility routines
584+! for pointers
585+!
586 ! Written by J.M.Soler. May 2000.
587+! Re-organized by A. Garcia, June 2015.
588 ! ==================================================================
589 ! SUBROUTINE alloc_default( old, new, restore, &
590 ! copy, shrink, imin, routine )
591@@ -45,44 +48,6 @@
592 ! Notice that, if the restore call is skipped, the new defaults will
593 ! stay in effect until a new call to alloc_dafault is made.
594 ! ==================================================================
595-! SUBROUTINE alloc_report( level, unit, file, printNow, threshold )
596-! Sets the output file for the allocation report
597-! INPUT (optional):
598-! integer :: level : Level (detail) of report
599-! integer :: unit : Output file unit
600-! character*(*):: file : Output file name
601-! logical :: printNow : If present & true => print report now
602-! real(dp) :: threshold : Memory threshold (in bytes) to print
603-! the memory use of any given array
604-! BEHAVIOR:
605-! The detail/extent of the report increses with the value of level:
606-! level=0 : no report at all (the default)
607-! level=1 : only total memory peak and where it occurred
608-! level=2 : detailed report created but printed only upon request
609-! level=3 : detailed report printed at every new memory peak
610-! level=4 : print every individual reallocation or deallocation
611-! If unit is present, alloc_report merely takes note of it for
612-! future use, assuming that it has been already open outside.
613-! In this case, file is not used.
614-! If unit is absent, and file is present, a file with that
615-! name is open for future use.
616-! If both arguments are absent, a file named 'alloc_report'
617-! is open for future use.
618-! If alloc_report is called with printNow=.true. several times in
619-! a program, with the same unit or file argument, the subsequent
620-! reports are written consecutively in the same file, each with a
621-! time stamp header.
622-! If threshold is not present, threshold=0 is assumed.
623-! In parallel execution, the report sections that involve every
624-! reallocation (levels 1, 3, and 4) are written only by node 0.
625-! The section that is written upon request (level 2) is written
626-! only by the node with the highest peak of memory up to that time,
627-! but it contains a summary of the memory used by all other nodes.
628-! In parallel execution, the nodes that share the same file
629-! system (e.g. different chip cores or NFS-connected nodes) write
630-! on the same file. Otherwise they write on files with the same name
631-! in their local disks.
632-! ==================================================================
633 ! SUBROUTINE re_alloc( array, [i1min,] i1max,
634 ! [[i2min,] i2max, [[i3min,] i3max]],
635 ! name, routine, copy, shrink )
636@@ -138,22 +103,21 @@
637 ! zero (integer and real), .false. (logical), or blank (character).
638 ! If imin>imax for any dimension, the array pointer returns
639 ! associated to a zero-size array.
640-! Besides allocating or reallocating the array, re_alloc keeps a count
641-! of memory usage (and prints a report in a file previously fixed by a
642-! call to alloc_report). Thus, it is not recommended to call re_alloc
643-! to reallocate an array not allocated by it the first time.
644-! If name is not present, the memory count associated to the
645-! allocation/deallocation is still made, but the allocation report
646-! will account the array under the generic name 'unknown'.
647-! The routine argument is NOT used to classify the counting of
648-! memory usage. The classification uses only the name argument.
649-! This is because a pointer may be allocated in one routine and
650-! deallocated in a different one (i.e. when it is used to return an
651-! array whose size is not known in advance). However, the routine
652-! argument is reported when alloc_report=4, and it is also used to
653-! report in which routine the memory peack occurs. If you want the
654-! routine name to be used for classification, you should include it
655-! as part of the name argument, like in name='matInvert '//'aux'.
656+!
657+! Besides allocating or reallocating the array, re_alloc calls
658+! the external routine 'alloc_memory_event' with the number
659+! of bytes involved in the allocation and a string identifier
660+! built from the 'routine' and 'name' arguments: 'routine@name'.
661+! Clients of this module can process this information at will.
662+!
663+! Error conditions are reported via a callback to the external
664+! routine 'alloc_error_report', with a string message and an
665+! integer code.
666+! Clients of this module can process this information at will.
667+!
668+! In future, an extra 'stat' argument might be included in the calls
669+! to re_alloc and de_alloc for finer control.
670+!
671 ! ==================================================================---
672 ! SUBROUTINE de_alloc( array, name, routine )
673 ! INPUT (optional):
674@@ -170,69 +134,47 @@
675 ! Equally, arrays allocated or reallocated by re_alloc should be
676 ! deallocated by dealloc.
677 ! ==================================================================---
678-! SUBROUTINE alloc_count( delta_size, type, name, routine )
679-! INPUT:
680-! integer :: delta_size : +/-size(array)
681-! + => allocation
682-! - => deallocation
683-! character :: type : 'I' => integer
684-! 'E' => integer*8
685-! 'R' => real*4
686-! 'D' => real*8
687-! 'L' => logical
688-! 'S' => character (string)
689-! INPUT (optional):
690-! character(len=*) :: name : Actual array name or a label for it
691-! character(len=*) :: routine : Name of the calling routine
692-! or routine section
693-! USAGE:
694-! integer, allocatable:: intArray(:)
695-! double precision,allocatable:: doubleArray(:)
696-! complex, allocatable:: complexArray(:)
697-! allocate( intArray(n), doubleArray(n), complexArray(n) )
698-! call alloc_count( +n, 'I', 'intArray', programName )
699-! call alloc_count( +n, 'D', 'doubleArray', programName )
700-! call alloc_count( +2*n, 'R', 'complexArray', programName )
701-! deallocate( intArray, doubleArray, complexArray )
702-! call alloc_count( -n, 'I', 'intArray', programName )
703-! call alloc_count( -n, 'D', 'doubleArray', programName )
704-! call alloc_count( -2*n, 'R', 'complexArray', programName )
705-!
706-! ==================================================================---
707-
708 MODULE alloc
709-
710- use precision, only: sp ! Single precision real type
711- use precision, only: dp ! Double precision real type
712- use parallel, only: Node ! My processor node index
713- use parallel, only: Nodes ! Number of parallel processors
714- use parallel, only: ionode ! Am I the I/O processor?
715- use parallel, only: parallel_init ! Initialize parallel variables
716- use sys, only: die ! Termination routine
717- use m_io, only: io_assign ! Get and reserve an available IO unit
718-#ifdef MPI
719-! use mpi_siesta
720- use mpi_siesta, only: MPI_AllGather
721- use mpi_siesta, only: MPI_Barrier
722- use mpi_siesta, only: MPI_Bcast
723- use mpi_siesta, only: MPI_Comm_World
724- use mpi_siesta, only: MPI_double_precision
725- use mpi_siesta, only: MPI_integer
726- use mpi_siesta, only: MPI_character
727-#endif
728-
729+!
730+! This module has no external build dependencies
731+! Final executables must resolve the symbols for the two handlers
732+! alloc_memory_event
733+! alloc_error_report
734+! with interfaces specified below
735+!
736 implicit none
737
738 PUBLIC :: &
739 alloc_default, &! Sets allocation defaults
740- alloc_report, &! Sets log report defaults
741 re_alloc, &! Allocation/reallocation
742 de_alloc, &! Deallocation
743- alloc_count, &! Memory counting for external allocs
744 allocDefaults ! Derived type to hold allocation defaults
745
746 PRIVATE ! Nothing is declared public beyond this point
747
748+integer, parameter :: sp = selected_real_kind(5,10)
749+integer, parameter :: dp = selected_real_kind(10,100)
750+
751+! Interfaces to external routines that must be provided
752+! by the calling program
753+!
754+interface
755+ ! Error message and integer code
756+ ! If 'code' is 0, this is the last call in a series
757+ ! (see below for usage)
758+ subroutine alloc_error_report(str,code)
759+ character(len=*), intent(in) :: str
760+ integer, intent(in) :: code
761+ end subroutine alloc_error_report
762+ !
763+ ! Logger for memory events
764+ !
765+ subroutine alloc_memory_event(bytes,name)
766+ integer, intent(in) :: bytes
767+ character(len=*), intent(in) :: name
768+ end subroutine alloc_memory_event
769+end interface
770+
771 interface de_alloc
772 module procedure &
773 dealloc_i1, dealloc_i2, dealloc_i3, &
774@@ -265,14 +207,6 @@
775 DEFAULT_NAME = 'unknown_name' ! Array name default
776 character(len=*), parameter :: &
777 DEFAULT_ROUTINE = 'unknown_routine' ! Routine name default
778- integer, save :: &
779- REPORT_LEVEL = 0, &! Level (detail) of allocation report
780- REPORT_UNIT = 0 ! Output file unit for report
781- character(len=50), save :: &
782- REPORT_FILE = 'alloc_report' ! Output file name for report
783- real(dp), save :: &
784- REPORT_THRESHOLD = 0 ! Memory threshold (in bytes) to print
785- ! the memory use of any given array
786
787 ! Derived type to hold allocation default options
788 type allocDefaults
789@@ -286,28 +220,6 @@
790 ! Object to hold present allocation default options
791 type(allocDefaults), save :: DEFAULT
792
793- ! Internal auxiliary type for a binary tree
794- type TREE
795- character(len=80) :: name ! Name of an allocated array
796- real(DP) :: mem ! Present memory use of the array
797- real(DP) :: max ! Maximum memory use of the array
798- real(DP) :: peak ! Memory use of the array during
799- ! peak of total memory
800- type(TREE), pointer :: left ! Pointer to data of allocated arrays
801- ! preceeding in alphabetical order
802- type(TREE), pointer :: right ! Pointer to data of allocated arrays
803- ! trailing in alphabetical order
804- end type TREE
805-
806- ! Global variables used to store allocation data
807- real(DP), parameter :: MBYTE = 1.e6_dp
808- type(TREE), pointer, save :: REPORT_TREE
809- real(DP), save :: TOT_MEM = 0._dp
810- real(DP), save :: PEAK_MEM = 0._dp
811- character(len=80), save :: PEAK_ARRAY = ' '
812- character(len=32), save :: PEAK_ROUTINE = ' '
813- integer, save :: MAX_LEN = 0
814-
815 ! Other common variables
816 integer :: IERR
817 logical :: ASSOCIATED_ARRAY, NEEDS_ALLOC, NEEDS_COPY, NEEDS_DEALLOC
818@@ -336,74 +248,6 @@
819 END SUBROUTINE alloc_default
820
821 ! ==================================================================
822-
823-SUBROUTINE alloc_report( level, unit, file, printNow, threshold )
824-
825-implicit none
826-
827-integer, optional, intent(in) :: level, unit
828-character(len=*), optional, intent(in) :: file
829-logical, optional, intent(in) :: printNow
830-real(dp), optional, intent(in) :: threshold
831-
832-logical open
833-
834-#ifdef MPI
835-integer MPIerror
836-#endif
837-
838-if (present(level)) then
839- REPORT_LEVEL = level
840-end if
841-
842-if (node == 0) then
843- if (present(unit)) then ! Assume that unit has been open outside
844- if (unit > 0) then
845- REPORT_UNIT = unit
846- if (present(file)) then
847- REPORT_FILE = file
848- else
849- REPORT_FILE = 'unknown'
850- end if
851- end if
852- else if (present(file)) then ! If file is the same, do nothing
853- if (file /= REPORT_FILE) then ! Check if file was open outside
854- REPORT_FILE = file
855- inquire( file=REPORT_FILE, opened=open, number=REPORT_UNIT )
856- if (.not.open) then ! Open new file
857- call io_assign(REPORT_UNIT)
858- open( REPORT_UNIT, file=REPORT_FILE, status='unknown')
859- write(REPORT_UNIT,*) ' ' ! Overwrite previous reports
860- end if
861- end if
862- else if (REPORT_UNIT==0) then ! No unit has been open yet
863- REPORT_FILE = 'alloc_report'
864- call io_assign(REPORT_UNIT)
865- open( REPORT_UNIT, file=REPORT_FILE, status='unknown')
866- write(REPORT_UNIT,*) ' ' ! Overwrite previous reports
867- end if
868-end if
869-
870-#ifdef MPI
871-! Distribute information to other nodes and open REPORT_UNIT
872-call MPI_Bcast(REPORT_LEVEL,1,MPI_integer,0,MPI_Comm_World,MPIerror)
873-call MPI_Bcast(REPORT_UNIT,1,MPI_integer,0,MPI_Comm_World,MPIerror)
874-call MPI_Bcast(REPORT_FILE,50,MPI_character,0,MPI_Comm_World,MPIerror)
875-! JMS: open file only in node 0
876-!if (node > 0) then
877-! open( REPORT_UNIT, file=REPORT_FILE )
878-!end if
879-#endif
880-
881-if (present(threshold)) REPORT_THRESHOLD = threshold
882-
883-if (present(printNow)) then
884- if (printNow) call print_report( )
885-end if
886-
887-END SUBROUTINE alloc_report
888-
889-! ==================================================================
890 ! Integer array reallocs
891 ! ==================================================================
892
893@@ -447,7 +291,6 @@
894 if (NEEDS_DEALLOC .and. .not.NEEDS_COPY) then
895 call alloc_count( -size(old_array), type, name, routine )
896 deallocate(old_array,stat=IERR)
897- call alloc_err( IERR, name, routine, old_bounds )
898 end if
899
900 ! Allocate new space
901@@ -1816,8 +1659,53 @@
902
903 ! ==================================================================
904
905+SUBROUTINE alloc_err( ierr, name, routine, bounds )
906+implicit none
907+
908+integer, intent(in) :: ierr
909+character(len=*), optional, intent(in) :: name
910+character(len=*), optional, intent(in) :: routine
911+integer, dimension(:,:), optional, intent(in) :: bounds
912+
913+integer i
914+character(len=128) :: msg
915+
916+if (ierr/=0) then
917+ write(msg,*) 'alloc_err: allocate status error', ierr
918+ call alloc_error_report(trim(msg),1)
919+ if (present(name).and.present(routine)) then
920+ write(msg,*) 'alloc_err: array ', name, &
921+ ' requested by ', routine
922+ call alloc_error_report(trim(msg),2)
923+ elseif (present(name)) then
924+ write(msg,*) 'alloc_err: array ', name, &
925+ ' requested by unknown'
926+ call alloc_error_report(trim(msg),3)
927+ elseif (present(routine)) then
928+ write(msg,*) 'alloc_err: array unknown', &
929+ ' requested by ', routine
930+ call alloc_error_report(trim(msg),4)
931+ endif
932+ if (present(bounds)) then
933+ write(msg,'(a,i3,2i10)') ('alloc_err: dim, lbound, ubound:', &
934+ i,bounds(1,i),bounds(2,i), &
935+ i=1,size(bounds,dim=2))
936+ call alloc_error_report(trim(msg),5)
937+ endif
938+ call alloc_error_report("alloc_err: end of error report",0)
939+end if
940+
941+END SUBROUTINE alloc_err
942+
943+! ==================================================================
944+
945 SUBROUTINE alloc_count( delta_size, type, name, routine )
946
947+!
948+! This version simply computes the total size and calls
949+! the external routine alloc_memory_event with the size
950+! in bytes and a string identifier of the form 'routine@name'.
951+!
952 implicit none
953
954 integer, intent(in) :: delta_size ! +/-size(array)
955@@ -1830,114 +1718,32 @@
956 character(len=*), optional, intent(in) :: name
957 character(len=*), optional, intent(in) :: routine
958
959-character(len=32) :: aname, rname
960-character(len=1) :: memType, task
961-real(DP) :: delta_mem
962-logical :: newPeak
963-logical, save :: header_written = .false.
964-logical, save :: tree_nullified = .false.
965-integer :: memSize
966-
967-! Set routine name
968-if (present(routine)) then
969- rname = routine
970-else
971- rname = DEFAULT%routine
972-end if
973-
974-! Call siesta counting routine 'memory'
975-! Switched off in Aug.2009, and made 'memory' call alloc_count instead
976-! if (delta_size > 0) then
977-! task = 'A'
978-! else
979-! task = 'D'
980-! end if
981-! select case( type )
982-! case ('R') ! Real --> single
983-! memType = 'S'
984-! memSize = abs(delta_size)
985-! case ('S') ! Character (string) --> integer/4
986-! memType = 'I'
987-! memSize = abs(delta_size) / type_mem('I')
988-! case default
989-! memType = type
990-! memSize = abs(delta_size)
991-! end select
992-! call memory( task, memType, memSize, trim(rname) )
993-
994-
995-if (REPORT_LEVEL <= 0) return
996+character(len=32) :: aname
997+integer :: bytes
998
999 ! Compound routine+array name
1000 if (present(name) .and. present(routine)) then
1001- aname = trim(routine)//' '//name
1002+ aname = trim(routine)//'@'//name
1003 else if (present(name) .and. DEFAULT%routine/=DEFAULT_ROUTINE) then
1004- aname = trim(DEFAULT%routine)//' '//name
1005+ aname = trim(DEFAULT%routine)//'@'//name
1006 else if (present(name)) then
1007- aname = name
1008+ aname = trim(DEFAULT_ROUTINE)//'@'//name
1009 else if (present(routine)) then
1010- aname = trim(routine)//' '//DEFAULT_NAME
1011+ aname = trim(routine)//'@'//DEFAULT_NAME
1012 else if (DEFAULT%routine/=DEFAULT_ROUTINE) then
1013- aname = trim(DEFAULT%routine)//' '//DEFAULT_NAME
1014+ aname = trim(DEFAULT%routine)//'@'//DEFAULT_NAME
1015 else
1016- aname = DEFAULT_ROUTINE//' '//DEFAULT_NAME
1017+ aname = DEFAULT_ROUTINE//'@'//DEFAULT_NAME
1018 end if
1019
1020-MAX_LEN = max( MAX_LEN, len(trim(aname)) )
1021-
1022 ! Find memory increment and total allocated memory
1023-delta_mem = delta_size * type_mem(type)
1024-TOT_MEM = TOT_MEM + delta_mem
1025-if (TOT_MEM > PEAK_MEM+0.5_dp) then
1026- newPeak = .true.
1027- PEAK_MEM = TOT_MEM
1028- PEAK_ARRAY = aname
1029- PEAK_ROUTINE = rname
1030-! print'(/,a,f18.6),a,/)',
1031-! 'alloc_count: Memory peak =', PEAK_MEM/MBYTE, ' Mbytes'
1032-else
1033- newPeak = .false.
1034-end if
1035-
1036-! Add/subtract/classify array memory
1037-if (REPORT_LEVEL > 1) then
1038- if (.not.tree_nullified) then
1039- nullify(report_tree)
1040- tree_nullified = .true.
1041- end if
1042- call tree_add( report_tree, aname, delta_mem )
1043- if (newPeak) call tree_peak( report_tree )
1044-end if
1045-
1046-! Print report, but only in node 0, as not all
1047-! processors may follow the same route here
1048-! The detail/extent of the report increses with the value of level:
1049-! level=0 : no report at all (the default)
1050-! level=1 : only total memory peak and where it occurred
1051-! level=2 : detailed report created but printed only upon request
1052-! level=3 : detailed report printed at every new memory peak
1053-! level=4 : print every individual reallocation or deallocation
1054-
1055-
1056-if (newPeak .and. (REPORT_LEVEL==1 .or. REPORT_LEVEL==3) .and. &
1057- node == 0) then
1058- call print_report(.false.)
1059-end if
1060-
1061-if (REPORT_LEVEL == 4 .and. node == 0) then
1062- if (.not.header_written) then
1063- write(REPORT_UNIT,'(/,a7,9x,1x,a4,28x,1x,2a15)') &
1064- 'Routine', 'Name', 'Incr. (MB)', 'Total (MB)'
1065- header_written = .true.
1066- end if
1067- write(REPORT_UNIT,'(a16,1x,a32,1x,2f15.6)') &
1068- rname, aname, delta_mem/MBYTE, TOT_MEM/MBYTE
1069-end if
1070-END SUBROUTINE alloc_count
1071-
1072-! ==================================================================
1073-
1074-INTEGER FUNCTION type_mem( var_type )
1075+bytes = delta_size * type_mem(type)
1076+
1077+call alloc_memory_event(bytes,trim(aname))
1078+
1079+CONTAINS
1080+
1081+ INTEGER FUNCTION type_mem( var_type )
1082 !
1083 ! It is not clear that the sizes assumed are universal for
1084 ! non-Cray machines...
1085@@ -1971,274 +1777,48 @@
1086 case default
1087 write(message,"(2a)") &
1088 'alloc_count: ERROR: unknown type = ', var_type
1089- call die(trim(message))
1090+ call alloc_error_report(trim(message),0)
1091 end select
1092
1093 END FUNCTION type_mem
1094
1095-! ==================================================================
1096-
1097-RECURSIVE SUBROUTINE tree_add( t, name, delta_mem )
1098-
1099-implicit none
1100-type(TREE), pointer :: t
1101-character(len=*), intent(in) :: name
1102-real(DP), intent(in) :: delta_mem
1103-
1104-logical, save :: warn_negative = .true.
1105-
1106-if (.not.associated(t)) then
1107- allocate( t )
1108- t%name = name
1109- t%mem = delta_mem
1110- t%max = delta_mem
1111- t%peak = 0._dp
1112- nullify( t%left, t%right )
1113-else if (name == t%name) then
1114- t%mem = t%mem + delta_mem
1115- ! The abs is to handle the case of apparent de_allocs without re_allocs,
1116- ! caused by routine/name argument mismatches
1117- if (abs(t%mem) > abs(t%max)) t%max = t%mem
1118-else if ( llt(name,t%name) ) then
1119- call tree_add( t%left, name, delta_mem )
1120-else
1121- call tree_add( t%right, name, delta_mem )
1122-end if
1123-
1124-if (warn_negative .and. t%mem<0._dp) then
1125- call parallel_init() ! Make sure that node and Nodes are initialized
1126- if (Node==0) then
1127- write(6,'(/,a,/,2a,/,a,f18.0,a)') &
1128- 'WARNING: alloc-realloc-dealloc name mismatch', &
1129- ' Name: ', trim(name), &
1130- ' Size: ', t%mem, ' Bytes'
1131- if (Nodes>1) write(6,'(9x,a,i6)') 'Node:', Node
1132- write(6,'(9x,a)') 'Subsequent mismatches will not be reported'
1133- warn_negative = .false. ! Print this warning only once
1134- end if
1135-end if
1136-
1137-END SUBROUTINE tree_add
1138-
1139-! ==================================================================
1140-
1141-RECURSIVE SUBROUTINE tree_peak( t )
1142-
1143-implicit none
1144-type(TREE), pointer :: t
1145-
1146-if (.not.associated(t)) return
1147-
1148-t%peak = t%mem
1149-call tree_peak( t%left )
1150-call tree_peak( t%right )
1151-
1152-END SUBROUTINE tree_peak
1153-
1154-! ==================================================================
1155-
1156-RECURSIVE SUBROUTINE tree_print( t )
1157-
1158-implicit none
1159-type(TREE), pointer :: t
1160-
1161-if (.not.associated(t)) return
1162-
1163-call tree_print( t%left )
1164-
1165-if (abs(t%max) >= REPORT_THRESHOLD) then
1166- write(REPORT_UNIT,'(a,1x,3f15.6,f9.2)') &
1167- t%name(1:MAX_LEN), t%mem/MBYTE, t%max/MBYTE, t%peak/MBYTE, &
1168- 100._dp * t%peak / (PEAK_MEM + tiny(PEAK_MEM) )
1169-end if
1170-
1171-call tree_print( t%right )
1172-
1173-END SUBROUTINE tree_print
1174-
1175-! ==================================================================
1176-
1177-SUBROUTINE print_report(all)
1178-
1179-implicit none
1180-
1181-! Whether MPI reductions should be performed
1182-! If, not then ensure that no MPI calls are performed
1183-logical, intent(in), optional :: all
1184-
1185-character(len=80) :: string = 'Name'
1186-character :: date*8, time*10, zone*5
1187-integer :: iNode, peakNode
1188-real(dp) :: maxPeak
1189-real(dp),allocatable:: nodeMem(:), nodePeak(:)
1190-logical :: lall
1191-
1192-#ifdef MPI
1193-integer :: MPIerror
1194-#endif
1195-
1196-! Enables parallel call of print-report
1197-lall = .true.
1198-if ( present(all) ) lall = all
1199-
1200-! Only if MPI should all be used
1201-if ( lall ) then
1202-! Make sure that variables node and Nodes are initialized
1203-call parallel_init()
1204-end if
1205-
1206-! Allocate and initialize two small arrays
1207-allocate( nodeMem(0:Nodes-1), nodePeak(0:Nodes-1) )
1208-! initialize (in case all == .false.)
1209-nodeMem = 0._dp
1210-nodePeak = 0._dp
1211-
1212-! Initializations for Nodes=1 (serial case)
1213-nodeMem(node) = TOT_MEM
1214-nodePeak(node) = PEAK_MEM
1215-peakNode = node
1216-
1217-! In parallel, find the memory values of all nodes
1218-#ifdef MPI
1219-if (Nodes > 1 .and. lall ) then
1220- ! Gather the present and peak memories of all nodes
1221- call MPI_AllGather( TOT_MEM, 1, MPI_double_precision, &
1222- nodeMem, 1, MPI_double_precision, &
1223- MPI_COMM_WORLD, MPIerror )
1224- call MPI_AllGather( PEAK_MEM, 1, MPI_double_precision, &
1225- nodePeak, 1, MPI_double_precision, &
1226- MPI_COMM_WORLD, MPIerror )
1227- ! Find the node with the highest peak of memory
1228- maxPeak = 0
1229- do iNode = 0,Nodes-1
1230- if (nodePeak(iNode) > maxPeak) then
1231- peakNode = iNode
1232- maxPeak = nodePeak(iNode)
1233- end if
1234- end do ! iNode
1235- ! Change the writing node for the peak-node information
1236- if (node==0 .and. peakNode/=0) close( unit=REPORT_UNIT )
1237- call MPI_Barrier( MPI_COMM_WORLD, MPIerror )
1238- if (node==peakNode .and. peakNode/=0) &
1239- open( unit=REPORT_UNIT, file=REPORT_FILE, &
1240- status='unknown', position='append' )
1241-end if ! (Nodes>1)
1242-#endif
1243-
1244-! The report is printed by the highest-peak node
1245-if (node == peakNode) then
1246-
1247- ! AG: Commented out to allow multiple batches of information
1248- ! if (REPORT_LEVEL < 4) rewind(REPORT_UNIT)
1249-
1250- call date_and_time( date, time, zone )
1251-
1252- write(REPORT_UNIT,'(/,a,16a)') &
1253- 'Allocation summary at ', &
1254- date(1:4),'/',date(5:6),'/',date(7:8),' ', &
1255- time(1:2),':',time(3:4),':',time(5:10),' ', &
1256- zone(1:3),':',zone(4:5)
1257-
1258- if (Nodes > 1) then
1259- write(REPORT_UNIT,'(/,(a,f18.6,a))') &
1260- 'Present memory all nodes : ', sum(nodeMem)/MBYTE, ' MB', &
1261- 'Added peak mem all nodes : ', sum(nodePeak)/MBYTE, ' MB', &
1262- 'Min peak memory in a node: ', minval(nodePeak)/MBYTE, ' MB', &
1263- 'Max peak memory in a node: ', maxval(nodePeak)/MBYTE, ' MB'
1264-! Impractical for many nodes:
1265-! write(REPORT_UNIT,'(/,a,/,(i6,f12.6))') &
1266-! 'Memory peaks of individual nodes (Mb):', &
1267-! (iNode,nodePeak(iNode)/MBYTE,iNode=0,Nodes-1)
1268- write(REPORT_UNIT,'(/,a,i6)') &
1269- 'Maximum peak of memory occurred in node:', peakNode
1270- end if
1271-
1272- write(REPORT_UNIT,'(2(/,a,f18.6,a),/,2a,/,2a)') &
1273- 'Present memory allocation: ', TOT_MEM/MBYTE, ' MB', &
1274- 'Maximum memory allocation: ', PEAK_MEM/MBYTE, ' MB', &
1275- 'Occurred after allocating: ', trim(PEAK_ARRAY), &
1276- 'In routine: ', trim(PEAK_ROUTINE)
1277-
1278- if (REPORT_LEVEL > 1) then
1279- if (REPORT_THRESHOLD > 0._dp) then
1280- write(REPORT_UNIT,'(/,a,f12.6,a,/,a,1x,3a15,a9)') &
1281- 'Allocated sizes (in MByte) of arrays larger than ', &
1282- REPORT_THRESHOLD/MBYTE, ' MB:', &
1283- string(1:MAX_LEN), 'Present', 'Maximum', 'At peak', '%'
1284- else
1285- write(REPORT_UNIT,'(/,a,/,a,1x,3a15,a9)') &
1286- 'Allocated array sizes (in MByte):', &
1287- string(1:MAX_LEN), 'Present', 'Maximum', 'At peak', '%'
1288- end if
1289- call tree_print( report_tree )
1290- end if
1291-
1292-end if ! (node == peakNode)
1293-
1294-! Change again the writing node for the rest of the report
1295-#ifdef MPI
1296-if (node==peakNode .and. peakNode/=0) close( unit=REPORT_UNIT )
1297-if (lall) call MPI_Barrier( MPI_COMM_WORLD, MPIerror )
1298-if (node==0 .and. peakNode/=0) &
1299- open( unit=REPORT_UNIT, file=REPORT_FILE, &
1300- status='unknown', position='append' )
1301-#endif
1302-
1303-deallocate( nodeMem, nodePeak )
1304-
1305-END SUBROUTINE print_report
1306-
1307-! ==================================================================
1308-
1309-SUBROUTINE alloc_err( ierr, name, routine, bounds )
1310-#ifdef DEBUG
1311- use debugMpi, only : mpiUnit
1312-#endif
1313-implicit none
1314-
1315-integer, intent(in) :: ierr
1316-character(len=*), optional, intent(in) :: name
1317-character(len=*), optional, intent(in) :: routine
1318-integer, dimension(:,:), optional, intent(in) :: bounds
1319-
1320-integer i
1321-
1322-if (ierr/=0) then
1323- if (ionode) print*, 'alloc_err: allocate status error', ierr
1324- if (present(name).and.present(routine)) then
1325- if (ionode) print*, 'alloc_err: array ', name, &
1326- ' requested by ', routine
1327- elseif (present(name)) then
1328- if (ionode) print*, 'alloc_err: array ', name, &
1329- ' requested by unknown'
1330- elseif (present(routine)) then
1331- if (ionode) print* , 'alloc_err: array unknown', &
1332- ' requested by ', routine
1333- endif
1334- if (ionode.and.present(bounds)) &
1335- print '(a,i3,2i10)', ('alloc_err: dim, lbound, ubound:', &
1336- i,bounds(1,i),bounds(2,i), &
1337- i=1,size(bounds,dim=2))
1338-#ifdef DEBUG
1339- write(mpiUnit,*) 'alloc_err: allocate status error', ierr
1340- if (present(name).and.present(routine)) then
1341- write(mpiUnit,*) 'alloc_err: array ', name, ' requested by ', routine
1342- elseif (present(name)) then
1343- write(mpiUnit,*) 'alloc_err: array ', name, ' requested by unknown'
1344- elseif (present(routine)) then
1345- write(mpiUnit,*) 'alloc_err: array unknown requested by ', routine
1346- endif
1347- write(mpiUnit,'(a,i3,2i10)') ('alloc_err: dim, lbound, ubound:', &
1348- i,bounds(1,i),bounds(2,i), &
1349- i=1,size(bounds,dim=2))
1350- call pxfflush(mpiUnit)
1351-#endif
1352-
1353- call die('alloc_err: allocate error')
1354-end if
1355-
1356-END SUBROUTINE alloc_err
1357-
1358-! ==================================================================
1359+END SUBROUTINE alloc_count
1360
1361 END MODULE alloc
1362+
1363+#ifdef __TEST__MODULE__ALLOC__
1364+! Optional test code
1365+!
1366+program testalloc
1367+use alloc, only: re_alloc, de_alloc
1368+
1369+real, pointer :: x(:) => null()
1370+real(kind=kind(1.d0)), pointer :: y(:,:) => null()
1371+
1372+call re_alloc(x,1,10,"x","testalloc")
1373+call re_alloc(y,-3,4,1,3,"y","testalloc")
1374+print *, "Shape of x: ", shape(x)
1375+print *, "Shape of y: ", shape(y)
1376+call de_alloc(x,"x","testalloc")
1377+call de_alloc(y,"y","testalloc")
1378+
1379+end program testalloc
1380+!
1381+! Handlers
1382+! Note: In systems with weak symbols, these handlers
1383+! could be compiled marked as such. (Future extension)
1384+!
1385+subroutine alloc_memory_event(bytes,name)
1386+integer, intent(in) :: bytes
1387+character(len=*), intent(in) :: name
1388+write(*,*) "alloc: allocated ", bytes, "bytes for "//trim(name)
1389+end subroutine alloc_memory_event
1390+
1391+subroutine alloc_error_report(name,code)
1392+character(len=*), intent(in) :: name
1393+integer, intent(in) :: code
1394+write(*,*) "alloc error: "//trim(name)
1395+end subroutine alloc_error_report
1396+
1397+#endif
1398+
1399
1400=== added file 'Src/alloc_error_report.F'
1401--- Src/alloc_error_report.F 1970-01-01 00:00:00 +0000
1402+++ Src/alloc_error_report.F 2016-07-19 08:21:24 +0000
1403@@ -0,0 +1,55 @@
1404+!--------------------------------------------------
1405+! Stand-alone routine to capture error messages from
1406+! the alloc module
1407+!
1408+! This functionality could be made more general,
1409+! and use a uniform interface for all the utility
1410+! modules developed in-house. (Let's say, call it
1411+! 'error_report' with severity arguments, etc).
1412+!
1413+! Each program using the alloc module needs to
1414+! provide a routine with the proper interface, but
1415+! accomodating the needs and conventions of the program.
1416+! For example, in Siesta:
1417+!
1418+! - The tagging of the message by Node.
1419+! - The use of 'unit 6' as output and '0' as error.
1420+!
1421+! Routines using this functionality should include
1422+! the following
1423+!
1424+! subroutine alloc_error_report(str,code)
1425+! character(len=*), intent(in) :: str
1426+! integer, intent(in) :: code
1427+! end subroutine alloc_error_report
1428+!
1429+!------------------------------------------------------
1430+
1431+ subroutine alloc_error_report(str,code)
1432+
1433+ use parallel, only : Node
1434+
1435+ character(len=*), intent(in) :: str
1436+ integer, intent(in) :: code
1437+
1438+! Even though formally (in MPI 1.X), only the master node
1439+! can do I/O, in those systems that allow it having each
1440+! node state its complaint can be useful.
1441+
1442+ write(6,'(a,i0,1x,a)') 'Node: ', Node, trim(str)
1443+ write(0,'(a,i0,1x,a)') 'Node: ', Node, trim(str)
1444+
1445+ ! The convention for this reporter, which can
1446+ ! send multi-call messages, is that code=0
1447+ ! signals the end of the series
1448+ ! We choose to kill the program
1449+ !
1450+ ! This is actually too stringent, as a given failed
1451+ ! allocation could be handled more gracefully at
1452+ ! the point at which it is made. But in absence of
1453+ ! a 'stat' argument for the re_alloc and de_alloc
1454+ ! routines, this is the only thing we can do....
1455+ !
1456+ if (code == 0) call die(str)
1457+
1458+ end subroutine alloc_error_report
1459
1460=== added file 'Src/alloc_memory_event.F'
1461--- Src/alloc_memory_event.F 1970-01-01 00:00:00 +0000
1462+++ Src/alloc_memory_event.F 2016-07-19 08:21:24 +0000
1463@@ -0,0 +1,30 @@
1464+!--------------------------------------------------
1465+! Stand-alone routine to capture memory events from
1466+! the alloc module
1467+!
1468+! Each program using the alloc module needs to
1469+! provide a routine with the proper interface, but
1470+! accomodating the needs and conventions of the program.
1471+! For example, in Siesta
1472+!
1473+! - The use of the memory_log module for reports
1474+!
1475+! Routines using this functionality should include
1476+! the following
1477+!
1478+! subroutine alloc_memory_event(str,code)
1479+! character(len=*), intent(in) :: str
1480+! integer, intent(in) :: code
1481+! end subroutine alloc_memory_event
1482+!
1483+!------------------------------------------------------
1484+
1485+ subroutine alloc_memory_event(bytes,name)
1486+ use memory_log, only: memory_event
1487+
1488+ integer, intent(in) :: bytes
1489+ character(len=*), intent(in) :: name
1490+
1491+ call memory_event(bytes,name)
1492+
1493+ end subroutine alloc_memory_event
1494
1495=== modified file 'Src/atom.F'
1496--- Src/atom.F 2016-07-12 13:38:13 +0000
1497+++ Src/atom.F 2016-07-19 08:21:24 +0000
1498@@ -48,8 +48,8 @@
1499 use fdf
1500 use m_ncps, only: pseudopotential_t => froyen_ps_t
1501 #ifndef BSC_CELLXC
1502- use siestaXC, only: atomXC ! XC for a spherical charge
1503- use siestaXC, only: getXC ! Returns the XC functional to be used
1504+ use gridXC, only: atomXC=>gridxc_atomXC ! XC for a spherical charge
1505+ use gridXC, only: getXC=>gridxc_getXC ! Returns the XC functional to be used
1506 #endif /* ! BSC_CELLXC */
1507
1508 implicit none
1509
1510=== modified file 'Src/broyden_optim.F'
1511--- Src/broyden_optim.F 2016-01-25 16:00:16 +0000
1512+++ Src/broyden_optim.F 2016-07-19 08:21:24 +0000
1513@@ -68,7 +68,7 @@
1514 $ broyden_destroy, broyden_init,
1515 $ broyden_is_setup
1516
1517- use m_memory, only: memory, mem_stat
1518+ use memory_log, only: memory, mem_stat
1519 use parallel, only : ionode
1520
1521 ! Subroutine arguments:
1522
1523=== modified file 'Src/cell_fire_optim.F'
1524--- Src/cell_fire_optim.F 2016-01-25 16:00:16 +0000
1525+++ Src/cell_fire_optim.F 2016-07-19 08:21:24 +0000
1526@@ -18,7 +18,7 @@
1527 use m_fire
1528 use siesta_options, only: dt
1529
1530- use m_memory, only: memory, mem_stat
1531+ use memory_log, only: memory, mem_stat
1532 use parallel, only : ionode
1533
1534 implicit none
1535
1536=== modified file 'Src/cellxc_mod.F'
1537--- Src/cellxc_mod.F 2016-01-25 16:00:16 +0000
1538+++ Src/cellxc_mod.F 2016-07-19 08:21:24 +0000
1539@@ -12,7 +12,7 @@
1540 CONTAINS
1541 subroutine setGGA( )
1542 #ifndef BSC_CELLXC
1543- use siestaXC, only : getXC ! Returns the XC functional used
1544+ use gridXC, only : gridxc_getXC ! Returns the XC functional used
1545 #else /* BSC_CELLXC */
1546 use bsc_xcmod, only : nXCfunc, XCfunc
1547 #endif /* BSC_CELLXC */
1548@@ -28,7 +28,7 @@
1549
1550 !---------------------------------------------------------------------- BEGIN
1551 #ifndef BSC_CELLXC
1552- call getXC( nXCfunc, XCfunc, XCauth )
1553+ call gridxc_getXC( nXCfunc, XCfunc, XCauth )
1554 #endif /* ! BSC_CELLXC */
1555 do nf = 1,nXCfunc
1556 if ( XCfunc(nf).eq.'GGA' .or. XCfunc(nf).eq.'gga') then
1557
1558=== modified file 'Src/dhscf.F'
1559--- Src/dhscf.F 2016-01-25 16:00:16 +0000
1560+++ Src/dhscf.F 2016-07-19 08:21:24 +0000
1561@@ -64,7 +64,7 @@
1562 use mesh, only : xdsp, nsm, nsp
1563 use parsing
1564 #ifndef BSC_CELLXC
1565- use siestaXC, only : getXC ! Returns the XC functional used
1566+ use gridXC, only : getXC=>gridxc_getXC ! Returns the XC functional used
1567 #else /* BSC_CELLXC */
1568 use bsc_xcmod, only : nXCfunc, XCauth
1569 #endif /* BSC_CELLXC */
1570@@ -546,9 +546,9 @@
1571 use m_partial_charges, only: want_partial_charges
1572 #ifndef BSC_CELLXC
1573
1574- use siestaXC, only : cellXC ! Finds xc energy and potential
1575- use siestaXC, only : myMeshBox ! Returns my processor mesh box
1576- use siestaXC, only : jms_setMeshDistr => setMeshDistr
1577+ use gridXC, only : cellXC=>gridxc_cellXC ! Finds xc energy and potential
1578+ use gridXC, only : myMeshBox ! Returns my processor mesh box
1579+ use gridXC, only : jms_setMeshDistr => setMeshDistr
1580 ! Sets a distribution of mesh
1581 ! points over parallel processors
1582 #endif /* BSC_CELLXC */
1583
1584=== renamed file 'Src/memoryinfo.F' => 'Src/diagmemory.F'
1585--- Src/memoryinfo.F 2016-01-25 16:00:16 +0000
1586+++ Src/diagmemory.F 2016-07-19 08:21:24 +0000
1587@@ -5,51 +5,6 @@
1588 ! or http://www.gnu.org/copyleft/gpl.txt.
1589 ! See Docs/Contributors.txt for a list of contributors.
1590 !
1591- module memoryinfo
1592-
1593-C
1594-C WordsInteger = number of words of memory for integer variables
1595-C WordsSP = number of words of memory for single precision variables
1596-C WordsDP = number of words of memory for double precision variables
1597-C WordsLogical = number of words of memory for logical variables
1598-C WordsSC = number of words of memory for single complex variables
1599-C WordsDC = number of words of memory for double complex variables
1600-C PeakMemory = maximum amount of dynamic memory used
1601-C PeakRoutine = routine name where memory peak was reached
1602-C ByteSize = array of values specifying the size of a word for
1603-C each data type
1604-C
1605- implicit none
1606-
1607- integer*8, save ::
1608- . WordsInteger, WordsSP, WordsDP, WordsLogical, WordsSC, WordsDC,
1609- . WordsString, WordsLongInt,
1610- . PeakMemory, CurrentMemory
1611-
1612- character(len=30), save ::
1613- . PeakRoutine
1614-
1615- data
1616- . WordsInteger / 0 /,
1617- . WordsSP / 0 /,
1618- . WordsDP / 0 /,
1619- . WordsLogical / 0 /,
1620- . WordsSC / 0 /,
1621- . WordsDC / 0 /,
1622- . WordsString / 0 /,
1623- . WordsLongInt / 0 /,
1624- . PeakMemory / 0 /,
1625- . CurrentMemory / 0 /
1626-
1627- integer, parameter, dimension(8) :: ByteSize =
1628-#ifdef OLD_CRAY
1629- . (/8,8,8,8,8,16,8,8/)
1630-#else
1631- . (/4,4,8,4,8,16,4,8/)
1632-#endif
1633-
1634- end module memoryinfo
1635-
1636 module diagmemory
1637 C
1638 C Stores the factor used to scale the default memory in rdiag/cdiag
1639
1640=== modified file 'Src/diagon.F'
1641--- Src/diagon.F 2016-01-25 16:00:16 +0000
1642+++ Src/diagon.F 2016-07-19 08:21:24 +0000
1643@@ -98,7 +98,7 @@
1644 use m_diagon, only : qspiral, spiral, frstme
1645 use fdf
1646 use alloc
1647- use m_memory
1648+ use memory_log
1649 #ifdef MPI
1650 use m_diagon, only : paralleloverk
1651 use mpi_siesta, only : mpi_bcast, mpi_comm_world,
1652
1653=== modified file 'Src/fft.F'
1654--- Src/fft.F 2016-01-25 16:00:16 +0000
1655+++ Src/fft.F 2016-07-19 08:21:24 +0000
1656@@ -53,8 +53,8 @@
1657 use sys, only : die
1658 use alloc, only : re_alloc, de_alloc
1659 use mesh, only : nsm
1660- use fft1d, only : gpfa ! 1-D FFT routine
1661- use fft1d, only : setgpfa ! Sets gpfa routine
1662+ use m_fft_gpfa, only : gpfa ! 1-D FFT routine
1663+ use m_fft_gpfa, only : setgpfa=>setgpfa_check ! Sets gpfa routine
1664 use m_timer, only : timer_start ! Start counting CPU time
1665 use m_timer, only : timer_stop ! Stop counting CPU time
1666 #ifdef MPI
1667
1668=== modified file 'Src/forhar.F'
1669--- Src/forhar.F 2016-01-25 16:00:16 +0000
1670+++ Src/forhar.F 2016-07-19 08:21:24 +0000
1671@@ -11,9 +11,9 @@
1672 #ifndef BSC_CELLXC
1673 use parallel, only : ProcessorY
1674 use mesh, only : NSM
1675- use siestaXC, only : cellXC ! Finds xc energy and potential
1676- use siestaXC, only : myMeshBox ! Returns my processor mesh box
1677- use siestaXC, only : jms_setMeshDistr => setMeshDistr
1678+ use gridXC, only : cellXC=>gridxc_cellXC ! Finds xc energy and potential
1679+ use gridXC, only : myMeshBox ! Returns my processor mesh box
1680+ use gridXC , only : jms_setMeshDistr => setMeshDistr
1681 ! Sets a distribution of mesh
1682 ! points over parallel processors
1683
1684
1685=== modified file 'Src/ldau_specs.f'
1686--- Src/ldau_specs.f 2016-06-29 04:22:46 +0000
1687+++ Src/ldau_specs.f 2016-07-19 08:21:24 +0000
1688@@ -658,8 +658,8 @@
1689 use basis_specs, only : restricted_grid
1690 use basis_specs, only : rmax_radial_grid
1691
1692- use siestaXC, only : setXC
1693- use siestaXC, only : atomXC
1694+ use gridXC, only : setXC=>gridxc_setXC
1695+ use gridXC, only : atomXC=>gridxc_atomXC
1696
1697 integer, intent(in) :: isp ! Species index
1698
1699
1700=== removed file 'Src/m_memory.F'
1701--- Src/m_memory.F 2016-01-25 16:00:16 +0000
1702+++ Src/m_memory.F 1970-01-01 00:00:00 +0000
1703@@ -1,134 +0,0 @@
1704-!
1705-! Copyright (C) 1996-2016 The SIESTA group
1706-! This file is distributed under the terms of the
1707-! GNU General Public License: see COPYING in the top directory
1708-! or http://www.gnu.org/copyleft/gpl.txt.
1709-! See Docs/Contributors.txt for a list of contributors.
1710-!
1711- module m_memory
1712-
1713- integer, public :: mem_stat ! For use in calls to allocate
1714- ! and deallocate
1715-
1716- public :: memory
1717- private
1718-
1719- CONTAINS
1720-
1721- subroutine memory( Task, Type, NElements, CallingRoutine,
1722- $ stat,id)
1723-C
1724-C This subroutine keeps track of information relating to the use
1725-C of dynamic memory
1726-C
1727-C Input :
1728-C
1729-C character*1 Task : job type = 'A' -> allocate
1730-C : 'D' -> deallocate
1731-C character*1 Type : type of variable = 'I' = integer
1732-C : 'S' = single precision real
1733-C : 'D' = double precision real
1734-C : 'X' = grid precision real
1735-C : 'L' = logical
1736-C : 'C' = single precision complex
1737-C : 'Z' = double precision complex
1738-C : 'S' = character data (we assume takes one word)
1739-C : 'E' = double precision integer
1740-C integer NElements : number of array elements being
1741-C : allocated/deallocated
1742-C character :
1743-C CallingRoutine : string containing the name of the calling routine
1744-C
1745-C Created by J.D. Gale, October 1999
1746-C
1747-C Stat and ID keyword arguments added by Alberto Garcia, 2005
1748-
1749- use memoryinfo
1750- use sys, only: die
1751- use parallel, only: Node
1752-
1753- implicit none
1754-
1755- integer, intent(in) :: NElements
1756- character(len=1), intent(in) :: Task, Type
1757- character(len=*), intent(in) :: CallingRoutine
1758- integer, intent(in), optional :: stat
1759- character(len=*), intent(in), optional :: id
1760-
1761-C Local variables
1762- integer Sign
1763-C
1764-C CAG
1765-C if (Node.eq.0) then
1766-C write(66,'(a,a,a,a,i10)') "---memory: ", CallingRoutine // " ",
1767-C $ task // " ",
1768-C $ type // " ", nelements
1769-C call flush(66)
1770-C endif
1771- if (present(stat)) then
1772- if (stat .ne. 0) then
1773- if (present(id)) then
1774- call die(Task // "-llocation failed in " //
1775- $ CallingRoutine // id)
1776- else
1777- call die(Task // "-llocation failed in " //
1778- $ CallingRoutine)
1779- endif
1780- endif
1781- endif
1782-
1783-C Assign sign of operation based on task
1784- if (Task .eq. 'A' .or. Task .eq. 'a') then
1785- Sign = +1
1786- else
1787- Sign = -1
1788- endif
1789-
1790-C Add number of elements to appropriate pointer
1791- if (Type .eq. 'I' .or. Type .eq. 'i') then
1792- WordsInteger = WordsInteger + Sign*NElements
1793- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(1)
1794- elseif (Type .eq. 'S' .or. Type .eq. 's') then
1795- WordsSP = WordsSP + Sign*NElements
1796- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(2)
1797- elseif (Type .eq. 'D' .or. Type .eq. 'd') then
1798- WordsDP = WordsDP + Sign*NElements
1799- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(3)
1800-!
1801-! Support for flexible precision in grid-related arrays
1802-!
1803- elseif (Type .eq. 'X' .or. Type .eq. 'x') then
1804-#ifdef GRID_DP
1805- WordsDP = WordsDP + Sign*NElements
1806- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(3)
1807-#else
1808- WordsSP = WordsSP + Sign*NElements
1809- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(2)
1810-#endif
1811-
1812- elseif (Type .eq. 'L' .or. Type .eq. 'l') then
1813- WordsLogical = WordsLogical + Sign*NElements
1814- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(4)
1815- elseif (Type .eq. 'C' .or. Type .eq. 'c') then
1816- WordsSC = WordsSC + Sign*NElements
1817- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(5)
1818- elseif (Type .eq. 'Z' .or. Type .eq. 'z') then
1819- WordsDC = WordsDC + Sign*NElements
1820- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(6)
1821- elseif (Type .eq. 'S' .or. Type .eq. 's') then
1822- WordsString = WordsString + Sign*NElements
1823- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(7)
1824- elseif (Type .eq. 'E' .or. Type .eq. 'e') then
1825- WordsLongInt = WordsLongInt + Sign*NElements
1826- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(8)
1827- endif
1828-
1829-C Check whether memory is greater than peak memory so far
1830- if (CurrentMemory .gt. PeakMemory) then
1831- PeakMemory = CurrentMemory
1832- PeakRoutine = CallingRoutine
1833- endif
1834-
1835- end subroutine memory
1836-
1837- end module m_memory
1838
1839=== modified file 'Src/m_timer.F90'
1840--- Src/m_timer.F90 2016-01-25 16:00:16 +0000
1841+++ Src/m_timer.F90 2016-07-19 08:21:24 +0000
1842@@ -12,6 +12,10 @@
1843 ! Provides utility routines for CPU timing
1844 ! Written by J.M.Soler. July 2009
1845 !===============================================================================
1846+
1847+ ! The user must provide an external function 'use_walltime_in_timer'
1848+ ! with the interface specified below to set the value of 'use_walltime'
1849+!
1850 ! Used MPI routines and parameters
1851 ! use mpi_siesta, only: MPI_AllGather
1852 ! use mpi_siesta, only: MPI_Bcast
1853@@ -97,6 +101,7 @@
1854 ! ALGORITHMS:
1855 ! Calls intrinsic routine cpu_time and stores the present time, associated
1856 ! to the prog name, for future use by timer_stop
1857+! If use_walltime is .true., it uses wall_time instead
1858 !===============================================================================
1859 ! SUBROUTINE timer_stop( prog )
1860 ! Stops counting time for a program or code section
1861@@ -226,6 +231,12 @@
1862
1863 PRIVATE ! Nothing is declared public beyond this point
1864
1865+ interface
1866+ function use_walltime_in_timer() result(use_walltime)
1867+ logical :: use_walltime
1868+ end function use_walltime_in_timer
1869+ end interface
1870+
1871 ! Parameters
1872 character(len=*),parameter:: myName = 'timer '
1873 character(len=*),parameter:: errHead = myName//'ERROR: '
1874@@ -246,6 +257,7 @@
1875 end type times_t
1876
1877 ! Module variables and arrays
1878+ logical, save :: use_walltime ! wall-time or cpu-time?
1879 real(dp),save :: minRepTime = 0.0_dp ! Min reported CPU time fraction
1880 integer, save :: nProgs=0 ! Number of timed programs
1881 type(times_t), target, save:: progData(maxProgs) ! Holds data of timed progs
1882@@ -287,8 +299,7 @@
1883 writingTimes = .true.
1884
1885 ! Find present CPU time and convert it to double precision
1886- call cpu_time( treal )
1887- timeNow = treal
1888+ call current_time(timeNow)
1889 totalTime = timeNow - time0
1890 call wall_time( wallTime )
1891 wallTime = wallTime - wallTime0
1892@@ -404,15 +415,17 @@
1893 'Calc: Sum, Avge, myNode, Avg/Max =', &
1894 sum(nodeCalTime), sum(nodeCalTime)/nNodes, totalCalTime, &
1895 sum(nodeCalTime)/nNodes / maxval(nodeCalTime)
1896-#ifdef MPI_TIMING
1897+
1898 write(iu,'(a,3f12.3,f8.3)') &
1899 'Comm: Sum, Avge, myNode, Avg/Max =', &
1900 sum(nodeComTime), sum(nodeComTime)/nNodes, totalComTime, &
1901 sum(nodeComTime)/nNodes / maxval(nodeComTime)
1902-#else
1903- totalComTime = huge(1.0_dp) ! Avoid division by zero in prog table output
1904- write(iu,'(a)') 'No communications time available. Compile with -DMPI_TIMING'
1905-#endif
1906+
1907+ if (totalComTime < 1.0e-4) then
1908+ ! Avoid division by zero in prog table output when not timing comms
1909+ totalComTime = huge(1.0_dp)
1910+ endif
1911+
1912 write(iu,'(a,3f12.3,f8.3)') &
1913 'Tot: Sum, Avge, myNode, Avg/Max =', &
1914 sum(nodeTotTime), sum(nodeTotTime)/nNodes, totalTime, &
1915@@ -471,13 +484,14 @@
1916
1917 ! Write total communications time
1918 if (myNode==writerNode) then
1919-#ifdef MPI_TIMING
1920+
1921+ if (totalComTime > huge(1.0_dp)/2.0_dp) then
1922+ ! Set back to 0
1923+ totalComTime = 0.0_dp
1924+ endif
1925 write(iu,'(a15,i9,2(f12.3,f9.4))') &
1926 'MPI total ', totalComCalls, &
1927 totalComTime, 1., totalComTime, totalComTime/totalTime
1928-#else
1929- write(iu,'(a)') 'No communications time available. Compile with -DMPI_TIMING'
1930-#endif
1931 endif ! (myNode==writerNode)
1932
1933
1934@@ -650,12 +664,11 @@
1935
1936 subroutine timer_init() ! Initialize timing
1937
1938-! Internal variables
1939- real :: treal
1940+ use_walltime = use_walltime_in_timer()
1941
1942 call wall_time( wallTime0 )
1943- call cpu_time( treal ) ! Notice single precision
1944- time0 = treal
1945+ call current_time(time0)
1946+
1947 nProgs = 0
1948
1949 ! (Re)initialize data array
1950@@ -717,9 +730,7 @@
1951 ! Do not change data if writing a report
1952 if (writingTimes) return
1953
1954-! Find present CPU time and convert it to double precision
1955- call cpu_time( treal ) ! Standard Fortran95
1956- timeNow = treal
1957+ call current_time(timeNow)
1958
1959 ! Find program index
1960 iProg = prog_index( prog )
1961@@ -757,9 +768,7 @@
1962 ! Do not change data if writing a report
1963 if (writingTimes) return
1964
1965-! Find present CPU time and convert it to double precision
1966- call cpu_time( treal ) ! Standard Fortran95
1967- timeNow = treal
1968+ call current_time(timeNow)
1969
1970 ! Find program index
1971 iProg = prog_index( prog, found )
1972@@ -818,6 +827,23 @@
1973 enddo
1974 end subroutine timer_all_stop
1975
1976+ !------------------------------------------------
1977+ subroutine current_time(t)
1978+ !
1979+ ! CPU or walltime, depending on the setting of 'use_walltime'
1980+ !
1981+ use m_walltime, only: wall_time
1982+ real(dp), intent(out) :: t
1983+
1984+ real :: treal ! for call to cpu_time
1985+
1986+ if (use_walltime) then
1987+ call wall_time(t)
1988+ else
1989+ call cpu_time(treal)
1990+ t = treal
1991+ endif
1992+ end subroutine current_time
1993
1994 END MODULE m_timer
1995
1996
1997=== modified file 'Src/memory.F'
1998--- Src/memory.F 2016-01-25 16:00:16 +0000
1999+++ Src/memory.F 2016-07-19 08:21:24 +0000
2000@@ -30,9 +30,8 @@
2001 C
2002 C Created by J.D. Gale, October 1999
2003 C
2004- use memoryinfo
2005 use parallel, only: Node
2006- use alloc, only: alloc_count
2007+ use memory_log, only: memory_event, type_mem
2008
2009 implicit none
2010
2011@@ -41,71 +40,9 @@
2012 character(len=*), intent(in) :: CallingRoutine
2013
2014 C Local variables
2015- integer :: Sign
2016- integer*8 :: prevMem
2017- integer :: allocSize
2018+ integer :: allocSize, bytes
2019 character(len=1):: allocType
2020-CAG
2021-! if (Node.eq.0) then
2022-! write(66,'(a,a,a,a,i10)') "---memory: ", CallingRoutine // " ",
2023-! $ task // " ",
2024-! $ type // " ", nelements
2025-! call flush(66)
2026-! endif
2027- prevMem = CurrentMemory
2028-C Assign sign of operation based on task
2029- if (Task .eq. 'A' .or. Task .eq. 'a') then
2030- Sign = +1
2031- else
2032- Sign = -1
2033- endif
2034-
2035-C Add number of elements to appropriate pointer
2036- if (Type .eq. 'I' .or. Type .eq. 'i') then
2037- WordsInteger = WordsInteger + Sign*NElements
2038- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(1)
2039- elseif (Type .eq. 'S' .or. Type .eq. 's') then
2040- WordsSP = WordsSP + Sign*NElements
2041- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(2)
2042- elseif (Type .eq. 'D' .or. Type .eq. 'd') then
2043- WordsDP = WordsDP + Sign*NElements
2044- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(3)
2045-!
2046-! Support for flexible precision in grid-related arrays
2047-!
2048- elseif (Type .eq. 'X' .or. Type .eq. 'x') then
2049-#ifdef GRID_DP
2050- WordsDP = WordsDP + Sign*NElements
2051- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(3)
2052-#else
2053- WordsSP = WordsSP + Sign*NElements
2054- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(2)
2055-#endif
2056-
2057- elseif (Type .eq. 'L' .or. Type .eq. 'l') then
2058- WordsLogical = WordsLogical + Sign*NElements
2059- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(4)
2060- elseif (Type .eq. 'C' .or. Type .eq. 'c') then
2061- WordsSC = WordsSC + Sign*NElements
2062- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(5)
2063- elseif (Type .eq. 'Z' .or. Type .eq. 'z') then
2064- WordsDC = WordsDC + Sign*NElements
2065- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(6)
2066- elseif (Type .eq. 'S' .or. Type .eq. 's') then
2067- WordsString = WordsString + Sign*NElements
2068- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(7)
2069- elseif (Type .eq. 'E' .or. Type .eq. 'e') then
2070- WordsLongInt = WordsLongInt + Sign*NElements
2071- CurrentMemory = CurrentMemory + Sign*NElements*ByteSize(8)
2072- endif
2073-
2074-C Check whether memory is greater than peak memory so far
2075- if (CurrentMemory .gt. PeakMemory) then
2076- PeakMemory = CurrentMemory
2077- PeakRoutine = CallingRoutine
2078- endif
2079-
2080-C Call alloc_count routine
2081+
2082 select case(Type)
2083 case('S')
2084 allocType = 'R'
2085@@ -128,82 +65,8 @@
2086 allocSize = NElements
2087 end select
2088 if (Task=='D') allocSize = -allocSize
2089- call alloc_count( allocSize, allocType,
2090- . name=trim(CallingRoutine)//' unknown' )
2091+ bytes = allocSize*type_mem(allocType)
2092+ call memory_event(bytes,
2093+ $ aname=trim(CallingRoutine)//'@'//'unknown' )
2094
2095 end subroutine memory
2096-
2097- subroutine printmemory( Unit, Level )
2098-C
2099-C Outputs the information about the dynamic memory useage
2100-C
2101-C Created by J.D. Gale, October 1999
2102-C
2103-C Input :
2104-C
2105-C integer Unit : channel number for output
2106-C integer Level : number controlling the level of output
2107-C : 0 = peak memory details only
2108-C : 1 = peak memory on all Nodes
2109-C
2110- use memoryinfo
2111- use precision
2112- use parallel, only : Node, Nodes
2113-#ifdef MPI
2114- use mpi_siesta
2115-#endif
2116- implicit none
2117-C Passed arguments
2118- integer :: Unit, Level
2119-C Local arguments
2120- integer :: n
2121- integer*8 :: MaxMemory
2122- integer*8, pointer :: maxmemlist(:)
2123-#ifdef MPI
2124- integer :: MPIerror
2125-#endif
2126-
2127-C Find peak memory use over all Nodes
2128-#ifdef MPI
2129- call MPI_AllReduce( PeakMemory, MaxMemory, 1, MPI_INTEGER8,
2130- & MPI_MAX, MPI_COMM_WORLD, MPIerror )
2131-#else
2132- MaxMemory = PeakMemory
2133-#endif
2134-
2135-C Output memory use information
2136- if (Node.eq.0) then
2137- write(Unit,'(a)') ' '
2138- endif
2139- if (Level.eq.0) then
2140- if (Node.eq.0) then
2141- write(Unit,'(''* Maximum dynamic memory allocated = '',i5,
2142- & '' MB'')') (MaxMemory/1000000)+1
2143- endif
2144- else
2145- nullify(maxmemlist)
2146- if (node==0) then
2147- allocate(maxmemlist(nodes))
2148- else
2149- allocate(maxmemlist(1))
2150- endif
2151-#ifdef MPI
2152- call mpi_gather( peakmemory, 1, MPI_INTEGER8,
2153- & maxmemlist, 1, MPI_INTEGER8,
2154- & 0, MPI_COMM_WORLD, MPIerror )
2155-#else
2156- maxmemlist=peakmemory
2157-#endif
2158- if (node==0) then
2159- do n=0,Nodes-1
2160- write(Unit,'(''* Maximum dynamic memory allocated : Node ''
2161- & ,i4,'' = '',i5,'' MB'')') n,(maxmemlist(n+1)/1000000)+1
2162- enddo
2163- write(Unit,'(a)') ' '
2164- write(Unit,'(''* Maximum memory occured during '',a30)')
2165- & PeakRoutine
2166- endif
2167- deallocate(maxmemlist)
2168- endif
2169-
2170- end subroutine printmemory
2171
2172=== added file 'Src/memory_log.F90'
2173--- Src/memory_log.F90 1970-01-01 00:00:00 +0000
2174+++ Src/memory_log.F90 2016-07-19 08:21:24 +0000
2175@@ -0,0 +1,587 @@
2176+! ---
2177+! Copyright (C) 1996-2016 The SIESTA group
2178+! This file is distributed under the terms of the
2179+! GNU General Public License: see COPYING in the top directory
2180+! or http://www.gnu.org/copyleft/gpl.txt .
2181+! See Docs/Contributors.txt for a list of contributors.
2182+! ---
2183+! ==================================================================
2184+
2185+! Written by J.M.Soler. May 2000.
2186+! Re-organized by A. Garcia, June 2015
2187+!
2188+! ==================================================================
2189+! SUBROUTINE memory_report( level, unit, file, printNow, threshold )
2190+! Sets the output file for the allocation report
2191+! INPUT (optional):
2192+! integer :: level : Level (detail) of report
2193+! integer :: unit : Output file unit
2194+! character*(*):: file : Output file name
2195+! logical :: printNow : If present & true => print report now
2196+! real(dp) :: threshold : Memory threshold (in bytes) to print
2197+! the memory use of any given array
2198+! BEHAVIOR:
2199+! The detail/extent of the report increses with the value of level:
2200+! level=0 : no report at all (the default)
2201+! level=1 : only total memory peak and where it occurred
2202+! level=2 : detailed report created but printed only upon request
2203+! level=3 : detailed report printed at every new memory peak
2204+! level=4 : print every individual reallocation or deallocation
2205+! If unit is present, memory_report merely takes note of it for
2206+! future use, assuming that it has been already open outside.
2207+! In this case, file is not used.
2208+! If unit is absent, and file is present, a file with that
2209+! name is open for future use.
2210+! If both arguments are absent, a file named 'memory_report'
2211+! is open for future use.
2212+! If memory_report is called with printNow=.true. several times in
2213+! a program, with the same unit or file argument, the subsequent
2214+! reports are written consecutively in the same file, each with a
2215+! time stamp header.
2216+! If threshold is not present, threshold=0 is assumed.
2217+! In parallel execution, the report sections that involve every
2218+! reallocation (levels 1, 3, and 4) are written only by node 0.
2219+! The section that is written upon request (level 2) is written
2220+! only by the node with the highest peak of memory up to that time,
2221+! but it contains a summary of the memory used by all other nodes.
2222+! In parallel execution, the nodes that share the same file
2223+! system (e.g. different chip cores or NFS-connected nodes) write
2224+! on the same file. Otherwise they write on files with the same name
2225+! in their local disks.
2226+! ==================================================================---
2227+
2228+MODULE memory_log
2229+
2230+ use precision, only: dp ! Double precision real type
2231+ use parallel, only: Node ! My processor node index
2232+ use parallel, only: Nodes ! Number of parallel processors
2233+ use parallel, only: ionode ! Am I the I/O processor?
2234+ use parallel, only: parallel_init ! Initialize parallel variables
2235+ use m_io, only: io_assign ! Get and reserve an available IO unit
2236+#ifdef MPI
2237+! use mpi_siesta
2238+ use mpi_siesta, only: MPI_AllGather
2239+ use mpi_siesta, only: MPI_Barrier
2240+ use mpi_siesta, only: MPI_Bcast
2241+ use mpi_siesta, only: MPI_Comm_World
2242+ use mpi_siesta, only: MPI_double_precision
2243+ use mpi_siesta, only: MPI_integer
2244+ use mpi_siesta, only: MPI_character
2245+#endif
2246+
2247+ implicit none
2248+
2249+PUBLIC :: &
2250+ memory_report, &! Sets log report defaults
2251+ memory_event, &! Memory counting for allocs
2252+ type_mem ! Converter
2253+
2254+public :: memory ! The old (re-furbished) routine
2255+
2256+integer, public :: mem_stat ! (legacy) For use in calls to allocate
2257+ ! and deallocate
2258+
2259+PRIVATE ! Nothing is declared public beyond this point
2260+
2261+ ! Initial default values
2262+ character(len=*), parameter :: &
2263+ DEFAULT_NAME = 'unknown_name' ! Array name default
2264+ character(len=*), parameter :: &
2265+ DEFAULT_ROUTINE = 'unknown_routine' ! Routine name default
2266+
2267+ integer, save :: &
2268+ REPORT_LEVEL = 0, &! Level (detail) of allocation report
2269+ REPORT_UNIT = 0 ! Output file unit for report
2270+
2271+ character(len=50), save :: &
2272+ REPORT_FILE = 'memory_report' ! Output file name for report
2273+ real(dp), save :: &
2274+ REPORT_THRESHOLD = 0 ! Memory threshold (in bytes) to print
2275+ ! the memory use of any given array
2276+
2277+ ! Internal auxiliary type for a binary tree
2278+ type TREE
2279+ character(len=80) :: name ! Name of an allocated array
2280+ real(DP) :: mem ! Present memory use of the array
2281+ real(DP) :: max ! Maximum memory use of the array
2282+ real(DP) :: peak ! Memory use of the array during
2283+ ! peak of total memory
2284+ type(TREE), pointer :: left ! Pointer to data of allocated arrays
2285+ ! preceeding in alphabetical order
2286+ type(TREE), pointer :: right ! Pointer to data of allocated arrays
2287+ ! trailing in alphabetical order
2288+ end type TREE
2289+
2290+ ! Global variables used to store allocation data
2291+ real(DP), parameter :: MBYTE = 1.e6_dp
2292+ type(TREE), pointer, save :: REPORT_TREE
2293+ real(DP), save :: TOT_MEM = 0._dp
2294+ real(DP), save :: PEAK_MEM = 0._dp
2295+ character(len=80), save :: PEAK_ARRAY = ' '
2296+ character(len=32), save :: PEAK_ROUTINE = ' '
2297+ integer, save :: MAX_LEN = 0
2298+
2299+CONTAINS
2300+
2301+! ==================================================================
2302+
2303+SUBROUTINE memory_report( level, unit, file, printNow, threshold )
2304+
2305+implicit none
2306+
2307+integer, optional, intent(in) :: level, unit
2308+character(len=*), optional, intent(in) :: file
2309+logical, optional, intent(in) :: printNow
2310+real(dp), optional, intent(in) :: threshold
2311+
2312+logical open
2313+
2314+#ifdef MPI
2315+integer MPIerror
2316+#endif
2317+
2318+if (present(level)) then
2319+ REPORT_LEVEL = level
2320+end if
2321+
2322+if (node == 0) then
2323+ if (present(unit)) then ! Assume that unit has been open outside
2324+ if (unit > 0) then
2325+ REPORT_UNIT = unit
2326+ if (present(file)) then
2327+ REPORT_FILE = file
2328+ else
2329+ REPORT_FILE = 'unknown'
2330+ end if
2331+ end if
2332+ else if (present(file)) then ! If file is the same, do nothing
2333+ if (file /= REPORT_FILE) then ! Check if file was open outside
2334+ REPORT_FILE = file
2335+ inquire( file=REPORT_FILE, opened=open, number=REPORT_UNIT )
2336+ if (.not.open) then ! Open new file
2337+ call io_assign(REPORT_UNIT)
2338+ open( REPORT_UNIT, file=REPORT_FILE, status='unknown')
2339+ write(REPORT_UNIT,*) ' ' ! Overwrite previous reports
2340+ end if
2341+ end if
2342+ else if (REPORT_UNIT==0) then ! No unit has been open yet
2343+ REPORT_FILE = 'memory_report'
2344+ call io_assign(REPORT_UNIT)
2345+ open( REPORT_UNIT, file=REPORT_FILE, status='unknown')
2346+ write(REPORT_UNIT,*) ' ' ! Overwrite previous reports
2347+ end if
2348+end if
2349+
2350+#ifdef MPI
2351+! Distribute information to other nodes and open REPORT_UNIT
2352+call MPI_Bcast(REPORT_LEVEL,1,MPI_integer,0,MPI_Comm_World,MPIerror)
2353+call MPI_Bcast(REPORT_UNIT,1,MPI_integer,0,MPI_Comm_World,MPIerror)
2354+call MPI_Bcast(REPORT_FILE,50,MPI_character,0,MPI_Comm_World,MPIerror)
2355+! JMS: open file only in node 0
2356+!if (node > 0) then
2357+! open( REPORT_UNIT, file=REPORT_FILE )
2358+!end if
2359+#endif
2360+
2361+if (present(threshold)) REPORT_THRESHOLD = threshold
2362+
2363+if (present(printNow)) then
2364+ if (printNow) call print_report( )
2365+end if
2366+
2367+END SUBROUTINE memory_report
2368+
2369+! ==================================================================
2370+! Internal subroutines
2371+! ==================================================================
2372+
2373+SUBROUTINE memory_event( bytes, aname )
2374+
2375+implicit none
2376+
2377+integer, intent(in) :: bytes
2378+character(len=*), intent(in) :: aname
2379+
2380+character(len=1) :: memType, task
2381+real(DP) :: delta_mem
2382+logical :: newPeak
2383+logical, save :: header_written = .false.
2384+logical, save :: tree_nullified = .false.
2385+integer :: memSize
2386+
2387+if (REPORT_LEVEL <= 0) return
2388+
2389+MAX_LEN = max( MAX_LEN, len(trim(aname)) )
2390+
2391+! Find memory increment and total allocated memory
2392+delta_mem = real(bytes,kind=dp)
2393+TOT_MEM = TOT_MEM + delta_mem
2394+if (TOT_MEM > PEAK_MEM+0.5_dp) then
2395+ newPeak = .true.
2396+ PEAK_MEM = TOT_MEM
2397+ PEAK_ARRAY = aname
2398+ PEAK_ROUTINE = '-'
2399+! print'(/,a,f18.6),a,/)',
2400+! 'memory: Memory peak =', PEAK_MEM/MBYTE, ' Mbytes'
2401+else
2402+ newPeak = .false.
2403+end if
2404+
2405+! Add/subtract/classify array memory
2406+if (REPORT_LEVEL > 1) then
2407+ if (.not.tree_nullified) then
2408+ nullify(report_tree)
2409+ tree_nullified = .true.
2410+ end if
2411+ call tree_add( report_tree, aname, delta_mem )
2412+ if (newPeak) call tree_peak( report_tree )
2413+end if
2414+
2415+! Print report, but only in node 0, as not all
2416+! processors may follow the same route here
2417+! The detail/extent of the report increses with the value of level:
2418+! level=0 : no report at all (the default)
2419+! level=1 : only total memory peak and where it occurred
2420+! level=2 : detailed report created but printed only upon request
2421+! level=3 : detailed report printed at every new memory peak
2422+! level=4 : print every individual reallocation or deallocation
2423+
2424+
2425+if (newPeak .and. (REPORT_LEVEL==1 .or. REPORT_LEVEL==3) .and. &
2426+ node == 0) then
2427+ call print_report
2428+end if
2429+
2430+if (REPORT_LEVEL == 4 .and. node == 0) then
2431+ if (.not.header_written) then
2432+ write(REPORT_UNIT,'(/,a7,9x,1x,a4,28x,1x,2a15)') &
2433+ 'Routine', 'Name', 'Incr. (MB)', 'Total (MB)'
2434+ header_written = .true.
2435+ end if
2436+ write(REPORT_UNIT,'(a32,1x,2f15.6)') &
2437+ aname, delta_mem/MBYTE, TOT_MEM/MBYTE
2438+end if
2439+END SUBROUTINE memory_event
2440+
2441+! ==================================================================
2442+
2443+INTEGER FUNCTION type_mem( var_type )
2444+!
2445+! It is not clear that the sizes assumed are universal for
2446+! non-Cray machines...
2447+!
2448+implicit none
2449+character, intent(in) :: var_type
2450+character(len=40) :: message
2451+
2452+select case( var_type )
2453+#ifdef OLD_CRAY
2454+ case('I')
2455+ type_mem = 8
2456+ case('R')
2457+ type_mem = 8
2458+ case('L')
2459+ type_mem = 8
2460+#else
2461+ case('I')
2462+ type_mem = 4
2463+ case('R')
2464+ type_mem = 4
2465+ case('L')
2466+ type_mem = 4
2467+#endif
2468+case('E')
2469+ type_mem = 8
2470+case('D')
2471+ type_mem = 8
2472+case('S')
2473+ type_mem = 1
2474+case default
2475+ write(message,"(2a)") &
2476+ 'memory_log: ERROR: unknown type = ', var_type
2477+ call die(trim(message))
2478+end select
2479+
2480+END FUNCTION type_mem
2481+
2482+! ==================================================================
2483+
2484+RECURSIVE SUBROUTINE tree_add( t, name, delta_mem )
2485+
2486+implicit none
2487+type(TREE), pointer :: t
2488+character(len=*), intent(in) :: name
2489+real(DP), intent(in) :: delta_mem
2490+
2491+logical, save :: warn_negative = .true.
2492+
2493+if (.not.associated(t)) then
2494+ allocate( t )
2495+ t%name = name
2496+ t%mem = delta_mem
2497+ t%max = delta_mem
2498+ t%peak = 0._dp
2499+ nullify( t%left, t%right )
2500+else if (name == t%name) then
2501+ t%mem = t%mem + delta_mem
2502+ ! The abs is to handle the case of apparent de_allocs without re_allocs,
2503+ ! caused by routine/name argument mismatches
2504+ if (abs(t%mem) > abs(t%max)) t%max = t%mem
2505+else if ( llt(name,t%name) ) then
2506+ call tree_add( t%left, name, delta_mem )
2507+else
2508+ call tree_add( t%right, name, delta_mem )
2509+end if
2510+
2511+if (warn_negative .and. t%mem<0._dp) then
2512+ call parallel_init() ! Make sure that node and Nodes are initialized
2513+ if (Node==0) then
2514+ write(6,'(/,a,/,2a,/,a,f18.0,a)') &
2515+ 'WARNING: alloc-realloc-dealloc name mismatch', &
2516+ ' Name: ', trim(name), &
2517+ ' Size: ', t%mem, ' Bytes'
2518+ if (Nodes>1) write(6,'(9x,a,i6)') 'Node:', Node
2519+ write(6,'(9x,a)') 'Subsequent mismatches will not be reported'
2520+ warn_negative = .false. ! Print this warning only once
2521+ end if
2522+end if
2523+
2524+END SUBROUTINE tree_add
2525+
2526+! ==================================================================
2527+
2528+RECURSIVE SUBROUTINE tree_peak( t )
2529+
2530+implicit none
2531+type(TREE), pointer :: t
2532+
2533+if (.not.associated(t)) return
2534+
2535+t%peak = t%mem
2536+call tree_peak( t%left )
2537+call tree_peak( t%right )
2538+
2539+END SUBROUTINE tree_peak
2540+
2541+! ==================================================================
2542+
2543+RECURSIVE SUBROUTINE tree_print( t )
2544+
2545+implicit none
2546+type(TREE), pointer :: t
2547+
2548+if (.not.associated(t)) return
2549+
2550+call tree_print( t%left )
2551+
2552+if (abs(t%max) >= REPORT_THRESHOLD) then
2553+ write(REPORT_UNIT,'(a,1x,3f15.6,f9.2)') &
2554+ t%name(1:MAX_LEN), t%mem/MBYTE, t%max/MBYTE, t%peak/MBYTE, &
2555+ 100._dp * t%peak / (PEAK_MEM + tiny(PEAK_MEM) )
2556+end if
2557+
2558+call tree_print( t%right )
2559+
2560+END SUBROUTINE tree_print
2561+
2562+! ==================================================================
2563+
2564+SUBROUTINE print_report
2565+
2566+implicit none
2567+
2568+character(len=80) :: string = 'Name'
2569+character :: date*8, time*10, zone*5
2570+integer :: iNode, peakNode
2571+real(dp) :: maxPeak
2572+real(dp),allocatable:: nodeMem(:), nodePeak(:)
2573+
2574+#ifdef MPI
2575+integer :: MPIerror
2576+#endif
2577+
2578+! Make sure that variables node and Nodes are initialized
2579+call parallel_init()
2580+
2581+! Allocate and initialize two small arrays
2582+allocate( nodeMem(0:Nodes-1), nodePeak(0:Nodes-1) )
2583+
2584+! Initializations for Nodes=1 (serial case)
2585+nodeMem(node) = TOT_MEM
2586+nodePeak(node) = PEAK_MEM
2587+peakNode = node
2588+
2589+! In parallel, find the memory values of all nodes
2590+#ifdef MPI
2591+if (Nodes > 1) then
2592+ ! Gather the present and peak memories of all nodes
2593+ call MPI_AllGather( TOT_MEM, 1, MPI_double_precision, &
2594+ nodeMem, 1, MPI_double_precision, &
2595+ MPI_COMM_WORLD, MPIerror )
2596+ call MPI_AllGather( PEAK_MEM, 1, MPI_double_precision, &
2597+ nodePeak, 1, MPI_double_precision, &
2598+ MPI_COMM_WORLD, MPIerror )
2599+ ! Find the node with the highest peak of memory
2600+ maxPeak = 0
2601+ do iNode = 0,Nodes-1
2602+ if (nodePeak(iNode) > maxPeak) then
2603+ peakNode = iNode
2604+ maxPeak = nodePeak(iNode)
2605+ end if
2606+ end do ! iNode
2607+ ! Change the writing node for the peak-node information
2608+ if (node==0 .and. peakNode/=0) close( unit=REPORT_UNIT )
2609+ call MPI_Barrier( MPI_COMM_WORLD, MPIerror )
2610+ if (node==peakNode .and. peakNode/=0) &
2611+ open( unit=REPORT_UNIT, file=REPORT_FILE, &
2612+ status='unknown', position='append' )
2613+end if ! (Nodes>1)
2614+#endif
2615+
2616+! The report is printed by the highest-peak node
2617+if (node == peakNode) then
2618+
2619+ ! AG: Commented out to allow multiple batches of information
2620+ ! if (REPORT_LEVEL < 4) rewind(REPORT_UNIT)
2621+
2622+ call date_and_time( date, time, zone )
2623+
2624+ write(REPORT_UNIT,'(/,a,16a)') &
2625+ 'Allocation summary at ', &
2626+ date(1:4),'/',date(5:6),'/',date(7:8),' ', &
2627+ time(1:2),':',time(3:4),':',time(5:10),' ', &
2628+ zone(1:3),':',zone(4:5)
2629+
2630+ if (Nodes > 1) then
2631+ write(REPORT_UNIT,'(/,(a,f18.6,a))') &
2632+ 'Present memory all nodes : ', sum(nodeMem)/MBYTE, ' MB', &
2633+ 'Added peak mem all nodes : ', sum(nodePeak)/MBYTE, ' MB', &
2634+ 'Min peak memory in a node: ', minval(nodePeak)/MBYTE, ' MB', &
2635+ 'Max peak memory in a node: ', maxval(nodePeak)/MBYTE, ' MB'
2636+! Impractical for many nodes:
2637+! write(REPORT_UNIT,'(/,a,/,(i6,f12.6))') &
2638+! 'Memory peaks of individual nodes (Mb):', &
2639+! (iNode,nodePeak(iNode)/MBYTE,iNode=0,Nodes-1)
2640+ write(REPORT_UNIT,'(/,a,i6)') &
2641+ 'Maximum peak of memory occurred in node:', peakNode
2642+ end if
2643+
2644+ write(REPORT_UNIT,'(2(/,a,f18.6,a),/,2a,/,2a)') &
2645+ 'Present memory allocation: ', TOT_MEM/MBYTE, ' MB', &
2646+ 'Maximum memory allocation: ', PEAK_MEM/MBYTE, ' MB', &
2647+ 'Occurred after allocating: ', trim(PEAK_ARRAY), &
2648+ 'In routine: ', trim(PEAK_ROUTINE)
2649+
2650+ if (REPORT_LEVEL > 1) then
2651+ if (REPORT_THRESHOLD > 0._dp) then
2652+ write(REPORT_UNIT,'(/,a,f12.6,a,/,a,1x,3a15,a9)') &
2653+ 'Allocated sizes (in MByte) of arrays larger than ', &
2654+ REPORT_THRESHOLD/MBYTE, ' MB:', &
2655+ string(1:MAX_LEN), 'Present', 'Maximum', 'At peak', '%'
2656+ else
2657+ write(REPORT_UNIT,'(/,a,/,a,1x,3a15,a9)') &
2658+ 'Allocated array sizes (in MByte):', &
2659+ string(1:MAX_LEN), 'Present', 'Maximum', 'At peak', '%'
2660+ end if
2661+ call tree_print( report_tree )
2662+ end if
2663+
2664+end if ! (node == peakNode)
2665+
2666+! Change again the writing node for the rest of the report
2667+#ifdef MPI
2668+if (node==peakNode .and. peakNode/=0) close( unit=REPORT_UNIT )
2669+call MPI_Barrier( MPI_COMM_WORLD, MPIerror )
2670+if (node==0 .and. peakNode/=0) &
2671+ open( unit=REPORT_UNIT, file=REPORT_FILE, &
2672+ status='unknown', position='append' )
2673+#endif
2674+
2675+deallocate( nodeMem, nodePeak )
2676+
2677+END SUBROUTINE print_report
2678+!
2679+! This routine is called "by hand" when allocations are not
2680+! handled by the 'alloc' mechanism, which is only suitable
2681+! for pointers.
2682+!
2683+subroutine memory( Task, Type, NElements, CallingRoutine, &
2684+ stat,id)
2685+!
2686+! This subroutine keeps track of information relating to the use
2687+! of dynamic memory
2688+
2689+! Input :
2690+! character*1 Task : job type = 'A' -> allocate
2691+! : 'D' -> deallocate
2692+! character*1 Type : type of variable = 'I' = integer
2693+! : 'S' = single precision real
2694+! : 'D' = double precision real
2695+! : 'X' = grid precision real
2696+! : 'L' = logical
2697+! : 'C' = single precision complex
2698+! : 'Z' = double precision complex
2699+! : 'S' = character data (we assume takes one word)
2700+! : 'E' = double precision integer
2701+! integer NElements : number of array elements being
2702+! : allocated/deallocated
2703+! character :
2704+! CallingRoutine : string containing the name of the calling routine
2705+
2706+! Created by J.D. Gale, October 1999
2707+
2708+! Stat and ID keyword arguments added by Alberto Garcia, 2005
2709+
2710+ implicit none
2711+
2712+ integer, intent(in) :: NElements
2713+ character(len=1), intent(in) :: Task, Type
2714+ character(len=*), intent(in) :: CallingRoutine
2715+ integer, intent(in), optional :: stat
2716+ character(len=*), intent(in), optional :: id
2717+
2718+! Local variables
2719+ integer :: allocSize, bytes
2720+ character(len=1):: allocType
2721+
2722+ if (present(stat)) then
2723+ if (stat .ne. 0) then
2724+ if (present(id)) then
2725+ call die(Task // "-llocation failed in " // &
2726+ CallingRoutine // id)
2727+ else
2728+ call die(Task // "-llocation failed in " // &
2729+ CallingRoutine)
2730+ endif
2731+ endif
2732+ endif
2733+
2734+ select case(Type)
2735+ case('S')
2736+ allocType = 'R'
2737+ allocSize = NElements
2738+ case('C')
2739+ allocType = 'R'
2740+ allocSize = NElements*2
2741+ case('Z')
2742+ allocType = 'D'
2743+ allocSize = NElements*2
2744+ case('X')
2745+#ifdef GRID_DP
2746+ allocType = 'D'
2747+#else
2748+ allocType = 'R'
2749+#endif
2750+ allocSize = NElements
2751+ case default
2752+ allocType = Type
2753+ allocSize = NElements
2754+ end select
2755+ if (Task=='D') allocSize = -allocSize
2756+ bytes = allocSize*type_mem(allocType)
2757+ call memory_event(bytes, &
2758+ aname=trim(CallingRoutine)//'@'//'unknown' )
2759+
2760+ end subroutine memory
2761+
2762+END MODULE memory_log
2763
2764=== modified file 'Src/meshsubs.F'
2765--- Src/meshsubs.F 2016-06-29 04:07:55 +0000
2766+++ Src/meshsubs.F 2016-07-19 08:21:24 +0000
2767@@ -261,7 +261,7 @@
2768 use precision, only : dp
2769 use cellsubs, only : reclat ! Finds reciprocal unit cell
2770 use m_chkgmx, only : chkgmx ! Checks planewave cutoff of a mesh
2771- use fft1d, only : nfft ! Finds allowed value for 1-D FFT
2772+ use m_fft_gpfa, only : nfft ! Finds allowed value for 1-D FFT
2773 use fdf
2774 use sys, only : die, message
2775
2776@@ -490,7 +490,7 @@
2777 ! (Re)allocate atom-mesh arrays
2778 call allocIpaDistr( distr, na )
2779 if (na.ne.lastna) then
2780- call re_alloc( dxa, 1,3, 1,na, myName//'dxa' )
2781+ call re_alloc( dxa, 1,3, 1,na, 'dxa', myName )
2782 call re_alloc( iatfold, 1,3, 1,na, myName//'iatfold' )
2783 endif
2784 lastna = na
2785
2786=== modified file 'Src/moreParallelSubs.F90'
2787--- Src/moreParallelSubs.F90 2016-01-25 16:00:16 +0000
2788+++ Src/moreParallelSubs.F90 2016-07-19 08:21:24 +0000
2789@@ -559,7 +559,7 @@
2790 call MPI_AllReduce( sendBuff, recvBuff, n, MPI_Integer, &
2791 MPI_Min, MPI_Comm_World, MPIerror )
2792 else
2793- call die(errHead//'unknown operator')
2794+ call die(errHead//'unknown operator:'//op)
2795 end if
2796
2797 ! Unpack recvBuff
2798@@ -738,7 +738,7 @@
2799 call MPI_AllReduce( sendBuff, recvBuff, n, MPI_double_precision, &
2800 MPI_Min, MPI_Comm_World, MPIerror )
2801 else
2802- call die(errHead//'unknown operator')
2803+ call die(errHead//'unknown operator:'//op)
2804 end if
2805
2806 ! Unpack recvBuff
2807
2808=== modified file 'Src/obj_setup.sh'
2809--- Src/obj_setup.sh 2015-11-25 17:03:59 +0000
2810+++ Src/obj_setup.sh 2016-07-19 08:21:24 +0000
2811@@ -55,6 +55,15 @@
2812 cp -f $relpath/*.h ${destdir}/$relpath
2813 done
2814 )
2815+# Replicate any .inc files
2816+#
2817+(cd $srcdir;
2818+ for i in $(find . -name '*.inc' ); do
2819+ relpath=${i%/*}
2820+ mkdir -p ${destdir}/$relpath
2821+ cp -f $relpath/*.inc ${destdir}/$relpath
2822+ done
2823+)
2824 #
2825 sed "s#VPATH=\.#VPATH=${srcdir}#g" ${srcdir}/Makefile | \
2826 sed "s#MAIN_OBJDIR=\.#MAIN_OBJDIR=${objdir}#g" > ${destdir}/Makefile
2827
2828=== modified file 'Src/read_xc_info.F'
2829--- Src/read_xc_info.F 2016-01-25 16:00:16 +0000
2830+++ Src/read_xc_info.F 2016-07-19 08:21:24 +0000
2831@@ -11,7 +11,7 @@
2832 C and calls setXC to store it
2833 C
2834 use precision, only : dp
2835- use SiestaXC, only : setXC
2836+ use gridXC, only : setXC=>gridxc_setXC
2837 use fdf
2838 use parallel, only : Node
2839 use sys, only : die
2840
2841=== modified file 'Src/siesta_end.F'
2842--- Src/siesta_end.F 2016-01-25 16:00:16 +0000
2843+++ Src/siesta_end.F 2016-07-19 08:21:24 +0000
2844@@ -12,7 +12,7 @@
2845 CONTAINS
2846
2847 subroutine siesta_end( )
2848- use alloc, only : alloc_report
2849+ use memory_log, only : memory_report
2850 use siesta_cml, only : cml_p, mainXML, cmlEndModule
2851 use siesta_cmlsubs, only : siesta_cml_exit
2852 use siesta_master, only : siesta_subroutine ! Is siesta a subroutine?
2853@@ -61,7 +61,7 @@
2854 !! call printmemory( 6, 1 )
2855
2856 ! Print allocation report
2857- call alloc_report( printNow=.true. )
2858+ call memory_report( printNow=.true. )
2859
2860 #ifdef DEBUG_XC
2861 ! Close debug outup file
2862
2863=== modified file 'Src/siesta_init.F'
2864--- Src/siesta_init.F 2016-05-02 15:51:23 +0000
2865+++ Src/siesta_init.F 2016-07-19 08:21:24 +0000
2866@@ -20,6 +20,8 @@
2867 use m_struct_init, only: struct_init
2868 use siesta_options
2869 use timer_options, only: use_tree_timer
2870+ use timer_options, only: time_mpi_calls
2871+ use timer_options, only: use_walltime
2872 use sparse_matrices
2873 use siesta_geom
2874 use atomlist, only: no_u, rmaxkb, amass, lasto, qtot,
2875@@ -29,11 +31,14 @@
2876 use sys, only: die, bye
2877 #ifdef BSC_CELLXC
2878 use bsc_xcmod, only: setXC
2879+#else
2880+ use gridxc, only: gridxc_init
2881 #endif /* BSC_CELLXC */
2882 use molecularmechanics, only: inittwobody
2883 use metaforce, only: initmeta
2884 use m_mpi_utils, only: broadcast
2885- use alloc, only: re_alloc, alloc_report
2886+ use alloc, only: re_alloc
2887+ use memory_log, only: memory_report
2888 use parallelsubs, only: getnodeorbs
2889 use m_iostruct, only: write_struct, read_struct
2890 use zmatrix, only: lUseZmatrix
2891@@ -165,11 +170,12 @@
2892 call siesta_cml_init( )
2893
2894 ! Set timer report file and threshold .................................
2895- threshold = fdf_get('timer_report_threshold', 0._dp)
2896 call timer_report( file=trim(slabel)//'.times',
2897- . threshold=threshold )
2898- ! This variable lives in siesta_options
2899+ . threshold=fdf_get('timer_report_threshold', 0._dp))
2900+
2901 use_tree_timer = fdf_get('UseTreeTimer', .false.)
2902+ time_mpi_calls = fdf_get('time-mpi-calls', .false.)
2903+ use_walltime = fdf_get('use-walltime', use_tree_timer)
2904
2905 ! Start time counter
2906 ! Note new placement of this first use, so that
2907@@ -180,12 +186,10 @@
2908 call timer( 'Setup', 1 )
2909
2910 ! Set allocation report level .........................................
2911-! variables level and threshold imported from module siesta_options
2912- level = fdf_get('alloc_report_level', 0)
2913- threshold = fdf_get('alloc_report_threshold', 0._dp)
2914- call alloc_report( level=level, file=trim(slabel)//'.alloc',
2915- . threshold=threshold,
2916- & printNow=.false. )
2917+ call memory_report( level=fdf_get('alloc_report_level',0),
2918+ $ file=trim(slabel)//'.alloc',
2919+ . threshold=fdf_get('alloc_report_threshold', 0._dp),
2920+ & printNow=.false. )
2921
2922 if ( IONode ) then
2923 ! Add citations
2924@@ -196,6 +200,12 @@
2925 ! Initialise exchange-correlation functional information
2926 #ifndef BSC_CELLXC
2927 call read_xc_info()
2928+#ifdef MPI
2929+ call gridxc_init(comm=MPI_Comm_World,
2930+ $ time_mpi_calls=fdf_get('gridxc-time-mpi-calls',.false.))
2931+#else
2932+ call gridxc_init()
2933+#endif
2934 #else /* BSC_CELLXC */
2935 call setXC( )
2936 #endif /* BSC_CELLXC */
2937
2938=== modified file 'Src/siesta_options.F90'
2939--- Src/siesta_options.F90 2016-01-25 16:00:16 +0000
2940+++ Src/siesta_options.F90 2016-07-19 08:21:24 +0000
2941@@ -132,7 +132,6 @@
2942 integer :: min_nscf ! Minimum number of SCF iteration steps
2943 integer :: pmax
2944 integer :: neigwanted ! Wanted number of eigenstates (per k point)
2945- integer :: level ! Option for allocation report level of detail
2946 integer :: call_diagon_default ! Default number of SCF steps for which to use diagonalization before OMM
2947 integer :: call_diagon_first_step ! Number of SCF steps for which to use diagonalization before OMM (first MD step)
2948 logical :: hasnobup ! Is the number of bands with spin up for
2949@@ -172,7 +171,6 @@
2950 real(dp) :: taurelax ! Relaxation time to reach desired T and P in anneal
2951 real(dp) :: temp
2952 real(dp) :: tempinit ! Initial ionic temperature read in redata
2953- real(dp) :: threshold ! Min. size of arrays printed by alloc_report
2954 real(dp) :: tp ! Target pressure. Read in redata. Used in dynamics routines
2955 real(dp) :: ts ! Total spin read from redata but not used
2956 real(dp) :: tt ! Target temperature. Read in redata. Used in dynamics rout.
2957
2958=== modified file 'Src/state_init.F'
2959--- Src/state_init.F 2016-05-02 15:51:23 +0000
2960+++ Src/state_init.F 2016-07-19 08:21:24 +0000
2961@@ -27,7 +27,7 @@
2962 & lastkb, lasto, superc, rmaxv, indxuo,
2963 & no_u, no_s
2964 use atomlist, only: no_l, iza
2965- use alloc, only: re_alloc, de_alloc, alloc_report
2966+ use alloc, only: re_alloc, de_alloc
2967 use m_hsparse, only: hsparse
2968 use m_overlap, only: overlap
2969 use m_check_supercell, only: check_sc_factors
2970
2971=== modified file 'Src/timer.F90'
2972--- Src/timer.F90 2016-01-25 16:00:16 +0000
2973+++ Src/timer.F90 2016-07-19 08:21:24 +0000
2974@@ -24,7 +24,9 @@
2975 ! WRITTEN BY J.SOLER. JUL.2009
2976 !=============================================================================
2977 module timer_options
2978- logical, public :: use_tree_timer
2979+ logical, public :: use_walltime
2980+ logical, public :: use_tree_timer
2981+ logical, public :: time_mpi_calls
2982 end module timer_options
2983
2984 subroutine timer( prog, iOpt )
2985@@ -85,3 +87,32 @@
2986
2987 end subroutine timer
2988
2989+subroutine timer_mpi( prog, iOpt )
2990+ use timer_options, only : time_mpi_calls
2991+
2992+ implicit none
2993+ character(len=*),intent(in):: prog ! Name of program to time
2994+ integer, intent(in):: iOpt ! Action option
2995+
2996+ if (time_mpi_calls) then
2997+ call timer(prog,iOpt)
2998+ endif
2999+
3000+end subroutine timer_mpi
3001+
3002+function use_walltime_in_timer()
3003+ use timer_options, only: use_walltime
3004+
3005+ logical :: use_walltime_in_timer
3006+ use_walltime_in_timer = use_walltime
3007+end function use_walltime_in_timer
3008+
3009+subroutine gridxc_timer_start(str)
3010+ character(len=*), intent(in) :: str
3011+ call timer("gridxc@"//trim(str),1)
3012+end subroutine gridxc_timer_start
3013+!
3014+subroutine gridxc_timer_stop(str)
3015+ character(len=*), intent(in) :: str
3016+ call timer("gridxc@"//trim(str),2)
3017+end subroutine gridxc_timer_stop
3018
3019=== modified file 'Src/timer_tree.f90'
3020--- Src/timer_tree.f90 2016-01-25 16:00:16 +0000
3021+++ Src/timer_tree.f90 2016-07-19 08:21:24 +0000
3022@@ -52,6 +52,9 @@
3023 ! specified below to properly abort the calling program in the event
3024 ! of an error (the routine could simply ignore timing errors...)
3025 !
3026+ ! The user must provide an external function 'use_walltime_in_timer'
3027+ ! with the interface specified below to set the value of 'use_walltime'
3028+ !
3029 ! Alberto Garcia, January 2013-, re-using some pieces of code by Jose Soler
3030 !
3031 implicit none
3032@@ -85,7 +88,6 @@
3033 type(section_t), pointer :: last_active => null()
3034
3035 real(dp) :: globaltime
3036- logical,public :: use_walltime = .true.
3037
3038 type(section_t), pointer :: p
3039 type(times_t), pointer :: pd
3040@@ -94,6 +96,8 @@
3041 real(dp) :: deltaTime
3042 character(len=256) :: msg
3043
3044+ logical, save :: use_walltime
3045+
3046
3047 public :: timer_on, timer_off, timer_report
3048 private
3049@@ -102,6 +106,9 @@
3050 subroutine die(str)
3051 character(len=*), intent(in), optional :: str
3052 end subroutine die
3053+ function use_walltime_in_timer() result(use_walltime)
3054+ logical :: use_walltime
3055+ end function use_walltime_in_timer
3056 end interface
3057
3058 CONTAINS
3059@@ -116,6 +123,11 @@
3060 ! so that multiple user "trees" can be supported
3061
3062 if (.not. associated(global_section)) then
3063+ ! Initialization
3064+ ! Get the value of this variable before
3065+ ! calling current_time...
3066+ use_walltime = use_walltime_in_timer()
3067+ !
3068 allocate(global_section)
3069 p => global_section
3070 p%active = .true.
3071
3072=== modified file 'Util/Denchar/Src/Makefile'
3073--- Util/Denchar/Src/Makefile 2016-07-12 13:38:13 +0000
3074+++ Util/Denchar/Src/Makefile 2016-07-19 08:21:24 +0000
3075@@ -73,7 +73,7 @@
3076 bessph.o chkdim.o dismin.o \
3077 dot.o readpla.o readsts.o \
3078 io.o iodm.o itochar.o length.o \
3079- matvect.o memory.o colinear.o\
3080+ matvect.o memory.o memory_log.o colinear.o\
3081 neighb.o paste.o pxf.o \
3082 radfft.o m_fft_gpfa.o ranger.o \
3083 readwavesx.o rhoofr.o wavofr.o \
3084@@ -97,13 +97,17 @@
3085 # This is crude but will have to do for now.
3086 # Note : precision must be the first module
3087 #
3088-MOD_OBJS=precision.o parallel.o debugmpi.o sys.o m_io.o alloc.o memoryinfo.o listsc.o \
3089+MOD_OBJS=precision.o parallel.o debugmpi.o sys.o m_io.o alloc.o listsc.o \
3090 atmparams.o atom_options.o atmfuncs.o atm_types.o \
3091 radial.o spher_harm.o basis_io.o basis_types.o parallelsubs.o \
3092 schecomm.o sparse_matrices.o\
3093 files.o interpolation.o chemical.o xml.o \
3094 domain_decom.o printmatrix.o qsort.o mmio.o pspltm1.o lenstr.o \
3095+<<<<<<< TREE
3096 spatial.o timer_local.o
3097+=======
3098+ spatial.o timer_local.o die.o alloc_handlers.o
3099+>>>>>>> MERGE-SOURCE
3100 #
3101 COM_OBJS_DENCHAR=$(OBJS_DENCHAR) $(SYSOBJ)
3102 ALL_OBJS_DENCHAR=$(MOD_OBJS) $(COM_OBJS_DENCHAR)
3103@@ -141,8 +145,6 @@
3104 debugmpi.o: parallel.o
3105 sys.o: parallel.o
3106 m_io.o: sys.o
3107-alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
3108-memoryinfo.o: precision.o
3109 listsc.o: alloc.o
3110 atom_options.o: sys.o
3111 atmfuncs.o: atm_types.o precision.o radial.o spher_harm.o sys.o
3112@@ -169,7 +171,8 @@
3113 readsts.o: precision.o
3114 io.o: sys.o
3115 iodm.o: alloc.o files.o parallel.o parallelsubs.o precision.o sys.o
3116-memory.o: alloc.o memoryinfo.o parallel.o precision.o
3117+memory.o: memory_log.o parallel.o
3118+memory_log.o: m_io.o parallel.o precision.o
3119 colinear.o: precision.o
3120 neighb.o: precision.o
3121 radfft.o: alloc.o bessph.o m_fft_gpfa.o precision.o
3122
3123=== added file 'Util/Denchar/Src/alloc_handlers.f90'
3124--- Util/Denchar/Src/alloc_handlers.f90 1970-01-01 00:00:00 +0000
3125+++ Util/Denchar/Src/alloc_handlers.f90 2016-07-19 08:21:24 +0000
3126@@ -0,0 +1,14 @@
3127+ ! Error message and integer code
3128+ ! If 'code' is 0, this is the last call in a series
3129+ ! (see below for usage)
3130+ subroutine alloc_error_report(str,code)
3131+ character(len=*), intent(in) :: str
3132+ integer, intent(in) :: code
3133+ end subroutine alloc_error_report
3134+ !
3135+ ! Logger for memory events
3136+ !
3137+ subroutine alloc_memory_event(bytes,name)
3138+ integer, intent(in) :: bytes
3139+ character(len=*), intent(in) :: name
3140+ end subroutine alloc_memory_event
3141
3142=== modified file 'Util/Gen-basis/Makefile'
3143--- Util/Gen-basis/Makefile 2016-07-12 13:38:13 +0000
3144+++ Util/Gen-basis/Makefile 2016-07-19 08:21:24 +0000
3145@@ -39,6 +39,8 @@
3146 FC_SERIAL?=$(FC_DEFAULT)
3147 FC:=$(FC_SERIAL) # Make it non-recursive
3148 #
3149+GRIDXC_SERIAL_ROOT ?= $(GRIDXC_ROOT)
3150+#
3151 DEFS:= $(DEFS) $(DEFS_PREFIX)-UMPI
3152 FPPFLAGS:=$(FPPFLAGS) $(DEFS_PREFIX)-UMPI
3153 #
3154@@ -60,20 +62,33 @@
3155 # Note that machine-specific files are now in top Src directory.
3156 #
3157 OBJS_GEN-BASIS=m_io.o io.o alloc.o basis_types.o precision.o parallel.o \
3158- parsing.o basis_io.o chemical.o atm_transfer.o atm_types.o\
3159+ parsing.o basis_io.o chemical.o atm_transfer.o atm_types.o\
3160 atmparams.o old_atmfuncs.o radial.o interpolation.o \
3161 paste.o bessph.o radfft.o sorting.o m_filter.o \
3162+<<<<<<< TREE
3163 basis_specs.o atom.o memoryinfo.o memory.o periodic_table.o\
3164 pxf.o dot.o atom_options.o arw.o \
3165 sys.o timer.o xml.o m_walltime.o read_xc_info.o gen-basis.o $(SYSOBJ) \
3166 xc.o bsc_xcmod.o local_die.o ldau_specs.o m_cite.o
3167+=======
3168+ basis_specs.o ldau_specs.o atom.o memory.o memory_log.o periodic_table.o\
3169+ pseudopotential.o pxf.o dot.o atom_options.o arw.o \
3170+ sys.o xml.o m_walltime.o read_xc_info.o gen-basis.o $(SYSOBJ) \
3171+ xc.o bsc_xcmod.o handlers.o m_fft_gpfa.o m_cite.o
3172+>>>>>>> MERGE-SOURCE
3173 #
3174 IONCAT_OBJS=f2kcli.o m_getopts.o basis_types.o precision.o parallel.o \
3175 parsing.o m_io.o io.o alloc.o atom_options.o basis_io.o atm_types.o\
3176 atmparams.o radial.o memory.o chkdim.o\
3177+<<<<<<< TREE
3178 paste.o chemical.o \
3179 basis_specs.o memoryinfo.o m_memory.o periodic_table.o pxf.o \
3180+=======
3181+ paste.o pseudopotential.o chemical.o \
3182+ basis_specs.o memory_log.o periodic_table.o pxf.o \
3183+>>>>>>> MERGE-SOURCE
3184 atmfuncs.o spher_harm.o interpolation.o\
3185+<<<<<<< TREE
3186 sys.o xml.o m_walltime.o ioncat.o local_die.o $(SYSOBJ)
3187 #
3188 # Compile XC in a private directory, without MPI
3189@@ -90,6 +105,13 @@
3190 "FPPFLAGS=$(FPPFLAGS)" \
3191 "MPI_INTERFACE= " \
3192 "FFLAGS=$(FFLAGS)" module )
3193+=======
3194+ sys.o xml.o m_walltime.o ioncat.o handlers.o $(SYSOBJ)
3195+#
3196+include $(GRIDXC_SERIAL_ROOT)/gridxc.mk
3197+XC = $(GRIDXC_LIBS)
3198+INCFLAGS:= $(INCFLAGS) $(GRIDXC_INCFLAGS)
3199+>>>>>>> MERGE-SOURCE
3200 #
3201 NCPS=$(MAIN_OBJDIR)/ncps/src/libncps.a
3202 PSOP=$(MAIN_OBJDIR)/psoplib/src/libpsop.a
3203@@ -98,7 +120,7 @@
3204 #
3205 FDF=libfdf.a
3206 FDF_MAKEFILE=$(TOP_LEVEL)/fdf/makefile
3207-FDF_INCFLAGS:=-I $(TOP_LEVEL)/fdf $(INCFLAGS)
3208+FDF_INCFLAGS:=#-I $(TOP_LEVEL)/fdf $(INCFLAGS)
3209 $(FDF):
3210 (mkdir -p fdf ; cd fdf ; $(MAKE) -f $(FDF_MAKEFILE) "FC=$(FC)" "VPATH=$(TOP_LEVEL)/fdf" \
3211 "ARCH_MAKE=$(ARCH_MAKE)" \
3212@@ -132,7 +154,6 @@
3213 rm -f gen-basis ioncat *.o *.a
3214 rm -f *.mod
3215 rm -rf fdf
3216- rm -rf SiestaXC
3217 rm -f _tmp_deps deps.list protomake*
3218 #
3219 ALL_OBJS=$(IONCAT_OBJS) $(OBJS_GEN-BASIS)
3220@@ -153,28 +174,41 @@
3221 basis_types.o: alloc.o atmparams.o precision.o sys.o
3222 m_io.o: sys.o
3223 io.o: sys.o
3224-alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
3225 atom_options.o: sys.o
3226 basis_io.o: atm_types.o atmparams.o atom_options.o basis_types.o chemical.o
3227 basis_io.o: precision.o radial.o sys.o xml.o
3228 atm_types.o: precision.o radial.o
3229 radial.o: alloc.o interpolation.o precision.o xml.o
3230-memory.o: alloc.o memoryinfo.o parallel.o precision.o
3231+memory.o: memory_log.o parallel.o
3232 chkdim.o: sys.o
3233 chemical.o: parallel.o precision.o sys.o
3234+<<<<<<< TREE
3235 basis_specs.o: basis_types.o chemical.o periodic_table.o precision.o sys.o
3236 memoryinfo.o: precision.o
3237 m_memory.o: memoryinfo.o parallel.o sys.o
3238+=======
3239+basis_specs.o: basis_types.o chemical.o periodic_table.o precision.o
3240+basis_specs.o: pseudopotential.o sys.o
3241+memory_log.o: m_io.o parallel.o precision.o
3242+>>>>>>> MERGE-SOURCE
3243 periodic_table.o: precision.o sys.o
3244 atmfuncs.o: atm_types.o precision.o radial.o spher_harm.o sys.o
3245 spher_harm.o: alloc.o precision.o sys.o
3246 sys.o: parallel.o
3247 xml.o: precision.o
3248 ioncat.o: atm_types.o atmfuncs.o basis_io.o m_getopts.o precision.o
3249+<<<<<<< TREE
3250+=======
3251+handlers.o: memory_log.o
3252+>>>>>>> MERGE-SOURCE
3253 m_io.o: sys.o
3254 io.o: sys.o
3255+<<<<<<< TREE
3256 alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
3257 basis_types.o: alloc.o atmparams.o precision.o sys.o
3258+=======
3259+basis_types.o: alloc.o atmparams.o precision.o pseudopotential.o sys.o
3260+>>>>>>> MERGE-SOURCE
3261 basis_io.o: atm_types.o atmparams.o atom_options.o basis_types.o chemical.o
3262 basis_io.o: precision.o radial.o sys.o xml.o
3263 chemical.o: parallel.o precision.o sys.o
3264@@ -186,23 +220,40 @@
3265 bessph.o: precision.o sys.o
3266 radfft.o: alloc.o bessph.o m_fft_gpfa.o precision.o
3267 m_filter.o: bessph.o precision.o radfft.o sorting.o sys.o
3268+<<<<<<< TREE
3269 basis_specs.o: basis_types.o chemical.o periodic_table.o precision.o sys.o
3270+=======
3271+basis_specs.o: basis_types.o chemical.o periodic_table.o precision.o
3272+basis_specs.o: pseudopotential.o sys.o
3273+ldau_specs.o: alloc.o atm_types.o atmparams.o atom.o atom_options.o
3274+ldau_specs.o: basis_specs.o basis_types.o interpolation.o m_cite.o parallel.o
3275+ldau_specs.o: precision.o pseudopotential.o radial.o sys.o units.o
3276+>>>>>>> MERGE-SOURCE
3277 atom.o: atmparams.o atom_options.o basis_specs.o basis_types.o bsc_xcmod.o
3278 atom.o: interpolation.o m_filter.o old_atmfuncs.o periodic_table.o precision.o
3279+<<<<<<< TREE
3280 atom.o: sys.o
3281 memoryinfo.o: precision.o
3282 memory.o: alloc.o memoryinfo.o parallel.o precision.o
3283+=======
3284+atom.o: pseudopotential.o sys.o
3285+memory.o: memory_log.o parallel.o
3286+memory_log.o: m_io.o parallel.o precision.o
3287+>>>>>>> MERGE-SOURCE
3288 periodic_table.o: precision.o sys.o
3289 atom_options.o: sys.o
3290 arw.o: alloc.o parallel.o precision.o sys.o
3291 sys.o: parallel.o
3292-timer.o: m_timer.o parallel.o sys.o timer_tree.o
3293 xml.o: precision.o
3294 read_xc_info.o: parallel.o precision.o sys.o
3295 gen-basis.o: atom.o atom_options.o basis_io.o basis_specs.o basis_types.o
3296 gen-basis.o: old_atmfuncs.o parallel.o precision.o sys.o
3297 xc.o: alloc.o bsc_xcmod.o precision.o sys.o
3298 bsc_xcmod.o: parallel.o precision.o sys.o
3299+<<<<<<< TREE
3300 ldau_specs.o: alloc.o atm_types.o atmparams.o atom.o atom_options.o
3301 ldau_specs.o: basis_specs.o basis_types.o interpolation.o m_cite.o parallel.o
3302 ldau_specs.o: precision.o radial.o sys.o units.o
3303+=======
3304+handlers.o: memory_log.o
3305+>>>>>>> MERGE-SOURCE
3306
3307=== added file 'Util/Gen-basis/handlers.f'
3308--- Util/Gen-basis/handlers.f 1970-01-01 00:00:00 +0000
3309+++ Util/Gen-basis/handlers.f 2016-07-19 08:21:24 +0000
3310@@ -0,0 +1,114 @@
3311+!--------------------------------------------------
3312+! Stand-alone 'die' routine for use by libraries and
3313+! low-level modules.
3314+!
3315+! Each program using the module or library needs to
3316+! provide a routine with the proper interface, but
3317+! accomodating the needs and conventions of the program.
3318+! For example, in Siesta:
3319+!
3320+! - The use of a Siesta-specific 'mpi_siesta' module.
3321+! - The need to have the pxf functionality.
3322+! - The use of 'unit 6' as output.
3323+!
3324+! Routines using this functionality should include
3325+! the following
3326+!
3327+! interface
3328+! subroutine die(str)
3329+! character(len=*), intent(in) :: str
3330+! end subroutine die
3331+! end interface
3332+!
3333+!------------------------------------------------------
3334+
3335+ subroutine die(str)
3336+
3337+ character(len=*), intent(in) :: str
3338+
3339+ write(6,'(a)') trim(str)
3340+ write(0,'(a)') trim(str)
3341+ write(6,'(a,i4)') 'Stopping Program from Node: ', Node
3342+ write(0,'(a,i4)') 'Stopping Program from Node: ', Node
3343+ call pxfflush(6)
3344+ call pxfflush(0)
3345+ call pxfabort()
3346+
3347+ end subroutine die
3348+
3349+ subroutine timer(str,i)
3350+
3351+ character(len=*), intent(in) :: str
3352+ integer, intent(in) :: i
3353+ end subroutine timer
3354+
3355+!--------------------------------------------------
3356+! Stand-alone routine to capture error messages from
3357+! the alloc module
3358+!
3359+! This functionality could be made more general,
3360+! and use a uniform interface for all the utility
3361+! modules developed in-house. (Let's say, call it
3362+! 'error_report' with severity arguments, etc).
3363+!
3364+! Each program using the alloc module needs to
3365+! provide a routine with the proper interface, but
3366+! accomodating the needs and conventions of the program.
3367+! For example, in Siesta:
3368+!
3369+! - The tagging of the message by Node.
3370+! - The use of 'unit 6' as output and '0' as error.
3371+!
3372+! Routines using this functionality should include
3373+! the following
3374+!
3375+! subroutine alloc_error_report(str,code)
3376+! character(len=*), intent(in) :: str
3377+! integer, intent(in) :: code
3378+! end subroutine alloc_error_report
3379+!
3380+!------------------------------------------------------
3381+
3382+ subroutine alloc_error_report(str,code)
3383+
3384+ character(len=*), intent(in) :: str
3385+ integer, intent(in) :: code
3386+
3387+ if (code == 0) then
3388+ call die(str)
3389+ else
3390+ write(0,*) trim(str)
3391+ write(6,*) trim(str)
3392+ endif
3393+
3394+ end subroutine alloc_error_report
3395+!--------------------------------------------------
3396+! Stand-alone routine to capture memory events from
3397+! the alloc module
3398+!
3399+! Each program using the alloc module needs to
3400+! provide a routine with the proper interface, but
3401+! accomodating the needs and conventions of the program.
3402+! For example, in Siesta
3403+!
3404+! - The use of the memory_log module for reports
3405+!
3406+! Routines using this functionality should include
3407+! the following
3408+!
3409+! subroutine alloc_memory_event(str,code)
3410+! character(len=*), intent(in) :: str
3411+! integer, intent(in) :: code
3412+! end subroutine alloc_memory_event
3413+!
3414+!------------------------------------------------------
3415+
3416+ subroutine alloc_memory_event(bytes,name)
3417+ use memory_log, only: memory_event
3418+
3419+ integer, intent(in) :: bytes
3420+ character(len=*), intent(in) :: name
3421+
3422+ call memory_event(bytes,name)
3423+
3424+ end subroutine alloc_memory_event
3425
3426=== renamed file 'Util/Gen-basis/local_die.F' => 'Util/Gen-basis/local_die.F.THIS'
3427=== modified file 'Util/SiestaSubroutine/ProtoNEB/Src/Makefile'
3428--- Util/SiestaSubroutine/ProtoNEB/Src/Makefile 2016-06-29 04:07:55 +0000
3429+++ Util/SiestaSubroutine/ProtoNEB/Src/Makefile 2016-07-19 08:21:24 +0000
3430@@ -39,6 +39,7 @@
3431 SIESTA_LIB=libSiestaForces.a
3432 FDF=libfdf.a
3433 XMLPARSER=libxmlparser.a
3434+<<<<<<< TREE
3435 XC=libSiestaXC.a
3436 #
3437 include $(MAIN_OBJDIR)/Mk/FoX.mk
3438@@ -47,6 +48,10 @@
3439 PSOP=$(MAIN_OBJDIR)/psoplib/src/libpsop.a
3440 PSML=$(MAIN_OBJDIR)/psml/src/libpsml.a
3441 #
3442+=======
3443+XC=libGridXC.a
3444+FoX_LIBS=`$(OBJ_DIR)/FoX/FoX-config --libs --wcml`
3445+>>>>>>> MERGE-SOURCE
3446 ALL_LIBS= $(SIESTA_LIB) $(FDF) $(WXML) $(XMLPARSER) $(XC) \
3447 $(NCPS) $(PSML) $(PSOP) \
3448 $(MPI_INTERFACE) $(COMP_LIBS) $(FOX_LIBS) $(LIBS)
3449
3450=== modified file 'Util/SiestaSubroutine/SimpleTest/Src/Makefile'
3451--- Util/SiestaSubroutine/SimpleTest/Src/Makefile 2016-06-29 04:07:55 +0000
3452+++ Util/SiestaSubroutine/SimpleTest/Src/Makefile 2016-07-19 08:21:24 +0000
3453@@ -57,6 +57,7 @@
3454 SIESTA_LIB=libSiestaForces.a
3455 FDF=libfdf.a
3456 XMLPARSER=libxmlparser.a
3457+<<<<<<< TREE
3458 XC=libSiestaXC.a
3459 include $(MAIN_OBJDIR)/Mk/FoX.mk
3460 #
3461@@ -64,6 +65,10 @@
3462 PSOP=$(MAIN_OBJDIR)/psoplib/src/libpsop.a
3463 PSML=$(MAIN_OBJDIR)/psml/src/libpsml.a
3464 #
3465+=======
3466+XC=libGridXC.a
3467+FoX_LIBS=`$(OBJ_DIR)/FoX/FoX-config --libs --wcml`
3468+>>>>>>> MERGE-SOURCE
3469 ALL_LIBS= $(SIESTA_LIB) $(FDF) $(WXML) $(XMLPARSER) $(XC) \
3470 $(NCPS) $(PSML) $(PSOP) \
3471 $(MPI_INTERFACE) $(COMP_LIBS) $(FOX_LIBS) $(LIBS)
3472
3473=== modified file 'Util/VCA/Makefile'
3474--- Util/VCA/Makefile 2016-07-12 13:38:13 +0000
3475+++ Util/VCA/Makefile 2016-07-19 08:21:24 +0000
3476@@ -85,17 +85,28 @@
3477 #
3478 MIXPS_OBJS= f2kcli.o interpolation.o atom_options.o \
3479 sys.o m_io.o io.o alloc.o pxf.o parallel.o periodic_table.o \
3480+<<<<<<< TREE
3481 memory.o memoryinfo.o mixps.o psml_die.o die.o
3482 #
3483 NCPS=$(MAIN_OBJDIR)/ncps/src/libncps.a
3484 #
3485 mixps: $(FDF) $(MIXPS_OBJS) $(NCPS)
3486+=======
3487+ memory.o memory_log.o mixps.o handlers.o
3488+
3489+mixps: $(FDF) $(MIXPS_OBJS)
3490+>>>>>>> MERGE-SOURCE
3491 $(FC) -o mixps \
3492 $(LDFLAGS) $(MIXPS_OBJS) $(NCPS) $(FDF) $(PSML_LIBS) $(XMLF90_LIBS)
3493 #----------------------------------------------------------------------------
3494 FRACTIONAL_OBJS= f2kcli.o m_io.o alloc.o interpolation.o fractional.o \
3495+<<<<<<< TREE
3496 atom_options.o memory.o memoryinfo.o sys.o \
3497 io.o pxf.o parallel.o periodic_table.o psml_die.o die.o
3498+=======
3499+ atom_options.o memory.o memory_log.o pseudopotential.o \
3500+ io.o pxf.o parallel.o periodic_table.o handlers.o sys.o
3501+>>>>>>> MERGE-SOURCE
3502
3503 fractional: $(FDF) $(FRACTIONAL_OBJS) $(NCPS)
3504 $(FC) -o fractional \
3505@@ -128,19 +139,38 @@
3506 sys.o: parallel.o
3507 m_io.o: sys.o
3508 io.o: sys.o
3509-alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
3510 periodic_table.o: precision.o sys.o
3511-memory.o: alloc.o memoryinfo.o parallel.o precision.o
3512-memoryinfo.o: precision.o
3513+memory.o: memory_log.o parallel.o
3514+memory_log.o: m_io.o parallel.o precision.o
3515 mixps.o: f2kcli.o interpolation.o periodic_table.o precision.o
3516+<<<<<<< TREE
3517 die.o: parallel.o
3518+=======
3519+mixps.o: pseudopotential.o
3520+handlers.o: memory_log.o
3521+>>>>>>> MERGE-SOURCE
3522 m_io.o: sys.o
3523+<<<<<<< TREE
3524 alloc.o: debugmpi.o m_io.o parallel.o precision.o sys.o
3525 fractional.o: f2kcli.o periodic_table.o precision.o
3526+=======
3527+fractional.o: f2kcli.o periodic_table.o precision.o pseudopotential.o
3528+>>>>>>> MERGE-SOURCE
3529 atom_options.o: sys.o
3530+<<<<<<< TREE
3531 memory.o: alloc.o memoryinfo.o parallel.o precision.o
3532 memoryinfo.o: precision.o
3533 sys.o: parallel.o
3534+=======
3535+memory.o: memory_log.o parallel.o
3536+memory_log.o: m_io.o parallel.o precision.o
3537+pseudopotential.o: alloc.o atom_options.o interpolation.o precision.o sys.o
3538+>>>>>>> MERGE-SOURCE
3539 io.o: sys.o
3540 periodic_table.o: precision.o sys.o
3541+<<<<<<< TREE
3542 die.o: parallel.o
3543+=======
3544+handlers.o: memory_log.o
3545+sys.o: parallel.o
3546+>>>>>>> MERGE-SOURCE
3547
3548=== added file 'Util/VCA/handlers.f'
3549--- Util/VCA/handlers.f 1970-01-01 00:00:00 +0000
3550+++ Util/VCA/handlers.f 2016-07-19 08:21:24 +0000
3551@@ -0,0 +1,114 @@
3552+!--------------------------------------------------
3553+! Stand-alone 'die' routine for use by libraries and
3554+! low-level modules.
3555+!
3556+! Each program using the module or library needs to
3557+! provide a routine with the proper interface, but
3558+! accomodating the needs and conventions of the program.
3559+! For example, in Siesta:
3560+!
3561+! - The use of a Siesta-specific 'mpi_siesta' module.
3562+! - The need to have the pxf functionality.
3563+! - The use of 'unit 6' as output.
3564+!
3565+! Routines using this functionality should include
3566+! the following
3567+!
3568+! interface
3569+! subroutine die(str)
3570+! character(len=*), intent(in) :: str
3571+! end subroutine die
3572+! end interface
3573+!
3574+!------------------------------------------------------
3575+
3576+ subroutine die(str)
3577+
3578+ character(len=*), intent(in) :: str
3579+
3580+ write(6,'(a)') trim(str)
3581+ write(0,'(a)') trim(str)
3582+ write(6,'(a,i4)') 'Stopping Program from Node: ', Node
3583+ write(0,'(a,i4)') 'Stopping Program from Node: ', Node
3584+ call pxfflush(6)
3585+ call pxfflush(0)
3586+ call pxfabort()
3587+
3588+ end subroutine die
3589+
3590+ subroutine timer(str,i)
3591+
3592+ character(len=*), intent(in) :: str
3593+ integer, intent(in) :: i
3594+ end subroutine timer
3595+
3596+!--------------------------------------------------
3597+! Stand-alone routine to capture error messages from
3598+! the alloc module
3599+!
3600+! This functionality could be made more general,
3601+! and use a uniform interface for all the utility
3602+! modules developed in-house. (Let's say, call it
3603+! 'error_report' with severity arguments, etc).
3604+!
3605+! Each program using the alloc module needs to
3606+! provide a routine with the proper interface, but
3607+! accomodating the needs and conventions of the program.
3608+! For example, in Siesta:
3609+!
3610+! - The tagging of the message by Node.
3611+! - The use of 'unit 6' as output and '0' as error.
3612+!
3613+! Routines using this functionality should include
3614+! the following
3615+!
3616+! subroutine alloc_error_report(str,code)
3617+! character(len=*), intent(in) :: str
3618+! integer, intent(in) :: code
3619+! end subroutine alloc_error_report
3620+!
3621+!------------------------------------------------------
3622+
3623+ subroutine alloc_error_report(str,code)
3624+
3625+ character(len=*), intent(in) :: str
3626+ integer, intent(in) :: code
3627+
3628+ if (code == 0) then
3629+ call die(str)
3630+ else
3631+ write(0,*) trim(str)
3632+ write(6,*) trim(str)
3633+ endif
3634+
3635+ end subroutine alloc_error_report
3636+!--------------------------------------------------
3637+! Stand-alone routine to capture memory events from
3638+! the alloc module
3639+!
3640+! Each program using the alloc module needs to
3641+! provide a routine with the proper interface, but
3642+! accomodating the needs and conventions of the program.
3643+! For example, in Siesta
3644+!
3645+! - The use of the memory_log module for reports
3646+!
3647+! Routines using this functionality should include
3648+! the following
3649+!
3650+! subroutine alloc_memory_event(str,code)
3651+! character(len=*), intent(in) :: str
3652+! integer, intent(in) :: code
3653+! end subroutine alloc_memory_event
3654+!
3655+!------------------------------------------------------
3656+
3657+ subroutine alloc_memory_event(bytes,name)
3658+ use memory_log, only: memory_event
3659+
3660+ integer, intent(in) :: bytes
3661+ character(len=*), intent(in) :: name
3662+
3663+ call memory_event(bytes,name)
3664+
3665+ end subroutine alloc_memory_event
3666
3667=== modified file 'version.info'
3668--- version.info 2016-07-16 20:21:18 +0000
3669+++ version.info 2016-07-19 08:21:24 +0000
3670@@ -1,6 +1,12 @@
3671+<<<<<<< TREE
3672 trunk-506--psml-81
3673
3674
3675
3676
3677
3678+=======
3679+siesta-trunk-503--gridxc-12
3680+
3681+
3682+>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches