prismtrs_target_real.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 ! Copyright 2009, DKRZ, Hamburg, Germany.
00005 ! All rights reserved. Use is subject to OASIS4 license terms.
00006 !-----------------------------------------------------------------------
00007 !BOP
00008 !
00009 ! !ROUTINE: PRISMTrs_Target_real
00010 !
00011 ! !INTERFACE
00012 subroutine prismtrs_target_real(id_process_global_rank,  &
00013                                 id_transient_in_id,      &
00014                                 id_epio_id,              &
00015                                 id_nbr_fields,           &
00016                                 id_err)
00017 
00018 !
00019 ! !USES:
00020 !
00021   USE PRISMDrv, dummy_interface => PRISMTrs_Target_real
00022 
00023   IMPLICIT NONE
00024 
00025 !
00026 ! !PARAMETERS:
00027 !
00028 ! rank of the psmile target process sending the info
00029   INTEGER , INTENT (In)       :: id_process_global_rank
00030 
00031 ! id of the required field
00032   INTEGER, INTENT (In)        :: id_transient_in_id
00033 
00034 ! Epio index
00035   INTEGER, INTENT (IN)        :: id_epio_id
00036 
00037 ! nbr of bundle components
00038   INTEGER, INTENT (In)        :: id_nbr_fields
00039 
00040 !
00041 ! ! RETURN VALUE
00042 !
00043   INTEGER, INTENT (Out)       :: id_err   ! error value
00044 
00045 ! !DESCRIPTION
00046 ! Subroutines "PRISMTrs_Target_real" checks if the required field is ready 
00047 ! and sends it to the target model which requested it.
00048 !
00049 ! !REVISED HISTORY
00050 !   Date      Programmer   Description
00051 ! ----------  ----------   -----------
00052 ! 28/01/2003  D. Declat    Creation
00053 ! 01/12/2003  D. Declat    Adapted to type real, dble
00054 ! 03/12/2009  M. Hanke     Simplified field handling
00055 !
00056 ! EOP
00057 !----------------------------------------------------------------------
00058 ! $Id: prismtrs_target_real.F90 2685 2010-10-28 14:05:10Z coquart $
00059 ! $Author: coquart $
00060 !----------------------------------------------------------------------
00061 !
00062 ! Local declarations
00063 !
00064   CHARACTER(LEN=len_cvs_string), SAVE  :: mycvs = 
00065      '$Id: prismtrs_target_real.F90 2685 2010-10-28 14:05:10Z coquart $'
00066 !
00067 ! received field
00068 !
00069   REAL, DIMENSION(:), ALLOCATABLE :: rla_field
00070   INTEGER :: il_field_status
00071 !
00072 ! Auxialiary varaibles
00073 !
00074   INTEGER :: il_size
00075 !
00076   INTEGER :: ib
00077   INTEGER :: il_exchange_id
00078 
00079   LOGICAL :: conservation
00080 
00081 !     ... for error handling
00082   LOGICAL             :: ll_found
00083   INTEGER, PARAMETER  :: nerrp = 2
00084   INTEGER             :: ierrp (nerrp)
00085 !
00086 ! ---------------------------------------------------------------------
00087 !
00088 #ifdef VERBOSE
00089   PRINT *, '| | | Enter PRISMTrs_Target_real '
00090   call psmile_flushstd
00091 #endif
00092 
00093 !
00094 ! 2. Get the exchange id
00095 !
00096   ll_found = .false.
00097   DO ib = 1, Number_of_Exchanges
00098     IF (Drv_Exchanges(ib)%trans_in_id .eq. id_transient_in_id) THEN
00099         IF (Drv_Exchanges(ib)%epio_id .eq. id_epio_id) THEN
00100             il_exchange_id = ib
00101             ll_found = .true.
00102             EXIT
00103         END IF
00104     END IF
00105   END DO
00106 
00107   IF (.NOT. ll_found) THEN
00108       ierrp(1) = Number_of_Exchanges
00109       ierrp(2) = ib
00110       call psmile_error_common ( id_err, 'PRISMTrs_Target_real', &
00111          ierrp, 2, __FILE__, __LINE__ )
00112   END IF
00113 
00114   conservation = Drv_Exchanges(il_exchange_id)%conservation &
00115                  .ne. PSMILe_undef
00116 !
00117 ! 3. Get the field if available
00118 !
00119 ! 3.1. Reduce status by 1
00120       Drv_Exchanges(il_exchange_id)%trans_in_status =  &
00121          Drv_Exchanges(il_exchange_id)%trans_in_status-1
00122 ! 3.2. Check the status of the transformation:
00123 !      if the interpolation is not completed, post a request...
00124   IF (Drv_Exchanges(il_exchange_id)%trans_in_status .EQ. -1) THEN
00125 
00126       ! store rank of process which requested the data
00127       ! why is this stored? the epio_id should be sufficient
00128       Drv_Exchanges(il_exchange_id)%trans_in_request = &
00129          id_process_global_rank
00130 
00131 #ifdef VERBOSE
00132       PRINT *, &
00133          '| | | | The transient_in ', id_transient_in_id, &
00134          'is NOT available ! Post a request '
00135       call psmile_flushstd
00136 #endif
00137 
00138 !     if available send it !
00139   ELSE IF (Drv_Exchanges(il_exchange_id)%trans_in_status .GE. 0) THEN
00140 
00141       il_size = Drv_Exchanges(il_exchange_id)%trans_in_field_size*id_nbr_fields
00142 
00143 #ifdef VERBOSE
00144       PRINT *, '| | | | Sending transient_in ', id_transient_in_id, &
00145          'to process ', id_process_global_rank, 'size ', &
00146           il_size
00147       call psmile_flushstd
00148 #endif
00149 
00150       ! send data
00151       call MPI_Send(Drv_Exchanges(il_exchange_id)%trans_in_field_real(1), &
00152          il_size, MPI_Real,    &
00153          id_process_global_rank, 0177, comm_drv_trans, id_err)
00154       ! remove sent field from memory
00155       call prismtrs_dequeue_in_field_real(il_size, il_exchange_id, id_err)
00156 
00157       if (conservation) then
00158 #ifdef VERBOSE
00159          PRINT *, '| | | | Sending global_sum ', Drv_Exchanges(il_exchange_id)%global_sum_dble, &
00160             conservation
00161          call psmile_flushstd
00162 #endif
00163          ! send global sum
00164          call MPI_Send(Drv_Exchanges(il_exchange_id)%global_sum_dble(1), &
00165             id_nbr_fields, MPI_Double_Complex,    &
00166             id_process_global_rank, CONSERVTAG, comm_drv_trans, id_err)
00167          ! remove sent sum from memory
00168          call prismtrs_dequeue_glob_sum_dble(id_nbr_fields, il_exchange_id, id_err)
00169       endif
00170 
00171 !      status is < 0, this is not allowed, because a prism_get is assumed to be blocking
00172   ELSE
00173 
00174      ierrp (1) = Drv_Exchanges(il_exchange_id)%trans_in_status
00175 
00176      call psmile_error_common ( PRISM_Error_Parameter, 'prismtrs_target_dble',&
00177           ierrp, 1, __FILE__, __LINE__ )
00178   ENDIF
00179 
00180 !
00181 #ifdef VERBOSE
00182   PRINT *, '| | | Quit PRISMTrs_Target_real'
00183   call psmile_flushstd
00184 #endif
00185 
00186 END SUBROUTINE PRISMTrs_Target_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1