00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_write_3d_log(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
00024
00025
00026 use psmile
00027 #ifdef __PSMILE_WITH_IO
00028 implicit none
00029 include 'prism.inc'
00030
00031
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 logical , 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 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
00047
00048 integer, intent(out) :: ierror
00049
00050
00051
00052 integer::ierrp(2)
00053 integer::i,j,k
00054 double precision,allocatable :: atmp(:,:,:)
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 character(len=len_cvs_string),save :: mcvs =
00072 '$Id: psmile_write_3d_log.F90 2325 2010-04-21 15:00:07Z valcke $'
00073
00074 ierror=0
00075
00076 #ifdef VERBOSE
00077 print*,trim(ch_id),' : psmile_write_3d_log: start'
00078 print*,trim(ch_id),' : psmile_write_3d_log: size',size(a) &
00079 ,a_shape(1,1),a_shape(2,1),a_shape(1,2),a_shape(2,2) &
00080 ,a_shape(1,3),a_shape(2,3)
00081 call psmile_flushstd
00082 #endif
00083
00084
00085 allocate(atmp(a_shape(1,1):a_shape(2,1) &
00086 ,a_shape(1,2):a_shape(2,2) &
00087 ,a_shape(1,3):a_shape(2,3)),stat=ierror)
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
00097
00098
00099
00100 do k=a_shape(1,3),a_shape(2,3)
00101 do j=a_shape(1,2),a_shape(2,2)
00102 do i=a_shape(1,1),a_shape(2,1)
00103 if(a(i,j,k)) then
00104 atmp(i,j,k)=1
00105 else
00106 atmp(i,j,k)=0
00107 endif
00108 enddo
00109 enddo
00110 enddo
00111
00112 if(block_used) then
00113 if(id_blockid.le.0) then
00114 ierror = PRISM_Error_Internal
00115 call psmile_error ( ierror, 'id_blockid <= 0! ', &
00116 ierrp, 0, __FILE__, __LINE__ )
00117 endif
00118
00119 if(time_used) then
00120 call mpp_write(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00121 ,v_shape(1,2):v_shape(2,2) &
00122 ,v_shape(1,3):v_shape(2,3)) &
00123 ,tstamp=time,blockid=id_blockid)
00124 else
00125 call mpp_write( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00126 ,v_shape(1,2):v_shape(2,2) &
00127 ,v_shape(1,3):v_shape(2,3))&
00128 ,blockid=id_blockid)
00129 endif
00130 else
00131 if(time_used) then
00132 call mpp_write(unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00133 ,v_shape(1,2):v_shape(2,2) &
00134 ,v_shape(1,3):v_shape(2,3)) &
00135 ,tstamp=time)
00136 else
00137 call mpp_write( unit,var,domain,atmp(v_shape(1,1):v_shape(2,1) &
00138 ,v_shape(1,2):v_shape(2,2) &
00139 ,v_shape(1,3):v_shape(2,3)))
00140 endif
00141 endif
00142
00143 deallocate(atmp,stat=ierror)
00144
00145 if ( ierror /= 0 ) then
00146 ierrp (1) = 1
00147 ierror = PRISM_Error_Alloc
00148 call psmile_error ( ierror, 'deallocate(atmp)', ierrp, 1, __FILE__ &
00149 , __LINE__ )
00150 return
00151 endif
00152 #ifdef __PSMILE_IO_SYNC
00153 call mpp_flush(unit)
00154 #endif
00155
00156
00157 #ifdef VERBOSE
00158 print*,trim(ch_id),' : psmile_write_3d_log: end'
00159 call psmile_flushstd
00160
00161 #endif
00162 #endif
00163 end subroutine psmile_write_3d_log