psmile_get_comp_handle.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_comp_handle
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_get_comp_handle (comp_id, comp_name, ierror)
00012 !
00013 ! !USES:
00014 !
00015       use PRISM_constants
00016 !
00017       use PSMILe, dummy_interface => PSMILe_Get_comp_handle
00018 
00019       implicit none
00020 !
00021 ! !INPUT PARAMETERS:
00022 !
00023       character (len=*), Intent(In)       :: comp_name
00024 
00025 !     Name of the component
00026 !
00027 ! !OUTPUT PARAMETERS:
00028 !
00029       integer, Intent (Out)               :: comp_id
00030 
00031 !     Returns the handle to the component information created.
00032 
00033       integer, Intent (Out)               :: ierror
00034 
00035 !     Returns the error code of PRISM_Init;
00036 !             ierror = 0 : No error
00037 !             ierror > 0 : Severe error
00038 !
00039 !
00040 ! !LOCAL VARIABLES
00041 !
00042       type (Component), Pointer :: New_Comps(:)
00043 
00044       integer             :: i
00045       integer             :: new_dim
00046 
00047       integer, parameter  :: nerrp = 2
00048       integer             :: ierrp (nerrp)
00049 !
00050 ! !DESCRIPTION:
00051 !
00052 ! Subroutine "PSMILe_Get_comp_handle" returns a handle to a model
00053 ! component.
00054 !
00055 !
00056 ! !REVISION HISTORY:
00057 !
00058 !   Date      Programmer    Description
00059 ! ----------  -----------   -----------
00060 ! 01.12.03    H. Ritzdorf   created
00061 !
00062 !EOP
00063 !----------------------------------------------------------------------
00064 !
00065 ! $Id: psmile_get_comp_handle.F90 2325 2010-04-21 15:00:07Z valcke $
00066 ! $Author: valcke $
00067 !
00068    Character(len=len_cvs_string), save :: mycvs = 
00069        '$Id: psmile_get_comp_handle.F90 2325 2010-04-21 15:00:07Z valcke $'
00070 !
00071 !----------------------------------------------------------------------
00072 
00073 #ifdef VERBOSE
00074       print *, trim(ch_id), ': PSMILe_Get_comp_handle: start'
00075 
00076       call psmile_flushstd
00077 #endif /* VERBOSE */
00078 
00079 !----------------------------------------------------------------------
00080 !   Initialization
00081 !----------------------------------------------------------------------
00082 
00083       ierror  = 0
00084       comp_id = 0
00085 
00086 !----------------------------------------------------------------------
00087 !   Search in list for the component name and return its index
00088 !----------------------------------------------------------------------
00089 
00090       do i = 1, Number_of_Comps_allocated
00091          if (Comps(i)%status == PSMILe_status_free) exit
00092       end do
00093 
00094       if ( i <= Number_of_Comps_allocated) then
00095 
00096          comp_id = i
00097 
00098       else
00099 !
00100 !   ... Allocate new Components vector, initialise and copy old vector
00101 !
00102          new_dim = Number_of_Comps_allocated + 8
00103 !
00104          Allocate (New_Comps (new_dim), STAT = ierror)
00105          if (ierror > 0) then
00106             ierrp (1) = ierror
00107             ierrp (2) = new_dim
00108             ierror = PRISM_Error_Alloc
00109 
00110             call psmile_error ( ierror, 'New_Comps', &
00111                                 ierrp, 2, __FILE__, __LINE__ )
00112             return
00113          endif
00114 !
00115          New_Comps (1:Number_of_Comps_allocated) = &
00116              Comps (1:Number_of_Comps_allocated)
00117 
00118          New_Comps(Number_of_Comps_allocated+1:new_dim)%status = &
00119              PSMILe_status_free
00120 !
00121 !   ... De-allocate Comps vector
00122 !
00123          Deallocate (Comps, STAT = ierror)
00124          if (ierror > 0) then
00125             ierrp (1) = ierror
00126             ierror = PRISM_Error_Dealloc
00127 
00128             call psmile_error ( ierror, 'Comps', &
00129                                 ierrp, 1, __FILE__, __LINE__ )
00130             return
00131          endif
00132 !
00133 !   ... Update Number of Components
00134 !
00135          Comps => New_Comps
00136 !
00137          comp_id = Number_of_Comps_allocated + 1
00138 !
00139          Number_of_Comps_allocated = new_dim
00140 
00141       endif
00142 
00143       Comps(comp_id)%status   = PSMILe_status_defined
00144       Comps(comp_id)%act_comm = MPI_COMM_NULL
00145 
00146 #ifdef VERBOSE
00147       print *, trim(ch_id), ': PSMILe_Get_comp_handle: eof handle, ierror =', &
00148                comp_id, ierror
00149 
00150       call psmile_flushstd
00151 #endif /* VERBOSE */
00152 !
00153       end subroutine PSMILe_Get_comp_handle

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1