psmile_check_restart.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, SGI Germany, Munich, Germany.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILE_Check_Restart
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine  psmile_check_restart(id_varid,id_taskid,id_info,ierror)
00012 
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_Constants
00017       use PSMILe_SMIOC, only : sga_smioc_transi
00018       use PSMILe, dummy_interface => PSMILE_Check_Restart
00019       use PRISM_calendar
00020       use psmile_io_utils
00021       implicit none
00022 !
00023 ! !INPUT PARAMETERS:
00024 !
00025       Integer, Intent (In)                 :: id_varid
00026       Integer, Intent (In)                 :: id_taskid
00027 !
00028 ! !OUTPUT PARAMETERS:
00029 !
00030 
00031       Integer, Intent (Out)                 :: id_info
00032       Integer, Intent (Out)                :: ierror
00033 
00034 !
00035 ! !LOCAL VARIABLES:
00036 !
00037       integer                             :: ierrp(3)
00038       integer                             :: il_taskid_restr
00039       integer                             :: il_smioc_loc,il_transiouts
00040       integer                             :: il_i
00041       Type(IO_Data),Pointer               :: pl_io_info
00042       Type(PRISM_Time_Struct)             :: current_date
00043       integer,dimension(6)        :: il_date
00044 !
00045 !
00046 ! !DESCRIPTION:
00047 !
00048 ! The routine interfaces the routine psmile_open_restart_file_byid
00049 ! which attempts to open a restart file.   
00050 ! If the open of a restart file is successful the routine
00051 ! returns for id_info a value larger than zero. Otherwise that value
00052 ! is zero.
00053 
00054 !
00055 ! !REVISION HISTORY:
00056 !
00057 !   Date      Programmer   Description
00058 ! ----------  ----------   -----------
00059 ! 23.8.04     R. Vogelsang Created
00060 !
00061 !EOP
00062 !----------------------------------------------------------------------
00063 
00064        Character(len=len_cvs_string),save :: check_restart= 
00065 '$Id: psmile_check_restart.F90 2325 2010-04-21 15:00:07Z valcke $'
00066 
00067       ierror = 0
00068       id_info= 0
00069 #ifdef __PSMILE_WITH_IO
00070 #ifdef VERBOSE
00071       print*,trim(ch_id),' : psmile_check_restart: start'
00072       call psmile_flushstd
00073 
00074 #endif
00075       if (.not.associated(Fields)) then
00076 
00077          ierror = PRISM_Error_Internal
00078          call psmile_error ( ierror, 'Fields not allocated ', &
00079                              ierrp, 0, __FILE__, __LINE__ )
00080       endif
00081 
00082       if ( (id_varid .gt. Size(Fields)).or.(id_varid.lt.1) .or. &
00083            (Fields(id_varid)%status .eq. PSMILe_Status_undefined) ) then
00084 
00085          ierror = PRISM_Error_Internal
00086          call psmile_error ( ierror, 'Fields(varid) status undefined ', &
00087                              ierrp, 0, __FILE__, __LINE__ )
00088       endif
00089       
00090       if (.not.associated(Fields(id_varid)%io_chan_infos)) then
00091 
00092          ierror = PRISM_Error_Internal
00093          call psmile_error ( ierror, 'Fields has no I/O infos! ', &
00094                              ierrp, 0, __FILE__, __LINE__ )
00095       endif
00096       
00097 !
00098 !     Shift task id into the range of task ids for reading a restart!
00099 !
00100       il_transiouts=0
00101       il_smioc_loc=Fields(id_varid)%smioc_loc
00102 
00103       if(associated(sga_smioc_transi(il_smioc_loc)%sga_transi_out)) &
00104            il_transiouts=size(sga_smioc_transi(il_smioc_loc)%sga_transi_out)
00105       if(id_taskid .gt. 0 ) then
00106 
00107          il_taskid_restr=2*il_transiouts+id_taskid +1
00108 
00109       else
00110 
00111         ierror = PRISM_Error_IO_Meta
00112         ierrp (1) = id_taskid
00113         call psmile_error ( ierror &
00114                           , 'Task id out of range! ', &
00115                             ierrp, 1, __FILE__, __LINE__ )
00116       endif
00117 
00118       if(il_taskid_restr .le. size(Fields(id_varid)%io_task_lookup)) then
00119 
00120         il_i=Fields(id_varid)%io_task_lookup(il_taskid_restr)
00121 
00122       else
00123         ierror = PRISM_Error_IO_Meta
00124         ierrp (1) = il_taskid_restr
00125         call psmile_error ( ierror &
00126                           , 'Task id out of range! ', &
00127                             ierrp, 1, __FILE__, __LINE__ )
00128         return
00129 
00130       endif
00131 
00132       if (il_i.gt.0) then
00133 
00134          Fields(id_varid)%io_infos =>  Fields(id_varid)%io_chan_infos(il_i)
00135 
00136       else
00137         ierror = PRISM_Error_IO_Meta
00138         ierrp (1) = id_taskid
00139         call psmile_error ( ierror &
00140                           , 'Negative task id! ', &
00141                             ierrp, 1, __FILE__, __LINE__ )
00142         return
00143       endif
00144 
00145 !
00146 !     Check open status of the potential restart file.
00147 !
00148       id_info=0
00149 
00150 !
00151 !     If a restart file was opened we have a restart.
00152 !
00153       if ( Fields(id_varid)%io_infos%opened ) id_info=1
00154 
00155 #ifdef VERBOSE
00156 
00157       if (id_info .gt. 0 ) then
00158          print*,trim(ch_id),' : psmile_check_restart: Restart from file ' &
00159                ,trim( Fields(id_varid)%io_infos%filename),' is possible!'
00160          call psmile_flushstd
00161       else
00162          print*,trim(ch_id),' : psmile_check_restart: Restart from file ' &
00163                ,trim( Fields(id_varid)%io_infos%filename), ' is not possible!'
00164       endif
00165 
00166       print*,trim(ch_id),' : psmile_check_restart: end'
00167       call psmile_flushstd
00168 
00169 #endif
00170 #endif
00171       
00172 
00173       end subroutine PSMILe_check_restart

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1