Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c------------------------------------------------------------------
- c
- c module name - mumps_data
- c
- c------------------------------------------------------------------
- c
- c computer - machine independent
- c
- c latest revision - Oct 04
- c
- c purpose - module stores a [dz]mumps_struc object and
- c interface routines to control MUMPS
- c
- c-----------------------------------------------------------------------
- module mumps_data
- c
- c use non-preprocessed include statement since preprocessor objects
- c to un-paired quotation marks
- #if C_MODE
- include 'zmumps_struc.h'
- #else
- include 'dmumps_struc.h'
- #endif
- c
- save
- c
- #if C_MODE
- type(zmumps_struc) :: mumps_par
- #else
- type(dmumps_struc) :: mumps_par
- #endif
- c
- integer, parameter :: mumps_histlen = 100
- integer :: mumps_nrhist(2)
- integer :: mumps_nrdof_total(2,mumps_histlen)
- integer :: mumps_nrdof_inter(2,mumps_histlen)
- integer :: mumps_store_inter(2,mumps_histlen)
- integer :: mumps_store_addit(2,mumps_histlen)
- double precision :: mumps_input_time(2,mumps_histlen)
- double precision :: mumps_solve_time(2,mumps_histlen)
- double precision :: mumps_total_time(2,mumps_histlen)
- c
- contains
- c
- c
- c-----------------------------------------------------------------------
- c INITIALIZE MUMPS FOR THE FIRST TIME (BEGINNING OF MAIN)
- c-----------------------------------------------------------------------
- subroutine start_mumps
- #include "syscom.blk"
- include 'mpif.h'
- c
- c ...set an MPI communicator for all MUMPS processors
- mumps_par%comm = MPI_COMM_WORLD
- c
- c ...indicate that host processor should participate in the
- c factorization and solve phases (this is a sequential code)
- mumps_par%par = 1
- c
- #if C_MODE
- c unsymmetric
- mumps_par%sym = 0
- #else
- c symmetric and positive definite (2 = general symmetric)
- mumps_par%sym = 1
- #endif
- c
- mumps_nrhist = 0
- mumps_nrdof_total = 0
- mumps_nrdof_inter = 0
- mumps_store_inter = 0
- mumps_store_addit = 0
- mumps_input_time = 0.d0
- mumps_solve_time = 0.d0
- mumps_total_time = 0.d0
- c
- end subroutine start_mumps
- c
- c
- c-----------------------------------------------------------------------
- c TERMINATE MUMPS FOR THE LAST TIME (END OF MAIN)
- c-----------------------------------------------------------------------
- subroutine end_mumps
- #include "syscom.blk"
- include 'mpif.h'
- call mpi_finalize(ierr)
- end subroutine end_mumps
- c
- c
- c-----------------------------------------------------------------------
- c INITIALIZE MUMPS
- c-----------------------------------------------------------------------
- subroutine alloc_mumps
- c
- c ...initialize an instance of MUMPS
- mumps_par%job = -1
- #if C_MODE
- call zmumps(mumps_par)
- #else
- call dmumps(mumps_par)
- #endif
- c
- c ...set control flags
- #if C_MODE
- c error output stream (non-positive to suppress)
- mumps_par%icntl(1) = 0
- c diagnostic, statistics and warnings
- mumps_par%icntl(2) = 0
- c global information
- mumps_par%icntl(3) = 0
- c printing level
- mumps_par%icntl(4) = 0
- c input matrix in element format
- mumps_par%icntl(5) = 1
- c column permutation for zero-free diagonal (automatic)
- mumps_par%icntl(6) = 7
- c pivot order (automatic)
- mumps_par%icntl(7) = 7
- c scaling (automatic)
- mumps_par%icntl(8) = 7
- c no transpose
- mumps_par%icntl(9) = 1
- c max steps for iterative refinement
- mumps_par%icntl(10) = 0
- c statistics info
- mumps_par%icntl(11) = 0
- c controls parallelism
- mumps_par%icntl(12) = 0
- c use ScaLAPACK for root node
- mumps_par%icntl(13) = 0
- c percentage increase in estimated workspace
- mumps_par%icntl(14) = 20
- c
- c matrix distribution for assembled input
- mumps_par%icntl(18) = 0
- c nonzero for Schur complement
- mumps_par%icntl(19) = 0
- #else
- c error output stream (non-positive to suppress)
- mumps_par%icntl(1) = 0
- c diagnostic, statistics and warnings
- mumps_par%icntl(2) = 0
- c global information
- mumps_par%icntl(3) = 0
- c printing level
- mumps_par%icntl(4) = 2
- c input matrix in element format
- mumps_par%icntl(5) = 1
- c column permutation for zero-free diagonal (automatic)
- c mumps_par%icntl(6) = 7
- c pivot order (automatic)
- c mumps_par%icntl(7) = 7
- c scaling (automatic)
- c mumps_par%icntl(8) = 7
- c no transpose
- mumps_par%icntl(9) = 1
- c max steps for iterative refinement
- c mumps_par%icntl(10) = 0
- c statistics info
- c mumps_par%icntl(11) = 0
- c controls parallelism
- c mumps_par%icntl(12) = 0
- c use ScaLAPACK for root node
- c mumps_par%icntl(13) = 0
- c percentage increase in estimated workspace
- mumps_par%icntl(14) = 0
- c
- c matrix distribution for assembled input
- c mumps_par%icntl(18) = 0
- c nonzero for Schur complement
- c mumps_par%icntl(19) = 0
- #endif
- c
- end subroutine alloc_mumps
- c
- c
- c-----------------------------------------------------------------------
- c RUN MUMPS SOLVE (LU FACTORIZATION)
- c-----------------------------------------------------------------------
- subroutine run_mumps_solve(Idec)
- #include "syscom.blk"
- c
- iprint=0
- c
- c start clock for solution time
- if (MUMPS_PAR%MYID == 0) then
- call start_clock(iclock)
- endif
- c
- c analysis, factorization and solve
- #if C_MODE
- mumps_par%job = 1
- call zmumps(mumps_par)
- mumps_par%job = 2
- call zmumps(mumps_par)
- #else
- mumps_par%job = 1
- call dmumps(mumps_par)
- c
- mumps_par%job = 2
- call dmumps(mumps_par)
- #endif
- c
- c ...check for errors
- if (mumps_par%info(1).ne.0) then
- write (*,*) 'mumps_par%job=',mumps_par%job
- write (*,*) 'mumps_par%info=',mumps_par%info
- stop1
- endif
- c
- c ...host processor
- if (MUMPS_PAR%MYID == 0) then
- c
- c .....check for errors
- if (mumps_par%info(1).ne.0) then
- write (*,*) 'mumps_par%job=',mumps_par%job
- write (*,*) 'mumps_par%info=',mumps_par%info
- stop1
- endif
- c
- c .....record total factorization time
- call stop_clock(dtime,iclock)
- mumps_solve_time(Idec,mumps_nrhist(Idec)) = dtime
- if (iprint>=1) then
- write(*,1002) dtime
- 1002 format('MUMPS SOLUTION TIME: ',f9.4,'s')
- endif
- c
- c .....print statistical information
- if (mumps_par%icntl(11)>0) then
- write(*,1010) mumps_par%rinfog(10)
- write(*,1011) mumps_par%rinfog(11)
- 1010 format('cond1(A) = ',e15.8)
- 1011 format('cond2(A) = ',e15.8)
- endif
- endif
- c
- end subroutine run_mumps_solve
- c
- c-----------------------------------------------------------------------
- c BACKWARD ELIMINATION
- c-----------------------------------------------------------------------
- subroutine run_mumps_rhs
- #include "syscom.blk"
- #if C_MODE
- mumps_par%job = 3
- call zmumps(mumps_par)
- #else
- mumps_par%job = 3
- call dmumps(mumps_par)
- #endif
- c
- c ...check for errors
- if (mumps_par%info(1).ne.0) then
- write (*,*) 'mumps_par%job=',mumps_par%job
- write (*,*) 'mumps_par%info=',mumps_par%info
- stop1
- endif
- c
- end subroutine run_mumps_rhs
- c
- c-----------------------------------------------------------------------
- c TERMINATE MUMPS
- c-----------------------------------------------------------------------
- subroutine dealloc_mumps
- c
- c ...terminate an instance of MUMPS
- mumps_par%job = -2
- #if C_MODE
- call zmumps(mumps_par)
- #else
- call dmumps(mumps_par)
- #endif
- c
- end subroutine dealloc_mumps
- c
- c
- c-----------------------------------------------------------------------
- c PRINT MUMPS DATA
- c-----------------------------------------------------------------------
- c
- subroutine print_mumps_data(Idec)
- #include "syscom.blk"
- c
- if (Idec==1 .or. Idec==3) then
- c
- c .....print coarse grid results
- write(*,2000)
- write(*,2002)
- do i=1,mumps_nrhist(1)
- write(*,2001) mumps_nrdof_total(1,i),mumps_nrdof_inter(1,i),
- . mumps_store_inter(1,i),mumps_store_addit(1,i),
- . mumps_input_time(1,i),mumps_solve_time(1,i),
- . mumps_total_time(1,i)
- enddo
- endif
- if (Idec==2 .or. Idec==3) then
- c
- c .....print fine grid results
- if (Idec==2) write(*,2000)
- write(*,2002)
- do i=1,mumps_nrhist(2)
- write(*,2001) mumps_nrdof_total(2,i),mumps_nrdof_inter(2,i),
- . mumps_store_inter(2,i),mumps_store_addit(2,i),
- . mumps_input_time(2,i),mumps_solve_time(2,i),
- . mumps_total_time(2,i)
- enddo
- endif
- write(*,2002)
- 2000 format(' NRDOFB NRDOFI STORAGE INPUT SOLUTION TOTAL')
- 2001 format(i7,1x,i7,1x,i4,'+',i3,1x,f7.2,3x,f7.2,1x,f7.2)
- 2002 format('--------------------------------------------------')
- c
- end subroutine print_mumps_data
- end module mumps_data
Add Comment
Please, Sign In to add comment