psmile_write_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_write_4d_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_write_4d_real(unit                &
00012                                      ,var                 &
00013                                      ,domain              &
00014                                      ,a                   &
00015                                      ,a_shape             &
00016                                      ,v_shape             &
00017                                      ,time                &
00018                                      ,time_used           &
00019                                      ,id_blockid          &
00020                                      ,block_used          &
00021                                      ,ierror)
00022 !
00023 ! !USES:
00024 !
00025       use psmile
00026 #ifdef __PSMILE_WITH_IO
00027       implicit none
00028       include 'prism.inc'
00029 !
00030 ! !INPUT PARAMETERS:
00031 !
00032       integer,intent(in) :: unit
00033       Type(fieldtype),intent(in) :: var
00034       Type(domain2D),intent(inout)  :: domain
00035       integer,intent(in) :: a_shape(2,*)
00036       integer,intent(in) :: v_shape(2,*)
00037       real            , intent(in) :: a(a_shape(1,1):a_shape(2,1)  
00038                                        ,a_shape(1,2):a_shape(2,2)  
00039                                        ,a_shape(1,3):a_shape(2,3)  
00040                                        ,a_shape(1,4):a_shape(2,4)) 
00041       double precision, intent(in) :: time
00042       logical,intent(in) :: time_used
00043       integer,intent(in) :: id_blockid
00044       logical,intent(in) :: block_used
00045 !
00046 ! !OUTPUT PARAMETERS:
00047 !
00048       integer, intent(out) :: ierror
00049 !
00050 ! !LOCAL VARIABLES:
00051 !
00052       double precision,allocatable    :: atmp(:,:,:,:)
00053       integer :: ierrp(2)
00054 !
00055 ! !DESCRIPTION:
00056 !
00057 ! Writes a real partitioned 4d array to a file.
00058 ! Subblocks are supported.
00059 !
00060 ! !REVISION HISTORY:
00061 !
00062 !   Date      Programmer   Description
00063 ! ----------  ----------   -----------
00064 !  09.12.03   R. Vogelsang created
00065 !
00066 !EOP
00067 !----------------------------------------------------------------------
00068 
00069       character(len=len_cvs_string),save :: mcvs = 
00070 '$Id: psmile_write_4d_real.F90 2325 2010-04-21 15:00:07Z valcke $'
00071       
00072       ierror=0
00073 
00074 #ifdef VERBOSE
00075       print*,trim(ch_id),' :   psmile_write_4d_real: start'
00076       print*,trim(ch_id),' :   psmile_write_4d_real: size ',size(a)
00077       call psmile_flushstd
00078 
00079 #endif
00080 
00081       allocate( atmp(a_shape(1,1):a_shape(2,1)  &
00082                     ,a_shape(1,2):a_shape(2,2)  &
00083                     ,a_shape(1,3):a_shape(2,3)  &
00084                     ,a_shape(1,4):a_shape(2,4)),stat=ierror)
00085 
00086       if ( ierror /= 0 ) then
00087          ierrp (1) = 1
00088          ierror = PRISM_Error_Alloc
00089          call psmile_error ( ierror, 'atmp', ierrp, 1, __FILE__, __LINE__ )
00090          return
00091       endif
00092 
00093       atmp=a
00094       if(block_used) then
00095       if(id_blockid.le.0) then
00096          ierror = PRISM_Error_Internal
00097          call psmile_error ( ierror, 'id_blockid <= 0! ', &
00098                              ierrp, 0, __FILE__, __LINE__ )
00099       endif
00100       if(time_used) then
00101         call mpp_write(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00102                                              ,v_shape(1,2):v_shape(2,2) &
00103                                              ,v_shape(1,3):v_shape(2,3) &
00104                                              ,v_shape(1,4):v_shape(2,4)) &
00105                                       ,tstamp=time,blockid=id_blockid)
00106       else
00107         call mpp_write( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00108                                               ,v_shape(1,2):v_shape(2,2) &
00109                                              ,v_shape(1,3):v_shape(2,3) &
00110                                               ,v_shape(1,4):v_shape(2,4)) &
00111                                               , blockid=id_blockid)
00112       endif
00113       else
00114       if(time_used) then
00115         call mpp_write(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00116                                              ,v_shape(1,2):v_shape(2,2) &
00117                                              ,v_shape(1,3):v_shape(2,3) &
00118                                              ,v_shape(1,4):v_shape(2,4)) &
00119                                       ,tstamp=time)
00120       else
00121         call mpp_write( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00122                                               ,v_shape(1,2):v_shape(2,2) &
00123                                              ,v_shape(1,3):v_shape(2,3) &
00124                                               ,v_shape(1,4):v_shape(2,4)))
00125       endif
00126       endif
00127       deallocate(atmp,stat=ierror)
00128 
00129       if ( ierror /= 0 ) then
00130          ierrp (1) = 1
00131          ierror = PRISM_Error_Alloc
00132          call psmile_error ( ierror, 'deallocate(atmp)', ierrp, 1, __FILE__ &
00133                            , __LINE__ )
00134          return
00135       endif
00136 #ifdef __PSMILE_IO_SYNC
00137       call mpp_flush(unit)
00138 #endif
00139 
00140 
00141 #ifdef VERBOSE
00142       print*,trim(ch_id),' :   psmile_write_4d_real: end'
00143       call psmile_flushstd
00144 
00145 #endif
00146 #endif
00147       end subroutine psmile_write_4d_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1