Skip to content

Commit 2ba00b7

Browse files
fangjianfangjian
authored andcommitted
a minor adjust to some modules
1 parent f0058ae commit 2ba00b7

File tree

4 files changed

+130
-129
lines changed

4 files changed

+130
-129
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_executable(astr
3939
userdefine.F90
4040
utility.F90
4141
vtkio.F90)
42+
4243
target_link_libraries(astr)
4344
if (MPI_FOUND)
4445
target_link_libraries(astr PRIVATE MPI::MPI_Fortran)

src/commfunc.F90

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3938,7 +3938,130 @@ end function isidenmar
39383938
!+-------------------------------------------------------------------+
39393939
!| The end of the function isidenmar. |
39403940
!+-------------------------------------------------------------------+
3941-
!
3941+
3942+
!+-------------------------------------------------------------------+
3943+
!| This subroutine is a preprocessor of the Thomas algorithm. |
3944+
!+-------------------------------------------------------------------+
3945+
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
3946+
!+-------------------------------------------------------------------+
3947+
!| CHANGE RECORD |
3948+
!| ------------- |
3949+
!| 27-05-2025 | Rewrite by J. Fang @ Liverpool. |
3950+
!+-------------------------------------------------------------------+
3951+
subroutine tridiagonal_thomas_proprocess(a,c,ac)
3952+
3953+
real(8),intent(in) :: a(:),c(:)
3954+
3955+
real(8) :: ac(3,size(a))
3956+
3957+
integer :: i
3958+
3959+
ac(1,1)=c(1)
3960+
3961+
do i=2,size(a)
3962+
3963+
ac(1,i)=c(i)/(1.d0-a(i)*ac(1,i-1))
3964+
3965+
ac(2,i)=1.d0/(1.d0-a(i)*ac(1,i-1))
3966+
3967+
ac(3,i)=a(i)/(1.d0-a(i)*ac(1,i-1))
3968+
3969+
enddo
3970+
3971+
return
3972+
3973+
end subroutine tridiagonal_thomas_proprocess
3974+
!+-------------------------------------------------------------------+
3975+
!| The end of the subroutine tridiagonal_thomas_proprocess. |
3976+
!+-------------------------------------------------------------------+
3977+
3978+
!+-------------------------------------------------------------------+
3979+
!| This is a standard tridiagonal matrix algorithm, also known as the|
3980+
!| Thomas algorithm to solve tridiagonal systems of equations. |
3981+
!+-------------------------------------------------------------------+
3982+
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
3983+
!+-------------------------------------------------------------------+
3984+
!| CHANGE RECORD |
3985+
!| ------------- |
3986+
!| 25-05-2025 | Rewrite by J. Fang @ Liverpool. |
3987+
!| 26-05-2025 | Separate the solver part by J. Fang @ Liverpool. |
3988+
!+-------------------------------------------------------------------+
3989+
function tridiagonal_thomas_solver(ac,d) result(x)
3990+
3991+
! arguments
3992+
real(8),intent(in) :: ac(:,:)
3993+
real(8) :: d(:)
3994+
real(8) :: x(size(d))
3995+
3996+
! local data
3997+
integer :: i,n
3998+
3999+
n=size(d)
4000+
4001+
do i=2,n
4002+
d(i)=d(i)*ac(2,i)-d(i-1)*ac(3,i)
4003+
enddo
4004+
4005+
x(n)=d(n)
4006+
do i=n-1,1,-1
4007+
x(i)=d(i)-ac(1,i)*x(i+1)
4008+
enddo
4009+
4010+
return
4011+
4012+
end function tridiagonal_thomas_solver
4013+
!+-------------------------------------------------------------------+
4014+
!| The end of the function tridiagonal_thomas_solver. |
4015+
!+-------------------------------------------------------------------+
4016+
4017+
!+-------------------------------------------------------------------+
4018+
!| This is a standard tridiagonal matrix algorithm, also known as the|
4019+
!| Thomas algorithm to solve tridiagonal systems of equations. |
4020+
!+-------------------------------------------------------------------+
4021+
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
4022+
!+-------------------------------------------------------------------+
4023+
!| CHANGE RECORD |
4024+
!| ------------- |
4025+
!| 25-05-2025 | Rewrite by J. Fang @ Liverpool. |
4026+
!+-------------------------------------------------------------------+
4027+
function tridiagonal_thomas(a,c,d) result(x)
4028+
4029+
! arguments
4030+
real(8),intent(in) :: a(:),c(:),d(:)
4031+
real(8) :: x(size(d))
4032+
4033+
! local data
4034+
integer :: i,n
4035+
real(8),allocatable :: cc(:),dd(:)
4036+
4037+
n=size(d)
4038+
4039+
allocate(cc(n),dd(n))
4040+
4041+
cc(1)=c(1)
4042+
dd(1)=d(1)
4043+
do i=2,n
4044+
4045+
cc(i)=c(i)/(1.d0-a(i)*cc(i-1))
4046+
4047+
dd(i)=(d(i)-a(i)*dd(i-1))/(1.d0-a(i)*cc(i-1))
4048+
4049+
enddo
4050+
4051+
x(n)=dd(n)
4052+
do i=n-1,1,-1
4053+
x(i)=dd(i)-cc(i)*x(i+1)
4054+
enddo
4055+
4056+
deallocate(cc,dd)
4057+
4058+
return
4059+
4060+
end function tridiagonal_thomas
4061+
!+-------------------------------------------------------------------+
4062+
!| The end of the function tridiagonal_thomas. |
4063+
!+-------------------------------------------------------------------+
4064+
39424065
end module commfunc
39434066
!+---------------------------------------------------------------------+
39444067
!| The end of the module commfunc. |

