Line data Source code
1 : !!****m* ABINIT/m_array
2 : !! NAME
3 : !! m_array
4 : !!
5 : !! FUNCTION
6 : !! This module provides data types that can be used to construct ragged arrays
7 : !! and helper functions to print/write the array in different formats.
8 : !!
9 : !! COPYRIGHT
10 : !! Copyright (C) 2008-2026 ABINIT group (MG)
11 : !! This file is distributed under the terms of the
12 : !! GNU General Public License, see ~abinit/COPYING
13 : !! or http://www.gnu.org/copyleft/gpl.txt .
14 : !!
15 : !! SOURCE
16 :
17 : #if defined HAVE_CONFIG_H
18 : #include "config.h"
19 : #endif
20 :
21 : #include "abi_common.h"
22 :
23 : MODULE m_array
24 :
25 : use defs_basis
26 : use m_abicore
27 : use m_errors
28 : use m_nctk
29 : use netcdf
30 :
31 : use m_numeric_tools, only : c2r
32 :
33 : implicit none
34 :
35 : private
36 : !!***
37 :
38 : public :: farray_ncwrite ! Write the values to a netcdf file with id ncid (debugging tool)
39 : ! Ex: call farray_ncwrite("array_name", array, "ncid).
40 :
41 : !public :: array_print ! Print the values of the array (formatted form)
42 :
43 : !interface array_print
44 : ! module procedure array2_gwpc_print
45 : !end interface array_print
46 :
47 : !interface array_allgatherv
48 : ! module procedure
49 : !end interface array_allgatherv
50 :
51 : interface farray_ncwrite
52 : module procedure farr_real_dp1
53 : module procedure farr_complex_dpc1
54 : end interface farray_ncwrite
55 :
56 :
57 : !!****t* m_array/array2_gwpc_type
58 : !! NAME
59 : !! array2_gwpc_t
60 : !!
61 : !! FUNCTION
62 : !! A datatype used to construct ragged 2D-arrays with KIND=gwpc
63 : !!
64 : !! SOURCE
65 :
66 : type,public :: array2_gwpc_t
67 : complex(gwp),allocatable :: vals(:,:)
68 :
69 : contains
70 :
71 : procedure :: free => array2_gwpc_free
72 :
73 : end type array2_gwpc_t
74 :
75 : interface array_free
76 : module procedure array2_gwpc_free
77 : end interface array_free
78 :
79 : public :: array_free ! Free memory
80 : !!***
81 :
82 : contains
83 :
84 : !!****f* m_array/array2_gwpc_free
85 : !! NAME
86 : !! array2_gwpc_free
87 : !!
88 : !! FUNCTION
89 : !! Free memory
90 : !!
91 : !! SOURCE
92 :
93 2544 : subroutine array2_gwpc_free(Array)
94 :
95 : !Arguments ------------------------------------
96 : class(array2_gwpc_t),intent(inout) :: Array
97 : ! *********************************************************************
98 :
99 2544 : ABI_SFREE(Array%vals)
100 :
101 2544 : end subroutine array2_gwpc_free
102 : !!***
103 :
104 : ! Include routines for dumping results in Netcdf format.
105 : ! (useful for debugging or quick analysis)
106 : ! The include file is automatically generated by the script genarray.py
107 : ! Change the python code if you need to support other kinds or types
108 : ! then add the new routines to the generic interface *farray_ncwrite*
109 : !
110 : ! API Example
111 : ! Open the netcdf file and get the NC id
112 : ! ...
113 : ! Write data values. Use "array_name" as keyword
114 : ! call farray_ncwrite(array, "array_name", ncid)
115 :
116 : #include "farray_ncwrite.finc"
117 :
118 0 : END MODULE m_array
|