psmile_do_masks_match.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_do_masks_match
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_do_masks_match (mask1_array, mask1_shape, &
00012                                         mask2_array, mask2_shape, &
00013                                         inter, nparts,            &
00014                                         match, ierror)
00015 !
00016 ! !USES:
00017 !
00018       use PRISM_constants
00019 !
00020       use PSMILe, dummy_interface => PSMILe_do_masks_match
00021 
00022       implicit none
00023 !
00024 ! !INPUT PARAMETERS:
00025 !
00026       Integer, Intent (In)               :: mask1_shape (2, ndim_3d)
00027 !
00028 !     Dimensions of mask array "mask1_array"
00029 !
00030       Logical, Intent (In)               :: mask1_array (                      
00031                                             mask1_shape(1,1):mask1_shape(2,1), 
00032                                             mask1_shape(1,2):mask1_shape(2,2), 
00033                                             mask1_shape(1,3):mask1_shape(2,3))
00034 !
00035 !     Mask array "mask1_array" to be controlled
00036 !
00037       Integer, Intent (In)               :: mask2_shape (2, ndim_3d)
00038 !
00039 !     Dimensions of mask array "mask2_array"
00040 !
00041       Logical, Intent (In)               :: mask2_array (                      
00042                                             mask2_shape(1,1):mask2_shape(2,1), 
00043                                             mask2_shape(1,2):mask2_shape(2,2), 
00044                                             mask2_shape(1,3):mask2_shape(2,3))
00045 !
00046 !     Mask array "mask2_array" to be controlled
00047 !
00048       Integer, Intent (In)               :: nparts
00049 !
00050 !     Number of sub-regions to be controlled
00051 !
00052       Integer, Intent (In)               :: inter (2, ndim_3d, nparts)
00053 
00054 !     Sub-regions to be controlled
00055 !
00056 ! !OUTPUT PARAMETERS:
00057 !
00058       Logical, Intent (Out)             :: match
00059 
00060 !     Returns the status of mask evaluation with
00061 !     match = .true.:  Masks "mask1_array" and "mask2_array" have the same
00062 !                      values in the controlled subregions "inter".
00063 !     match = .false.: Masks "mask1_array" and "mask2_array" don't have the same
00064 !                      values in the controlled subregions "inter".
00065 !
00066       Integer, Intent (Out)             :: ierror
00067 
00068 !     Returns the error code of PSMILe_do_masks_match;
00069 !             ierror = 0 : No error
00070 !             ierror > 0 : Severe error
00071 !
00072 ! !LOCAL VARIABLES
00073 !
00074       Integer                      :: i, ipart, j, k
00075 
00076 !  ... for error parameters
00077 
00078 !     Integer, Parameter           :: nerrp = 3
00079 !     Integer                      :: ierrp (nerrp)
00080 !
00081 ! !DESCRIPTION:
00082 !
00083 ! Subroutine "PSMILe_do_masks_match" controls whether the masks
00084 ! "mask1_array" and "mask2_array" have the same values in the
00085 ! subregions "inter(:,:,1:nparts)" to be controlled.
00086 !
00087 ! !REVISION HISTORY:
00088 !
00089 !   Date      Programmer   Description
00090 ! ----------  ----------   -----------
00091 ! 11.02.05    H. Ritzdorf  created
00092 !
00093 !EOP
00094 !----------------------------------------------------------------------
00095 !
00096 ! $Id: psmile_do_masks_match.F90 2325 2010-04-21 15:00:07Z valcke $
00097 ! $Author: valcke $
00098 !
00099    Character(len=len_cvs_string), save :: mycvs = 
00100        '$Id: psmile_do_masks_match.F90 2325 2010-04-21 15:00:07Z valcke $'
00101 !
00102 !----------------------------------------------------------------------
00103 !
00104 #ifdef VERBOSE
00105       print 9990, trim(ch_id)
00106 
00107       call psmile_flushstd
00108 #endif /* VERBOSE */
00109 !
00110 !  Initialization
00111 !
00112       ierror = 0
00113 !
00114 !  Control mask values
00115 !
00116 parts:   do ipart = 1, nparts
00117 !
00118          if (inter(2,1,ipart) > inter(1,1,ipart)) then
00119 !
00120              do k = inter(1,3,ipart), inter(2,3,ipart)
00121                 do j = inter(1,2,ipart), inter(2,2,ipart)
00122 !cdir vector
00123                    do i = inter(1,1,ipart), inter(2,1,ipart)
00124                    if ( mask1_array (i,j,k) .neqv. mask2_array (i,j,k) ) exit parts
00125                    end do
00126                 end do
00127              end do
00128 !
00129          else if (inter(2,1,ipart) == inter(1,1,ipart)) then
00130 !
00131 !            Special case: only single point in I direction
00132 !
00133              i = inter(1,1,ipart)
00134 !
00135              do k = inter(1,3,ipart), inter(2,3,ipart)
00136                 do j = inter(1,2,ipart), inter(2,2,ipart)
00137 !cdir vector
00138                 if ( mask1_array (i,j,k) .neqv. mask2_array (i,j,k) ) exit parts
00139                 end do
00140              end do
00141          endif
00142 !
00143          end do parts ! ipart
00144 !
00145 !     Does the mask arrays match in the regions to be controlled
00146 !
00147       match = ipart > nparts
00148 !
00149 #ifdef VERBOSE
00150       if (.not. match) then
00151          print 9970, trim(ch_id), i,j,k, &
00152                      mask1_array(i,j,k), mask2_array (i,j,k)
00153       endif
00154 #endif /* VERBOSE */
00155 !
00156 !===> All done
00157 !
00158 #ifdef VERBOSE
00159       print 9980, trim(ch_id), ierror, match
00160       call psmile_flushstd
00161 #endif /* VERBOSE */
00162 
00163 !
00164 !  Formats:
00165 !
00166 
00167 #ifdef VERBOSE
00168 
00169 9990  format (1x, a, ': psmile_do_masks_match:')
00170 9980  format (1x, a, ': psmile_do_masks_match: eof ierror =', i3, &
00171                      '; match =', l2)
00172 
00173 9970  format (1x, a, ": psmile_do_masks_match: mask values don't match ", &
00174                      "in index (", i4, ',', i4, ',', i4, ") !", &
00175              /1x, 'local value', l2, ', remote value', l2)
00176 
00177 #endif /* VERBOSE */ 
00178 
00179       end subroutine PSMILe_do_masks_match

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1