00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 subroutine prism_put_inquire ( field_id, date, date_bounds, info, ierror )
00014
00015
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
00025
00026 Integer, Intent (In) :: field_id
00027
00028
00029
00030 Type(PRISM_Time_Struct), Intent (In) :: date
00031
00032
00033
00034 Type(PRISM_Time_Struct), Intent (In) :: date_bounds(2)
00035
00036
00037
00038
00039
00040
00041
00042
00043 Integer, Intent (Out) :: info
00044
00045
00046
00047 Integer, Intent (Out) :: ierror
00048
00049
00050
00051
00052
00053
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
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
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
00106
00107
00108 ierror = 0
00109 info = PRISM_NOACTION
00110 flag = .false.
00111 action = .false.
00112
00113
00114
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
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
00157
00158
00159
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
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
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
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
00217
00218
00219 do i = 1, il_nb_transi_out
00220
00221
00222
00223
00224
00225
00226
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
00258
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
00267
00268 do j = 1, 3
00269 if (action(j)) flag(j) = .true.
00270 enddo
00271
00272 enddo
00273
00274 if ( flag(1) ) info = info + 1000
00275 if ( flag(2) ) info = info + 100
00276 if ( flag(3) ) info = info + 10
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