prism_put_inquire.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! Copyright 2006-2010, SGI Germany, Munich, Germany.
00004 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00005 ! All rights reserved. Use is subject to OASIS4 license terms.
00006 !-----------------------------------------------------------------------
00007 !BOP
00008 !
00009 ! !ROUTINE: PRISM_Put_inquire
00010 !
00011 ! !INTERFACE:
00012 
00013 subroutine prism_put_inquire ( field_id, date, date_bounds, info, ierror )
00014 !
00015 ! !USES:
00016 !
00017   use PRISM, dummy_interface => prism_put_inquire
00018   use PRISM_calendar
00019   use PSMILe
00020   use PSMILe_SMIOC, only : sga_smioc_comp, transient
00021 
00022   implicit none
00023 !
00024 ! !INPUT PARAMETERS:
00025 !
00026   Integer, Intent (In)                 :: field_id
00027 
00028 !     Handle to the variable information
00029 
00030   Type(PRISM_Time_Struct), Intent (In) :: date
00031 
00032 !     Date on which the information is located in time
00033 
00034   Type(PRISM_Time_Struct), Intent (In) :: date_bounds(2)
00035 
00036 !     Time interval for which the data is representative
00037 !     lower bound: date_bounds(1), upper bound: date_bounds(2)
00038 !
00039 !
00040 ! !OUTPUT PARAMETERS:
00041 !
00042   
00043   Integer, Intent (Out)               :: info
00044 
00045 !     returned info about action performed
00046 
00047   Integer, Intent (Out)               :: ierror
00048 
00049 !     Returns the error code of prism_put_inquire;
00050 !             ierror = 0 : No error
00051 !             ierror > 0 : Severe error
00052 !
00053 ! !LOCAL VARIABLES
00054 !
00055   Type (GridFunction), Pointer :: fp
00056   Type (transient), Pointer    :: sga_smioc_transi(:)
00057 
00058   Double Precision   :: julian_day, julian_dayb(2)
00059   Double Precision   :: julian_sec, julian_secb(2)
00060 
00061   Double Precision   :: delta_sec
00062 
00063   Logical            :: action(3)
00064   Logical            :: flag(3)
00065 
00066   Integer            :: add_days
00067   Integer            :: lag
00068 
00069   Integer            :: i, j
00070   Integer            :: il_nb_transi_out
00071 
00072   Integer, Parameter :: nerrp = 2
00073   Integer            :: ierrp (nerrp)
00074   !
00075 !
00076 ! !DESCRIPTION:
00077 !
00078 !  Subroutine "prism_put_inquire" takes the data and sends them
00079 !          to remote application on the the io library
00080 !
00081 !
00082 ! !REVISION HISTORY:
00083 !   Date      Programmer   Description
00084 ! ----------  ----------   -----------
00085 ! 03.07.03    R. Redler    created
00086 ! 04.12.14    R. Redler    revised
00087 !
00088 !EOP
00089 !----------------------------------------------------------------------
00090 !
00091 ! $Id: prism_put_inquire.F90 3248 2011-06-23 13:03:19Z coquart $
00092 ! $Author: coquart $
00093 !
00094   Character(len=len_cvs_string), save :: mycvs = 
00095       '$Id: prism_put_inquire.F90 3248 2011-06-23 13:03:19Z coquart $'
00096 !
00097 !----------------------------------------------------------------------
00098 
00099 #ifdef VERBOSE
00100    print *, trim(ch_id), ': prism_put_inquire: field_id', field_id
00101    call psmile_flushstd
00102 #endif /* VERBOSE */
00103 
00104 !----------------------------------------------------------------------
00105 !  1st Initialization
00106 !----------------------------------------------------------------------
00107 
00108    ierror          = 0
00109    info            = PRISM_NOACTION
00110    flag            = .false.
00111    action          = .false.
00112 
00113 !----------------------------------------------------------------------
00114 !  2nd Check field_id
00115 !----------------------------------------------------------------------
00116 
00117    if ( Fields(field_id)%status /= PSMILe_status_defined ) then
00118 
00119       ierror = PRISM_Error_Arg
00120 
00121       print *, trim(ch_id), ': prism_put_inquire: eof field_id not defined'
00122       call psmile_flushstd
00123 
00124       return
00125 
00126    endif
00127 
00128    fp               => Fields(field_id)
00129    sga_smioc_transi => sga_smioc_comp(Fields(field_id)%comp_id)%sga_smioc_transi
00130    il_nb_transi_out =  sga_smioc_transi(fp%smioc_loc)%ig_nb_transi_out
00131 
00132 !-----------------------------------------------------------------------
00133 ! 3rd Return in case there is nothing to do
00134 !-----------------------------------------------------------------------
00135 
00136    if ( il_nb_transi_out < 1 ) then
00137 #ifdef VERBOSE
00138       print *, trim(ch_id), ': prism_put_inquire: eof ig_nb_transi_out ', il_nb_transi_out
00139       call psmile_flushstd
00140 #endif /* VERBOSE */
00141       return
00142    endif
00143 
00144    if ( fp%smioc_loc == PRISM_UNDEFINED ) then
00145 
00146       ierror = PRISM_Error_Arg
00147 
00148       print *, trim(ch_id), ': prism_put_inquire: WARNING: smioc_loc undefined'
00149       call psmile_flushstd
00150 
00151       return
00152 
00153    endif
00154 
00155 !-----------------------------------------------------------------------
00156 ! 4th Check date information
00157 !-----------------------------------------------------------------------
00158 !
00159 !  ... convert date and date bounds into julian days and seconds
00160 !
00161    call psmile_date2ju ( date,           julian_day,     julian_sec    )
00162    call psmile_date2ju ( date_bounds(1), julian_dayb(1), julian_secb(1))
00163    call psmile_date2ju ( date_bounds(2), julian_dayb(2), julian_secb(2))
00164 
00165 !   ... check whether bounds are consistent
00166 
00167    if ( julian_dayb(2) <  julian_dayb(1) .or. &
00168       ( julian_dayb(1) == julian_dayb(2) .and. &
00169         julian_secb(2) <  julian_secb(1) ) ) then
00170 
00171       ierror = PRISM_Error_Date
00172 
00173       print *, trim(ch_id), ': prism_put_inquire: WARNING: upper bound < lower bound'
00174       call psmile_flushstd
00175 
00176       return
00177 
00178    endif
00179 
00180 !  ... check whether date is within bounds
00181 
00182    if ( ( julian_dayb(1) >  julian_day       .or.  &
00183           julian_day     >  julian_dayb(2) ) .or.  &
00184         ( julian_dayb(1) == julian_day       .and. &
00185           julian_sec     <  julian_secb(1) ) .or.  &
00186         ( julian_dayb(2) == julian_day       .and. &
00187           julian_sec     >  julian_secb(2) ) ) then
00188 
00189       ierrp (1) = field_id
00190 
00191       ierror = PRISM_Error_Date
00192 
00193       print *, trim(ch_id), ': prism_put_inquire: WARNING: date out of bounds'
00194       call psmile_flushstd
00195 
00196       return
00197 
00198    endif
00199 
00200 !----------------------------------------------------------------------
00201 ! 5th Check whether any action is required because of Average or Summation
00202 !----------------------------------------------------------------------
00203 
00204    do i = 1, il_nb_transi_out
00205       if ( sga_smioc_transi(fp%smioc_loc)%sga_transi_out(i)%ig_src_timeop /= PSMILe_undef ) then
00206            info = info + 1
00207 #ifdef VERBOSE
00208            print *, trim(ch_id), ': prism_put_inquire: eof summation required'
00209            call psmile_flushstd
00210 #endif /* VERBOSE */
00211            exit
00212       endif
00213    enddo
00214 
00215 !-----------------------------------------------------------------------
00216 ! 6th Loop over the tasks for a particular prism_put_inquire
00217 !-----------------------------------------------------------------------
00218 
00219    do i = 1, il_nb_transi_out
00220 
00221 !------------------------------------------------------------------------
00222 !  ... shift date and bounds according to lag information
00223 !      We assume the upper bound lies halfway between two
00224 !      consecutive calls to Prism_put_inquire and that the delta_t
00225 !      does not change between two consecutive calls to
00226 !      Prism_put_inquire.
00227 !------------------------------------------------------------------------
00228 
00229       lag = sga_smioc_transi(fp%smioc_loc)%sga_transi_out(i)%ig_lag
00230 
00231       if ( lag /= PSMILe_undef ) then
00232 
00233 #ifdef DEBUG
00234          print *, trim(ch_id), ': prism_put_inquire: lag is active and set to ', lag
00235 #endif
00236          delta_sec = (julian_dayb(2) - julian_day) * 86400.0 &
00237               +  julian_secb(2) - julian_secb(1)
00238 
00239          julian_sec = julian_sec + lag * delta_sec
00240          add_days   = floor(julian_sec / 86400.0)
00241          julian_day = julian_day + add_days
00242          julian_sec = julian_sec - float(add_days) * 86400.0
00243 
00244          julian_secb(1) = julian_secb(1) + lag * delta_sec
00245          add_days       = floor(julian_secb(1) / 86400.0)
00246          julian_dayb(1) = julian_dayb(1) + add_days
00247          julian_secb(1) = julian_secb(1) - float(add_days) * 86400.0
00248 
00249          julian_secb(2) = julian_secb(2) + lag * delta_sec
00250          add_days       = floor(julian_secb(2) / 86400.0)
00251          julian_dayb(2) = julian_dayb(2) + add_days
00252          julian_secb(2) = julian_secb(2) - float(add_days) * 86400.0
00253 
00254       endif
00255 
00256 !-----------------------------------------------------------------------
00257 ! ... determine the concrete action that has to be performed for this
00258 !     particular task.
00259 !-----------------------------------------------------------------------
00260 
00261       call psmile_check_action ( field_id, i, .true.,       &
00262                                 julian_day, julian_dayb(1), &
00263                                 julian_sec, julian_secb(1), &
00264                                 action )
00265 
00266 ! accumulate actions in flag for all tasks
00267 
00268       do j = 1, 3
00269          if (action(j)) flag(j) = .true.
00270       enddo
00271 
00272    enddo ! il_nb_transi_out
00273 
00274    if ( flag(1) ) info = info + 1000 ! Coupling
00275    if ( flag(2) ) info = info +  100 ! IO
00276    if ( flag(3) ) info = info +   10 ! Restart
00277 
00278 #ifdef VERBOSE
00279    print *, trim(ch_id), ': prism_put_inquire: eof ierror ', ierror
00280    call psmile_flushstd
00281 #endif /* VERBOSE */
00282 !
00283 end subroutine prism_put_inquire

Generated on 1 Dec 2011 for Oasis4 by  doxygen 1.6.1