⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f_pddrive.f90

📁 SuperLU 2.2版本。对大型、稀疏、非对称的线性系统的直接求解
💻 F90
字号:
! -- Distributed SuperLU routine (version 2.0) --! Lawrence Berkeley National Lab, Univ. of California Berkeley.! October 15, 2003!!      program f_pddrive! ! Purpose! =======!! The driver program F_PDDRIVE.!! This example illustrates how to use F_PDGSSVX with the full! (default) options to solve a linear system.! ! Seven basic steps are required:!   1. Create C structures used in SuperLU_DIST!   2. Initialize the MPI environment and the SuperLU process grid!   3. Set up the input matrix and the right-hand side!   4. Set the options argument!   5. Call f_pdgssvx!   6. Release the process grid and terminate the MPI environment!   7. Release all structures!!      use superlu_mod!      implicit none      include 'mpif.h'      integer maxn, maxnz, maxnrhs      parameter ( maxn = 10000, maxnz = 100000, maxnrhs = 10 )      integer rowind(maxnz), colptr(maxn)      real*8  values(maxnz), b(maxn), berr(maxnrhs)      integer n, m, nnz, nrhs, ldb, i, ierr, info, iam      integer nprow, npcol      integer init      integer(superlu_ptr) :: grid      integer(superlu_ptr) :: options      integer(superlu_ptr) :: ScalePermstruct      integer(superlu_ptr) :: LUstruct      integer(superlu_ptr) :: SOLVEstruct      integer(superlu_ptr) :: A      integer(superlu_ptr) :: stat! Initialize MPI environment       call mpi_init(ierr)! Check malloc!      call f_check_malloc(iam)! Create Fortran handles for the C structures used in SuperLU_DIST      call f_create_gridinfo_handle(grid)      call f_create_options_handle(options)      call f_create_ScalePerm_handle(ScalePermstruct)      call f_create_LUstruct_handle(LUstruct)      call f_create_SOLVEstruct_handle(SOLVEstruct)      call f_create_SuperMatrix_handle(A)      call f_create_SuperLUStat_handle(stat)! Initialize the SuperLU_DIST process grid      nprow = 2      npcol = 2      call f_superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, grid)! Bail out if I do not belong in the grid.       call get_GridInfo(grid, iam=iam)      if ( iam >= nprow * npcol ) then          go to 100      endif      if ( iam == 0 ) then          write(*,*) ' Process grid ', nprow, ' X ', npcol      endif! Read Harwell-Boeing matrix, and adjust the pointers and indices! to 0-based indexing, as required by C routines.      if ( iam == 0 ) then          open(file = "g20.rua", status = "old", unit = 5)         call hbcode1(m, n, nnz, values, rowind, colptr)         close(unit = 5)!         do i = 1, n+1            colptr(i) = colptr(i) - 1         enddo         do i = 1, nnz            rowind(i) = rowind(i) - 1         enddo      endif! Distribute the matrix to the process gird      call  f_dcreate_dist_matrix(A, m, n, nnz, values, rowind, colptr, grid)! Setup the right hand side      nrhs = 1      call get_CompRowLoc_Matrix(A, nrow_loc=ldb)      do i = 1, ldb         b(i) = 1.0      enddo! Set the default input options      call f_set_default_options(options)! Change one or more options!      call set_superlu_options(options,Fact=FACTORED)!      call set_superlu_options(options,ParSymbFact=YES)! Initialize ScalePermstruct and LUstruct      call get_SuperMatrix(A,nrow=m,ncol=n)      call f_ScalePermstructInit(m, n, ScalePermstruct)      call f_LUstructInit(m, n, LUstruct)! Initialize the statistics variables      call f_PStatInit(stat)! Call the linear equation solver      call f_pdgssvx(options, A, ScalePermstruct, b, ldb, nrhs, &                     grid, LUstruct, SOLVEstruct, berr, stat, info)      if (info == 0) then         write (*,*) 'Backward error: ', (berr(i), i = 1, nrhs)      else         write(*,*) 'INFO from f_pdgssvx = ', info      endif! Deallocate the storage allocated by SuperLU_DIST      call f_PStatFree(stat)      call f_Destroy_SuperMat_Store_dist(A)      call f_ScalePermstructFree(ScalePermstruct)      call f_Destroy_LU(n, grid, LUstruct)      call f_LUstructFree(LUstruct)      call get_superlu_options(options, SolveInitialized=init)      if (init == YES) then         call f_dSolveFinalize(options, SOLVEstruct)      endif! Release the SuperLU process grid100   call f_superlu_gridexit(grid)! Deallocate the C structures pointed to by the Fortran handles      call f_destroy_gridinfo_handle(grid)      call f_destroy_options_handle(options)      call f_destroy_ScalePerm_handle(ScalePermstruct)      call f_destroy_LUstruct_handle(LUstruct)      call f_destroy_SOLVEstruct_handle(SOLVEstruct)      call f_destroy_SuperMatrix_handle(A)      call f_destroy_SuperLUStat_handle(stat)! Check malloc!      call f_check_malloc(iam)! Terminate the MPI execution environment      call mpi_finalize(ierr)      stop      end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -