marray_cellscalar.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: marray_cellscalar.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!#############################################################################
25!----------------------------------------------------------------------------!
32!----------------------------------------------------------------------------!
35 IMPLICIT NONE
36 !--------------------------------------------------------------------------!
37 PRIVATE
40 REAL, DIMENSION(:,:,:), POINTER :: &
41 center => null(), &
42 bcenter=> null()
43
44 REAL, DIMENSION(:,:,:,:), POINTER :: &
45 faces => null(), &
46 corners => null()
47 CONTAINS
48 PROCEDURE :: assignpointers
49 PROCEDURE :: destroy
50 final :: finalize
51 END TYPE
52 INTERFACE marray_cellscalar
53 MODULE PROCEDURE createmarray_cellscalar
54 END INTERFACE
55 !--------------------------------------------------------------------------!
56 PUBLIC :: marray_cellscalar
57
58CONTAINS
59
60 FUNCTION createmarray_cellscalar() RESULT(new_cs)
61 IMPLICIT NONE
62 !-------------------------------------------------------------------!
63 TYPE(marray_cellscalar) :: new_cs
64 !-------------------------------------------------------------------!
65#if DEBUG > 2
66 print *,"DEBUG INFO in marray_cellscalar::CreateMArray_cellscalar: creating new cellscalar"
67#endif
68 ! 1 center + 1 bcenter + 6 faces + 8 corners = 16
69 IF (new_cs%Init(16)) return ! immediately return if successful
70#ifdef DEBUG
71 print *,"ERROR in marray_cellscalar::CreateMArray: cellscalar initialization failed"
72 stop 1
73#endif
74 END FUNCTION createmarray_cellscalar
75
76 FUNCTION assignpointers(this) RESULT(success)
77 IMPLICIT NONE
78 !------------------------------------------------------------------------!
79 CLASS(marray_cellscalar),INTENT(INOUT) :: this
80 LOGICAL :: success
81 !------------------------------------------------------------------------!
82#if DEBUG > 2
83 print *,"DEBUG INFO in marray_cellscalar::AssignPointers: assigning pointers"
84#endif
85 success = this%marray_base%AssignPointers()
86 IF (success) THEN
87 ! assign array pointers
88 this%center => this%RemapBounds(this%data4d(:,:,:,1))
89 this%bcenter => this%RemapBounds(this%data4d(:,:,:,2))
90 this%faces => this%RemapBounds(this%data4d(:,:,:,3:8))
91 this%corners => this%RemapBounds(this%data4d(:,:,:,9:16))
92#ifdef DEBUG
93 ELSE
94 print *,"ERROR in marray_cellscalar::AssignPointers: pointer assignment failed"
95#endif
96 END IF
97 END FUNCTION assignpointers
98
100 SUBROUTINE destroy(this,called_from_finalize)
101 IMPLICIT NONE
102 !-------------------------------------------------------------------!
103 CLASS(marray_cellscalar) :: this
104 LOGICAL, OPTIONAL :: called_from_finalize
105 !-------------------------------------------------------------------!
106#if DEBUG > 2
107 print *,"DEBUG INFO in marray_cellscalar::Destroy: nullify pointers"
108#endif
109 NULLIFY(this%center,this%bcenter,this%faces,this%corners)
110 ! only call inherited destructor if not called from Finalize
111 IF (PRESENT(called_from_finalize)) THEN
112 IF (called_from_finalize) RETURN
113 END IF
114 CALL this%marray_base%Destroy()
115 END SUBROUTINE destroy
116
118 SUBROUTINE finalize(this)
119 IMPLICIT NONE
120 !-------------------------------------------------------------------!
121 TYPE(marray_cellscalar) :: this
122 !-------------------------------------------------------------------!
123#if DEBUG > 2
124 print *,"DEBUG INFO in marray_cellscalar::Finalize called"
125#endif
126 CALL this%Destroy(.true.)
127 END SUBROUTINE finalize
128
129END MODULE marray_cellscalar_mod
base class for mesh arrays
Definition: marray_base.f90:36
logical function assignpointers(this)
assign pointers of different shapes to the 1D data
subroutine finalize(this)
subroutine destroy(this, called_from_finalize)
basic destructor of mesh arrays - this is called automatically if deallocate is invoked
derived mesh array class for scalar cell data
type(marray_cellscalar) function createmarray_cellscalar()
basic mesh array class
Definition: marray_base.f90:69