psmile_get_grid_extent.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILe_Get_Grid_Extent
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_get_grid_extent (grid_id, extent, ierror)
00012 
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017       use PSMILe, dummy_interface => PSMILe_Get_Grid_Extent
00018 
00019       Implicit none
00020 !
00021 ! !INPUT PARAMETERS:
00022 !
00023       Integer,                  Intent (In)  :: grid_id
00024 
00025 !     Specifies the handle to the grid information.
00026 !
00027 ! !OUTPUT PARAMETERS:
00028 !
00029       Real (PSMILe_float_kind), Intent (Out) :: extent (2, ndim_3d)
00030 
00031 !     Returns the extent of grid "grid_id"
00032 
00033       Integer,                  Intent (Out) :: ierror
00034 
00035 !     Returns the error code of PSMILe_Get_Grid_Extent;
00036 !             ierror = 0 : No error
00037 !             ierror > 0 : Severe error
00038 !
00039 !
00040 ! !LOCAL VARIABLES
00041 !
00042       Type (Corner_Block), Pointer :: corner_pointer
00043 
00044       Integer, parameter           :: nerrp = 1
00045       Integer                      :: ierrp (nerrp)
00046       Integer                      :: i, index
00047 !
00048 ! !DESCRIPTION:
00049 !
00050 ! Subroutine "PSMILe_Get_Grid_Extent" computes the extent of the grid
00051 ! "grid_id".
00052 !
00053 !
00054 ! !REVISION HISTORY:
00055 !
00056 !   Date      Programmer   Description
00057 ! ----------  ----------   -----------
00058 ! 01.12.03    H. Ritzdorf  created
00059 !
00060 !EOP
00061 !----------------------------------------------------------------------
00062 !
00063 ! $Id: psmile_get_grid_extent.F90 2325 2010-04-21 15:00:07Z valcke $
00064 ! $Author: valcke $
00065 !
00066    Character(len=len_cvs_string), save :: mycvs = 
00067        '$Id: psmile_get_grid_extent.F90 2325 2010-04-21 15:00:07Z valcke $'
00068 !
00069 !----------------------------------------------------------------------
00070 
00071 #ifdef VERBOSE
00072       print *, trim(ch_id), ': PSMILe_Get_Grid_Extent: start'
00073       print *, trim(ch_id), ': PSMILe_Get_Grid_Extent: grid_id', grid_id
00074 
00075       call psmile_flushstd
00076 #endif /* VERBOSE */
00077 !
00078 !  Initialization
00079 !
00080       ierror = 0
00081 
00082       if (Grids(grid_id)%grid_type == PRISM_Gridless) then
00083 !
00084 !  No grid
00085 !
00086          extent (1:2, 1:ndim_3d) = Grids(grid_id)%grid_shape (1:2, 1:ndim_3d)
00087          
00088          if (Associated (Grids(grid_id)%partition)) then
00089 
00090                do i = 1, ndim_3d
00091 
00092                extent (1,i) = Grids(grid_id)%partition  (1,i) + 1
00093                extent (2,i) = Grids(grid_id)%partition  (1,i) + &
00094                               Grids(grid_id)%grid_shape (2,i) - &
00095                               Grids(grid_id)%grid_shape (1,i) + 1
00096 
00097                end do
00098 
00099          else
00100 
00101                extent (1:2, 1:ndim_3d) = Grids(grid_id)%grid_shape (1:2, 1:ndim_3d)
00102 
00103          endif
00104 !
00105       else
00106 
00107           corner_pointer => Grids(grid_id)%corner_pointer
00108 !
00109           if (corner_pointer%corner_datatype == MPI_REAL) then
00110 
00111 !            ... Real datatype
00112 
00113              call psmile_get_grid_extent_real (grid_id, extent, ierror)
00114 
00115 !            ... expand the extend to the pole when the pole is included in the grid.
00116              if ( associated ( corner_pointer%pole_array ) ) then
00117                 do i = 1, size(corner_pointer%pole_array)
00118                    index = corner_pointer%pole_array(i)
00119                    if (index /= PRISM_UNDEFINED) then
00120                    if      ( corner_pointer%corners_real(1)%vector(index) > 0.0 ) then
00121                       extent(2,2) =  90.0
00122                    else if ( corner_pointer%corners_real(1)%vector(index) < 0.0 ) then
00123                       extent(1,2) = -90.0
00124                    endif
00125                    endif
00126                 enddo
00127              endif
00128 
00129           else if (corner_pointer%corner_datatype == MPI_DOUBLE_PRECISION) then
00130 
00131 !            ... Double precision datatype
00132 
00133              call psmile_get_grid_extent_dble (grid_id, extent, ierror)
00134 
00135 !            ... expand the extend to the pole when the pole is included in the grid.
00136              if ( associated ( corner_pointer%pole_array ) ) then
00137                 do i = 1, size(corner_pointer%pole_array)
00138                    index = corner_pointer%pole_array(i)
00139                    if (index /= PRISM_UNDEFINED) then
00140                    if      ( corner_pointer%corners_dble(2)%vector(index) > 0.0 ) then
00141                       extent(2,2) =  90.0
00142                    else if ( corner_pointer%corners_dble(2)%vector(index) < 0.0 ) then
00143                       extent(1,2) = -90.0
00144                    endif
00145                    endif
00146                 enddo
00147              endif
00148 
00149 #if defined ( PRISM_QUAD_TYPE )
00150 
00151           else if (corner_pointer%corner_datatype == MPI_REAL16) then
00152 
00153 !            ... Quadruple precision datatype
00154 
00155              call psmile_get_grid_extent_quad (grid_id, extent, ierror)
00156 
00157 !            ... expand the extend to the pole when the pole is included in the grid.
00158              if ( associated ( corner_pointer%pole_array ) ) then
00159                 do i = 1, size(corner_pointer%pole_array)
00160                    index = corner_pointer%pole_array(i)
00161                    if (index /= PRISM_UNDEFINED) then
00162                    if      ( corner_pointer%corners_quad(1)%vector(index) > 0.0 ) then
00163                       extent(2,2) = 90.0
00164                    else if ( corner_pointer%corners_quad(1)%vector(index) < 0.0 ) then
00165                       extent(2,1) = -90.0
00166                    endif
00167                    endif
00168                 enddo
00169              endif
00170 #endif
00171 
00172           else
00173 
00174 !            ... Unknown data type
00175 
00176              ierrp (1) = corner_pointer%corner_datatype
00177              ierror = PRISM_Error_Internal
00178              call psmile_error ( ierror, 'unsupported data type', &
00179                                  ierrp, 1, __FILE__, __LINE__ )
00180           endif
00181 
00182       endif
00183 !
00184 !===> All done
00185 !
00186 #ifdef VERBOSE
00187       print *, trim(ch_id), ': PSMILe_Get_Grid_Extent eof: grid_id',&
00188                              grid_id, ', ierror =', ierror
00189 
00190       call psmile_flushstd
00191 #endif /* VERBOSE */
00192 !
00193       end subroutine PSMILe_Get_Grid_Extent

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1