TreeMig Code
Loading...
Searching...
No Matches
AllocateAreasAndKernels.f90
Go to the documentation of this file.
1!==============================================================================
26!===============================================================
27SUBROUTINE allocateareas
30 !>avbio,
33 use loggermodule, only: loginfo
34 IMPLICIT NONE
35 INTEGER :: alloc_st
36 character(len=500) :: errormsg
37
38 call loginfo("Allocating areas...")
39
40 allocate (seedrain(1:maxlat, 1:maxlon), stat=alloc_st, errmsg=errormsg)
41 call checkalloc(alloc_st, errormsg, "seedrain")
42
43 allocate (stockability(1:maxlat, 1:maxlon), stat=alloc_st, errmsg=errormsg)
44 call checkalloc(alloc_st, errormsg, "stockability")
45 stockability = 0
46
47 allocate (landcoverfilter(1:maxlat, 1:maxlon), stat=alloc_st, errmsg=errormsg)
48 call checkalloc(alloc_st, errormsg, "landcoverfilter")
50
51 allocate (stocksum(1:maxlat), stat=alloc_st)
52 call checkalloc(alloc_st, errormsg, "stocksum")
53 stocksum = 0
54
55 allocate (stocksumcum(1:maxlat), stat=alloc_st)
56 call checkalloc(alloc_st, errormsg, "stocksumcum")
57 stocksumcum = 0
58
59! allocate (avbio(1:maxlat, 1:maxlon, 1:maxspc, 0:3), stat=alloc_st)
60! call CheckAlloc(alloc_st, errormsg, "avbio")
61! avbio = 0
62
63 allocate (stategrid(1:maxlat, 1:maxlon), stat=alloc_st)
64 call checkalloc(alloc_st, errormsg, "stateGrid")
65
66
67 allocate (oldbioclim%bc(1:maxlat, 1:maxlon), stat=alloc_st)
68 call checkalloc(alloc_st, errormsg, "oldBioClim%bc")
69
70 allocate (newbioclim%bc(1:maxlat, 1:maxlon), stat=alloc_st)
71 call checkalloc(alloc_st, errormsg, "newBioClim%bc")
72end SUBROUTINE allocateareas
73
74! ==============================================================================
93! ===============================================================
94SUBROUTINE allocatekernel(rad, vartxt)
96 use loggermodule, only: logwarning
97 IMPLICIT NONE
98 ! REAL, allocatable, INTENT(out):: kernel(:,:)
99 INTEGER, INTENT(in) :: rad
100 character*10, INTENT(in):: vartxt
101 INTEGER :: alloc_st
102 character(len=500) :: errormsg
103
104 select case (vartxt)
105 case ("kernel ")
106 if (allocated(kernel)) deallocate (kernel)
107 allocate (kernel(-rad:rad, -rad:rad), stat=alloc_st, errmsg=errormsg)
108 kernel = 0
109 case ("kernel1 ")
110 if (allocated(kernel1)) deallocate (kernel1)
111 allocate (kernel1(-rad:rad, -rad:rad), stat=alloc_st, errmsg=errormsg)
112 kernel1 = 0
113 case ("kernel2 ")
114 if (allocated(kernel2)) deallocate (kernel2)
115 allocate (kernel2(-rad:rad, -rad:rad), stat=alloc_st, errmsg=errormsg)
116 kernel2 = 0
117 case ("kernelFine")
118 if (allocated(kernelfine)) deallocate (kernelfine)
119 allocate (kernelfine(-rad:rad, -rad:rad), stat=alloc_st, errmsg=errormsg)
120 kernelfine = 0
121 case default
122 call logwarning("Cannot allocate "//trim(vartxt)//". Not defined!>")
123 end select
124 call checkalloc(alloc_st, errormsg, vartxt)
125end SUBROUTINE allocatekernel
126
127!==============================================================================
149SUBROUTINE allocatespeckernel(rad, ispec)
150 use all_par, only: spec
151 IMPLICIT NONE
152 ! REAL, allocatable, INTENT(out):: kernel(:,:)
153 INTEGER, INTENT(in) :: rad, ispec
154 INTEGER :: alloc_st
155 character*17 :: vartxt
156 character(len=500) :: errormsg
157
158 if (allocated(spec(ispec)%kernel)) deallocate (spec(ispec)%kernel)
159 allocate (spec(ispec)%kernel(-rad:rad, -rad:rad), stat=alloc_st, errmsg=errormsg)
160 vartxt = "species "//char(ispec)//" kernel"
161 call checkalloc(alloc_st, errormsg, vartxt)
162 spec(ispec)%kernel(-rad:rad, -rad:rad) = 0
163end SUBROUTINE allocatespeckernel
164
165! ==============================================================================
180! ===============================================================
182 use all_par, only: spec
183 IMPLICIT NONE
184 ! REAL, allocatable, INTENT(out):: kernel(:,:)
185 INTEGER, INTENT(in) :: ispec
186 INTEGER :: alloc_st
187 character*17 :: vartxt
188 character(len=500) :: errormsg
189
190 if (allocated(spec(ispec)%kernel_FT)) deallocate (spec(ispec)%kernel_FT)
191 allocate (spec(ispec)%kernel_FT(0 : spec(ispec)%maxlatExt/2, 1 : spec(ispec)%maxlonExt), stat=alloc_st, errmsg=errormsg)
192 vartxt = "species "//char(ispec)//" transformed kernel"
193 call checkalloc(alloc_st, errormsg, vartxt)
194 spec(ispec)%kernel_FT(0:spec(ispec)%maxlatExt/2, 1:spec(ispec)%maxlonExt) = 0.
196
197! ==============================================================================
212! ===============================================================
213SUBROUTINE checkalloc(alloc_st, errormsg, txt)
214 use loggermodule, only: logerror
215 IMPLICIT NONE
216 INTEGER, INTENT(in) :: alloc_st
217 character(len=*), INTENT(in):: errormsg
218 character(len=*), INTENT(in):: txt
219 if (alloc_st /= 0) then
220 call logerror("Could not allocate '"//trim(txt)//"', "//trim(errormsg))
221 error stop
222 end if
223end SUBROUTINE checkalloc
224! done
subroutine allocatespeckernel(rad, ispec)
AllocateSpecKernel.
subroutine allocatespectransformedkernel(ispec)
AllocateSpecTransformedKernel.
subroutine checkalloc(alloc_st, errormsg, txt)
CheckAlloc.
subroutine allocateareas
AllocateAreas.
subroutine allocatekernel(rad, vartxt)
AllocateKernel.
real, dimension(:, :), allocatable landcoverfilter
Definition All_par.f90:355
real, dimension(:, :), allocatable stockability
Definition All_par.f90:53
real, dimension(:, :), allocatable kernel2
Definition All_par.f90:154
real, dimension(:,:, 1:maxspc, 0:3), allocatable avbio
Definition All_par.f90:360
type(specproperties), dimension(maxspc) spec
Definition All_par.f90:345
type(currstateincell), dimension(:, :), allocatable stategrid
Definition All_par.f90:340
real, dimension(:, :), allocatable kernel1
Definition All_par.f90:154
integer maxlon
Definition All_par.f90:46
type(bioclimdata) newbioclim
Definition All_par.f90:351
real, dimension(:, :), allocatable kernel
Definition All_par.f90:62
type(newseedsincell), dimension(:, :), allocatable seedrain
Definition All_par.f90:342
real, dimension(:), allocatable stocksumcum
Definition All_par.f90:356
real, dimension(:, :), allocatable kernelfine
Definition All_par.f90:154
integer, parameter maxspc
Definition All_par.f90:98
type(bioclimdata) oldbioclim
Definition All_par.f90:351
real, dimension(:), allocatable stocksum
Definition All_par.f90:356
integer maxlat
Definition All_par.f90:45
LoggerModule.
subroutine logwarning(msg)
LogError
subroutine loginfo(msg)
LogInfo
subroutine logerror(msg)
LogError