-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSRFPACKInterface2.f90
696 lines (604 loc) · 23.5 KB
/
SSRFPACKInterface2.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
module SSRFPACKInterfaceModule
!------------------------------------------------------------------------------
! Lagrangian Particle / Panel Method - Spherical Model
!------------------------------------------------------------------------------
!
!> @author
!> Peter Bosler, Department of Mathematics, University of Michigan
!
!> @defgroup SSRFPACKInterface SSRFPACK Interface Module
!> Provides and object-oriented interface into the ssrfpack.f module @cite SSRFPACK .
!
!
! DESCRIPTION:
!> @file
!> Provides and object-oriented interface into the ssrfpack.f module.
!
!------------------------------------------------------------------------------
use NumberKindsModule
use LoggerModule
use SphereGeomModule
use PanelsModule, only : GetNTracer
use STRIPACKInterfaceModule
implicit none
private
public SSRFPACKData
public New, Delete
public SetSourceLagrangianParameter
public SetSourceAbsVort, SetSourceRelVort
public SetSourceTracer
public SetSourceVelocity
public SetSourceKineticEnergy
public SetSourceGeneralScalar
public SetSigmaTol
public SIGMA_FLAG, GRAD_FLAG
public InterpolateVector, InterpolateScalar, InterpolateTracer, InterpScalarToLLGrid
public SetSourceH
!
!----------------
! Types and module constants
!----------------
!
type SSRFPACKData
real(kreal), pointer :: data1(:) => null(), & ! Source data values
data2(:) => null(), & ! Source data values
data3(:) => null(), & ! Source data values
grad1(:,:) => null(), & ! Estimated gradients of source data1
grad2(:,:) => null(), & ! Estimated gradients of source data2
grad3(:,:) => null(), & ! Estimated gradients of source data3
sigma1(:) => null(), & ! Smoothing factors for source data1
sigma2(:) => null(), & ! Smoothing factors for source data2
sigma3(:) => null(), & ! Smoothing factors for source data3
tracer(:,:) => null(), & ! tracer data values
tracerGrad(:,:,:) => null(), & ! tracer gradient values
sigmaTracer(:,:) => null() ! smoothing factors for tracers
real(kreal) :: dSig1, & ! Maximum difference in smoothing factors for source data1
dSig2, & ! Maximum difference in smoothing factors for source data2
dSig3, & ! Maximum difference in smoothing factors for source data3
sigmaTol = 0.01_kreal ! Tolerance for setting smoothing factors in SSRFPACK GETSIG subroutine
end type
integer(kint), parameter :: SIGMA_FLAG = 1,& ! Flag indicates smoothing parameters are pre-computed
GRAD_FLAG = 1 ! Flag indicates gradient estimates are pre-computed
integer(kint), save :: startTriangle = 1 ! Stores initial guesses for locating new points within a Delaunay triangulation.
!
!----------------
! Logging
!----------------
!
logical(klog), save :: logInit = .FALSE.
type(Logger) :: log
character(len=28) :: logKey = 'SSRFPACK'
integer(kint), parameter :: logLevel = TRACE_LOGGING_LEVEL
character(len=28) :: formatString
character(len=128) :: logString
!
!----------------
! Interfaces
!----------------
!
interface New
module procedure NewPrivate
module procedure NewPrivateTracer
end interface
interface Delete
module procedure DeletePrivate
end interface
interface SetSourceVelocity
module procedure SetSourceVelocityFromMeshData
module procedure SetSourceVelocityFromArrays
end interface
interface SetSourceH
module procedure SetSourceHFromArrays
end interface
contains
!
!----------------
! Standard methods : Constructor / Destructor
!----------------
!
subroutine NewPrivate(self,DelTri,interpVector)
! Allocate memory for SSRFPACK interpolation source data associated with spherical Delaunay triangulation object DelTri.
type(SSRFPACKData), intent(out) :: self
type(STRIPACKData), intent(in) :: DelTri
logical(klog), intent(in) :: interpVector
integer(kint) :: n
if ( .NOT. logInit ) call InitLogger(log,procRank)
n = delTri%n
if ( interpVector ) then
allocate(self%data1(n))
self%data1 = 0.0_kreal
allocate(self%data2(n))
self%data2 = 0.0_kreal
allocate(self%data3(n))
self%data3 = 0.0_kreal
allocate(self%grad1(3,n))
self%grad1 = 0.0_kreal
allocate(self%grad2(3,n))
self%grad2 = 0.0_kreal
allocate(self%grad3(3,n))
self%grad3 = 0.0_kreal
allocate(self%sigma1(6*n-12))
self%sigma1 = 0.0_kreal
allocate(self%sigma2(6*n-12))
self%sigma2 = 0.0_kreal
allocate(self%sigma3(6*n-12))
self%sigma3 = 0.0_kreal
call LogMessage(log,DEBUG_LOGGING_LEVEL,logKey,' SSRFPACK allocated for vector interp.')
else
allocate(self%data1(n))
self%data1 = 0.0_kreal
allocate(self%grad1(3,n))
self%grad1 = 0.0_kreal
allocate(self%sigma1(6*n-12))
self%sigma1 = 0.0_kreal
call LogMessage(log,DEBUG_LOGGING_LEVEL,logKey,' SSRFPACK allocated for scalar interp.')
endif
end subroutine
subroutine NewPrivateTracer(self,DelTri,nTracers)
! Allocate memory for SSRFPACK interpolation source data associated with spherical Delaunay triangulation object DelTri.
type(SSRFPACKData), intent(out) :: self
type(STRIPACKData), intent(in) :: DelTri
integer(kint), intent(in) :: nTracers
integer(kint) :: n
if ( .NOT. logInit ) call InitLogger(log,procRank)
n = delTri%n
allocate(self%tracer(n,nTracers))
self%tracer = 0.0_kreal
allocate(self%tracerGrad(3,n,nTracers))
self%tracerGrad = 0.0_kreal
allocate(self%sigmaTracer(6*n-12,nTracers))
self%sigmaTracer = 0.0_kreal
call LogMessage(log,DEBUG_LOGGING_LEVEL,logKey,' SSRFPACK allocated for tracer interp.')
end subroutine
subroutine DeletePrivate(self)
! Free memory associated with an instance of SSRFPACKData
type(SSRFPACKData), intent(inout) :: self
if (associated(self%data1)) then
deallocate(self%data1)
deallocate(self%sigma1)
deallocate(self%grad1)
endif
if ( associated(self%data2) ) then
deallocate(self%data2)
deallocate(self%data3)
deallocate(self%grad2)
deallocate(self%grad3)
deallocate(self%sigma2)
deallocate(self%sigma3)
endif
if ( associated(self%tracer)) then
deallocate(self%tracer)
deallocate(self%tracerGrad)
deallocate(self%sigmaTracer)
endif
end subroutine
!
!----------------
! Public functions
!----------------
!
subroutine SetSigmaTol(self,newTol)
! Set tolerance for SSRFPACK smoothing parameter subroutines
type(SSRFPACKData), intent(inout) :: self
real(kreal), intent(in) :: newTol
self%sigmaTol = newTol
end subroutine
subroutine SetSourceLagrangianParameter(self,delTri)
! Set the SSRFPACK source data for interpolation of Lagrangian parameter vectors.
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint) :: j, nActive, nParticles, errCode
nActive = delTri%activePanels%N_Active
nParticles = delTri%particles%N
! Record source data values from source mesh
do j=1,nActive
self%data1(j) = delTri%activePanels%x0(1,j)
self%data2(j) = delTri%activePanels%x0(2,j)
self%data3(j) = delTri%activePanels%x0(3,j)
enddo
do j=1,nParticles
self%data1(nActive + j ) = delTri%particles%x0(1,j)
self%data2(nActive + j ) = delTri%particles%x0(2,j)
self%data3(nActive + j ) = delTri%particles%x0(3,j)
enddo
! Estimate gradients at nodes of Delaunay triangulation
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data2,&
delTri%list,delTri%lptr,delTri%lend,self%grad2(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data3,&
delTri%list,delTri%lptr,delTri%lend,self%grad3(:,j),errCode)
enddo
! Determine smoothing factors at each Delaunay node
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig x0 = ',self%dSig1)
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data2,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad2,self%sigmaTol,self%sigma2,self%dSig2,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig y0 = ',self%dSig2)
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data3,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad3,self%sigmaTol,self%sigma3,self%dSig3,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig z0 = ',self%dSig3)
end subroutine
subroutine SetSourceTracer(self,delTri)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
!
integer(kint) :: j, k, nActive, nParticles, errCode, nTracer
nActive = delTri%activePanels%N_active
nParticles = delTri%particles%N
nTracer = GetNTracer(delTri%activePanels)
! record source data values from source mesh
do k=1,nTracer
do j=1,nActive
self%tracer(j,k) = delTri%activePanels%tracer(j,k)
enddo
do j=1,nParticles
self%tracer(nActive+j,k) = delTri%particles%tracer(j,k)
enddo
enddo
! estimate gradients at nodes of Delaunay graph
do k=1,nTracer
do j=1,delTri%n
call GRADL(delTri%n, j, delTri%x, delTri%y, delTri%z, self%tracer(:,k), &
delTri%list, delTri%lptr, delTri%lend, self%tracerGrad(:,j,k), errCode)
enddo
enddo
! find smoothing factors at each node of Delaunay graph
do k=1, nTracer
call GETSIG(delTri%n, delTri%x, delTri%y, delTri%z, self%tracer(:,k), &
delTri%list, delTri%lptr, delTri%lend, &
self%tracerGrad(:,:,k), self%sigmaTol, self%sigmaTracer(:,k), self%dSig1, errCode)
enddo
end subroutine
subroutine SetSourceVelocityFromMeshData(self,delTri)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint) :: j, nActive, nParticles, errCode
nActive = delTri%activePanels%N_Active
nParticles = delTri%particles%N
! record source data values from source mesh
do j=1,nActive
self%data1(j) = delTri%activePanels%u(1,j)
self%data2(j) = delTri%activePanels%u(2,j)
self%data3(j) = delTri%activePanels%u(3,j)
enddo
do j=1,nParticles
self%data1(j) = delTri%particles%u(1,j)
self%data2(j) = delTri%particles%u(2,j)
self%data3(j) = delTri%particles%u(3,j)
enddo
! Estimate gradients at nodes of Delaunay triangulation
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data2,&
delTri%list,delTri%lptr,delTri%lend,self%grad2(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data3,&
delTri%list,delTri%lptr,delTri%lend,self%grad3(:,j),errCode)
enddo
! Determine smoothing factors at each Delaunay node
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig u = ',self%dSig1)
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data2,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad2,self%sigmaTol,self%sigma2,self%dSig2,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig v = ',self%dSig2)
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data3,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad3,self%sigmaTol,self%sigma3,self%dSig3,errCode)
if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig w = ',self%dSig3)
end subroutine
subroutine SetSourceVelocityFromArrays(self, delTri, particlesVelocity, nParticles, activePanelsVelocity, nActive)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal), intent(in) :: particlesVelocity(:,:), activePanelsVelocity(:,:)
integer(kint), intent(in) :: nParticles, nActive
!
integer(kint) :: j, errCode
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'entering SetSourceVelocityFromArrays...')
do j=1, nActive
self%data1(j) = activePanelsVelocity(1,j)
self%data2(j) = activePanelsVelocity(2,j)
self%data3(j) = activePanelsVelocity(3,j)
enddo
do j=1, nParticles
self%data1(nActive + j) = particlesVelocity(1,j)
self%data2(nActive + j) = particlesVelocity(2,j)
self%data3(nActive + j) = particlesVelocity(3,j)
enddo
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'...velocity data copied. estimating gradients.')
do j=1, delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data2,&
delTri%list,delTri%lptr,delTri%lend,self%grad2(:,j),errCode)
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data3,&
delTri%list,delTri%lptr,delTri%lend,self%grad3(:,j),errCode)
enddo
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'...gradients done.')
! Determine smoothing factors at each Delaunay node
! call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
! delTri%list,delTri%lptr,delTri%lend,&
! self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
! if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig u = ',self%dSig1)
! call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data2,&
! delTri%list,delTri%lptr,delTri%lend,&
! self%grad2,self%sigmaTol,self%sigma2,self%dSig2,errCode)
! if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig v = ',self%dSig2)
! call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data3,&
! delTri%list,delTri%lptr,delTri%lend,&
! self%grad3,self%sigmaTol,self%sigma3,self%dSig3,errCode)
! if ( procRank == 0 ) call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig w = ',self%dSig3)
end subroutine
subroutine SetSourceHFromArrays(self, delTri, particlesH, nParticles, activePanelsH, nActive)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal), intent(in) :: particlesH(:), activePanelsH(:)
integer(kint), intent(in) :: nParticles, nActive
!
integer(kint) :: j, errCode
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'entering SetSourceHFromArrays.')
do j=1, nActive
self%data1(j) = activePanelsH(j)
enddo
do j=1, nParticles
self%data1(nActive + j) = particlesH(j)
enddo
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'...h data copied. estimating gradients.')
do j=1, delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
enddo
call LogMessage(log,DEBUG_LOGGING_LEVEL,logkey,'...gradients done. finding smoothing factors.')
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
call LogMessage(log,DEBUG_LOGGING_LEVEL,'SSRFPACK : dSig H = ',self%dSig1)
end subroutine
subroutine SetSourceAbsVort(self,delTri)
! Setup SSRFPACK to interpolate scalar absolute vorticity data
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint) :: j, nActive, nParticles, errCode
nActive = delTri%activePanels%N_Active
nParticles = delTri%particles%N
do j=1,nActive
self%data1(j) = delTri%activePanels%absVort(j)
enddo
do j=1,nParticles
self%data1(nActive + j ) = delTri%particles%absVort(j)
enddo
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
enddo
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
call LogMessage(log,TRACE_LOGGING_LEVEL,'SSRFPACK : dSig absVort = ',self%dSig1)
end subroutine
subroutine SetSourceRelVort(self,delTri)
! Setup SSSRFPACK to interpolate scalar relative vorticity data
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint) :: j, nActive, nParticles, errCode
nActive = delTri%activePanels%N_Active
nParticles = delTri%particles%N
do j=1,nActive
self%data1(j) = delTri%activePanels%relVort(j)
enddo
do j=1,nParticles
self%data1(nActive + j ) = delTri%particles%relVort(j)
enddo
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
enddo
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
!call LogMessage(log,TRACE_LOGGING_LEVEL,'SSRFPACK : dSig relVort = ',self%dSig1)
end subroutine
subroutine SetSourceGeneralScalar(self, delTri, scalarData)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal), intent(in) :: scalarData(:)
!
integer(kint) :: j, errCode
do j = 1, delTri%n
self%data1(j) = scalarData(j)
enddo
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
enddo
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
end subroutine
subroutine InterpScalarToLLGrid(llOutput , self, delTri, lon, lat, nlon, nlat)
real(kreal), intent(out) :: llOutput(:,:)
type(SSRFPACKData), intent(in) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal), intent(in) :: lon(:), lat(:)
integer(kint), intent(in) :: nLon, nLat
!
integer(kint) :: errCode
call UNIF(delTri%n, delTri%x, delTri%y, delTri%z, self%data1, &
delTri%list, delTri%lptr, delTri%lend, SIGMA_FLAG, self%sigma1, &
nLat, nLat, nLon, lat, lon, GRAD_FLAG, self%grad1, llOutput, errCode)
end subroutine
!subroutine SetSourceEnergy(self,delTri)
! type(SSRFPACKData), intent(inout) :: self
! type(STRIPACKData), intent(in) :: delTri
! integer(kint) :: j, nActive, nParticles, errCode
!
! if ( (.NOT. associated(delTri%activePanels%energy) ).OR. (.NOT. associated(delTri%particles%energy) ) ) then
! call LogMessage(log,ERROR_LOGGING_LEVEL,trim(logKey),' SetSourceEnergy ERROR : energy not defined.')
! return
! endif
!
! nActive = delTri%activePanels%N_Active
! nParticles = delTri%particles%N
!
! do j=1,nActive
! self%data1(j) = delTri%activePanels%energy(j)
! enddo
!
! do j=1,nParticles
! self%data1(nActive+j) = delTri%particles%energy(j)
! enddo
!
! do j=1,delTri%n
! call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
! delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
! enddo
!
! call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
! delTri%list,delTri%lptr,delTri%lend,&
! self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
! call LogMessage(log,TRACE_LOGGING_LEVEL,'SSRFPACK : dSig relVort = ',self%dSig1)
!
!end subroutine
subroutine SetSourceKineticEnergy(self,delTri)
type(SSRFPACKData), intent(inout) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint) :: j, nActive, nParticles, errCode
if ( (.NOT. associated(delTri%activePanels%ke) ).OR. (.NOT. associated(delTri%particles%ke) ) ) then
call LogMessage(log,ERROR_LOGGING_LEVEL,trim(logKey),' SetSourceKineticEnergy ERROR : KE not defined.')
return
endif
nActive = delTri%activePanels%N_Active
nParticles = delTri%particles%N
do j=1,nActive
self%data1(j) = delTri%activePanels%ke(j)
enddo
do j=1,nParticles
self%data1(nActive+j) = delTri%particles%ke(j)
enddo
do j=1,delTri%n
call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
enddo
call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend,&
self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
call LogMessage(log,TRACE_LOGGING_LEVEL,'SSRFPACK : dSig relVort = ',self%dSig1)
end subroutine
!subroutine SetSourceTracer(self,delTri,tracerNumber)
!! Setup SSRFPACK to interpolate scalar tracer data
! type(SSRFPACKData), intent(inout) :: self
! type(STRIPACKData), intent(in) :: delTri
! integer(kint), intent(in) :: tracerNumber
! integer(kint) :: j, nActive, nParticles, errCode
!
! nActive = delTri%activePanels%N_Active
! nParticles = delTri%particles%N
!
! do j=1,nActive
! self%data1(j) = delTri%activePanels%tracer(j,tracerNumber)
! enddo
!
! do j=1,nParticles
! self%data1(nActive + j ) = delTri%particles%tracer(j,tracerNumber)
! enddo
!
! call LogMessage(log,DEBUG_LOGGING_LEVEL,'SetSourcTracer : ','data set. Estimating gradients.')
!
! do j=1,delTri%n
! call GRADL(delTri%n,j,delTri%x,delTri%y,delTri%z,self%data1,&
! delTri%list,delTri%lptr,delTri%lend,self%grad1(:,j),errCode)
! enddo
!
! call LogMessage(log,DEBUG_LOGGING_LEVEL,'SetSourcTracer : ','gradients done. Finding smoothing factors.')
!
! call GETSIG(delTri%n,delTri%x,delTri%y,delTri%z,self%data1,&
! delTri%list,delTri%lptr,delTri%lend,&
! self%grad1,self%sigmaTol,self%sigma1,self%dSig1,errCode)
! write(logString,'(A,I1,A)') 'SSRFPACK : dSig Tracer',tracerNumber,' = '
! call LogMessage(log,TRACE_LOGGING_LEVEL,trim(logString),self%dSig1)
!end subroutine
function InterpolateVector(xyz,self,delTri)
! Interpolate (using SSRFPACK) vector source data from self and delTri to value
! at destination point xyz.
!
real(kreal) :: InterpolateVector(3)
real(kreal), intent(in) :: xyz(3)
type(SSRFPACKData), intent(in) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal) :: newLat, newLon, newVector(3)
integer(kint) :: errCode
newLat = Latitude(xyz)
newLon = Longitude(xyz)
startTriangle = 1
call INTRC1(delTri%n,newLat,newLon,delTri%x,delTri%y,delTri%z,self%data1, &
delTri%list,delTri%lptr,delTri%lend, &
SIGMA_FLAG,self%sigma1,GRAD_FLAG,self%grad1,startTriangle,&
newVector(1),errCode)
call INTRC1(delTri%n,newLat,newLon,delTri%x,delTri%y,delTri%z,self%data2, &
delTri%list,delTri%lptr,delTri%lend, &
SIGMA_FLAG,self%sigma2,GRAD_FLAG,self%grad2,startTriangle,&
newVector(2),errCode)
call INTRC1(delTri%n,newLat,newLon,delTri%x,delTri%y,delTri%z,self%data3, &
delTri%list,delTri%lptr,delTri%lend, &
SIGMA_FLAG,self%sigma3,GRAD_FLAG,self%grad3,startTriangle,&
newVector(3),errCode)
InterpolateVector = newVector
end function
function InterpolateScalar(xyz,self,delTri)
! Interpolate (using SSRFPACK) scalar source data from self and delTri to value
! at destination point xyz.
!
real(kreal) :: InterpolateScalar
real(kreal), intent(in) :: xyz(3)
type(SSRFPACKData), intent(in) :: self
type(STRIPACKData), intent(in) :: delTri
real(kreal) :: newLat, newLon, newScalar
integer(kint) :: errCode
newLat = Latitude(xyz)
newLon = Longitude(xyz)
call INTRC1(delTri%n,newLat,newLon,delTri%x,delTri%y,delTri%z,self%data1,&
delTri%list,delTri%lptr,delTri%lend, &
SIGMA_FLAG,self%sigma1,GRAD_FLAG,self%grad1,startTriangle,&
newScalar,errCode)
InterpolateScalar = newScalar
end function
function InterpolateTracer(xyz,self,delTri, tracerID)
! Interpolate (using SSRFPACK) scalar source data from self and delTri to value
! at destination point xyz.
!
real(kreal) :: InterpolateTracer
real(kreal), intent(in) :: xyz(3)
type(SSRFPACKData), intent(in) :: self
type(STRIPACKData), intent(in) :: delTri
integer(kint), intent(in) :: tracerID
real(kreal) :: newLat, newLon, newScalar
integer(kint) :: errCode
newLat = Latitude(xyz)
newLon = Longitude(xyz)
call INTRC1(delTri%n,newLat,newLon,delTri%x,delTri%y,delTri%z,self%tracer(:,tracerID),&
delTri%list,delTri%lptr,delTri%lend, &
SIGMA_FLAG,self%sigmaTracer(:,tracerID),GRAD_FLAG,self%tracerGrad(:,:,tracerID),startTriangle,&
newScalar,errCode)
InterpolateTracer = newScalar
end function
!
!----------------
! Module methods : type-specific functions
!----------------
!
subroutine InitLogger(aLog,rank)
type(Logger), intent(inout) :: aLog
integer(kint), intent(in) :: rank
write(logKey,'(A,A,I0.2,A)') trim(logKey),'_',rank,' : '
call New(aLog,logLevel)
logInit = .TRUE.
end subroutine
end module