CGpop mini-Application (2-sided MPI 1D data structure version) 0.1
cgpop.F90
Go to the documentation of this file.
00001 !==============================================================================
00002 ! Copyright (C) 2010, University Corporation for Atmospheric Research,
00003 !                     Colorado State University,
00004 !                     Los Alamos National Security, LLC,
00005 !                     United States Department of Energy
00006 !
00007 ! All rights reserved.  See ../COPYING for copyright details
00008 !==============================================================================
00009 
00010 !>
00011 !! This is the main driver for the standalone Parallel Ocean Program (POP) 
00012 !! conjugate gradient solver.
00013 !<
00014 program CGpop
00015     use kinds_mod, only: i4, r8
00016     use simple_blocks, only: nx_block,ny_block,nblocks_tot
00017     use domain_size, only: nx_global,ny_global, max_blocks_tropic
00018     use communicate, only: init_communicate, my_task, master_task, &
00019         MPI_COMM_OCN, get_num_procs
00020     use simple_domain, only: init_domain_blocks, init_domain_distribution
00021     use solvers, only: esolver, init_solvers
00022     use constants, only: init_constants!, ntrials
00023     use timers, only: get_timer, timer_start, timer_stop, timer_print_all, &
00024         init_timers
00025     use check, only: CheckAnswers
00026 
00027     implicit none
00028 
00029     real(r8), dimension(nx_block,ny_block,max_blocks_tropic) :: 
00030         PRESSI,  ! Initial guess for pressure (x in the Ax=b equation)
00031         RHS,     ! Right-hand side of equation Ax=b
00032         PRESSF,  ! Expected resulting pressure (expected value of x)
00033         PRESS     ! Solved result (calculated value of x)
00034 
00035     integer(i4) :: timer_mpi2s_solver_1D  ! Timer for how long it takes to do
00036                                           ! ntrials of the CG algorithm
00037     integer(i4), pointer :: reorder(:)
00038     integer(i4) :: ntrials=1
00039 
00040 !-----------------------------------------------------------------------
00041 !
00042 !  local variables
00043 !
00044 !-----------------------------------------------------------------------
00045     integer (i4) :: nstep
00046     integer (i4) :: ierr
00047     integer (i4) :: n, nprocs
00048 
00049 !-----------------------------------------------------------------------
00050 !  initialize message-passing or other communication protocol
00051 !-----------------------------------------------------------------------
00052     call init_communicate
00053     nprocs = get_num_procs()
00054 
00055 !-----------------------------------------------------------------------
00056 !  initialize constants and i/o stuff
00057 !-----------------------------------------------------------------------
00058     call init_constants
00059 
00060 !-----------------------------------------------------------------------
00061 !  initialize domain and grid
00062 !-----------------------------------------------------------------------
00063     call init_domain_blocks(reorder)
00064     call init_domain_distribution(reorder)
00065 
00066 !-----------------------------------------------------------------------
00067 !  initialize timers and additional communication routines
00068 !-----------------------------------------------------------------------
00069     call init_timers()
00070 
00071 !-----------------------------------------------------------------------
00072 ! Initialize the solver
00073 !-----------------------------------------------------------------------
00074 
00075     !-----------------------------------
00076     ! 2 sided MPI with 1D data structure
00077     !-----------------------------------
00078     call get_timer(timer_mpi2s_solver_1D,'MPI2S_1D',1,nprocs)
00079 
00080     call init_solvers(RHS,PRESSI,PRESSF)
00081     call MPI_BARRIER(MPI_COMM_OCN, ierr)
00082     call timer_start(timer_mpi2s_solver_1d)
00083     do n=1,ntrials
00084         PRESS=PRESSI
00085         call esolver(RHS,PRESS)
00086     enddo
00087     call timer_stop(timer_mpi2s_solver_1d)
00088     !----------------------------------
00089     ! check the accuracy of the solver
00090     !----------------------------------
00091     call CheckAnswers('MPI2S_1D',PRESSF,PRESS)
00092 
00093     if(my_task == master_task) then 
00094        write(*,*) 'Number of trials: ',ntrials 
00095     endif
00096     call timer_print_all()
00097 end program CGpop
 All Classes Namespaces Files Functions Variables