psmile_get_field_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_field_handle
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_get_field_handle (field_id, ierror)
00012 !
00013 ! !USES:
00014 !
00015       use PRISM_constants
00016       use PSMILe, dummy_interface => PSMILe_Get_field_handle
00017       implicit none
00018 !
00019 !
00020 ! !OUTPUT PARAMETERS:
00021 !
00022       integer, Intent (Out)               :: field_id
00023 
00024 !     Returns the handle to the grid function information created.
00025 
00026       integer, Intent (Out)               :: ierror
00027 
00028 !     Returns the error code of PRISM_Init;
00029 !             ierror = 0 : No error
00030 !             ierror > 0 : Severe error
00031 !
00032 !
00033 ! !LOCAL VARIABLES
00034 !
00035       integer             :: i, new_dim
00036 
00037       integer, parameter  :: nerrp = 2
00038       integer             :: ierrp (nerrp)
00039 
00040       type (GridFunction), Dimension(:), Pointer :: New_Fields
00041 !
00042 !
00043 ! !DESCRIPTION:
00044 !
00045 ! Subroutine "PSMILe_Get_field_handle" returns a handle to a grid
00046 ! function (field).
00047 !
00048 !
00049 ! !REVISION HISTORY:
00050 !
00051 !   Date      Programmer    Description
00052 ! ----------  -----------   -----------
00053 ! 01.12.03    H. Ritzdorf   created
00054 !
00055 !EOP
00056 !----------------------------------------------------------------------
00057 !
00058 ! $Id: psmile_get_field_handle.F90 3248 2011-06-23 13:03:19Z coquart $
00059 ! $Author: coquart $
00060 !
00061    Character(len=len_cvs_string), save :: mycvs = 
00062        '$Id: psmile_get_field_handle.F90 3248 2011-06-23 13:03:19Z coquart $'
00063 !
00064 !----------------------------------------------------------------------
00065 
00066 #ifdef VERBOSE
00067       print *, trim(ch_id), ': psmile_get_field_handle: start'
00068 
00069       call psmile_flushstd
00070 #endif /* VERBOSE */
00071 
00072 !
00073 !   Initialization
00074 !
00075       ierror = 0
00076 !
00077 !   Search for a free field index
00078 !
00079       do i = 1, Number_of_Fields_allocated
00080          if (Fields(i)%status == PSMILe_status_free) exit
00081       end do
00082 !
00083       if (i <= Number_of_Fields_allocated) then
00084          field_id = i
00085 !        Fields(field_id)%status = PSMILe_status_defined
00086       else
00087 !
00088 !   Allocate new Fields vector and copy old vector
00089 !
00090          new_dim = Number_of_Fields_allocated + 8
00091 !
00092          Allocate (New_Fields (new_dim), STAT = ierror)
00093          if (ierror > 0) then
00094             ierrp (1) = ierror
00095             ierrp (2) = new_dim
00096             ierror = PRISM_Error_Alloc
00097 
00098             call psmile_error ( ierror, 'New_Fields', &
00099                               ierrp, 2, __FILE__, __LINE__ )
00100             return
00101          endif
00102 !
00103          New_Fields (1:Number_of_Fields_allocated) = &
00104             Fields (1:Number_of_Fields_allocated)
00105 
00106          New_Fields(Number_of_Fields_allocated+1:new_dim)%status = &
00107             PSMILe_status_free
00108 
00109          do i = Number_of_Fields_allocated+1, new_dim
00110             Nullify ( New_Fields(i)%io_infos )
00111             Nullify ( New_Fields(i)%io_chan_infos )
00112             Nullify ( New_Fields(i)%io_task_lookup )
00113 
00114             Nullify ( New_Fields(i)%Taskout )
00115 
00116             Nullify ( New_Fields(i)%Taskin%recv_direct )
00117             Nullify ( New_Fields(i)%Taskin%recv_coupler )
00118             Nullify ( New_Fields(i)%Taskin%buffer_int )
00119             Nullify ( New_Fields(i)%Taskin%buffer_real )
00120             Nullify ( New_Fields(i)%Taskin%buffer_dble )
00121 #if defined ( PRISM_QUAD_TYPE )
00122             Nullify ( New_Fields(i)%Taskin%buffer_quad )
00123 #endif
00124             Nullify ( New_Fields(i)%Taskin%In_Channel )
00125 
00126             New_Fields(i)%smioc_loc = PRISM_Undefined
00127             New_Fields(i)%status    = PSMILe_status_free
00128 !
00129 !     Initialize further values of field
00130 !
00131             New_Fields(i)%used_for_coupling = .false.
00132 
00133 !     Recv info's, send infos are handled in prism_def_var
00134 
00135             New_Fields(i)%Taskin%n_recv_direct  = 0
00136             New_Fields(i)%Taskin%n_recv_coupler = 0
00137 !
00138             New_Fields(i)%Taskin%n_alloc_recv_direct  = 0
00139             New_Fields(i)%Taskin%n_alloc_recv_coupler = 0
00140 
00141          enddo
00142 !
00143 !   De-allocate Fields vector
00144 !
00145          Deallocate (Fields, STAT = ierror)
00146          if (ierror > 0) then
00147             ierrp (1) = ierror
00148             ierror = PRISM_Error_Dealloc
00149 
00150             call psmile_error ( ierror, 'Fields', &
00151                               ierrp, 1, __FILE__, __LINE__ )
00152             return
00153          endif
00154 !
00155 !   Update Number of Fields
00156 !
00157          Fields => New_Fields
00158 !
00159          field_id = Number_of_Fields_allocated + 1
00160          Number_of_Fields_allocated = new_dim
00161 
00162 !     Fields(field_id)%status = PSMILe_status_defined
00163 !
00164       endif
00165 
00166 #ifdef VERBOSE
00167       print *, trim(ch_id), ': psmile_get_field_handle: eof handle, ierror =', &
00168                field_id, ierror
00169 
00170       call psmile_flushstd
00171 #endif /* VERBOSE */
00172 !
00173       end subroutine PSMILe_Get_field_handle

Generated on 1 Dec 2011 for Oasis4 by  doxygen 1.6.1