prismtrs_get_epio_handle.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! Copyright 2006-2010, NEC High Performance Computing, Duesseldorf, Germany.
00004 ! All rights reserved. Use is subject to OASIS4 license terms.
00005 !-----------------------------------------------------------------------
00006 !BOP
00007 !
00008 ! !ROUTINE: PRISMTrs_get_epio_handle
00009 !
00010 ! !INTERFACE:
00011 
00012 subroutine prismtrs_get_epio_handle (id_epio_id,               &
00013                                      id_err)
00014 !
00015 ! !USES:
00016 !
00017   USE PRISMDrv, dummy_interface => PRISMTrs_get_epio_handle
00018 
00019   IMPLICIT NONE
00020 !
00021 ! !PARAMETERS:
00022 !
00023 ! ! RETURN VALUE
00024 !
00025 !     Returns the handle to the grid information created.
00026   INTEGER, INTENT (Out)               :: id_epio_id
00027 
00028 !     Returns the error code of Prismtrs_get_epio_handle;
00029 !             id_err = 0 : No error
00030 !             id_err > 0 : Severe error
00031   INTEGER, INTENT (Out)               :: id_err
00032 
00033 !
00034 ! !LOCAL VARIABLES
00035 !
00036   INTEGER             :: ib, il_new_dim
00037 
00038   INTEGER, PARAMETER  :: nerrp = 2
00039   INTEGER             :: ierrp (nerrp)
00040 
00041   TYPE (Drv_Epio), DIMENSION(:), POINTER :: NewDrv_Epios
00042 !
00043 !
00044 ! !DESCRIPTION:
00045 !
00046 ! Subroutine "PRISMTrs_get_epio_handle" returns a epio handle.
00047 !
00048 !
00049 ! !REVISION HISTORY:
00050 !
00051 !   Date      Programmer    Description
00052 ! ----------  -----------   -----------
00053 ! 17/11/2003  D. Declat     created from psmile_get_grid_handle
00054 !
00055 !EOP
00056 !----------------------------------------------------------------------
00057 !
00058 ! $Id: prismtrs_get_epio_handle.F90 2325 2010-04-21 15:00:07Z valcke $
00059 ! $Author: valcke $
00060 !
00061   Character(len=len_cvs_string), save :: mycvs = 
00062      '$Id: prismtrs_get_epio_handle.F90 2325 2010-04-21 15:00:07Z valcke $'
00063 !
00064 !----------------------------------------------------------------------
00065 !
00066 #ifdef VERBOSE
00067   PRINT *, '| Enter PRISMTrs_get_epio_handle'
00068   call psmile_flushstd
00069 #endif
00070 !   Initialization
00071 !
00072   id_err = 0
00073 !
00074 !   If new Epio, Search for a free epio index
00075 !
00076   DO ib = 1, Number_of_Epios_allocated
00077     IF (Drv_Epios(ib)%status == PSMILe_status_free) EXIT
00078   END DO
00079 !
00080   IF (ib <= Number_of_Epios_allocated) THEN
00081       id_epio_id = ib
00082       Drv_Epios(id_epio_id)%status = PSMILe_status_defined
00083 #ifdef VERBOSE
00084       PRINT *, '| Quit PRISMTrs_get_epio_handle - no reallocation'
00085       call psmile_flushstd
00086 #endif      
00087       RETURN
00088   ENDIF
00089 !
00090 !   Allocate new Epios vector and copy old vector
00091 !
00092   il_new_dim = Number_of_Epios_allocated + 8
00093 !
00094   ALLOCATE (NewDrv_Epios (il_new_dim), STAT = id_err)
00095   IF (id_err > 0) THEN
00096       ierrp (1) = id_err
00097       ierrp (2) = il_new_dim
00098       id_err = PRISM_Error_Alloc
00099 
00100       call psmile_error_common ( id_err, 'NewEPIOs', &
00101          ierrp, 2, __FILE__, __LINE__ )
00102       RETURN
00103   ENDIF
00104 !
00105   IF (Number_of_Epios_allocated > 0) &
00106      NewDrv_Epios (1:Number_of_Epios_allocated) = &
00107         Drv_Epios (1:Number_of_Epios_allocated)
00108 
00109   NewDrv_Epios(Number_of_Epios_allocated+1:il_new_dim)%status = &
00110      PSMILe_status_free
00111 !
00112 !   De-allocate Drv_Epios vector
00113 !
00114   IF (Number_of_Epios_allocated > 0) THEN
00115       DEALLOCATE (Drv_Epios, STAT = id_err)
00116       IF (id_err > 0) THEN
00117           ierrp (1) = id_err
00118           id_err = PRISM_Error_Dealloc
00119 
00120           call psmile_error_common ( id_err, 'EPIOs', &
00121              ierrp, 1, __FILE__, __LINE__ )
00122           RETURN
00123       ENDIF
00124   END IF
00125 !
00126 !   Update Number of Drv_Epios
00127 !
00128   Drv_Epios => NewDrv_Epios
00129 !
00130   id_epio_id = Number_of_Epios_allocated + 1
00131   Number_of_Epios_allocated = il_new_dim
00132 !
00133   Drv_Epios(id_epio_id)%status = PSMILe_status_defined
00134 !
00135 #ifdef VERBOSE
00136       PRINT *, '| Quit PRISMTrs_get_epio_handle - reallocation done'
00137       call psmile_flushstd
00138 #endif      
00139 END SUBROUTINE PRISMTrs_get_epio_handle

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1