src/filter.F90

Lines changed: 3 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module filter
2929
subroutine compact_filter_initiate(ntype,dim,dir)
3030

3131
use commvar, only : hm,alfa_filter
32+
use commfunc,only : tridiagonal_thomas_proprocess
3233

3334
integer,intent(in) :: ntype,dim,dir
3435

@@ -249,6 +250,7 @@ end function compact_filter_rhs
249250
function compact_filter(f,ntype,dim,dir) result(ff)
250251

251252
use commvar, only : hm
253+
use commfunc,only : tridiagonal_thomas_solver
252254

253255
! arguments
254256
integer,intent(in) :: ntype,dim,dir
@@ -631,130 +633,7 @@ end function spafilter6exp
631633
!+-------------------------------------------------------------------+
632634
!| The end of the function spafilter6exp. |
633635
!+-------------------------------------------------------------------+
634-
!
635-
!+-------------------------------------------------------------------+
636-
!| This subroutine is a preprocessor of the Thomas algorithm. |
637-
!+-------------------------------------------------------------------+
638-
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
639-
!+-------------------------------------------------------------------+
640-
!| CHANGE RECORD |
641-
!| ------------- |
642-
!| 27-05-2025 | Rewrite by J. Fang @ Liverpool. |
643-
!+-------------------------------------------------------------------+
644-
subroutine tridiagonal_thomas_proprocess(a,c,ac)
645-
646-
real(8),intent(in) :: a(:),c(:)
647-
648-
real(8) :: ac(3,size(a))
649-
650-
integer :: i
651-
652-
ac(1,1)=c(1)
653-
654-
do i=2,size(a)
655-
656-
ac(1,i)=c(i)/(1.d0-a(i)*ac(1,i-1))
657-
658-
ac(2,i)=1.d0/(1.d0-a(i)*ac(1,i-1))
659-
660-
ac(3,i)=a(i)/(1.d0-a(i)*ac(1,i-1))
661-
662-
enddo
663-
664-
return
665-
666-
end subroutine tridiagonal_thomas_proprocess
667-
!+-------------------------------------------------------------------+
668-
!| The end of the subroutine tridiagonal_thomas_proprocess. |
669-
!+-------------------------------------------------------------------+
670-
671-
!+-------------------------------------------------------------------+
672-
!| This is a standard tridiagonal matrix algorithm, also known as the|
673-
!| Thomas algorithm to solve tridiagonal systems of equations. |
674-
!+-------------------------------------------------------------------+
675-
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
676-
!+-------------------------------------------------------------------+
677-
!| CHANGE RECORD |
678-
!| ------------- |
679-
!| 25-05-2025 | Rewrite by J. Fang @ Liverpool. |
680-
!| 26-05-2025 | Separate the solver part by J. Fang @ Liverpool. |
681-
!+-------------------------------------------------------------------+
682-
function tridiagonal_thomas_solver(ac,d) result(x)
683-
684-
! arguments
685-
real(8),intent(in) :: ac(:,:)
686-
real(8) :: d(:)
687-
real(8) :: x(size(d))
688-
689-
! local data
690-
integer :: i,n
691-
692-
n=size(d)
693-
694-
do i=2,n
695-
d(i)=d(i)*ac(2,i)-d(i-1)*ac(3,i)
696-
enddo
697-
698-
x(n)=d(n)
699-
do i=n-1,1,-1
700-
x(i)=d(i)-ac(1,i)*x(i+1)
701-
enddo
702-
703-
return
704-
705-
end function tridiagonal_thomas_solver
706-
!+-------------------------------------------------------------------+
707-
!| The end of the function tridiagonal_thomas_solver. |
708-
!+-------------------------------------------------------------------+
709-
710-
!+-------------------------------------------------------------------+
711-
!| This is a standard tridiagonal matrix algorithm, also known as the|
712-
!| Thomas algorithm to solve tridiagonal systems of equations. |
713-
!+-------------------------------------------------------------------+
714-
!|ref: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
715-
!+-------------------------------------------------------------------+
716-
!| CHANGE RECORD |
717-
!| ------------- |
718-
!| 25-05-2025 | Rewrite by J. Fang @ Liverpool. |
719-
!+-------------------------------------------------------------------+
720-
function tridiagonal_thomas(a,c,d) result(x)
721-
722-
! arguments
723-
real(8),intent(in) :: a(:),c(:),d(:)
724-
real(8) :: x(size(d))
725-
726-
! local data
727-
integer :: i,n
728-
real(8),allocatable :: cc(:),dd(:)
729-
730-
n=size(d)
731-
732-
allocate(cc(n),dd(n))
733-
734-
cc(1)=c(1)
735-
dd(1)=d(1)
736-
do i=2,n
737-
738-
cc(i)=c(i)/(1.d0-a(i)*cc(i-1))
739-
740-
dd(i)=(d(i)-a(i)*dd(i-1))/(1.d0-a(i)*cc(i-1))
741-
742-
enddo
743-
744-
x(n)=dd(n)
745-
do i=n-1,1,-1
746-
x(i)=dd(i)-cc(i)*x(i+1)
747-
enddo
748-
749-
deallocate(cc,dd)
750-
751-
return
752-
753-
end function tridiagonal_thomas
754-
!+-------------------------------------------------------------------+
755-
!| The end of the function tridiagonal_thomas. |
756-
!+-------------------------------------------------------------------+
757-
636+
758637
end module filter
759638
!+---------------------------------------------------------------------+
760639
!| The end of the module filter. |

src/readwrite.F90

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,9 @@ subroutine readinput
640640
read(strings(4),*)spg_jm
641641
read(strings(5),*)spg_k0
642642
read(strings(6),*)spg_km
643-
print*, spg_i0,spg_im,spg_j0,spg_jm,spg_k0,spg_km
644-
if(size(strings)>6 .or. trim(strings(7))=='layer' .or. trim(strings(7))=='circl') then
643+
spg_def='layer'
644+
if(size(strings)>6) then
645645
read(strings(7),*)spg_def
646-
else
647-
spg_def='layer'
648646
endif
649647
read(fh,'(/)')
650648
read(fh,'(A)')gridfile

0 commit comments

Comments
 (0)