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 2325 2010-04-21 15:00:07Z valcke $
00059 ! $Author: valcke $
00060 !
00061    Character(len=len_cvs_string), save :: mycvs = 
00062        '$Id: psmile_get_field_handle.F90 2325 2010-04-21 15:00:07Z valcke $'
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%Judate_Axis )
00125 
00126             Nullify ( New_Fields(i)%Taskin%In_Channel )
00127 
00128             New_Fields(i)%smioc_loc = PRISM_Undefined
00129             New_Fields(i)%status    = PSMILe_status_free
00130 !
00131 !     Initialize further values of field
00132 !
00133             New_Fields(i)%used_for_coupling = .false.
00134 
00135 !     Recv info's, send infos are handled in prism_def_var
00136 
00137             New_Fields(i)%Taskin%n_recv_direct  = 0
00138             New_Fields(i)%Taskin%n_recv_coupler = 0
00139 !
00140             New_Fields(i)%Taskin%n_alloc_recv_direct  = 0
00141             New_Fields(i)%Taskin%n_alloc_recv_coupler = 0
00142 
00143          enddo
00144 !
00145 !   De-allocate Fields vector
00146 !
00147          Deallocate (Fields, STAT = ierror)
00148          if (ierror > 0) then
00149             ierrp (1) = ierror
00150             ierror = PRISM_Error_Dealloc
00151 
00152             call psmile_error ( ierror, 'Fields', &
00153                               ierrp, 1, __FILE__, __LINE__ )
00154             return
00155          endif
00156 !
00157 !   Update Number of Fields
00158 !
00159          Fields => New_Fields
00160 !
00161          field_id = Number_of_Fields_allocated + 1
00162          Number_of_Fields_allocated = new_dim
00163 
00164 !     Fields(field_id)%status = PSMILe_status_defined
00165 !
00166       endif
00167 
00168 #ifdef VERBOSE
00169       print *, trim(ch_id), ': psmile_get_field_handle: eof handle, ierror =', &
00170                field_id, ierror
00171 
00172       call psmile_flushstd
00173 #endif /* VERBOSE */
00174 !
00175       end subroutine PSMILe_Get_field_handle

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1