psmile_enddef_comp_grid.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_Enddef_comp_grid
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_enddef_comp_grid (comp_id, n_grids, ierror)
00012 
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017 !
00018       use PSMILe, dummy_interface => PSMILe_enddef_comp_grid
00019 
00020       implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 !
00024       integer, Intent (In)                :: comp_id
00025 
00026 !     Specifies the handle to the component information.
00027 !
00028 ! !OUTPUT PARAMETERS:
00029 !
00030       integer, Intent (Out)               :: n_grids
00031 
00032 !     Returns the number of grids used in the coupling process.
00033 
00034       integer, Intent (Out)               :: ierror
00035 
00036 !     Returns the error code of PSMILe_enddef_comp_grid;
00037 !             ierror = 0 : No error
00038 !             ierror > 0 : Severe error
00039 !
00040 ! !LOCAL VARIABLES
00041 !
00042       Integer                      :: n, grid_id
00043       Integer                      :: color, key
00044       Integer                      :: il_size
00045 
00046       Integer, parameter           :: nerrp = 1
00047       Integer                      :: ierrp (nerrp)
00048 !
00049 ! !DESCRIPTION:
00050 !
00051 ! Subroutine "PSMILe_enddef_comp" computes the number of grids of
00052 ! component "comp_id" which are used in the coupling process, and
00053 ! for stand_alone application, the number of grids used in the IO
00054 ! process
00055 !
00056 !
00057 ! !REVISION HISTORY:
00058 !
00059 !   Date      Programmer   Description
00060 ! ----------  ----------   -----------
00061 ! 01.12.03    H. Ritzdorf  created
00062 !
00063 !EOP
00064 !----------------------------------------------------------------------
00065 !
00066 !  $Id: psmile_enddef_comp_grid.F90 2847 2011-01-04 17:07:21Z coquart $
00067 !  $Autor$
00068 !
00069    Character(len=len_cvs_string), save :: mycvs = 
00070        '$Id: psmile_enddef_comp_grid.F90 2847 2011-01-04 17:07:21Z coquart $'
00071 !
00072 !----------------------------------------------------------------------
00073 
00074 #ifdef VERBOSE
00075       print *, trim(ch_id), ': PSMILe_enddef_comp_grid: comp_id', comp_id
00076 
00077       call psmile_flushstd
00078 #endif /* VERBOSE */
00079 !
00080 !  Initialization
00081 !
00082       ierror = 0
00083 !
00084 !  Is the grid really used ?
00085 !  TODO
00086 !  ??? Wird das wirklich in der endgueltigen Version gebraucht ?
00087 !  ??? Wenn ja, dann Argument und bis zu psmile_enddef_comp passen
00088 !
00089 !
00090 !   Get the number of grids used for coupling
00091 !
00092       n = 0
00093       do grid_id = 1, Number_of_Grids_allocated
00094 
00095 #ifdef DEBUGX
00096         PRINT*, 'In psmile_enddef_comp_grid for grid_id:', grid_id
00097         PRINT*, 'Grids(grid_id)%status :',Grids(grid_id)%status
00098         PRINT*, 'Grids(grid_id)%comp_id , comp_id:',Grids(grid_id)%comp_id , comp_id
00099         PRINT*, 'Grids(grid_id)%used_for_coupling :',Grids(grid_id)%used_for_coupling
00100         PRINT*, 'Grids(grid_id)%used_for_io :',Grids(grid_id)%used_for_io
00101         call psmile_flushstd
00102 #endif
00103 
00104          if (Grids(grid_id)%status /= PSMILe_status_free .and. &
00105              Grids(grid_id)%comp_id == comp_id           .and. &
00106              Grids(grid_id)%used_for_coupling) then
00107 
00108             n = n + 1
00109 
00110          endif
00111 
00112          IF (Appl%stand_alone .AND. &
00113              Grids(grid_id)%status /= PSMILe_status_free .AND. &
00114              Grids(grid_id)%comp_id == comp_id           .and. &
00115              Grids(grid_id)%used_for_io ) then
00116 
00117             n = n + 1
00118 
00119         ENDIF
00120 
00121       enddo
00122 
00123       n_grids = n
00124 
00125       key     = 0
00126       color   = 0
00127       
00128       if ( n_grids > 0 )  color = 1
00129 !
00130 ! To support stand alone applications that only use OASIS4 PSMILE for IO
00131 !
00132 
00133       call MPI_Comm_Split ( Comps(comp_id)%comm, color, key, Comps(comp_id)%act_comm, ierror )
00134 #ifdef DEBUG
00135       call MPI_Comm_Size ( Comps(comp_id)%act_comm, il_size, ierror)
00136       WRITE (*,*) 'n_grids = ', n_grids, 'size of Comp(comp_id) =',il_size
00137 #endif
00138       if ( ierror /= MPI_SUCCESS ) then
00139          ierrp (1) = ierror
00140          ierror = PRISM_Error_MPI
00141 
00142          call psmile_error ( ierror, 'MPI_Comm_Split', &
00143               ierrp, 1, __FILE__, __LINE__ )
00144          return
00145       endif
00146 !
00147 #ifdef PRISM_ASSERTION
00148       if (n > Comps(comp_id)%n_grids) then
00149          write (*, 9990) n, Comps(comp_id)%n_grids
00150          call psmile_assert ( __FILE__, __LINE__, &
00151                               'n > Number_of_Grids')
00152       endif
00153 #endif /* PRISM_ASSERTION */
00154 !
00155 !===> All done
00156 !
00157 #ifdef VERBOSE
00158       print *, trim(ch_id), ': PSMILe_enddef_comp_grid: eof ierror =', ierror
00159 
00160       call psmile_flushstd
00161 #endif /* VERBOSE */
00162 !
00163 !  Fromats
00164 !
00165 #ifdef PRISM_ASSERTION
00166 9990 format (/1x, 'PSMILe_enddef_comp_grid: inconsistent number of grids: ',&
00167                   'n =', i7, '; Number_of_Grids =', i7)
00168 #endif /* PRISM_ASSERTION */
00169 
00170       end subroutine PSMILe_enddef_comp_grid

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1