00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 subroutine prism_put_restart ( field_id, date, date_bounds, data_array, info, ierror )
00014
00015
00016
00017 use PRISM_constants
00018 use PRISM_calendar
00019
00020 use PSMILe
00021 use PSMILe_SMIOC, only : sga_smioc_comp, transient
00022
00023 implicit none
00024
00025
00026
00027 Integer, Intent (In) :: field_id
00028
00029
00030
00031 Type(PRISM_Time_Struct), Intent (In) :: date
00032
00033
00034
00035 Type(PRISM_Time_Struct), Intent (In) :: date_bounds(2)
00036
00037
00038
00039
00040 Double Precision, Intent (In) :: data_array(*)
00041
00042
00043
00044
00045
00046
00047 integer, Intent (Out) :: info
00048
00049
00050
00051 integer, Intent (Out) :: ierror
00052
00053
00054
00055
00056
00057
00058
00059 Integer :: il_taskid_restr, il_transiouts, il_smioc_loc
00060 Double Precision :: julian_day, julian_dayb(2)
00061 Double Precision :: julian_sec, julian_secb(2)
00062
00063
00064 Logical :: restart_action
00065
00066 Integer :: task_id
00067 Integer, Parameter :: nerrp = 1
00068 Integer :: ierrp (nerrp)
00069
00070 Type (Transient), pointer :: sga_smioc_transi(:)
00071 Type (GridFunction), Pointer :: fp
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 Character(len=len_cvs_string), save :: mycvs =
00090 '$Id: prism_put_restart.F90 2325 2010-04-21 15:00:07Z valcke $'
00091
00092
00093 #ifdef VERBOSE
00094 print *, trim(ch_id), ': prism_put_restart: field_id', field_id
00095
00096 call psmile_flushstd
00097 #endif /* VERBOSE */
00098
00099
00100
00101
00102
00103 ierror = 0
00104 info = PRISM_NOACTION
00105
00106 sga_smioc_transi => sga_smioc_comp(Fields(field_id)%comp_id)%sga_smioc_transi
00107 fp => Fields(field_id)
00108
00109
00110
00111
00112
00113 if ( Fields(field_id)%status /= PSMILe_status_defined ) then
00114 ierrp (1) = field_id
00115
00116 ierror = PRISM_Error_Arg
00117
00118 call psmile_error ( ierror, 'field_id', &
00119 ierrp(1), 1, __FILE__, __LINE__ )
00120 return
00121 endif
00122
00123
00124
00125
00126
00127 if ( Fields(field_id)%smioc_loc == PRISM_UNDEFINED ) return
00128
00129
00130
00131
00132
00133
00134
00135 call psmile_date2ju ( date, julian_day, julian_sec )
00136 call psmile_date2ju ( date_bounds(1), julian_dayb(1), julian_secb(1))
00137 call psmile_date2ju ( date_bounds(2), julian_dayb(2), julian_secb(2))
00138
00139
00140
00141 if ( julian_dayb(2) < julian_dayb(1) .or. &
00142 ( julian_dayb(1) == julian_dayb(2) .and. &
00143 julian_secb(2) < julian_secb(1) ) ) then
00144
00145 ierrp (1) = field_id
00146
00147 ierror = PRISM_Error_Date
00148
00149 call psmile_error ( ierror, 'upper bound < lower bound', &
00150 ierrp(1), 1, __FILE__, __LINE__ )
00151 return
00152
00153 endif
00154
00155
00156
00157 if ( ( julian_dayb(1) > julian_day .or. &
00158 julian_day > julian_dayb(2) ) .or. &
00159 ( julian_dayb(1) == julian_day .and. &
00160 julian_sec < julian_secb(1) ) .or. &
00161 ( julian_dayb(2) == julian_day .and. &
00162 julian_sec > julian_secb(2) ) ) then
00163
00164 ierrp (1) = field_id
00165
00166 ierror = PRISM_Error_Date
00167
00168 call psmile_error ( ierror, 'date out of bounds', &
00169 ierrp(1), 1, __FILE__, __LINE__ )
00170 return
00171
00172 endif
00173
00174
00175
00176
00177
00178 task_id = 1
00179
00180
00181
00182
00183
00184
00185 il_smioc_loc=fp%smioc_loc
00186
00187 il_transiouts=0
00188
00189 if(associated(sga_smioc_transi(il_smioc_loc)%sga_transi_out)) &
00190 il_transiouts=size(sga_smioc_transi(il_smioc_loc)%sga_transi_out)
00191
00192
00193
00194
00195 il_taskid_restr=3*il_transiouts+task_id+1
00196
00197
00198
00199
00200
00201 restart_action = .false.
00202
00203 if(il_taskid_restr.le.size( fp%io_task_lookup)) &
00204 restart_action = fp%io_task_lookup(il_taskid_restr).gt.0
00205
00206
00207
00208
00209
00210 if ( restart_action ) then
00211
00212 #ifdef VERBOSE
00213 print *, trim(ch_id), ': prism_put_restart: dump out field ', trim(fp%local_name)
00214 call psmile_flushstd
00215 #endif /* VERBOSE */
00216
00217 if ( Fields(field_id)%dataType == PRISM_Integer ) &
00218 call psmile_write_byid_int ( field_id, il_taskid_restr, &
00219 data_array, julian_dayb(2), julian_secb(2), ierror )
00220
00221 if ( Fields(field_id)%dataType == PRISM_Real ) &
00222 call psmile_write_byid_real ( field_id, il_taskid_restr, &
00223 data_array, julian_dayb(2), julian_secb(2), ierror )
00224
00225 if ( Fields(field_id)%dataType == PRISM_Double_Precision ) &
00226 call psmile_write_byid_dble ( field_id, il_taskid_restr, &
00227 data_array, julian_dayb(2), julian_secb(2), ierror )
00228
00229 info = info + 10
00230
00231 endif
00232
00233 #ifdef VERBOSE
00234 print *, trim(ch_id), ': prism_put_restart: eof ierror ', ierror
00235
00236 call psmile_flushstd
00237 #endif /* VERBOSE */
00238
00239 end subroutine prism_put_restart