psmile_read_4d_real.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_read_4d_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_read_4d_real(unit                &
00012                                      ,var                 &
00013                                      ,domain              &
00014                                      ,a                   &
00015                                      ,a_shape             &
00016                                      ,v_shape             &
00017                                      ,itime               &
00018                                      ,time_used           &
00019                                      ,id_blockid          &
00020                                      ,block_used          &
00021                                      ,domain_used          &
00022                                      ,ierror)
00023 !
00024 ! !USES:
00025 !
00026       use psmile
00027 #ifdef __PSMILE_WITH_IO
00028       implicit none
00029       include 'prism.inc'
00030 !
00031 ! !INPUT PARAMETERS:
00032 !
00033       integer,intent(in) :: unit
00034       Type(fieldtype),intent(in) :: var
00035       Type(domain2D),intent(inout)  :: domain
00036       integer,intent(in) :: a_shape(2,*)
00037       integer,intent(in) :: v_shape(2,*)
00038       real            , intent(inout) :: a(a_shape(1,1):a_shape(2,1)  
00039                                        ,a_shape(1,2):a_shape(2,2)  
00040                                        ,a_shape(1,3):a_shape(2,3)  
00041                                        ,a_shape(1,4):a_shape(2,4)) 
00042       integer, intent(in) :: itime
00043       logical,intent(in) :: time_used
00044       integer,intent(in) :: id_blockid
00045       logical,intent(in) :: block_used
00046       logical,intent(in) :: domain_used
00047 !
00048 ! !OUTPUT PARAMETERS:
00049 !
00050       integer, intent(out) :: ierror
00051 !
00052 ! !LOCAL VARIABLES:
00053 !
00054       double precision,allocatable    :: atmp(:,:,:,:)
00055       integer :: ierrp(2)
00056 !
00057 ! !DESCRIPTION:
00058 !
00059 ! Reads a real partitioned 4d array to a file.
00060 ! Subblocks are supported.
00061 !
00062 ! !REVISION HISTORY:
00063 !
00064 !   Date      Programmer   Description
00065 ! ----------  ----------   -----------
00066 !  09.12.03   R. Vogelsang created
00067 !  6.05.04    R. Vogelsang bugfixes a=atmp
00068 !
00069 !EOP
00070 !----------------------------------------------------------------------
00071 
00072       character(len=len_cvs_string),save :: mcvs = 
00073 '$Id: psmile_read_4d_real.F90 2325 2010-04-21 15:00:07Z valcke $'
00074       
00075       ierror=0
00076 
00077 #ifdef VERBOSE
00078       print*,trim(ch_id),' :   psmile_read_4d_dble: start'
00079       print*,trim(ch_id),' :   psmile_read_4d_dble: size ',size(a)
00080       call psmile_flushstd
00081 
00082 #endif
00083 
00084       allocate( atmp(a_shape(1,1):a_shape(2,1)  &
00085                     ,a_shape(1,2):a_shape(2,2)  &
00086                     ,a_shape(1,3):a_shape(2,3)  &
00087                     ,a_shape(1,4):a_shape(2,4)))
00088 
00089       if ( ierror /= 0 ) then
00090          ierrp (1) = 1
00091          ierror = PRISM_Error_Alloc
00092          call psmile_error ( ierror, 'atmp', ierrp, 1, __FILE__, __LINE__ )
00093          return
00094       endif
00095 
00096       if(domain_used) then
00097       if(block_used) then
00098       if(id_blockid.le.0) then
00099          ierror = PRISM_Error_Internal
00100          call psmile_error ( ierror, 'id_blockid <= 0! ', &
00101                              ierrp, 0, __FILE__, __LINE__ )
00102       endif
00103       if(time_used) then
00104         call mpp_read(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00105                                              ,v_shape(1,2):v_shape(2,2) &
00106                                              ,v_shape(1,3):v_shape(2,3) &
00107                                              ,v_shape(1,4):v_shape(2,4)) &
00108                                       ,tindex=itime,blockid=id_blockid)
00109       else
00110         call mpp_read( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00111                                               ,v_shape(1,2):v_shape(2,2) &
00112                                              ,v_shape(1,3):v_shape(2,3) &
00113                                               ,v_shape(1,4):v_shape(2,4)) &
00114                                               , blockid=id_blockid)
00115       endif
00116       else
00117       if(time_used) then
00118         call mpp_read(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00119                                              ,v_shape(1,2):v_shape(2,2) &
00120                                              ,v_shape(1,3):v_shape(2,3) &
00121                                              ,v_shape(1,4):v_shape(2,4)) &
00122                                       ,tindex=itime)
00123       else
00124         call mpp_read( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00125                                               ,v_shape(1,2):v_shape(2,2) &
00126                                              ,v_shape(1,3):v_shape(2,3) &
00127                                               ,v_shape(1,4):v_shape(2,4)))
00128       endif
00129       endif
00130 !
00131       else
00132 !
00133       if(block_used) then
00134       if(id_blockid.le.0) then
00135          ierror = PRISM_Error_Internal
00136          call psmile_error ( ierror, 'id_blockid <= 0! ', &
00137                              ierrp, 0, __FILE__, __LINE__ )
00138       endif
00139       if(time_used) then
00140         call mpp_read(unit,var,atmp(v_shape(1,1):v_shape(2,1) &
00141                                              ,v_shape(1,2):v_shape(2,2) &
00142                                              ,v_shape(1,3):v_shape(2,3) &
00143                                              ,v_shape(1,4):v_shape(2,4)) &
00144                                       ,tindex=itime,blockid=id_blockid)
00145       else
00146         call mpp_read( unit,var,atmp(v_shape(1,1):v_shape(2,1) &
00147                                               ,v_shape(1,2):v_shape(2,2) &
00148                                              ,v_shape(1,3):v_shape(2,3) &
00149                                               ,v_shape(1,4):v_shape(2,4)) &
00150                                               , blockid=id_blockid)
00151       endif
00152       else
00153       if(time_used) then
00154         call mpp_read(unit,var,atmp(v_shape(1,1):v_shape(2,1) &
00155                                              ,v_shape(1,2):v_shape(2,2) &
00156                                              ,v_shape(1,3):v_shape(2,3) &
00157                                              ,v_shape(1,4):v_shape(2,4)) &
00158                                       ,tindex=itime)
00159       else
00160         call mpp_read( unit,var,atmp(v_shape(1,1):v_shape(2,1) &
00161                                               ,v_shape(1,2):v_shape(2,2) &
00162                                              ,v_shape(1,3):v_shape(2,3) &
00163                                               ,v_shape(1,4):v_shape(2,4)))
00164       endif
00165       endif
00166       endif
00167 
00168 !rv      a=atmp
00169       a(v_shape(1,1):v_shape(2,1)  &
00170        ,v_shape(1,2):v_shape(2,2)  &
00171        ,v_shape(1,3):v_shape(2,3)  &
00172        ,v_shape(1,4):v_shape(2,4)) = &
00173                                      atmp(v_shape(1,1):v_shape(2,1)  &
00174                                          ,v_shape(1,2):v_shape(2,2)  &
00175                                          ,v_shape(1,3):v_shape(2,3)  &
00176                                          ,v_shape(1,4):v_shape(2,4))
00177 
00178 
00179       deallocate(atmp,stat=ierror)
00180 
00181       if ( ierror /= 0 ) then
00182          ierrp (1) = 1
00183          ierror = PRISM_Error_Alloc
00184          call psmile_error ( ierror, 'deallocate(atmp)', ierrp, 1, __FILE__ &
00185                            , __LINE__ )
00186          return
00187       endif
00188 
00189 #ifdef VERBOSE
00190       print*,trim(ch_id),' :   psmile_read_4d_real: end'
00191       call psmile_flushstd
00192 
00193 #endif
00194 #endif
00195       end subroutine psmile_read_4d_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1