This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tools.f90
1917 lines (1680 loc) · 60.2 KB
/
tools.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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!################################################################################
!This file is part of Incompact3d.
!
!Incompact3d
!Copyright (c) 2012 Eric Lamballais and Sylvain Laizet
!eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com
!
! Incompact3d is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation.
!
! Incompact3d is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the code. If not, see <http://www.gnu.org/licenses/>.
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! We kindly request that you cite Incompact3d in your publications and
! presentations. The following citations are suggested:
!
! 1-Laizet S. & Lamballais E., 2009, High-order compact schemes for
! incompressible flows: a simple and efficient method with the quasi-spectral
! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015
!
! 2-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence
! problems with up to 0(10^5) computational cores, Int. J. of Numerical
! Methods in Fluids, vol 67 (11), pp 1735-1757
!################################################################################
!*******************************************************************
!
!
!*******************************************************************
subroutine test_scalar_min_max(phi)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
integer :: i,j,k
real(mytype) :: phimax,phimin,cfl
real(mytype) :: phimax1,phimin1
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: phi
integer :: code
phimax=-1609._mytype
phimin=1609._mytype
! do k=1,xsize(3)
! do j=1,xsize(2)
! do i=1,xsize(1)
! if (phi(i,j,k).gt.phimax) phimax=phi(i,j,k)
! if (phi(i,j,k).lt.phimin) phimin=phi(i,j,k)
! enddo
! enddo
! enddo
phimax = MAXVAL(phi)
phimin = MINVAL(phi)
call MPI_REDUCE(phimax,phimax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(phimin,phimin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
if (nrank==0) then
print *,'PHI max=',phimax1
print *,'PHI min=',phimin1
endif
return
end subroutine test_scalar_min_max
!*******************************************************************
!
!
!*******************************************************************
subroutine test_density_min_max(rho)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
integer :: i,j,k
real(mytype) :: rhomax,rhomin,cfl
real(mytype) :: rhomax1,rhomin1
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: rho
integer :: code
! rhomax=-1609._mytype
! rhomin=1609._mytype
! do k=1,xsize(3)
! do j=1,xsize(2)
! do i=1,xsize(1)
! if (rho(i,j,k).gt.rhomax) rhomax=rho(i,j,k)
! if (rho(i,j,k).lt.rhomin) rhomin=rho(i,j,k)
! enddo
! enddo
! enddo
rhomax = MAXVAL(rho)
rhomin = MINVAL(rho)
call MPI_REDUCE(rhomax,rhomax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(rhomin,rhomin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
if (nrank==0) then
print *,'RHO max=',rhomax1
print *,'RHO min=',rhomin1
endif
return
end subroutine test_density_min_max
subroutine test_temperature_min_max(temperature)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
integer :: i,j,k
real(mytype) :: temperaturemax,temperaturemin,cfl
real(mytype) :: temperaturemax1,temperaturemin1
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: temperature
integer :: code
! temperaturemax=-1609._mytype
! temperaturemin=1609._mytype
! do k=1,xsize(3)
! do j=1,xsize(2)
! do i=1,xsize(1)
! if (temperature(i,j,k).gt.temperaturemax) temperaturemax=temperature(i,j,k)
! if (temperature(i,j,k).lt.temperaturemin) temperaturemin=temperature(i,j,k)
! enddo
! enddo
! enddo
temperaturemax = MAXVAL(temperature)
temperaturemin = MINVAL(temperature)
call MPI_REDUCE(temperaturemax,temperaturemax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(temperaturemin,temperaturemin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
if (nrank==0) then
print *,'TEMPERATURE max=',temperaturemax1
print *,'TEMPERATURE min=',temperaturemin1
endif
return
end subroutine test_temperature_min_max
!*******************************************************************
!
!
!*******************************************************************
subroutine test_speed_min_max(ux,uy,uz)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
integer :: i,j,k
real(mytype) :: uxmax,uymax,uzmax,uxmin,uymin,uzmin,cfl
real(mytype) :: uxmax1,uymax1,uzmax1,uxmin1,uymin1,uzmin1
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux,uy,uz
integer :: code
! uxmax=-1609._mytype
! uymax=-1609._mytype
! uzmax=-1609._mytype
! uxmin=1609._mytype
! uymin=1609._mytype
! uzmin=1609._mytype
! do k=1,xsize(3)
! do j=1,xsize(2)
! do i=1,xsize(1)
! if (ux(i,j,k).gt.uxmax) uxmax=ux(i,j,k)
! if (uy(i,j,k).gt.uymax) uymax=uy(i,j,k)
! if (uz(i,j,k).gt.uzmax) uzmax=uz(i,j,k)
! if (ux(i,j,k).lt.uxmin) uxmin=ux(i,j,k)
! if (uy(i,j,k).lt.uymin) uymin=uy(i,j,k)
! if (uz(i,j,k).lt.uzmin) uzmin=uz(i,j,k)
! enddo
! enddo
! enddo
uxmax = MAXVAL(ux)
uxmin = MINVAL(ux)
uymax = MAXVAL(uy)
uymin = MINVAL(uy)
uzmax = MAXVAL(uz)
uzmin = MINVAL(uz)
call MPI_REDUCE(uxmax,uxmax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(uymax,uymax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(uzmax,uzmax1,1,real_type,MPI_MAX,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(uxmin,uxmin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(uymin,uymin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
call MPI_REDUCE(uzmin,uzmin1,1,real_type,MPI_MIN,0,MPI_COMM_WORLD,code)
if (nrank==0) then
print *,'U,V,W max=',uxmax1,uymax1,uzmax1
print *,'U,V,W min=',uxmin1,uymin1,uzmin1
endif
return
end subroutine test_speed_min_max
!*******************************************************************
!
!
!*******************************************************************
subroutine restart(ux1,uy1,uz1,rho1,temperature1,ep1,pp3,phi1,&
gx1,gy1,gz1,rhos1,px1,py1,pz1,phis1,&
hx1,hy1,hz1,rhoss1,phiss1,&
pressure0,phG,irestart)
USE decomp_2d
USE decomp_2d_io
USE variables
USE param
USE MPI
implicit none
TYPE(DECOMP_INFO) :: phG
integer :: i,j,k,ijk,irestart,nzmsize,fh,ierror,code
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1,ep1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: gx1,gy1,gz1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: hx1,hy1,hz1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: rho1,temperature1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: rhos1,rhoss1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: px1,py1,pz1
real(mytype), dimension(xsize(1),xsize(2),xsize(3)) :: phi1, phis1, phiss1
real(mytype), dimension(phG%zst(1):phG%zen(1),phG%zst(2):phG%zen(2),phG%zst(3):phG%zen(3)) :: pp3
real(mytype) :: pressure0
integer (kind=MPI_OFFSET_KIND) :: filesize, disp
real(mytype) :: xdt
integer, dimension(2) :: dims, dummy_coords
logical, dimension(2) :: dummy_periods
if (iscalar==0) then
if (nscheme.ne.4) then
if (irestart==1) then !write
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, &
fh, ierror)
filesize = 0_MPI_OFFSET_KIND
call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting
disp = 0_MPI_OFFSET_KIND
call decomp_2d_write_var(fh,disp,1,ux1)
call decomp_2d_write_var(fh,disp,1,uy1)
call decomp_2d_write_var(fh,disp,1,uz1)
call decomp_2d_write_var(fh,disp,1,rho1)
call decomp_2d_write_var(fh,disp,1,temperature1)
call decomp_2d_write_var(fh,disp,1,gx1)
call decomp_2d_write_var(fh,disp,1,gy1)
call decomp_2d_write_var(fh,disp,1,gz1)
call decomp_2d_write_var(fh,disp,1,rhos1)
call decomp_2d_write_var(fh,disp,1,px1)
call decomp_2d_write_var(fh,disp,1,py1)
call decomp_2d_write_var(fh,disp,1,pz1)
call decomp_2d_write_var(fh,disp,1,pp3,phG)
call MPI_FILE_CLOSE(fh,ierror)
else
if (nrank==0) then
print *,'RESTART'
endif
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_RDONLY, MPI_INFO_NULL, &
fh, ierror)
disp = 0_MPI_OFFSET_KIND
call decomp_2d_read_var(fh,disp,1,ux1)
call decomp_2d_read_var(fh,disp,1,uy1)
call decomp_2d_read_var(fh,disp,1,uz1)
call decomp_2d_read_var(fh,disp,1,rho1)
call decomp_2d_read_var(fh,disp,1,temperature1)
call decomp_2d_read_var(fh,disp,1,gx1)
call decomp_2d_read_var(fh,disp,1,gy1)
call decomp_2d_read_var(fh,disp,1,gz1)
call decomp_2d_read_var(fh,disp,1,rhos1)
call decomp_2d_read_var(fh,disp,1,px1)
call decomp_2d_read_var(fh,disp,1,py1)
call decomp_2d_read_var(fh,disp,1,pz1)
call decomp_2d_read_var(fh,disp,1,pp3,phG)
call MPI_FILE_CLOSE(fh,ierror)
endif
else !AB3
if (irestart==1) then !write
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, &
fh, ierror)
filesize = 0_MPI_OFFSET_KIND
call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting
disp = 0_MPI_OFFSET_KIND
call decomp_2d_write_var(fh,disp,1,ux1)
call decomp_2d_write_var(fh,disp,1,uy1)
call decomp_2d_write_var(fh,disp,1,uz1)
call decomp_2d_write_var(fh,disp,1,rho1)
call decomp_2d_write_var(fh,disp,1,temperature1)
call decomp_2d_write_var(fh,disp,1,gx1)
call decomp_2d_write_var(fh,disp,1,gy1)
call decomp_2d_write_var(fh,disp,1,gz1)
call decomp_2d_write_var(fh,disp,1,rhos1)
call decomp_2d_write_var(fh,disp,1,hx1)
call decomp_2d_write_var(fh,disp,1,hy1)
call decomp_2d_write_var(fh,disp,1,hz1)
call decomp_2d_write_var(fh,disp,1,rhoss1)
call decomp_2d_write_var(fh,disp,1,px1)
call decomp_2d_write_var(fh,disp,1,py1)
call decomp_2d_write_var(fh,disp,1,pz1)
call decomp_2d_write_var(fh,disp,1,pp3,phG)
call MPI_FILE_CLOSE(fh,ierror)
else
if (nrank==0) print *,'RESTART'
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_RDONLY, MPI_INFO_NULL, &
fh, ierror)
disp = 0_MPI_OFFSET_KIND
call decomp_2d_read_var(fh,disp,1,ux1)
call decomp_2d_read_var(fh,disp,1,uy1)
call decomp_2d_read_var(fh,disp,1,uz1)
call decomp_2d_read_var(fh,disp,1,rho1)
call decomp_2d_read_var(fh,disp,1,temperature1)
call decomp_2d_read_var(fh,disp,1,gx1)
call decomp_2d_read_var(fh,disp,1,gy1)
call decomp_2d_read_var(fh,disp,1,gz1)
call decomp_2d_read_var(fh,disp,1,rhos1)
call decomp_2d_read_var(fh,disp,1,hx1)
call decomp_2d_read_var(fh,disp,1,hy1)
call decomp_2d_read_var(fh,disp,1,hz1)
call decomp_2d_read_var(fh,disp,1,rhoss1)
call decomp_2d_read_var(fh,disp,1,px1)
call decomp_2d_read_var(fh,disp,1,py1)
call decomp_2d_read_var(fh,disp,1,pz1)
call decomp_2d_read_var(fh,disp,1,pp3,phG)
call MPI_FILE_CLOSE(fh,ierror)
endif
endif
else !SCALAR
if (nscheme.ne.4) then
if (irestart==1) then !write
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, &
fh, ierror)
filesize = 0_MPI_OFFSET_KIND
call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting
disp = 0_MPI_OFFSET_KIND
call decomp_2d_write_var(fh,disp,1,ux1)
call decomp_2d_write_var(fh,disp,1,uy1)
call decomp_2d_write_var(fh,disp,1,uz1)
call decomp_2d_write_var(fh,disp,1,rho1)
call decomp_2d_write_var(fh,disp,1,temperature1)
call decomp_2d_write_var(fh,disp,1,gx1)
call decomp_2d_write_var(fh,disp,1,gy1)
call decomp_2d_write_var(fh,disp,1,gz1)
call decomp_2d_write_var(fh,disp,1,rhos1)
call decomp_2d_write_var(fh,disp,1,px1)
call decomp_2d_write_var(fh,disp,1,py1)
call decomp_2d_write_var(fh,disp,1,pz1)
call decomp_2d_write_var(fh,disp,1,pp3,phG)
call decomp_2d_write_var(fh,disp,1,phi1)
call decomp_2d_write_var(fh,disp,1,phis1)
call MPI_FILE_CLOSE(fh,ierror)
else
if (nrank==0) then
print *,'RESTART'
endif
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_RDONLY, MPI_INFO_NULL, &
fh, ierror)
disp = 0_MPI_OFFSET_KIND
call decomp_2d_read_var(fh,disp,1,ux1)
call decomp_2d_read_var(fh,disp,1,uy1)
call decomp_2d_read_var(fh,disp,1,uz1)
call decomp_2d_read_var(fh,disp,1,rho1)
call decomp_2d_read_var(fh,disp,1,temperature1)
call decomp_2d_read_var(fh,disp,1,gx1)
call decomp_2d_read_var(fh,disp,1,gy1)
call decomp_2d_read_var(fh,disp,1,gz1)
call decomp_2d_read_var(fh,disp,1,rhos1)
call decomp_2d_read_var(fh,disp,1,px1)
call decomp_2d_read_var(fh,disp,1,py1)
call decomp_2d_read_var(fh,disp,1,pz1)
call decomp_2d_read_var(fh,disp,1,pp3,phG)
call decomp_2d_read_var(fh,disp,1,phi1)
call decomp_2d_read_var(fh,disp,1,phis1)
call MPI_FILE_CLOSE(fh,ierror)
endif
else !SCALAR + AB3
if (irestart==1) then !write
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, &
fh, ierror)
filesize = 0_MPI_OFFSET_KIND
call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting
disp = 0_MPI_OFFSET_KIND
call decomp_2d_write_var(fh,disp,1,ux1)
call decomp_2d_write_var(fh,disp,1,uy1)
call decomp_2d_write_var(fh,disp,1,uz1)
call decomp_2d_write_var(fh,disp,1,rho1)
call decomp_2d_write_var(fh,disp,1,temperature1)
call decomp_2d_write_var(fh,disp,1,gx1)
call decomp_2d_write_var(fh,disp,1,gy1)
call decomp_2d_write_var(fh,disp,1,gz1)
call decomp_2d_write_var(fh,disp,1,rhos1)
call decomp_2d_write_var(fh,disp,1,hx1)
call decomp_2d_write_var(fh,disp,1,hy1)
call decomp_2d_write_var(fh,disp,1,hz1)
call decomp_2d_write_var(fh,disp,1,rhoss1)
call decomp_2d_write_var(fh,disp,1,px1)
call decomp_2d_write_var(fh,disp,1,py1)
call decomp_2d_write_var(fh,disp,1,pz1)
call decomp_2d_write_var(fh,disp,1,pp3,phG)
call decomp_2d_write_var(fh,disp,1,phi1)
call decomp_2d_write_var(fh,disp,1,phis1)
call decomp_2d_write_var(fh,disp,1,phiss1)
call MPI_FILE_CLOSE(fh,ierror)
else
if (nrank==0) then
print *,'RESTART'
endif
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'sauve.dat', &
MPI_MODE_RDONLY, MPI_INFO_NULL, &
fh, ierror)
disp = 0_MPI_OFFSET_KIND
call decomp_2d_read_var(fh,disp,1,ux1)
call decomp_2d_read_var(fh,disp,1,uy1)
call decomp_2d_read_var(fh,disp,1,uz1)
call decomp_2d_read_var(fh,disp,1,rho1)
call decomp_2d_read_var(fh,disp,1,temperature1)
call decomp_2d_read_var(fh,disp,1,gx1)
call decomp_2d_read_var(fh,disp,1,gy1)
call decomp_2d_read_var(fh,disp,1,gz1)
call decomp_2d_read_var(fh,disp,1,rhos1)
call decomp_2d_read_var(fh,disp,1,hx1)
call decomp_2d_read_var(fh,disp,1,hy1)
call decomp_2d_read_var(fh,disp,1,hz1)
call decomp_2d_read_var(fh,disp,1,hz1)
call decomp_2d_read_var(fh,disp,1,rhoss1)
call decomp_2d_read_var(fh,disp,1,px1)
call decomp_2d_read_var(fh,disp,1,py1)
call decomp_2d_read_var(fh,disp,1,pz1)
call decomp_2d_read_var(fh,disp,1,pp3,phG)
call decomp_2d_read_var(fh,disp,1,phi1)
call decomp_2d_read_var(fh,disp,1,phis1)
call decomp_2d_read_var(fh,disp,1,phiss1)
call MPI_FILE_CLOSE(fh,ierror)
endif
endif
endif
if (irestart==0) then ! We are READING data
! reconstruction of the dp/dx, dp/dy and dp/dz from px1,py1 and pz1
! Temporal scheme (1:AB2, 2: RK3, 3:RK4, 4:AB3)
if (nscheme==1) then
xdt=adt(1)+bdt(1)
else if (nscheme==2) then
xdt=(3._mytype/4._mytype)*dt + (-5._mytype/12._mytype)*dt
else if (nscheme==3) then
xdt=0.041717869325_mytype*dt
else if (nscheme==4) then
xdt=adt(1)+bdt(1)+cdt(1)
else
if (nrank.eq.0) then
PRINT *, "Unknown nscheme=", nscheme
endif
endif
do k=1,xsize(3)
do j=1,xsize(2)
dpdyx1(j,k)=py1(1,j,k)/xdt
dpdzx1(j,k)=pz1(1,j,k)/xdt
dpdyxn(j,k)=py1(nx,j,k)/xdt
dpdzxn(j,k)=pz1(nx,j,k)/xdt
enddo
enddo
if (xsize(3)==1) then
do j=1,xsize(2)
do i=1,xsize(1)
dpdxz1(i,j)=px1(i,j,1)/xdt
dpdyz1(i,j)=py1(i,j,1)/xdt
enddo
enddo
endif
if (xsize(3)==nz) then
do j=1,xsize(2)
do i=1,xsize(1)
dpdxzn(i,j)=px1(i,j,nz)/xdt
dpdyzn(i,j)=py1(i,j,nz)/xdt
enddo
enddo
endif
! determine the processor grid in use
call MPI_CART_GET(DECOMP_2D_COMM_CART_X, 2, &
dims, dummy_periods, dummy_coords, code)
if (dims(1)==1) then
do k=1,xsize(3)
do i=1,xsize(1)
dpdxy1(i,k)=px1(i,1,k)/xdt
dpdzy1(i,k)=pz1(i,1,k)/xdt
enddo
enddo
do k=1,xsize(3)
do i=1,xsize(1)
dpdxyn(i,k)=px1(i,xsize(2),k)/xdt
dpdzyn(i,k)=pz1(i,xsize(2),k)/xdt
enddo
enddo
else
!find j=1 and j=ny
if (xstart(2)==1) then
do k=1,xsize(3)
do i=1,xsize(1)
dpdxy1(i,k)=px1(i,1,k)/xdt
dpdzy1(i,k)=pz1(i,1,k)/xdt
enddo
enddo
endif
! print *,nrank,xstart(2),ny-(nym/p_row)
if (ny-(nym/dims(1))==xstart(2)) then
do k=1,xsize(3)
do i=1,xsize(1)
dpdxyn(i,k)=px1(i,xsize(2),k)/xdt
dpdzyn(i,k)=pz1(i,xsize(2),k)/xdt
enddo
enddo
endif
endif
if (nrank==0) print *,'reconstruction pressure gradients done!'
!! Reconstruct thermodynamic pressure from density and
! temperature fields.
pressure0 = 0._mytype
do ijk = 1, xsize(1) * xsize(2) * xsize(3)
pressure0 = pressure0 + rho1(ijk, 1, 1) * temperature1(ijk, 1, 1)
enddo
pressure0 = pressure0 / float(xsize(1) * xsize(2) * xsize(3))
call MPI_Allreduce(MPI_IN_PLACE, pressure0, 1, real_type, MPI_SUM, MPI_COMM_WORLD, ierror)
pressure0 = pressure0 / float(nproc)
endif
if (irestart==0) then
if (ivirt==2) then
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'epsilon.dat', &
MPI_MODE_RDONLY, MPI_INFO_NULL, &
fh, ierror)
disp = 0_MPI_OFFSET_KIND
call decomp_2d_read_var(fh,disp,1,ep1)
call MPI_FILE_CLOSE(fh,ierror)
if (nrank==0) print *,'read epsilon file done from restart'
endif
endif
end subroutine restart
!*******************************************************************
!
!
!*******************************************************************
subroutine stretching()
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
real(mytype) :: yinf,den,xnum,xcx,den1,den2,den3,den4,xnum1,cst
integer :: j
yinf=-yly/2._mytype
den=2._mytype*beta*yinf
xnum=-yinf-sqrt(pi*pi*beta*beta+yinf*yinf)
alpha=abs(xnum/den)
xcx=1._mytype/beta/alpha
if (alpha.ne.0._mytype) then
if (istret.eq.1) yp(1)=0._mytype
if (istret.eq.2) yp(1)=0._mytype
if (istret.eq.1) yeta(1)=0._mytype
if (istret.eq.2) yeta(1)=-1._mytype/2._mytype
if (istret.eq.3) yp(1)=0._mytype
if (istret.eq.3) yeta(1)=-1._mytype/2._mytype
do j=2,ny!-1
if (istret==1) then
if (ncly.eq.0) yeta(j)=(j-1._mytype)*(1._mytype/ny)
if ((ncly.eq.1).or.(ncly.eq.2)) yeta(j)=(j-1._mytype)*(1._mytype/(ny-1._mytype))
endif
if (istret==2) then
if (ncly.eq.0) yeta(j)=(j-1._mytype)*(1._mytype/ny)-0.5_mytype
if ((ncly.eq.1).or.(ncly.eq.2)) yeta(j)=(j-1._mytype)*(1._mytype/(ny-1._mytype))-0.5_mytype
endif
if (istret==3) then
if (ncly.eq.0) yeta(j)=((j-1._mytype)*(1._mytype/2._mytype/ny)-0.5_mytype)
if ((ncly.eq.1).or.(ncly.eq.2)) yeta(j)=((j-1._mytype)*(1._mytype/2._mytype/(ny-1._mytype))-0.5_mytype)
endif
den1=sqrt(alpha*beta+1.)
xnum=den1/sqrt(alpha/pi)/sqrt(beta)/sqrt(pi)
den=2._mytype*sqrt(alpha/pi)*sqrt(beta)*pi*sqrt(pi)
den3=((sin(pi*yeta(j)))*(sin(pi*yeta(j)))/beta/pi)+alpha/pi
den4=2._mytype*alpha*beta-cos(2._mytype*pi*yeta(j))+1._mytype
if ((ncly.ne.0).and.(j==ny).and.(istret==1)) then
xnum1=0._mytype
else
xnum1=(atan(xnum*tan(pi*yeta(j))))*den4/den1/den3/den
endif
cst=sqrt(beta)*pi/(2._mytype*sqrt(alpha)*sqrt(alpha*beta+1._mytype))
if (istret==1) then
if (yeta(j).lt.0.5_mytype) yp(j)=xnum1-cst-yinf
if (yeta(j).eq.0.5_mytype) yp(j)=0._mytype-yinf
if (yeta(j).gt.0.5_mytype) yp(j)=xnum1+cst-yinf
endif
if (istret==2) then
if (yeta(j).lt.0.5_mytype) yp(j)=xnum1-cst+yly
if (yeta(j).eq.0.5_mytype) yp(j)=0._mytype+yly
if (yeta(j).gt.0.5_mytype) yp(j)=xnum1+cst+yly
endif
if (istret==3) then
if (yeta(j).lt.0.5_mytype) yp(j)=(xnum1-cst+yly)*2._mytype
if (yeta(j).eq.0.5_mytype) yp(j)=(0._mytype+yly)*2._mytype
if (yeta(j).gt.0.5_mytype) yp(j)=(xnum1+cst+yly)*2._mytype
endif
enddo
endif
!if (nrank==0) then
!do j=1,ny
!print *,j,yp(j),yeta(j)
!enddo
!endif
!stop
if (alpha.eq.0.) then
yp(1)=-1.e10_mytype
do j=2,ny
yeta(j)=(j-1._mytype)*(1._mytype/ny)
yp(j)=-beta*cos(pi*yeta(j))/sin(yeta(j)*pi)
enddo
endif
if (alpha.ne.0._mytype) then
do j=1,ny
if (istret==1) then
if (ncly.eq.0) then
yetai(j)=(j-0.5_mytype)*(1._mytype/ny)
else if ((ncly.eq.1).or.(ncly.eq.2)) then
yetai(j)=(j-0.5_mytype)*(1._mytype/(ny-1._mytype))
endif
else if (istret==2) then
if (ncly.eq.0) then
yetai(j)=(j-0.5_mytype)*(1._mytype/ny)-0.5_mytype
else if ((ncly.eq.1).or.(ncly.eq.2)) then
yetai(j)=(j-0.5_mytype)*(1._mytype/(ny-1._mytype))-0.5_mytype
endif
else if (istret==3) then
if (ncly.eq.0) then
yetai(j)=(j-0.5)*(1./2./ny)-0.5_mytype
else if ((ncly.eq.1).or.(ncly.eq.2)) then
yetai(j)=(j-0.5_mytype)*(1._mytype/2._mytype/(ny-1._mytype))-0.5_mytype
endif
endif
den1=sqrt(alpha*beta+1.)
xnum=den1/sqrt(alpha/pi)/sqrt(beta)/sqrt(pi)
den=2._mytype*sqrt(alpha/pi)*sqrt(beta)*pi*sqrt(pi)
den3=((sin(pi*yetai(j)))*(sin(pi*yetai(j)))/beta/pi)+alpha/pi
den4=2._mytype*alpha*beta-cos(2._mytype*pi*yetai(j))+1.
xnum1=(atan(xnum*tan(pi*yetai(j))))*den4/den1/den3/den
cst=sqrt(beta)*pi/(2._mytype*sqrt(alpha)*sqrt(alpha*beta+1.))
if (istret==1) then
if (yetai(j).lt.0.5_mytype) then
ypi(j)=xnum1-cst-yinf
else if (yetai(j).gt.0.5_mytype) then
ypi(j)=xnum1+cst-yinf
else
ypi(j)=0._mytype-yinf
endif
else if (istret==2) then
if (yetai(j).lt.0.5_mytype) then
ypi(j)=xnum1-cst+yly
else if (yetai(j).gt.0.5_mytype) then
ypi(j)=xnum1+cst+yly
else
ypi(j)=0._mytype+yly
endif
endif
if (istret==3) then
if (yetai(j).lt.0.5_mytype) then
ypi(j)=(xnum1-cst+yly)*2._mytype
else if (yetai(j).gt.0.5_mytype) then
ypi(j)=(xnum1+cst+yly)*2._mytype
else
ypi(j)=(0._mytype+yly)*2._mytype
endif
endif
enddo
endif
if (alpha.eq.0._mytype) then
ypi(1)=-1.e10_mytype
do j=2,ny
yetai(j)=(j-1._mytype)*(1._mytype/ny)
ypi(j)=-beta*cos(pi*yetai(j))/sin(yetai(j)*pi)
enddo
endif
do j=1,ny
ppy(j)=yly*(alpha/pi+(1./pi/beta)*sin(pi*yeta(j))* &
sin(pi*yeta(j)))
pp2y(j)=ppy(j)*ppy(j)
pp4y(j)=(-2._mytype/beta*cos(pi*yeta(j))*sin(pi*yeta(j)))
enddo
do j=1,ny
ppyi(j)=yly*(alpha/pi+(1./pi/beta)*sin(pi*yetai(j))* &
sin(pi*yetai(j)))
pp2yi(j)=ppyi(j)*ppyi(j)
pp4yi(j)=(-2._mytype/beta*cos(pi*yetai(j))*sin(pi*yetai(j)))
enddo
end subroutine stretching
!*****************************************************************
!
!
!*****************************************************************
subroutine inversion5_v1(aaa,eee,spI)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
! decomposition object for spectral space
TYPE(DECOMP_INFO) :: spI
#ifdef DOUBLE_PREC
real(mytype), parameter :: epsilon = 1.e-16_mytype
#else
real(mytype), parameter :: epsilon = 1.e-8_mytype
#endif
complex(mytype),dimension(spI%yst(1):spI%yen(1),ny/2,spI%yst(3):spI%yen(3),5) :: aaa
complex(mytype),dimension(spI%yst(1):spI%yen(1),spI%yst(2):spI%yen(2),spI%yst(3):spI%yen(3)) :: eee
integer :: i,j,k,m,mi,jc
integer,dimension(2) :: ja,jb
complex(mytype),dimension(spI%yst(1):spI%yen(1),spI%yst(3):spI%yen(3)) :: sr
complex(mytype),dimension(spI%yst(1):spI%yen(1),spI%yst(3):spI%yen(3)) :: a1,b1
real(mytype) :: tmp1,tmp2,tmp3,tmp4
do i=1,2
ja(i)=4-i
jb(i)=5-i
enddo
do m=1,ny/2-2
do i=1,2
mi=m+i
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
if (real(aaa(j,m,k,3), kind=mytype).ne.0._mytype) then
tmp1=real(aaa(j,mi,k,3-i), kind=mytype)/real(aaa(j,m,k,3), kind=mytype)
endif
if (aimag(aaa(j,m,k,3)).ne.0._mytype) then
tmp2=aimag(aaa(j,mi,k,3-i))/aimag(aaa(j,m,k,3))
endif
sr(j,k)=cmplx(tmp1,tmp2, kind=mytype)
eee(j,mi,k)=cmplx(real(eee(j,mi,k), kind=mytype)-tmp1*real(eee(j,m,k), kind=mytype),&
aimag(eee(j,mi,k))-tmp2*aimag(eee(j,m,k)), kind=mytype)
enddo
enddo
do jc=ja(i),jb(i)
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
aaa(j,mi,k,jc)=cmplx(real(aaa(j,mi,k,jc), kind=mytype)-real(sr(j,k), kind=mytype)&
* real(aaa(j,m,k,jc+i), kind=mytype), aimag(aaa(j,mi,k,jc))-aimag(sr(j,k))&
* aimag(aaa(j,m,k,jc+i)), kind=mytype)
enddo
enddo
enddo
enddo
enddo
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
if (abs(real(aaa(j,ny/2-1,k,3), kind=mytype)).gt.epsilon) then
tmp1=real(aaa(j,ny/2,k,2), kind=mytype)/real(aaa(j,ny/2-1,k,3), kind=mytype)
else
tmp1=0._mytype
endif
if (abs(aimag(aaa(j,ny/2-1,k,3))).gt.epsilon) then
tmp2=aimag(aaa(j,ny/2,k,2))/aimag(aaa(j,ny/2-1,k,3))
else
tmp2=0._mytype
endif
sr(j,k)=cmplx(tmp1,tmp2, kind=mytype)
b1(j,k)=cmplx(real(aaa(j,ny/2,k,3), kind=mytype)-tmp1*real(aaa(j,ny/2-1,k,4), kind=mytype),&
aimag(aaa(j,ny/2,k,3))-tmp2*aimag(aaa(j,ny/2-1,k,4)), kind=mytype)
if (abs(real(b1(j,k), kind=mytype)).gt.epsilon) then
tmp1=real(sr(j,k), kind=mytype)/real(b1(j,k), kind=mytype)
tmp3=real(eee(j,ny/2,k), kind=mytype)/real(b1(j,k), kind=mytype)-tmp1*real(eee(j,ny/2-1,k), kind=mytype)
else
tmp1=0._mytype
tmp3=0._mytype
endif
if (abs(aimag(b1(j,k))).gt.epsilon) then
tmp2=aimag(sr(j,k))/aimag(b1(j,k))
tmp4=aimag(eee(j,ny/2,k))/aimag(b1(j,k))-tmp2*aimag(eee(j,ny/2-1,k))
else
tmp2=0._mytype
tmp4=0._mytype
endif
a1(j,k)=cmplx(tmp1,tmp2, kind=mytype)
eee(j,ny/2,k)=cmplx(tmp3,tmp4, kind=mytype)
if (abs(real(aaa(j,ny/2-1,k,3), kind=mytype)).gt.epsilon) then
tmp1=1._mytype/real(aaa(j,ny/2-1,k,3), kind=mytype)
else
tmp1=0.
endif
if (abs(aimag(aaa(j,ny/2-1,k,3))).gt.epsilon) then
tmp2=1._mytype/aimag(aaa(j,ny/2-1,k,3))
else
tmp2=0._mytype
endif
b1(j,k)=cmplx(tmp1,tmp2, kind=mytype)
a1(j,k)=cmplx(real(aaa(j,ny/2-1,k,4), kind=mytype)*real(b1(j,k), kind=mytype),&
aimag(aaa(j,ny/2-1,k,4))*aimag(b1(j,k)), kind=mytype)
eee(j,ny/2-1,k)=cmplx(real(eee(j,ny/2-1,k))*real(b1(j,k))-real(a1(j,k))*real(eee(j,ny/2,k)),&
aimag(eee(j,ny/2-1,k))*aimag(b1(j,k))-aimag(a1(j,k))*aimag(eee(j,ny/2,k)), kind=mytype)
enddo
enddo
do i=ny/2-2,1,-1
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
if (abs(real(aaa(j,i,k,3), kind=mytype)).gt.epsilon) then
tmp1=1._mytype/real(aaa(j,i,k,3), kind=mytype)
else
tmp1=0._mytype
endif
if (abs(aimag(aaa(j,i,k,3))).gt.epsilon) then
tmp2=1._mytype/aimag(aaa(j,i,k,3))
else
tmp2=0._mytype
endif
sr(j,k)=cmplx(tmp1,tmp2, kind=mytype)
a1(j,k)=cmplx(real(aaa(j,i,k,4), kind=mytype)*real(sr(j,k), kind=mytype),&
aimag(aaa(j,i,k,4))*aimag(sr(j,k)), kind=mytype)
b1(j,k)=cmplx(real(aaa(j,i,k,5), kind=mytype)*real(sr(j,k), kind=mytype),&
aimag(aaa(j,i,k,5))*aimag(sr(j,k)), kind=mytype)
eee(j,i,k)=cmplx(real(eee(j,i,k), kind=mytype)*real(sr(j,k), kind=mytype)-&
real(a1(j,k), kind=mytype)*real(eee(j,i+1,k), kind=mytype)-&
real(b1(j,k), kind=mytype)*real(eee(j,i+2,k), kind=mytype),&
aimag(eee(j,i,k))*aimag(sr(j,k))-&
aimag(a1(j,k))*aimag(eee(j,i+1,k))-aimag(b1(j,k))*aimag(eee(j,i+2,k)), kind=mytype)
enddo
enddo
enddo
return
end subroutine inversion5_v1
!*****************************************************************
!
!
!*****************************************************************
subroutine inversion5_v2(aaa,eee,spI)
USE decomp_2d
USE decomp_2d_poisson
USE variables
USE param
USE var
USE MPI
implicit none
! decomposition object for spectral space
TYPE(DECOMP_INFO) :: spI
#ifdef DOUBLE_PREC
real(mytype), parameter :: epsilon = 1.e-16_mytype
#else
real(mytype), parameter :: epsilon = 1.e-8_mytype
#endif
complex(mytype),dimension(spI%yst(1):spI%yen(1),nym,spI%yst(3):spI%yen(3),5) :: aaa
complex(mytype),dimension(spI%yst(1):spI%yen(1),nym,spI%yst(3):spI%yen(3)) :: eee
integer :: i,j,k,m,mi,jc
integer,dimension(2) :: ja,jb
complex(mytype),dimension(spI%yst(1):spI%yen(1),spI%yst(3):spI%yen(3)) :: sr
complex(mytype),dimension(spI%yst(1):spI%yen(1),spI%yst(3):spI%yen(3)) :: a1,b1
real(mytype) :: tmp1,tmp2,tmp3,tmp4
do i=1,2
ja(i)=4-i
jb(i)=5-i
enddo
do m=1,nym-2
do i=1,2
mi=m+i
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
if (real(aaa(j,m,k,3), kind=mytype).ne.0._mytype) then
tmp1=real(aaa(j,mi,k,3-i), kind=mytype)/real(aaa(j,m,k,3), kind=mytype)
endif
if (aimag(aaa(j,m,k,3)).ne.0._mytype) then
tmp2=aimag(aaa(j,mi,k,3-i))/aimag(aaa(j,m,k,3))
endif
sr(j,k)=cmplx(tmp1,tmp2, kind=mytype)
eee(j,mi,k)=cmplx(real(eee(j,mi,k), kind=mytype)-tmp1*real(eee(j,m,k), kind=mytype),&
aimag(eee(j,mi,k))-tmp2*aimag(eee(j,m,k)), kind=mytype)
enddo
enddo
do jc=ja(i),jb(i)
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
aaa(j,mi,k,jc)=cmplx(real(aaa(j,mi,k,jc), kind=mytype)-real(sr(j,k), kind=mytype)&
* real(aaa(j,m,k,jc+i), kind=mytype), aimag(aaa(j,mi,k,jc))-aimag(sr(j,k))&
* aimag(aaa(j,m,k,jc+i)), kind=mytype)
enddo
enddo
enddo
enddo
enddo
do k=spI%yst(3),spI%yen(3)
do j=spI%yst(1),spI%yen(1)
if (abs(real(aaa(j,nym-1,k,3), kind=mytype)).gt.epsilon) then
tmp1=real(aaa(j,nym,k,2), kind=mytype)/real(aaa(j,nym-1,k,3), kind=mytype)
else
tmp1=0._mytype
endif
if (abs(aimag(aaa(j,nym-1,k,3))).gt.epsilon) then
tmp2=aimag(aaa(j,nym,k,2))/aimag(aaa(j,nym-1,k,3))
else
tmp2=0._mytype
endif
sr(j,k)=cmplx(tmp1,tmp2, kind=mytype)
b1(j,k)=cmplx(real(aaa(j,nym,k,3), kind=mytype)-tmp1*real(aaa(j,nym-1,k,4), kind=mytype),&
aimag(aaa(j,nym,k,3))-tmp2*aimag(aaa(j,nym-1,k,4)), kind=mytype)
if (abs(real(b1(j,k), kind=mytype)).gt.epsilon) then
tmp1=real(sr(j,k), kind=mytype)/real(b1(j,k), kind=mytype)
tmp3=real(eee(j,nym,k), kind=mytype)/real(b1(j,k), kind=mytype)-tmp1*real(eee(j,nym-1,k), kind=mytype)
else
tmp1=0._mytype
tmp3=0._mytype
endif
if (abs(aimag(b1(j,k))).gt.epsilon) then
tmp2=aimag(sr(j,k))/aimag(b1(j,k))
tmp4=aimag(eee(j,nym,k))/aimag(b1(j,k))-tmp2*aimag(eee(j,nym-1,k))
else
tmp2=0._mytype
tmp4=0._mytype
endif
a1(j,k)=cmplx(tmp1,tmp2, kind=mytype)
eee(j,nym,k)=cmplx(tmp3,tmp4, kind=mytype)
if (abs(real(aaa(j,nym-1,k,3), kind=mytype)).gt.epsilon) then
tmp1=1._mytype/real(aaa(j,nym-1,k,3), kind=mytype)
else
tmp1=0._mytype
endif
if (abs(aimag(aaa(j,nym-1,k,3))).gt.epsilon) then