added README_changes.txt
[wrffire.git] / WPS / metgrid / src / metgrid.F90
blob98c7c40534828cc9e2176501f664dd7f11b00ab8
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 ! Program metgrid
4 ! First version: Michael Duda -- January 2006 
5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6 program metgrid
8    use gridinfo_module
9    use interp_option_module
10    use module_debug
11    use parallel_module
12    use process_domain_module
14    implicit none
16    ! Local variables
17    integer :: n
18    logical :: extra_row, extra_col
20    !
21    ! Do general setup
22    !
24    ! Initialize parallel stuff
25    call parallel_start()
27    call mprintf(.true.,LOGFILE,' *** Starting program metgrid.exe *** ')
29    ! Get info about how many nests there are to process, etc.
30    call get_namelist_params()
32    ! Having determined which processor we are, which grid type we are, and where 
33    !   our patch is located in the domain, we can determine if U or V staggered 
34    !   fields will have one more row or column than the M staggered fields
35    if (gridtype == 'C') then
36       if (my_x == nproc_x-1) then
37          extra_col = .true.
38       else
39          extra_col = .false.
40       end if
42       if (my_y == nproc_y-1) then
43          extra_row = .true.
44       else
45          extra_row = .false.
46       end if
47    else if (gridtype == 'E') then
48       extra_col = .false.
49       extra_row = .false.
50    end if
52    ! Get info about which interpolators should be used with each field
53    call  read_interp_table()
55    !
56    ! Now begin the processing work, looping over all domains to be processed 
57    !
59    if (gridtype == 'C') then
61       do n=1,max_dom
63          call mprintf(.true.,STDOUT,'Processing domain %i of %i', i1=n, i2=max_dom)
64          call mprintf(.true.,LOGFILE,'Processing domain %i of %i', i1=n, i2=max_dom)
66          call process_domain(n, extra_row, extra_col)
68       end do  ! Loop over max_dom
70    else if (gridtype == 'E') then
72       call mprintf(.true.,STDOUT,'Processing coarse domain only for NMM.')
73       call mprintf(.true.,LOGFILE,'Processing coarse domain only for NMM.')
75       call process_domain(1, extra_row, extra_col)
77    end if
80    !
81    ! Clean up and quit.
82    !
84    call interp_option_destroy()
86    call parallel_finish()
88    call mprintf(.true.,STDOUT,'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
89    call mprintf(.true.,STDOUT,'!  Successful completion of metgrid.  !')
90    call mprintf(.true.,STDOUT,'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
92    call mprintf(.true.,LOGFILE,' *** Successful completion of program metgrid.exe *** ')
94    stop
96 end program metgrid