marray_base.f90
Go to the documentation of this file.
1 !#############################################################################
2 !# #
3 !# fosite - 3D hydrodynamical simulation program #
4 !# module: marray_base.f90 #
5 !# #
6 !# Copyright (C) 2018 #
7 !# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
8 !# #
9 !# This program is free software; you can redistribute it and/or modify #
10 !# it under the terms of the GNU General Public License as published by #
11 !# the Free Software Foundation; either version 2 of the License, or (at #
12 !# your option) any later version. #
13 !# #
14 !# This program is distributed in the hope that it will be useful, but #
15 !# WITHOUT ANY WARRANTY; without even the implied warranty of #
16 !# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
17 !# NON INFRINGEMENT. See the GNU General Public License for more #
18 !# details. #
19 !# #
20 !# You should have received a copy of the GNU General Public License #
21 !# along with this program; if not, write to the Free Software #
22 !# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
23 !# #
24 !#############################################################################
29 !----------------------------------------------------------------------------!
35 !----------------------------------------------------------------------------!
37  IMPLICIT NONE
38  !--------------------------------------------------------------------------!
39  PRIVATE
42  INTEGER, SAVE :: igmin,igmax
43  INTEGER, SAVE :: jgmin,jgmax
44  INTEGER, SAVE :: kgmin,kgmax
45  INTEGER, SAVE :: inum,jnum,knum
46  LOGICAL, SAVE :: idx_init = .false.
50  INTEGER :: imin,imax
51  INTEGER :: jmin,jmax
52  INTEGER :: kmin,kmax
53  LOGICAL, POINTER :: mask1d(:)
54  LOGICAL, POINTER :: mask2d(:,:)
55  LOGICAL, POINTER, CONTIGUOUS :: mask3d(:,:,:)
56  CONTAINS
58  PROCEDURE :: cuboid
59  PROCEDURE :: everything
60  PROCEDURE :: destroy_selection
61  generic :: destroy => destroy_selection
62  END TYPE selection_base
64  TYPE :: marray_base
65  INTEGER :: rank = -1,dims(2) = 0
66  REAL, POINTER, CONTIGUOUS :: data1d(:) => null()
67  REAL, POINTER, CONTIGUOUS :: data2d(:,:) => null()
68  REAL, POINTER, CONTIGUOUS :: data3d(:,:,:) => null()
69  REAL, POINTER, CONTIGUOUS :: data4d(:,:,:,:) => null()
70  REAL, POINTER, CONTIGUOUS :: data5d(:,:,:,:,:) => null()
71  CONTAINS
72  PROCEDURE :: assignpointers
73  PROCEDURE :: remapbounds_0
74  PROCEDURE :: remapbounds_1
75  PROCEDURE :: remapbounds_2
76  generic :: remapbounds => remapbounds_0, remapbounds_1, remapbounds_2
77  PROCEDURE :: assignmarray_0
78  PROCEDURE :: assignmarray_1
79  PROCEDURE :: assignmarray_2
80  PROCEDURE :: assignmarray_3
81  PROCEDURE :: assignmarray_4
82  PROCEDURE :: assignmarray_5
83  generic :: ASSIGNMENT (=) => assignmarray_0 , assignmarray_1, assignmarray_2, &
85  PROCEDURE :: addmarray_0
86  PROCEDURE :: addmarray_1
87  PROCEDURE :: addmarray_2
88  PROCEDURE :: addmarray_3
89  PROCEDURE :: addmarray_4
90  PROCEDURE :: addmarray_5
91  generic :: OPERATOR (+) => addmarray_0, addmarray_1, addmarray_2, &
93  PROCEDURE :: multmarray_0
94  PROCEDURE :: multmarray_1
95  PROCEDURE :: multmarray_2
96  PROCEDURE :: multmarray_3
97  PROCEDURE :: multmarray_4
98  PROCEDURE :: multmarray_5
99  generic :: OPERATOR (*) => multmarray_0, multmarray_1, multmarray_2, &
101  PROCEDURE :: destroy
102  END TYPE
103  INTERFACE marray_base
104  MODULE PROCEDURE createmarray
105  END INTERFACE
106  INTERFACE selection_base
107  MODULE PROCEDURE createselection
108  END INTERFACE
109  !--------------------------------------------------------------------------!
110  PUBLIC :: marray_base, &
111  selection_base, &
114 
115  CONTAINS
116 
118  FUNCTION createmarray(m,n) RESULT(new_ma)
119  IMPLICIT NONE
120  !-------------------------------------------------------------------!
121  TYPE(marray_base) :: new_ma
122  INTEGER, OPTIONAL, INTENT(IN) :: m,n
123  !-------------------------------------------------------------------!
124  INTEGER :: err
125  !-------------------------------------------------------------------!
126  IF (idx_init) THEN
127  IF (PRESENT(m)) THEN
128  new_ma%DIMS(1) = m
129  IF (PRESENT(n)) THEN
130  new_ma%DIMS(2) = n
131  new_ma%RANK = 2
132  ELSE
133  new_ma%DIMS(2) = 1
134  new_ma%RANK = 1
135  END IF
136  ELSE
137  new_ma%DIMS(:) = 1
138  new_ma%RANK = 0
139  END IF
140  END IF
141  END FUNCTION createmarray
142 
146  SUBROUTINE initmeshproperties(igmin_,igmax_,jgmin_,jgmax_,kgmin_,kgmax_)
147  IMPLICIT NONE
148  !-------------------------------------------------------------------!
149  INTEGER, INTENT(IN) :: igmin_,igmax_,jgmin_,jgmax_,kgmin_,kgmax_
150  !-------------------------------------------------------------------!
151  IF (.NOT.idx_init) THEN
152  igmin = igmin_
153  igmax = igmax_
154  jgmin = jgmin_
155  jgmax = jgmax_
156  kgmin = kgmin_
157  kgmax = kgmax_
158  inum = igmax-igmin+1
159  jnum = jgmax-jgmin+1
160  knum = kgmax-kgmin+1
161  idx_init = .true.
162  END IF
163  END SUBROUTINE initmeshproperties
164 
168  SUBROUTINE closemeshproperties
169  IMPLICIT NONE
170  !-------------------------------------------------------------------!
171  IF (idx_init) THEN
172  idx_init = .false.
173  END IF
174  END SUBROUTINE closemeshproperties
175 
177  SUBROUTINE assignpointers(this)
178  IMPLICIT NONE
179  !------------------------------------------------------------------------!
180  CLASS(marray_base),INTENT(INOUT) :: this
181  !------------------------------------------------------------------------!
182  IF (ASSOCIATED(this%data1d).AND.SIZE(this%data1d).GT.0) THEN
183  SELECT CASE(this%RANK)
184  CASE(0)
185  this%data2d(1:inum*jnum,kgmin:kgmax) => this%data1d
186  this%data3d(igmin:igmax,jgmin:jgmax,kgmin:kgmax) => this%data1d
187  this%data4d(igmin:igmax,jgmin:jgmax,kgmin:kgmax,1:1) => this%data1d
188  this%data5d(igmin:igmax,jgmin:jgmax,kgmin:kgmax,1:1,1:1) => this%data1d
189  CASE(1)
190  this%data2d(1:inum*jnum*knum,1:this%DIMS(1)) => this%data1d
191  this%data3d(1:inum*jnum,kgmin:kgmax,1:this%DIMS(1)) => this%data1d
192  this%data4d(igmin:igmax,jgmin:jgmax,kgmin:kgmax,1:this%DIMS(1)) => this%data1d
193  this%data5d(igmin:igmax,jgmin:jgmax,kgmin:kgmax,1:this%DIMS(1),1:1) => this%data1d
194  CASE(2)
195  this%data2d(1:inum*jnum*knum*this%DIMS(1),1:this%DIMS(2)) => this%data1d
196  this%data3d(1:inum*jnum*knum,1:this%DIMS(1),1:this%DIMS(2)) => this%data1d
197  this%data4d(1:inum*jnum,kgmin:kgmax,1:this%DIMS(1),1:this%DIMS(2)) => this%data1d
198  this%data5d(igmin:igmax,jgmin:jgmax,kgmin:kgmax,1:this%DIMS(1),1:this%DIMS(2)) => this%data1d
199  END SELECT
200  END IF
201  END SUBROUTINE assignpointers
202 
209  FUNCTION remapbounds_0(this,array) RESULT(ptr)
210  IMPLICIT NONE
211  !------------------------------------------------------------------------!
212  CLASS(marray_base) :: this
213  REAL, DIMENSION(IGMIN:,JGMIN:,KGMIN:), TARGET :: array
214  !------------------------------------------------------------------------!
215  REAL, DIMENSION(:,:,:), POINTER :: ptr
216  !------------------------------------------------------------------------!
217  INTENT(IN) :: array
218  !------------------------------------------------------------------------!
219  ptr => array
220  END FUNCTION remapbounds_0
221 
223  FUNCTION remapbounds_1(this,array) RESULT(ptr)
224  IMPLICIT NONE
225  !------------------------------------------------------------------------!
226  CLASS(marray_base) :: this
227  REAL, DIMENSION(IGMIN:,JGMIN:,KGMIN:,:), TARGET &
228  :: array
229  !------------------------------------------------------------------------!
230  REAL, DIMENSION(:,:,:,:), POINTER :: ptr
231  !------------------------------------------------------------------------!
232  INTENT(IN) :: array
233  !------------------------------------------------------------------------!
234  ptr => array
235  END FUNCTION remapbounds_1
236 
238  FUNCTION remapbounds_2(this,array) RESULT(ptr)
239  IMPLICIT NONE
240  !------------------------------------------------------------------------!
241  CLASS(marray_base) :: this
242  REAL, DIMENSION(IGMIN:,JGMIN:,KGMIN:,:,:), TARGET &
243  :: array
244  !------------------------------------------------------------------------!
245  REAL, DIMENSION(:,:,:,:,:), POINTER :: ptr
246  !------------------------------------------------------------------------!
247  INTENT(IN) :: array
248  !------------------------------------------------------------------------!
249  ptr => array
250  END FUNCTION remapbounds_2
251 
253  SUBROUTINE assignmarray_0(this,ma)
254  IMPLICIT NONE
255  !------------------------------------------------------------------------!
256  CLASS(marray_base),INTENT(INOUT) :: this
257  CLASS(marray_base),INTENT(IN) :: ma
258  !------------------------------------------------------------------------!
259  INTEGER :: err
260  !------------------------------------------------------------------------!
261  IF (ASSOCIATED(ma%data1d)) THEN
262  ! copy meta data
263  this%RANK = ma%RANK
264  this%DIMS(:) = ma%DIMS(:)
265  IF (ASSOCIATED(this%data1d)) THEN
266  IF (SIZE(this%data1d).EQ.0) THEN
267  ! this%data1d allocated with size zero
268  DEALLOCATE(this%data1d)
269  ! allocate and assign data
270  ALLOCATE(this%data1d(SIZE(ma%data1d,1)),source=ma%data1d,stat=err)
271  IF (err.NE.0) THEN
272  print *,"ERROR in marray_base::AssignMArray_0: memory allocation failed"
273  stop 1
274  END IF
275  ELSE IF (SIZE(this%data1d).EQ.SIZE(ma%data1d)) THEN
276  ! just copy the data
277  this%data1d(:) = ma%data1d(:)
278  ELSE
280  print *,"ERROR in marray_base::AssignMArray_0: size of input and output do not match"
281  stop 1
282  END IF
283  ELSE
284  ! allocate and copy data
285  ALLOCATE(this%data1d(SIZE(ma%data1d,1)),source=ma%data1d,stat=err)
286  IF (err.NE.0) THEN
287  print *,"ERROR in marray_base::AssignMArray_0: memory allocation failed"
288  stop 1
289  END IF
290  END IF
291  CALL this%AssignPointers()
292  ELSE IF ((.NOT.ASSOCIATED(ma%data1d)).AND.(ma%RANK.GE.0)) THEN
293  this%RANK = ma%RANK
294  this%DIMS(:) = ma%DIMS(:)
295  ! just allocate data of newly created marray without copying
296  ALLOCATE(this%data1d(inum*jnum*knum*this%DIMS(1)*this%DIMS(2)),stat=err)
297  IF (err.NE.0) THEN
298  print *,"ERROR in marray_base::AssignMArray_0: memory allocation failed"
299  stop 1
300  END IF
301  CALL this%AssignPointers()
302  ELSE IF (ASSOCIATED(this%data1d)) THEN
303  ! both of same type ma%data1d not associated, but this%data1d associated
304  print *,"ERROR in marray_base::AssignMArray_0: ma%data1d not associated but this%data1d is"
305  stop 1
306  ELSE
307  ! both of same type, but none of the data1d arrays allocated
308  print *,"ERROR in marray_base::AssignMArray_0: ma%data1d and this%data1d not associated"
309  stop 1
310  END IF
311  END SUBROUTINE assignmarray_0
312 
314  PURE SUBROUTINE assignmarray_1(this,a)
315  IMPLICIT NONE
316  !------------------------------------------------------------------------!
317  CLASS(marray_base),INTENT(INOUT) :: this
318  REAL, DIMENSION(INUM*JNUM*KNUM*this%DIMS(1)*this%DIMS(2)), INTENT(IN) :: a
319  !------------------------------------------------------------------------!
320  this%data1d(:) = a(:)
321  END SUBROUTINE assignmarray_1
322 
324  PURE SUBROUTINE assignmarray_2(this,a)
325  IMPLICIT NONE
326  !------------------------------------------------------------------------!
327  CLASS(marray_base),INTENT(INOUT) :: this
328  REAL, DIMENSION(SIZE(this%data2d,1),SIZE(this%data2d,2)), INTENT(IN) :: a
329  !------------------------------------------------------------------------!
330  this%data2d(:,:) = a(:,:)
331  END SUBROUTINE assignmarray_2
332 
334  PURE SUBROUTINE assignmarray_3(this,a)
335  IMPLICIT NONE
336  !------------------------------------------------------------------------!
337  CLASS(marray_base),INTENT(INOUT) :: this
338  REAL, DIMENSION(SIZE(this%data3d,1),SIZE(this%data3d,2),SIZE(this%data3d,3)), &
339  INTENT(IN) :: a
340  !------------------------------------------------------------------------!
341  this%data3d(:,:,:) = a(:,:,:)
342  END SUBROUTINE assignmarray_3
343 
345  PURE SUBROUTINE assignmarray_4(this,a)
346  IMPLICIT NONE
347  !------------------------------------------------------------------------!
348  CLASS(marray_base),INTENT(INOUT) :: this
349  REAL, DIMENSION(SIZE(this%data4d,1),SIZE(this%data4d,2),SIZE(this%data4d,3), & SIZE(this%data4d,4)), INTENT(IN) :: a
350  !------------------------------------------------------------------------!
351  this%data4d(:,:,:,:) = a(:,:,:,:)
352  END SUBROUTINE assignmarray_4
353 
355  PURE SUBROUTINE assignmarray_5(this,a)
356  IMPLICIT NONE
357  !------------------------------------------------------------------------!
358  CLASS(marray_base),INTENT(INOUT) :: this
359  REAL, DIMENSION(SIZE(this%data5d,1),SIZE(this%data5d,2),SIZE(this%data5d,3), & SIZE(this%data5d,4),SIZE(this%data5d,5)), INTENT(IN) :: a
360  !------------------------------------------------------------------------!
361  this%data5d(:,:,:,:,:) = a(:,:,:,:,:)
362  END SUBROUTINE assignmarray_5
363 
365  PURE FUNCTION addmarray_0(a,b) RESULT(c)
366  IMPLICIT NONE
367  !------------------------------------------------------------------------!
368  CLASS(marray_base),INTENT(IN) :: a,b
369  REAL, DIMENSION(SIZE(a%data1d)) :: c
370  !------------------------------------------------------------------------!
371  IF (SIZE(a%data1d).EQ.SIZE(b%data1d)) &
372  c(:) = a%data1d(:) + b%data1d(:)
373  END FUNCTION addmarray_0
374 
376  PURE FUNCTION addmarray_1(a,b) RESULT(c)
377  IMPLICIT NONE
378  !------------------------------------------------------------------------!
379  CLASS(marray_base),INTENT(IN) :: a
380  REAL, DIMENSION(SIZE(a%data1d)),INTENT(IN) :: b
381  REAL, DIMENSION(SIZE(a%data1d)) :: c
382  !------------------------------------------------------------------------!
383  c(:) = a%data1d(:) + b(:)
384  END FUNCTION addmarray_1
385 
387  PURE FUNCTION addmarray_2(a,b) RESULT(c)
388  IMPLICIT NONE
389  !------------------------------------------------------------------------!
390  CLASS(marray_base),INTENT(IN) :: a
391  REAL, DIMENSION(SIZE(a%data2d,1),SIZE(a%data2d,2)),INTENT(IN) :: b
392  REAL, DIMENSION(SIZE(a%data2d,1),SIZE(a%data2d,2)) :: c
393  !------------------------------------------------------------------------!
394  c(:,:) = a%data2d(:,:) + b(:,:)
395  END FUNCTION addmarray_2
396 
398  PURE FUNCTION addmarray_3(a,b) RESULT(c)
399  IMPLICIT NONE
400  !------------------------------------------------------------------------!
401  CLASS(marray_base),INTENT(IN) :: a
402  REAL, DIMENSION(SIZE(a%data3d,1),SIZE(a%data3d,2),SIZE(a%data3d,3)),INTENT(IN) :: b
403  REAL, DIMENSION(SIZE(a%data3d,1),SIZE(a%data3d,2),SIZE(a%data3d,3)) :: c
404  !------------------------------------------------------------------------!
405  c(:,:,:) = a%data3d(:,:,:) + b(:,:,:)
406  END FUNCTION addmarray_3
407 
409  PURE FUNCTION addmarray_4(a,b) RESULT(c)
410  IMPLICIT NONE
411  !------------------------------------------------------------------------!
412  CLASS(marray_base),INTENT(IN) :: a
413  REAL, DIMENSION(SIZE(a%data4d,1),SIZE(a%data4d,2),SIZE(a%data4d,3), & SIZE(a%data4d,4)),INTENT(IN) :: b
414  REAL, DIMENSION(SIZE(a%data4d,1),SIZE(a%data4d,2),SIZE(a%data4d,3), & SIZE(a%data4d,4)) :: c
415  !------------------------------------------------------------------------!
416  c(:,:,:,:) = a%data4d(:,:,:,:) + b(:,:,:,:)
417  END FUNCTION addmarray_4
418 
420  PURE FUNCTION addmarray_5(a,b) RESULT(c)
421  IMPLICIT NONE
422  !------------------------------------------------------------------------!
423  CLASS(marray_base),INTENT(IN) :: a
424  REAL, DIMENSION(SIZE(a%data5d,1),SIZE(a%data5d,2),SIZE(a%data5d,3), & SIZE(a%data5d,4),SIZE(a%data5d,5)),INTENT(IN) :: b
425  REAL, DIMENSION(SIZE(a%data5d,1),SIZE(a%data5d,2),SIZE(a%data5d,3), & SIZE(a%data5d,4),SIZE(a%data5d,5)) :: c
426  !------------------------------------------------------------------------!
427  c(:,:,:,:,:) = a%data5d(:,:,:,:,:) + b(:,:,:,:,:)
428  END FUNCTION addmarray_5
429 
431  PURE FUNCTION multmarray_0(a,b) RESULT(c)
432  IMPLICIT NONE
433  !------------------------------------------------------------------------!
434  CLASS(marray_base),INTENT(IN) :: a,b
435  REAL, DIMENSION(SIZE(a%data1d)) :: c
436  !------------------------------------------------------------------------!
437  IF (SIZE(a%data1d).EQ.SIZE(b%data1d)) &
438  c(:) = a%data1d(:) * b%data1d(:)
439  END FUNCTION multmarray_0
440 
442  PURE FUNCTION multmarray_1(a,b) RESULT(c)
443  IMPLICIT NONE
444  !------------------------------------------------------------------------!
445  CLASS(marray_base),INTENT(IN) :: a
446  REAL, DIMENSION(SIZE(a%data1d)),INTENT(IN) :: b
447  REAL, DIMENSION(SIZE(a%data1d)) :: c
448  !------------------------------------------------------------------------!
449  c(:) = a%data1d(:) * b(:)
450  END FUNCTION multmarray_1
451 
453  PURE FUNCTION multmarray_2(a,b) RESULT(c)
454  IMPLICIT NONE
455  !------------------------------------------------------------------------!
456  CLASS(marray_base),INTENT(IN) :: a
457  REAL, DIMENSION(SIZE(a%data2d,1),SIZE(a%data2d,2)),INTENT(IN) :: b
458  REAL, DIMENSION(SIZE(a%data2d,1),SIZE(a%data2d,2)) :: c
459  !------------------------------------------------------------------------!
460  c(:,:) = a%data2d(:,:) * b(:,:)
461  END FUNCTION multmarray_2
462 
464  PURE FUNCTION multmarray_3(a,b) RESULT(c)
465  IMPLICIT NONE
466  !------------------------------------------------------------------------!
467  CLASS(marray_base),INTENT(IN) :: a
468  REAL, DIMENSION(SIZE(a%data3d,1),SIZE(a%data3d,2),SIZE(a%data3d,3)),INTENT(IN) :: b
469  REAL, DIMENSION(SIZE(a%data3d,1),SIZE(a%data3d,2),SIZE(a%data3d,3)) :: c
470  !------------------------------------------------------------------------!
471  c(:,:,:) = a%data3d(:,:,:) * b(:,:,:)
472  END FUNCTION multmarray_3
473 
475  PURE FUNCTION multmarray_4(a,b) RESULT(c)
476  IMPLICIT NONE
477  !------------------------------------------------------------------------!
478  CLASS(marray_base),INTENT(IN) :: a
479  REAL, DIMENSION(SIZE(a%data4d,1),SIZE(a%data4d,2),SIZE(a%data4d,3), & SIZE(a%data4d,4)),INTENT(IN) :: b
480  REAL, DIMENSION(SIZE(a%data4d,1),SIZE(a%data4d,2),SIZE(a%data4d,3), & SIZE(a%data4d,4)) :: c
481  !------------------------------------------------------------------------!
482  c(:,:,:,:) = a%data4d(:,:,:,:) * b(:,:,:,:)
483  END FUNCTION multmarray_4
484 
486  PURE FUNCTION multmarray_5(a,b) RESULT(c)
487  IMPLICIT NONE
488  !------------------------------------------------------------------------!
489  CLASS(marray_base),INTENT(IN) :: a
490  REAL, DIMENSION(SIZE(a%data5d,1),SIZE(a%data5d,2),SIZE(a%data5d,3), & SIZE(a%data5d,4),SIZE(a%data5d,5)),INTENT(IN) :: b
491  REAL, DIMENSION(SIZE(a%data5d,1),SIZE(a%data5d,2),SIZE(a%data5d,3), & SIZE(a%data5d,4),SIZE(a%data5d,5)) :: c
492  !------------------------------------------------------------------------!
493  c(:,:,:,:,:) = a%data5d(:,:,:,:,:) * b(:,:,:,:,:)
494  END FUNCTION multmarray_5
497  SUBROUTINE destroy(this)
498  IMPLICIT NONE
499  !-------------------------------------------------------------------!
500  CLASS(marray_base) :: this
501  !-------------------------------------------------------------------!
502  IF (ASSOCIATED(this%data1d)) DEALLOCATE(this%data1d)
503  NULLIFY(this%data1d,this%data2d,this%data3d,this%data4d,this%data5d)
504  this%RANK = 0
505  this%DIMS = 0
506  END SUBROUTINE destroy
507 
508  FUNCTION createselection(idx) RESULT(new_sel)
509  IMPLICIT NONE
510  !-------------------------------------------------------------------!
511  TYPE(selection_base) :: new_sel
512  INTEGER, OPTIONAL :: idx(6)
513  !-------------------------------------------------------------------!
514  INTEGER :: err
515  !-------------------------------------------------------------------!
516  IF (idx_init) THEN
517  ! allocate 1D mask array
518  ALLOCATE(new_sel%mask3d(igmin:igmax,jgmin:jgmax,kgmin:kgmax),stat=err)
519  IF (err.NE.0) THEN
520  print *,"ERROR in marray_base::CreateSelection: memory allocation failed"
521  stop 1
522  END IF
523  ! create 2D & 3D pointers into the 1D mask array
524  new_sel%mask1d(1:inum*jnum*knum) => new_sel%mask3d
525  new_sel%mask2d(1:inum*jnum,kgmin:kgmax) => new_sel%mask3d
526  IF (PRESENT(idx)) THEN
527  CALL new_sel%Cuboid(idx(1),idx(2),idx(3),idx(4),idx(5),idx(6))
528  ELSE
529  CALL new_sel%Everything()
530  END IF
531  END IF
532  END FUNCTION createselection
533 
534  SUBROUTINE cuboid(this,imin,imax,jmin,jmax,kmin,kmax)
535  IMPLICIT NONE
536  !-------------------------------------------------------------------!
537  CLASS(selection_base) :: this
538  INTEGER, INTENT(IN) :: imin,imax,jmin,jmax,kmin,kmax
539  !-------------------------------------------------------------------!
540  INTEGER :: i,j,k
541  !-------------------------------------------------------------------!
542  this%imin = min(max(imin,igmin),igmax)
543  this%imax = max(min(imax,igmax),igmin)
544  this%jmin = min(max(jmin,jgmin),jgmax)
545  this%jmax = max(min(jmax,jgmax),jgmin)
546  this%kmin = min(max(kmin,kgmin),kgmax)
547  this%kmax = max(min(kmax,kgmax),kgmin)
548  DO k=kgmin,kgmax
549  DO j=jgmin,jgmax
550  DO i=igmin,igmax
551  IF ((i.GE.this%imin.AND.i.LE.this%imax).AND. &
552  (j.GE.this%jmin.AND.j.LE.this%jmax).AND. &
553  (k.GE.this%kmin.AND.k.LE.this%kmax)) THEN
554  this%mask3d(i,j,k) = .true.
555  ELSE
556  this%mask3d(i,j,k) = .false.
557  END IF
558  END DO
559  END DO
560  END DO
561  END SUBROUTINE cuboid
562 
563  SUBROUTINE everything(this)
564  IMPLICIT NONE
565  !-------------------------------------------------------------------!
566  CLASS(selection_base) :: this
567  !-------------------------------------------------------------------!
568  this%imin = igmin
569  this%imax = igmax
570  this%jmin = jgmin
571  this%jmax = jgmax
572  this%kmin = kgmin
573  this%imax = kgmax
574  this%mask1d(:) = .true.
575  END SUBROUTINE everything
576 
578  SUBROUTINE destroy_selection(this)
579  IMPLICIT NONE
580  !-------------------------------------------------------------------!
581  CLASS(selection_base) :: this
582  !-------------------------------------------------------------------!
583  IF (ASSOCIATED(this%mask3d)) DEALLOCATE(this%mask3d)
584  NULLIFY(this%mask1d,this%mask2d)
585  END SUBROUTINE destroy_selection
586 
587 END MODULE marray_base_mod
588 
pure real function, dimension(size(a%data1d)) addmarray_0(a, b)
add 2 mesh arrays
subroutine assignpointers(this)
assign pointers of different shapes to the 1D data
integer, save igmin
Definition: marray_base.f90:42
integer, save inum
Definition: marray_base.f90:45
pure real function, dimension(size(a%data4d, 1), size(a%data4d, 2), size(a%data4d, 3), size(a%data4d, 4)) multmarray_4(a, b)
multiply 4D fortran array and mesh arrays
integer, save jgmin
Definition: marray_base.f90:43
pure subroutine assignmarray_5(this, a)
assign 5D fortran array to mesh array
subroutine, public initmeshproperties(igmin_, igmax_, jgmin_, jgmax_, kgmin_, kgmax_)
sets global mesh properties
integer, save kgmin
Definition: marray_base.f90:44
type for selecting parts of an marray
Definition: marray_base.f90:48
base class for mesh arrays
Definition: marray_base.f90:36
pure subroutine assignmarray_2(this, a)
assign 2D fortran array to mesh array
pure real function, dimension(size(a%data1d)) addmarray_1(a, b)
add 1D fortran array and mesh array
type(selection_base) function createselection(idx)
integer, save knum
array sizes
Definition: marray_base.f90:45
pure subroutine assignmarray_1(this, a)
assign 1D fortran array to mesh array
pure real function, dimension(size(a%data3d, 1), size(a%data3d, 2), size(a%data3d, 3)) addmarray_3(a, b)
add 3D fortran array and mesh array
pure real function, dimension(size(a%data4d, 1), size(a%data4d, 2), size(a%data4d, 3), size(a%data4d, 4)) addmarray_4(a, b)
add 4D fortran array and mesh array
subroutine cuboid(this, imin, imax, jmin, jmax, kmin, kmax)
subroutine destroy_selection(this)
deconstructor of the mesh array
real function, dimension(:,:,:,:), pointer remapbounds_1(this, array)
remap lower bounds in the first 3 dimensions of rank 1 mesh arrays
pure subroutine assignmarray_3(this, a)
assign 3D fortran array to mesh array
basic mesh array class
Definition: marray_base.f90:64
integer, save kgmax
3rd dim
Definition: marray_base.f90:44
pure real function, dimension(size(a%data1d)) multmarray_1(a, b)
multiply 1D fortran array and mesh arrays
pure real function, dimension(size(a%data1d)) multmarray_0(a, b)
multiply 2 mesh arrays
pure subroutine assignmarray_4(this, a)
assign 4D fortran array to mesh array
pure real function, dimension(size(a%data5d, 1), size(a%data5d, 2), size(a%data5d, 3), size(a%data5d, 4), size(a%data5d, 5)) multmarray_5(a, b)
multiply 5D fortran array and mesh arrays
subroutine destroy(this)
deconstructor of the mesh array
integer, save jgmax
2nd dim
Definition: marray_base.f90:43
real function, dimension(:,:,:), pointer remapbounds_0(this, array)
remap lower bounds in the first 3 dimensions of rank 0 mesh arrays
pure real function, dimension(size(a%data2d, 1), size(a%data2d, 2)) multmarray_2(a, b)
multiply 2D fortran array and mesh arrays
integer, save jnum
Definition: marray_base.f90:45
pure real function, dimension(size(a%data5d, 1), size(a%data5d, 2), size(a%data5d, 3), size(a%data5d, 4), size(a%data5d, 5)) addmarray_5(a, b)
add 5D fortran array and mesh array
integer, save igmax
1st dim
Definition: marray_base.f90:42
subroutine everything(this)
pure real function, dimension(size(a%data3d, 1), size(a%data3d, 2), size(a%data3d, 3)) multmarray_3(a, b)
multiply 3D fortran array and mesh arrays
subroutine assignmarray_0(this, ma)
assigns one mesh array to another mesh array
pure real function, dimension(size(a%data2d, 1), size(a%data2d, 2)) addmarray_2(a, b)
add 2D fortran array and mesh array
subroutine, public closemeshproperties
unsets global mesh properties
logical, save idx_init
init status
Definition: marray_base.f90:46
real function, dimension(:,:,:,:,:), pointer remapbounds_2(this, array)
remap lower bounds in the first 3 dimensions of rank 2 mesh arrays
type(marray_base) function createmarray(m, n)
constructor for mesh arrays