psmile_write_meta_byid.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_meta_byid
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_write_meta_byid (id_varid,id_taskid,ierror)
00012 ! !USES:
00013       use prism_constants
00014       use psmile, dummy_interface => psmile_write_meta_byid
00015 #ifdef __PSMILE_WITH_IO
00016       use PRISM_calendar
00017       use psmile_io_utils
00018       use mpp_io_mod_oa, only: mpp_nullify_axistype_array
00019 #endif
00020       implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 !
00024       integer,intent(in)  :: id_varid
00025       integer,intent(in)  :: id_taskid
00026 !
00027 ! !OUTPUT PARAMETERS:
00028 !
00029       integer,intent(out) :: ierror
00030 !
00031 ! !LOCAL VARIABLES
00032 !
00033 #ifdef __PSMILE_WITH_IO
00034       integer :: ierrp(2)
00035       integer :: il,ih,jl,jh,kl,kh,kk,ll,lh,ii,il_i,jj,ilbl,ic,jc,kc,iloc,jloc
00036       integer :: il_grid_id,il_method_id,il_grid_type,iicomp_id,blkid,kkj
00037       integer :: len,lenaz,nvcomp,vcomp_id,vmsk_id(3),il_gridparam(3)
00038       integer :: il_date(6)
00039       integer :: lenb,no_of_blocks,il_id
00040       integer :: myashape(2,5)
00041       integer :: myvshape(2,5)
00042       integer :: il_pack
00043       integer :: fullsize
00044       integer :: len_alloc(3),nof(ndim_3d),ncells(ndim_3d),nvertices(ndim_3d) 
00045                  ,noc,stride
00046       logical :: is_bundle,is_regular, is_regvrt, lbackward
00047       real ,pointer :: lonr(:),latr(:),vertr(:)
00048       real ,pointer :: lonrb(:),latrb(:)
00049       real          ,pointer :: vertrb(:,:)
00050       real ,pointer :: bound_lonr(:,:,:)
00051       real ,pointer :: bound_latr(:,:,:)
00052       real ,pointer :: bound_vertr(:,:,:,:)
00053       double precision :: dl_time
00054       double precision,pointer :: lond(:),latd(:)
00055       double precision,pointer :: londb(:),latdb(:)
00056       double precision,pointer :: vertd(:)
00057       double precision,pointer :: vertdb(:,:)
00058       double precision,pointer :: bound_lond(:,:,:)
00059       double precision,pointer :: bound_latd(:,:,:)
00060       double precision,pointer :: bound_vertd(:,:,:,:)
00061       character(len=max_name) :: cl_field(3),cl_latij(3) 
00062                                 ,cl_lonij(3),cl_vertij(3) 
00063                                 ,cl_mskij(3),cl_crnij(3) 
00064                                 ,cl_subaij(3),cl_vert_longname(3) 
00065                                 ,cl_grid_longname(3)
00066       character(len=max_name) :: cl_timeunit
00067       character(len=4)        :: label
00068 
00069       Type fds
00070          double precision,pointer::fdble(:)
00071       End Type fds
00072       Type(fds),pointer::fdbles(:,:,:)
00073 
00074       Type frs
00075          real,pointer::freal(:)
00076       End Type frs
00077       Type(frs),pointer::freals(:,:,:)
00078       Type flgs
00079           logical,pointer::flog(:)
00080       End Type flgs
00081       Type(flgs),pointer::flogs(:,:)
00082 
00083       Type(PRISM_Time_Struct) :: ljobstart
00084       Type (Corner_Block), pointer :: corner_pointer
00085 #endif
00086 !
00087 ! !DESCRIPTION:
00088 ! For a prognostic field identified by id_varid this routine accomplishes 
00089 ! the following:
00090 !
00091 ! 1st) The routine declares the so-called axis of a NetCDF file.
00092 ! 2nd) Axis are assigned to field variables. Here, a field variable can
00093 !      be a set of longitudes,latitudes, vertical axis information
00094 !      masks and a prognostic  variable . The result is the 
00095 !      NetCDF CF header information or the so-called metadata information.
00096 ! 3rd) All data associated with the metadata of latitudes, longitudes,
00097 !      verticals and masks are written to the NetCDF CF file.
00098 !
00099 ! The routine supports scalar and vector fields and bundles of fields.
00100 ! Component of vector fields are assigned to different NetCDF variables.
00101 ! Thus it is possible to plot vector fields - which are 4d in general -
00102 ! with 3d plotting facilities.
00103 !
00104 ! For all of the types of prognostic variables mentioned above  GME-like
00105 ! blocked grids  are supported  where variables are assigned in a 
00106 ! round-robin fashion to blocks.
00107 !
00108 ! !REVISION HISTORY:
00109 !
00110 !   Date      Programmer   Description
00111 ! ----------  ----------   -----------
00112 ! 09.12.03    R. Vogelsang created
00113 ! 11.02.04    R. Vogelsang Modifications to use SMIOC related infos
00114 ! 04.03.01    R.Vogelsang  Added code to extract labels of bundles
00115 ! 23.3.04     R. Vogelsang Added the taskid to the interface and related code.
00116 ! 25.2.05     R. Vogelsang Corrrection of writing and extracting bounds
00117 !                  Bounds stored all vertices(1), all vertices(2)....
00118 ! 02.10.05    R. Vogelsang Added writing of vertical bounds and handling
00119 !              of Gaussian reduced grids.
00120 !
00121 ! 28.02.06    S. Valckes   prism.inc removed, replaced by prism_constants
00122 ! 04.03.06    R.Vogelsang  Sequence of writing corner points changed
00123 !                          to allow  reasonable plots. Nullify of
00124 !                          pointers and pointer substructures.
00125 !EOP
00126 !----------------------------------------------------------------------
00127 !
00128       Character(len=len_cvs_string), save :: mycvs = 
00129       '$Id: psmile_write_meta_byid.F90 2755 2010-11-19 15:19:52Z hanke $'
00130 
00131       ierror=0
00132 
00133 #ifdef __PSMILE_WITH_IO
00134 #ifdef VERBOSE
00135       print*,trim(ch_id),' :  psmile_write_meta_byid: start'
00136       call psmile_flushstd
00137 
00138 #endif
00139       
00140 !
00141 !     Not subject to I/O. Return!
00142 !
00143       if (.not.associated(Fields(id_varid)%io_chan_infos)) return
00144       
00145       Nullify (fdbles)
00146       Nullify (freals)
00147       Nullify (flogs)
00148       Nullify (bound_lonr)
00149       Nullify (bound_latr)
00150       Nullify (bound_vertr)
00151       Nullify (bound_lond)
00152       Nullify (bound_latd)
00153       Nullify (bound_vertd)
00154 !
00155 !     IO infos are pointing to io_chan_infos(taskid)
00156 !
00157       if(id_taskid .le. size(Fields(id_varid)%io_task_lookup)) then
00158 
00159         il_i=Fields(id_varid)%io_task_lookup(id_taskid)
00160 
00161       else
00162 
00163         ierror = PRISM_Error_IO_Meta
00164         ierrp (1) = id_taskid
00165         call psmile_error ( ierror &
00166                           , 'Task id out of range! ', &
00167                             ierrp, 1, __FILE__, __LINE__ )
00168         return
00169 
00170       endif
00171 
00172       if (il_i.gt.0) then
00173 
00174          Fields(id_varid)%io_infos =>  Fields(id_varid)%io_chan_infos(il_i)
00175 
00176       else
00177         ierror = PRISM_Error_IO_Meta
00178         ierrp (1) = id_taskid
00179         call psmile_error ( ierror &
00180                           , 'Negative task id! ', &
00181                             ierrp, 1, __FILE__, __LINE__ )
00182         return
00183       endif
00184 !
00185 !     The file is not considered for writing. Return!
00186 !
00187       if ( Fields(id_varid)%io_infos%action .ne.MPP_OVERWR) return
00188 !
00189 !     For GME grid only the last varid of the set of related varids
00190 !     does the writing of the meta data.
00191 !
00192       if(associated(Fields(id_varid)%io_infos%related_ids)) then
00193         fullsize=size(Fields(id_varid)%io_infos%related_ids)
00194         if(fullsize.gt.1) then
00195           do il_i=1,fullsize
00196            if(id_varid.eq. Fields(id_varid)%io_infos%related_ids(il_i)) exit 
00197           enddo
00198          if(il_i.lt.fullsize) return
00199         endif
00200       endif
00201 !     
00202 !     Last check: Is the file open?
00203 !
00204       if (.not. Fields(id_varid)%io_infos%opened) then
00205          ierror = PRISM_Error_IO_Meta
00206          ierrp (1) = ierror
00207          call psmile_error ( ierror &
00208                            , 'Attempt to write meta data to a non-open file', &
00209                              ierrp, 1, __FILE__, __LINE__ )
00210          return
00211       endif
00212 
00213 !
00214 !     Set the pelist for the current active component
00215 !
00216       iicomp_id=Fields(id_varid)%comp_id
00217       call mpp_set_current_pelist(IO_Comps_infos(iicomp_id)%pelist)
00218 
00219 !
00220 !     Allocate axis descriptors
00221 !
00222       
00223       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%x_axis)) then
00224           allocate(Fields(id_varid)%io_infos%p_mpp_io%x_axis(2),stat=ierror)
00225           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%x_axis)
00226           if (ierror > 0) then
00227              ierrp (1) = ierror
00228              ierrp (2) = 1
00229              ierror = PRISM_Error_Alloc
00230              call psmile_error ( ierror, 'x_axis', &
00231                              ierrp, 2, __FILE__, __LINE__ )
00232              return
00233           endif
00234       endif
00235 
00236 
00237       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%y_axis)) then
00238           allocate(Fields(id_varid)%io_infos%p_mpp_io%y_axis(1),stat=ierror)
00239           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%y_axis)
00240           if (ierror > 0) then
00241              ierrp (1) = ierror
00242              ierrp (2) = 1
00243              ierror = PRISM_Error_Alloc
00244              call psmile_error ( ierror, 'y_axis', &
00245                              ierrp, 2, __FILE__, __LINE__ )
00246              return
00247           endif
00248       endif
00249       
00250       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%z_axis)) then
00251           allocate(Fields(id_varid)%io_infos%p_mpp_io%z_axis(1),stat=ierror)
00252           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%z_axis)
00253           if (ierror > 0) then
00254              ierrp (1) = ierror
00255              ierrp (2) = 1
00256              ierror = PRISM_Error_Alloc
00257              call psmile_error ( ierror, 'z_axis', &
00258                              ierrp, 2, __FILE__, __LINE__ )
00259              return
00260           endif
00261       endif
00262 
00263       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%b_axis)) then
00264           allocate(Fields(id_varid)%io_infos%p_mpp_io%b_axis(1),stat=ierror)
00265           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%b_axis)
00266           if (ierror > 0) then
00267              ierrp (1) = ierror
00268              ierrp (2) = 1
00269              ierror = PRISM_Error_Alloc
00270              call psmile_error ( ierror, 'b_axis', &
00271                              ierrp, 2, __FILE__, __LINE__ )
00272              return
00273           endif
00274       endif
00275 
00276       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%blk_axis)) then
00277           allocate(Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1),stat=ierror)
00278           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%blk_axis)
00279           if (ierror > 0) then
00280              ierrp (1) = ierror
00281              ierrp (2) = 1
00282              ierror = PRISM_Error_Alloc
00283              call psmile_error ( ierror, 'blk_axis', &
00284                              ierrp, 2, __FILE__, __LINE__ )
00285              return
00286           endif
00287       endif
00288 
00289       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%t_axis)) then
00290           allocate(Fields(id_varid)%io_infos%p_mpp_io%t_axis(1),stat=ierror)
00291           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%t_axis)
00292           if (ierror > 0) then
00293              ierrp (1) = ierror
00294              ierrp (2) = 1
00295              ierror = PRISM_Error_Alloc
00296              call psmile_error ( ierror, 't_axis', &
00297                              ierrp, 2, __FILE__, __LINE__ )
00298              return
00299           endif
00300       endif
00301 
00302       if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%crnaxis)) then
00303           allocate(Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3),stat=ierror)
00304           call mpp_nullify_axistype_array(Fields(id_varid)%io_infos%p_mpp_io%crnaxis)
00305           if (ierror > 0) then
00306              ierrp (1) = ierror
00307              ierrp (2) = 1
00308              ierror = PRISM_Error_Alloc
00309              call psmile_error ( ierror, 'crnaxis(3)', &
00310                              ierrp, 2, __FILE__, __LINE__ )
00311              return
00312           endif
00313       endif
00314 
00315       if(.not.associated(Fields(id_varid)%io_infos%p_mpp_io%domain)) then
00316          ierrp (1) = id_varid
00317          ierrp (2) = 1
00318          ierror = PRISM_Error_Alloc
00319          call psmile_error ( ierror, 'domain not initialized!', &
00320                          ierrp, 2, __FILE__, __LINE__ )
00321          return
00322       endif
00323 !
00324 !     Get the global partition
00325 !
00326       call mpp_get_global_domain(Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
00327                                 ,xbegin=il,xend=ih         &
00328                                 ,ybegin=jl,yend=jh         )
00329 !
00330 !     Determine how many shape components of the grid where declared
00331 !
00332       
00333       il_grid_id =Methods(Fields(id_varid)%method_id)%grid_id
00334       il_grid_type=Grids(il_grid_id)%grid_type
00335       if ( il_grid_type == PRISM_unstructlonlatvrt) then
00336          len = 1
00337       else if ( il_grid_type == PRISM_unstructlonlat_sigmavrt .or. &
00338                 il_grid_type == PRISM_unstructlonlat_regvrt   ) then
00339          len = 2
00340       else if ( il_grid_type == PRISM_Gaussreduced_regvrt .or. &  
00341                 il_grid_type == PRISM_Gaussreduced_sigmavrt ) then
00342          len = 3
00343       else
00344          len = Grids(il_grid_id)%n_dim
00345       endif
00346 !------------------------------------------------------------------------------
00347 !
00348 !     Is the field a vector field or a scalar field ?
00349 !
00350       if(associated(Methods(Fields(id_varid)%method_id)%vector_pointer)) then
00351 !
00352 !     Allocate field descriptors. Vector fields have 3 components
00353 !     Anyway, use the statement below for the generality.
00354 !
00355         nvcomp=size(Methods(Fields(id_varid)%method_id) &
00356                    %vector_pointer%array_of_point_ids)
00357        is_bundle=.false.
00358 #ifdef VERBOSE
00359       print*,trim(ch_id),' :  psmile_write_meta_byid: Field(' &
00360             ,id_varid,') is vector field! nvcomp = ',nvcomp
00361       call psmile_flushstd
00362 #endif
00363       else ! Scalar field
00364 
00365         nvcomp=1
00366 !     
00367 !     Is the scalar field a bundle ?
00368 !       
00369         lenb=Fields(id_varid)%var_shape(2,len+1) &
00370             -Fields(id_varid)%var_shape(1,len+1)+1
00371         if(lenb.gt.1) then
00372           is_bundle=.true.
00373 #ifdef VERBOSE
00374       print*,trim(ch_id),' :  psmile_write_meta_byid: Field(' &
00375             ,id_varid,') is bundle! lenb = ',lenb
00376       call psmile_flushstd
00377 #endif
00378         else ! No bundle
00379           is_bundle=.false.
00380         endif
00381       endif
00382 
00383 !
00384 !     Allocate field descriptors for Fields(id_varid),lons,lats, verts 
00385 !     bounds and masks.
00386 !
00387         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%field)) &
00388             allocate(Fields(id_varid)%io_infos%p_mpp_io%field(nvcomp),stat=ierror)
00389         if (ierror > 0) then
00390            ierrp (1) = ierror
00391            ierrp (2) = 1
00392            ierror = PRISM_Error_Alloc
00393            call psmile_error ( ierror, 'field', &
00394                            ierrp, 2, __FILE__, __LINE__ )
00395            return
00396         endif
00397         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%latij)) &
00398             allocate(Fields(id_varid)%io_infos%p_mpp_io%latij(nvcomp),stat=ierror)
00399         if (ierror > 0) then
00400            ierrp (1) = ierror
00401            ierrp (2) = 1
00402            ierror = PRISM_Error_Alloc
00403            call psmile_error ( ierror, 'latij', &
00404                            ierrp, 2, __FILE__, __LINE__ )
00405            return
00406         endif
00407         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%lonij)) &
00408             allocate(Fields(id_varid)%io_infos%p_mpp_io%lonij(nvcomp),stat=ierror)
00409         if (ierror > 0) then
00410            ierrp (1) = ierror
00411            ierrp (2) = 1
00412            ierror = PRISM_Error_Alloc
00413            call psmile_error ( ierror, 'lonij', &
00414                            ierrp, 2, __FILE__, __LINE__ )
00415            return
00416         endif
00417         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%vertij)) &
00418             allocate(Fields(id_varid)%io_infos%p_mpp_io%vertij(nvcomp),stat=ierror)
00419         if (ierror > 0) then
00420            ierrp (1) = ierror
00421            ierrp (2) = 1
00422            ierror = PRISM_Error_Alloc
00423            call psmile_error ( ierror, 'vertij', &
00424                            ierrp, 2, __FILE__, __LINE__ )
00425            return
00426         endif
00427 
00428         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%maskij)) &
00429             allocate(Fields(id_varid)%io_infos%p_mpp_io%maskij(nvcomp),stat=ierror)
00430         if (ierror > 0) then
00431            ierrp (1) = ierror
00432            ierrp (2) = 1
00433            ierror = PRISM_Error_Alloc
00434            call psmile_error ( ierror, 'maskij', &
00435                            ierrp, 2, __FILE__, __LINE__ )
00436            return
00437         endif
00438 
00439         if (.not.associated(Fields(id_varid)%io_infos%p_mpp_io%crnij)) &
00440             allocate(Fields(id_varid)%io_infos%p_mpp_io%crnij(3),stat=ierror)
00441         if (ierror > 0) then
00442            ierrp (1) = ierror
00443            ierrp (2) = 1
00444            ierror = PRISM_Error_Alloc
00445            call psmile_error ( ierror, 'crnij(3)', &
00446                            ierrp, 2, __FILE__, __LINE__ )
00447            return
00448         endif
00449 !
00450 !      Define axis. Assumption is here that each of the vector
00451 !      components lives on the SAME grid indentified by grid_id.
00452 !
00453         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00454                            ,Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
00455                            ,'X','1','global index space for x' &
00456                            ,domain=Fields(id_varid)%io_infos%p_mpp_io%xdom(1) &
00457                            ,data=(/(il_i-0.d0,il_i=il,ih)/))
00458 !rr                        ,data=(/(il_i-1.d0,il_i=il,ih)/))
00459         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00460                            ,Fields(id_varid)%io_infos%p_mpp_io%y_axis(1) &
00461                            ,'Y','1','global index space for y' &
00462                            ,domain=Fields(id_varid)%io_infos%p_mpp_io%ydom(1) &
00463                            ,data=(/(il_i-0.d0,il_i=jl,jh)/))
00464 !rr                        ,data=(/(il_i-1.d0,il_i=jl,jh)/))
00465         if(len.eq.1) then
00466           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00467                            ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1) &
00468                            ,'Z','1','global index space for z' &
00469                            ,data=(/1.d0/))
00470         else
00471           lenaz=Fields(id_varid)%var_shape(2,len) &
00472                -Fields(id_varid)%var_shape(1,len)+1
00473           if(lenaz.gt.1) then
00474 !
00475 !         The user has declared the third dimension for a field!
00476 !
00477             kl=Grids(il_grid_id)%grid_shape(1,len)
00478             kh=Grids(il_grid_id)%grid_shape(2,len)
00479 #ifdef VERBOSE
00480       print*,trim(ch_id),' :  psmile_write_meta_byid: Field(' &
00481             ,id_varid,') has declared z-axis!',kl, kh
00482       call psmile_flushstd
00483 #endif
00484           else
00485             kl=1
00486             kh=1
00487           endif
00488           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00489                            ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1) &
00490                            ,'Z','1','global index space for z' &
00491                            ,data=(/(dble(real(il_i)),il_i=kl,kh)/))
00492           
00493         endif
00494 
00495         if(.not.is_bundle) then
00496 !
00497 !       Declare a 4th pseudo  axis for vector components. 
00498 !       Maybe, I need that for a future desgin where a vector field
00499 !       is written as 4d field.
00500 !
00501 !          ll=1
00502 !          lh=size(Methods(Fields(id_varid)%method_id)%vector_pointer &
00503 !                                                   %array_of_point_ids)
00504 !          call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00505 !                             ,Fields(id_varid)%io_infos%p_mpp_io%b_axis(1) &
00506 !                             ,'B','1','index space for vector components' &
00507 !                             ,data=(/(dble(il_i),il_i=ll,lh)/))
00508          else
00509 !
00510 !         Declare bundle axis
00511 !
00512           ll=1
00513           lh=lenb
00514 
00515           if(size(Fields(id_varid)%io_infos%labels).ne.lenb) then
00516             
00517             ierror=PRISM_Error_IO_Meta
00518             ierrp(1)=lenb
00519             ierrp(2)=size(Fields(id_varid)%io_infos%labels)
00520             call psmile_error(ierror,'Number oflabels given by SMIOC '// &
00521                               'does not match number of bundles!', &
00522                                ierrp,2, __FILE__, __LINE__)
00523           endif
00524 
00525           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00526                              ,Fields(id_varid)%io_infos%p_mpp_io%b_axis(1) &
00527                              ,'B','1','labels of the bundle components' &
00528                              ,cdata=(/(Fields(id_varid)%io_infos%labels(il_i) &
00529                                       ,il_i=ll,lh)/))
00530          endif
00531 !
00532 !        Declare a block index axis for GME style grids
00533 !
00534          no_of_blocks=1
00535          if(associated(Fields(id_varid)%io_infos%related_ids)) then
00536             no_of_blocks=size(Fields(id_varid)%io_infos%related_ids) 
00537             if(no_of_blocks .gt. 1) then
00538               ll=1
00539               lh=no_of_blocks
00540               call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00541                                  ,Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1) &
00542                                  ,'BLK','1','block indices' &
00543                                  ,data=(/(dble(real(il_i)),il_i=ll,lh)/))
00544             endif
00545          endif
00546 !
00547 !       Declare axis of bounds.
00548 !
00549         Nullify ( corner_pointer )
00550         corner_pointer => Grids(il_grid_id)%corner_pointer
00551 
00552         if(associated(corner_pointer%corners_real(1)%vector)) then
00553           len_alloc(1)=size(corner_pointer%corners_real(1)%vector)
00554         else if(associated(corner_pointer%corners_dble(1)%vector)) then
00555           len_alloc(1)=size(corner_pointer%corners_dble(1)%vector)
00556         else
00557           ierror=PRISM_Error_IO_Meta
00558           call psmile_error(ierror,'No corners specified!', &
00559                            ierrp,0, __FILE__, __LINE__)
00560         endif
00561 
00562         if(associated(corner_pointer%corners_real(2)%vector)) then
00563           len_alloc(2)=size(corner_pointer%corners_real(2)%vector)
00564         else if(associated(corner_pointer%corners_dble(2)%vector)) then
00565           len_alloc(2)=size(corner_pointer%corners_dble(2)%vector)
00566         else
00567           ierror=PRISM_Error_IO_Meta
00568           call psmile_error(ierror,'No corners specified!', &
00569                            ierrp,0, __FILE__, __LINE__)
00570         endif
00571 
00572         if(associated(corner_pointer%corners_real(3)%vector)) then
00573           len_alloc(3)=size(corner_pointer%corners_real(3)%vector)
00574         else if(associated(corner_pointer%corners_dble(3)%vector)) then
00575           len_alloc(3)=size(corner_pointer%corners_dble(3)%vector)
00576         else
00577           ierror=PRISM_Error_IO_Meta
00578           call psmile_error(ierror,'No corners specified!', &
00579                            ierrp,0, __FILE__, __LINE__)
00580         endif
00581 
00582         noc=corner_pointer%nbr_corners
00583 
00584         print*,'psmile_write_meta_byid: len_alloc',len_alloc
00585 
00586         select case ( Grids(il_grid_id)%grid_type )
00587   
00588         case ( PRISM_Irrlonlat_sigmavrt)
00589   
00590            nof(1:2) = noc/2
00591            nof(ndim_3d) = 2
00592 
00593            do jj=1,3
00594              ncells(jj)=len_alloc(jj)/nof(jj)
00595              nvertices(jj)=noc
00596            enddo
00597 
00598            ncells(1)=ncells(1)/(corner_pointer%corner_shape(2,2) - &
00599                                 corner_pointer%corner_shape(1,2)+1)
00600            ncells(2)=ncells(2)/(corner_pointer%corner_shape(2,1) - &
00601                                 corner_pointer%corner_shape(1,1)+1)
00602            nvertices(3)=nof(3)
00603 
00604            is_regvrt=.false.
00605   
00606         case ( PRISM_Irrlonlat_regvrt )
00607   
00608            nof(1:2)     = noc/2
00609            nof(ndim_3d) = 2
00610 
00611            do jj=1,3
00612              ncells(jj)=len_alloc(jj)/nof(jj)
00613              nvertices(jj)=noc
00614            enddo
00615 
00616            ncells(1)=ncells(1)/(corner_pointer%corner_shape(2,2) - &
00617                                 corner_pointer%corner_shape(1,2)+1)
00618            ncells(2)=ncells(2)/(corner_pointer%corner_shape(2,1) - &
00619                                 corner_pointer%corner_shape(1,1)+1)
00620            nvertices(3)=nof(3)
00621 
00622            is_regvrt=.true.
00623   
00624         case ( PRISM_Reglonlat_sigmavrt )
00625   
00626            nof(1:ndim_3d) = 2
00627 
00628            do jj=1,3
00629              ncells(jj)=len_alloc(jj)/nof(jj)
00630              nvertices(jj)=noc
00631            enddo
00632            nvertices(3)=nof(3)
00633 
00634 
00635 !RV           if(lenaz.eq.1) then
00636 !RV             do jj=1,2
00637 !RV               nvertices(jj)=max(nvertices(jj)/nof(jj),nof(jj))
00638 !RV             enddo
00639 !RV           endif
00640 
00641            is_regvrt=.false.
00642   
00643         case ( PRISM_Reglonlatvrt )
00644   
00645            nof(1:ndim_3d) = 2
00646 
00647            do jj=1,3
00648              ncells(jj)=len_alloc(jj)/nof(jj)
00649              nvertices(jj)=noc
00650            enddo
00651            nvertices(3)=nof(3)
00652 
00653 !RV           if(lenaz.eq.1) then
00654 !RV             do jj=1,2
00655 !RV               nvertices(jj)=max(nvertices(jj)/nof(jj),nof(jj))
00656 !RV             enddo
00657 !RV           endif
00658 
00659            is_regvrt=.true.
00660 
00661         case ( PRISM_Irrlonlatvrt )
00662   
00663            nof(1:ndim_3d) = noc
00664 
00665            do jj=1,3
00666              ncells(jj)=len_alloc(jj)/nof(jj) &
00667                                      /(corner_pointer%corner_shape(2,3) - &
00668                                        corner_pointer%corner_shape(1,3)+1)
00669              nvertices(jj)=noc
00670            enddo
00671            ncells(1)=ncells(1)/(corner_pointer%corner_shape(2,2) - &
00672                                 corner_pointer%corner_shape(1,2)+1)
00673            ncells(2)=ncells(2)/(corner_pointer%corner_shape(2,1) - &
00674                                 corner_pointer%corner_shape(1,1)+1)
00675            ncells(3)=(corner_pointer%corner_shape(2,3) - &
00676                       corner_pointer%corner_shape(1,3)+1)
00677            is_regvrt=.false.
00678   
00679         case ( PRISM_Unstructlonlatvrt )
00680   
00681            nof(1:ndim_3d) = noc
00682 
00683            do jj=1,3
00684              ncells(jj)=len_alloc(jj)/nof(jj)
00685              nvertices(jj)=noc
00686            enddo
00687            is_regvrt=.false.
00688   
00689         case ( PRISM_Unstructlonlat_regvrt )
00690   
00691            nof(1:2) = noc/2
00692            nof(ndim_3d) = 2
00693 
00694            do jj=1,3
00695              ncells(jj)=len_alloc(jj)/nof(jj)
00696              nvertices(jj)=noc
00697            enddo
00698   
00699            nvertices(3)=nof(3)
00700            is_regvrt=.true.
00701 
00702            ierrp (1) = Grids(il_grid_id)%grid_type
00703   
00704            ierror = PRISM_Error_Internal
00705   
00706            call psmile_error(ierror,'grid generation type not supported yet', &
00707                              ierrp, 1, __FILE__, __LINE__ )
00708            return
00709   
00710         case ( PRISM_Unstructlonlat_sigmavrt )
00711   
00712            nof(1:2) = noc/2
00713            nof(ndim_3d) = 2
00714 
00715            do jj=1,3
00716              ncells(jj)=len_alloc(jj)/nof(jj)
00717              nvertices(jj)=noc
00718            enddo
00719            nvertices(3)=nof(3)
00720            is_regvrt=.false.
00721   
00722   
00723         case ( PRISM_Gaussreduced_regvrt )
00724   
00725        nof(1:2)     = 2
00726            nof(ndim_3d) = 2
00727 
00728            do jj=1,3
00729              ncells(jj)=len_alloc(jj)/nof(jj)
00730              nvertices(jj)=noc
00731            enddo
00732   
00733            nvertices(3)=nof(3)
00734            is_regvrt=.true.
00735 
00736   
00737         case ( PRISM_Gaussreduced_sigmavrt )
00738   
00739            nof(1:2)     = 2
00740            nof(ndim_3d) = 2
00741 
00742            do jj=1,3
00743              ncells(jj)=len_alloc(jj)/nof(jj)
00744              nvertices(jj)=noc
00745            enddo
00746            nvertices(3)=nof(3)
00747            is_regvrt=.false.
00748   
00749   
00750         case DEFAULT
00751   
00752            ierrp (1) = Grids(il_grid_id)%grid_type
00753   
00754            ierror = PRISM_Error_Internal
00755   
00756            call psmile_error(ierror, 'unknown grid generation type', &
00757                                ierrp, 1, __FILE__, __LINE__ )
00758            return
00759   
00760         end select
00761 
00762         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00763                            ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(1) &
00764                           ,'NCORNERSLON','1','corner indices for longitudes' &
00765                           ,data=(/(dble(real(il_i)),il_i=1,nvertices(1))/))
00766         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00767                            ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(2) &
00768                           ,'NCORNERSLAT','1','corner indices for latitudes ' &
00769                           ,data=(/(dble(real(il_i)),il_i=1,nvertices(2))/))
00770         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00771                            ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3) &
00772                           ,'NCORNERSZ','1','corner indices for z' &
00773                           ,data=(/(dble(real(il_i)),il_i=1,nvertices(3))/))
00774 
00775         
00776 !
00777 !       Time axis
00778 !
00779         call psmile_io_get_jobstart_date(ljobstart,il_date,ierror) 
00780 !
00781 !       Remember the date as a Julian date in order to calculate the
00782 !       the offset  of a Gregorian time  stamp with respect to the 
00783 !       date of the job start.
00784 !
00785         call psmile_date2ju (ljobstart &
00786                             ,Fields(id_varid)%io_infos%ju_start_day &
00787                             ,Fields(id_varid)%io_infos%ju_start_sec)
00788         call combine_with_date('second','since',il_date,cl_timeunit)
00789 
00790         call mpp_write_meta( Fields(id_varid)%io_infos%file_unit &
00791                            , Fields(id_varid)%io_infos%p_mpp_io%t_axis(1) &
00792                            , 'time',trim(cl_timeunit), 'Time' )
00793 !--------------------------------------------------------------------------
00794 !
00795 !       NetCDF CF header informations
00796 !
00797 !
00798 !       Assign field components, lats, lons, verts and mask to axis
00799 !
00800         Select Case (il_grid_type)
00801         Case(PRISM_Reglonlatvrt)
00802           cl_vertij='regvert'
00803           cl_vert_longname='regular vertical'
00804           cl_grid_longname='PRISM_REGLONLATVRT'
00805           il_gridparam=PRISM_Reglonlatvrt
00806         Case(PRISM_Irrlonlat_regvrt)
00807           cl_vertij='regvert'
00808           cl_vert_longname='regular vertical'
00809           cl_grid_longname='PRISM_IRRLONLAT_REGVRT'
00810           il_gridparam=PRISM_Irrlonlat_regvrt
00811         Case(PRISM_Irrlonlatvrt)
00812           cl_vertij='irregvert'
00813           cl_vert_longname='irregular vertical'
00814           cl_grid_longname='PRISM_IRRLONLATVRT'
00815           il_gridparam=PRISM_Irrlonlat_regvrt
00816         Case(PRISM_Irrlonlat_sigmavrt)
00817           cl_vertij='sigmavert'
00818           cl_vert_longname='sigma vertical'
00819           cl_grid_longname='PRISM_IRRLONLAT_SIGMAVRT'
00820           il_gridparam=PRISM_Irrlonlat_sigmavrt
00821         Case(PRISM_Reglonlat_sigmavrt)
00822           cl_vertij='sigmavert'
00823           cl_vert_longname='sigma vertical'
00824           cl_grid_longname='PRISM_REGLONLAT_SIGMAVRT'
00825           il_gridparam=PRISM_Reglonlat_sigmavrt
00826         Case(PRISM_Unstructlonlat_regvrt)
00827           cl_vertij='regvert'
00828           cl_vert_longname='regular vertical'
00829           cl_grid_longname='PRISM_UNSTRUCTLONLAT_REGVRT'
00830           il_gridparam=PRISM_Unstructlonlat_regvrt
00831         Case(PRISM_Unstructlonlat_sigmavrt)
00832           cl_vertij='sigmavert'
00833           cl_vert_longname='sigma vertical'
00834           cl_grid_longname='PRISM_UNSTRUCTLONLAT_SIGMAVRT'
00835           il_gridparam=PRISM_Unstructlonlat_sigmavrt
00836         Case(PRISM_Unstructlonlatvrt)
00837           cl_vertij='unstructvert'
00838           cl_vert_longname='unstructured vertical'
00839           cl_grid_longname='PRISM_UNSTRUCTLONLATVRT'
00840           il_gridparam=PRISM_Unstructlonlatvrt
00841         Case(PRISM_Gaussreduced_regvrt)
00842           cl_vertij='regvert'
00843           cl_vert_longname='regular vertical'
00844           cl_grid_longname='PRISM_Gaussreduced_regvrt'
00845           il_gridparam=PRISM_Gaussreduced_regvrt
00846         Case(PRISM_Gaussreduced_sigmavrt)
00847           cl_vertij='sigmavrt'
00848           cl_vert_longname='sigma vertical'
00849           cl_grid_longname='PRISM_Gaussreduced_sigmavrt'
00850           il_gridparam=PRISM_Gaussreduced_sigmavrt
00851         Case DEFAULT
00852 
00853          ierror=PRISM_Error_IO_Meta
00854          ierrp(1)=il_grid_type
00855          call psmile_error(ierror,'Vector field on unkown grid type!', &
00856                            ierrp,1, __FILE__, __LINE__)
00857         End Select
00858 !
00859 !Header describing the grid type
00860 !
00861         print*,'il_gridparam',il_gridparam
00862         call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00863                        ,Fields(id_varid)%io_infos%p_mpp_io%x_axis(2) &
00864                            ,'PRISM_GRIDTYPE','1' &
00865                            ,trim(cl_grid_longname(1)) &
00866                            ,data=dble(il_gridparam(1:1)))
00867 !
00868 !       Header of bounds of longitudes and latitudes
00869 !
00870         if(associated(corner_pointer%corners_real(1)%vector)) then
00871           il_pack=2
00872         else if(associated(corner_pointer%corners_dble(1)%vector)) then
00873           il_pack=1
00874         endif
00875 
00876         if(il_grid_type.eq.PRISM_Unstructlonlatvrt .or. &
00877             il_grid_type .eq. PRISM_Gaussreduced_regvrt  .or. &  
00878             il_grid_type .eq. PRISM_Gaussreduced_sigmavrt  .or. &  
00879            il_grid_type.eq.PRISM_Unstructlonlat_sigmavrt ) then
00880           print*,'il_grid_type',il_grid_type
00881 
00882           is_regular=.FALSE.
00883 !
00884 !         For these grid types the assignment to the x axis
00885 !         serves as the information about the domain decomposition
00886 !         of the horizontal space.
00887 !
00888           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00889                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
00890                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(1) &
00891                         ,  Fields(id_varid)%io_infos%p_mpp_io%x_axis(1)    &
00892                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/)   &
00893                         ,  'bounds_lon','degrees_east','longitude' &
00894                         ,  pack=il_pack)
00895           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00896                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
00897                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(2) &
00898                         ,Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
00899                         ,Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/) &
00900                         ,  'bounds_lat','degrees_north','latitude' &
00901                         ,  pack=il_pack)
00902 
00903           if(is_regvrt) then
00904           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00905                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
00906                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3) &
00907                         ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/) &
00908                         ,  'bounds_'//trim(cl_vertij(1)) &
00909                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
00910                         ,  'bounds of '//trim(cl_vert_longname(1)) &
00911                         ,  pack=il_pack)
00912           else
00913           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00914                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
00915                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3) &
00916                         ,  Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
00917                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1) &
00918                         , Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/) &
00919                         ,  'bounds_'//trim(cl_vertij(1)) &
00920                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
00921                         ,  'bounds of '//trim(cl_vert_longname(1)) &
00922                         ,  pack=il_pack)
00923           endif 
00924         else if( il_grid_type.eq.PRISM_Irrlonlat_sigmavrt .or. &
00925                  il_grid_type.eq.PRISM_Irrlonlat_regvrt .or. &
00926                  il_grid_type.eq.PRISM_Irrlonlatvrt .or. &
00927                  il_grid_type.eq.PRISM_Reglonlat_sigmavrt .or. &
00928                  il_grid_type.eq.PRISM_Reglonlatvrt ) then
00929 
00930           is_regular=.TRUE.
00931 !
00932 !         For these grid types the rule is:
00933 !         Number of cells for longitudes is equal  to 
00934 !         the extent of the domain in x.
00935 !         Number of cells for latitudes is equal  to 
00936 !         the extent of the domain in y.
00937 !
00938 
00939           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00940                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
00941                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(1) &
00942                         ,  Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
00943                         ,Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/) &
00944                         ,  'bounds_lon','degrees_east','longitude' &
00945                         ,  pack=il_pack)
00946           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00947                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
00948                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(2) &
00949                         ,  Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
00950                         ,Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/) &
00951                         ,  'bounds_lat','degrees_north','latitude' &
00952                         ,  pack=il_pack)
00953 
00954           if(is_regvrt) then
00955           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00956                       ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
00957                       ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3) &
00958                       ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/)   &
00959                         ,  'bounds_'//trim(cl_vertij(1)) &
00960                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
00961                         ,  'bounds of '//trim(cl_vert_longname(1)) &
00962                         ,  pack=il_pack)
00963           else
00964           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
00965                         ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
00966                         ,(/Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3) &
00967                         ,  Fields(id_varid)%io_infos%p_mpp_io%x_axis(1)  &
00968                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)  &
00969                         ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/)  &
00970                         ,  'bounds_'//trim(cl_vertij(1)) &
00971                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
00972                         ,  'bounds of '//trim(cl_vert_longname(1)) &
00973                         ,  pack=il_pack)
00974            endif
00975 
00976          
00977         endif
00978 
00979         do ii=1,nvcomp
00980 
00981           vmsk_id(ii)=PRISM_UNDEFINED
00982           if(nvcomp.gt.1) then
00983             write(label,fmt='(i4.4)')ii
00984             cl_field(ii)=trim(Fields(id_varid)%io_infos%cfioname)//trim(label)
00985             cl_latij(ii)='lat'//trim(label)
00986             cl_lonij(ii)='lon'//trim(label)
00987             cl_vertij(ii)=trim(cl_vertij(ii))//trim(label)
00988             cl_vert_longname(ii)=trim(cl_vert_longname(ii))//' '//trim(label)
00989             cl_lonij(ii)='mask'//trim(label)
00990             vcomp_id=Methods(Fields(id_varid)%method_id)%vector_pointer &
00991                     %array_of_point_ids(ii)
00992 !
00993           else
00994 !
00995             cl_field(ii)=trim(Fields(id_varid)%io_infos%cfioname)
00996             cl_latij(ii)='lat'
00997             cl_lonij(ii)='lon'
00998             cl_mskij(ii)='mask'
00999             vcomp_id=Fields(id_varid)%method_id
01000             vmsk_id(ii)=Fields(id_varid)%mask_id
01001 !
01002           endif
01003 
01004 !
01005 !         I assume that lons comes first, then lats and verts.
01006 !         Pack modes are determined by the informations passed through
01007 !         the PSMILe API.
01008 !
01009 !         Header of the Longitudes
01010 !
01011           if(associated( &
01012              Methods(vcomp_id)%coords_pointer%coords_real(1)%vector)) then
01013              il_pack=2
01014           else
01015              il_pack=1
01016           endif
01017 
01018           if((il_grid_type .eq. PRISM_Unstructlonlatvrt) .or. &
01019              (il_grid_type .eq. PRISM_Irrlonlatvrt)) then
01020           if(no_of_blocks.eq.1) then
01021             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01022                         ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
01023                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01024                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01025                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/)   &
01026                         ,  trim(cl_lonij(ii)),'degrees_east','longitude' &
01027                         ,  pack=il_pack)
01028           else if(no_of_blocks .gt. 1) then
01029             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01030                         ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
01031                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01032                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01033                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01034                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/)   &
01035                         ,  trim(cl_lonij(ii)),'degrees_east','longitude' &
01036                         ,  pack=il_pack)
01037           endif
01038           else
01039           if(no_of_blocks.eq.1) then
01040             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01041                         ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
01042                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01043                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/)   &
01044                         ,  trim(cl_lonij(ii)),'degrees_east','longitude' &
01045                         ,  pack=il_pack)
01046           else if(no_of_blocks .gt. 1) then
01047             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01048                         ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
01049                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01050                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01051                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/)   &
01052                         ,  trim(cl_lonij(ii)),'degrees_east','longitude' &
01053                         ,  pack=il_pack)
01054           endif
01055           endif
01056 !
01057 !         Set the attribute bounds for the longitudes
01058 !
01059           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01060                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%lonij(ii)) &
01061                     ,'bounds' &
01062                     ,cval=trim('bounds_lon'))
01063 
01064 !
01065 !         Header of the Latitudes
01066 !
01067           if(associated( &
01068              Methods(vcomp_id)%coords_pointer%coords_real(2)%vector)) then
01069              il_pack=2
01070           else
01071              il_pack=1
01072           endif
01073           if((il_grid_type .eq. PRISM_Unstructlonlatvrt) .or. &
01074              (il_grid_type .eq. PRISM_Irrlonlatvrt)) then
01075           if(no_of_blocks.eq.1) then
01076             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01077                         ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
01078                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01079                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01080                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/) &
01081                         ,  trim(cl_latij(ii)),'degrees_north','latitude' &
01082                         ,  pack=il_pack)
01083           else if(no_of_blocks .gt. 1) then
01084             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01085                         ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
01086                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01087                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01088                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01089                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/) &
01090                         ,  trim(cl_latij(ii)),'degrees_north','latitude' &
01091                         ,  pack=il_pack)
01092           endif
01093           else
01094           if(no_of_blocks.eq.1) then
01095             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01096                         ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
01097                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01098                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)/) &
01099                         ,  trim(cl_latij(ii)),'degrees_north','latitude' &
01100                         ,  pack=il_pack)
01101           else if(no_of_blocks .gt. 1) then
01102             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01103                         ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
01104                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01105                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01106                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/) &
01107                         ,  trim(cl_latij(ii)),'degrees_north','latitude' &
01108                         ,  pack=il_pack)
01109           endif
01110           endif
01111 !
01112 !         Set the attribute bounds for the latitudes.
01113 !
01114           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01115                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%latij(ii)) &
01116                     ,'bounds' &
01117                     ,cval=trim('bounds_lat'))
01118 !
01119 !         Header of the Verticals
01120 !
01121           if(associated( &
01122              Methods(vcomp_id)%coords_pointer%coords_real(3)%vector)) then
01123              il_pack=2
01124           else
01125              il_pack=1
01126           endif
01127           if((il_grid_type .eq. PRISM_Unstructlonlatvrt) .or. &
01128              (il_grid_type .eq. PRISM_Irrlonlatvrt)) then
01129           if(no_of_blocks.eq.1) then
01130             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01131                         ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
01132                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01133                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01134                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/)   &
01135                         ,  trim(cl_vertij(ii))                   &
01136                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
01137                         ,  trim(cl_vert_longname(ii)) &
01138                         ,  pack=il_pack)
01139           else if(no_of_blocks .gt. 1) then
01140             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01141                         ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
01142                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01143                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01144                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01145                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/)   &
01146                         ,  trim(cl_vertij(ii))                   &
01147                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
01148                         ,  trim(cl_vert_longname(ii)) &
01149                         ,  pack=il_pack)
01150           endif
01151           else
01152           if(no_of_blocks.eq.1) then
01153             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01154                         ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
01155                         ,(/Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/) &
01156                         ,  trim(cl_vertij(ii))                   &
01157                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
01158                         ,  trim(cl_vert_longname(ii)) &
01159                         ,  pack=il_pack)
01160           else if(no_of_blocks .gt. 1) then
01161             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01162                         ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
01163                         ,(/Fields(id_varid)%io_infos%p_mpp_io%z_axis(1) &
01164                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/)   &
01165                         ,  trim(cl_vertij(ii))                   &
01166                         ,  trim(Fields(id_varid)%io_infos%height_unit) &
01167                         ,  trim(cl_vert_longname(ii)) &
01168                         ,  pack=il_pack)
01169           endif
01170           endif
01171 !
01172 !         Add the standard name to the vertical
01173 !
01174           if(trim(adjustl(Fields(id_varid)%io_infos%height_stdname)) &
01175              .ne. '') then
01176           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01177                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%vertij(ii)) &
01178                     ,'standard_name' &
01179                     ,cval=trim(Fields(id_varid)%io_infos%height_stdname))
01180           endif
01181           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01182                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%vertij(ii)) &
01183                     ,'positive' &
01184                     ,cval=trim(Fields(id_varid)%io_infos%positive))
01185 
01186 !
01187 !         Add the formular terms to the attributes of the verticals
01188 !
01189           if(trim(adjustl(Fields(id_varid)%io_infos%height_formular)) &
01190              .ne. '' ) then
01191 
01192             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01193                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%vertij(ii)) &
01194                     ,'formula_terms' &
01195                     ,cval=trim(Fields(id_varid)%io_infos%height_formular))
01196 
01197           endif
01198 !
01199 !         Set the attribute bounds for the vertical.
01200 !
01201           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01202                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%vertij(ii)) &
01203                     ,'bounds' &
01204                     ,cval='bounds_'//trim(cl_vertij(ii)))
01205 !
01206 !         Header of Masks
01207 !
01208 !         Masks are always 3d arrays. Assign all 3 spatial axis to masks.
01209 !         I am writing mask as FLOAT  0. = .FALSE., 1.=.TRUE.
01210 !
01211           if(vmsk_id(ii).ne.PRISM_UNDEFINED) then
01212           il_pack=2
01213           if(no_of_blocks.eq.1) then
01214             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01215                         ,Fields(id_varid)%io_infos%p_mpp_io%maskij(ii) &
01216                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01217                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01218                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)/)   &
01219                         ,  trim(cl_mskij(ii)),'1','mask' &
01220                         ,  pack=il_pack)
01221           else if(no_of_blocks .gt. 1) then
01222             call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01223                         ,Fields(id_varid)%io_infos%p_mpp_io%maskij(ii) &
01224                         ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01225                         ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01226                         ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01227                         ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)/)   &
01228                         ,  trim(cl_mskij(ii)),'1','mask' &
01229                         ,  pack=il_pack)
01230           endif
01231           endif
01232 
01233 !
01234 !        Header of the Field
01235 !
01236 !rv
01237           il_pack=Fields(id_varid)%io_infos%pack_mode
01238 !rv       The following coherence is performed in psmile_io_get_attr.F90
01239 !rv          il_pack=1
01240 !rv          select case(Fields(id_varid)%datatype)
01241 !rv          case(PRISM_Integer)
01242 !rv            il_pack=2
01243 !rv          case(PRISM_Logical)
01244 !rv            il_pack=2
01245 !rv          case(PRISM_Real)
01246 !rv            il_pack=2
01247 !rv            if(Fields(id_varid)%io_infos%pack_mode .gt. il_pack) then
01248 !rv              print*,trim(ch_id),' :  psmile_write_meta_byid: Warning:' &
01249 !rv              ,'SMIOC pack mode not consistent with PRISM_Real'
01250 !rv            endif
01251 !rv          case(PRISM_Double_Precision)
01252 !rv            il_pack=1
01253 !rv            if(Fields(id_varid)%io_infos%pack_mode .gt. il_pack) then
01254 !rv              print*,trim(ch_id),' :  psmile_write_meta_byid: Warning:' &
01255 !rv              ,'SMIOC pack mode not consistent with PRISM_Double_Precision'
01256 !rv            endif
01257 !rv          case DEFAULT
01258 !rv           ierrp (1) = Fields(id_varid)%datatype
01259 !rv           ierrp (2) = 1
01260 !rv           ierror =  PRISM_Error_IO_Meta
01261 !rv           call PSMILe_Error ( ierror, 'Data type not yet supported!', &
01262 !rv                           ierrp, 1, __FILE__, __LINE__ )
01263 !rv           return
01264 !rv
01265 !rv          end select
01266 
01267           if(.not.is_bundle) then
01268             if(no_of_blocks.eq.1) then
01269               call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01270                           ,Fields(id_varid)%io_infos%p_mpp_io%field(ii) &
01271                           ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01272                           ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01273                           ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01274                           ,  Fields(id_varid)%io_infos%p_mpp_io%t_axis(1)/) &
01275                           ,  trim(cl_field(ii))                    &
01276                           ,  trim(Fields(id_varid)%io_infos%units) &
01277                           ,  trim(Fields(id_varid)%io_infos%long_name) &
01278                           ,  min=Fields(id_varid)%io_infos%valid_min &
01279                           ,  max=Fields(id_varid)%io_infos%valid_max &
01280                           ,  missing=Fields(id_varid)%io_infos%missing_value &
01281                           ,  fill=Fields(id_varid)%io_infos%fill_value &
01282                           ,  scale=Fields(id_varid)%io_infos%scale &
01283                           ,  add=Fields(id_varid)%io_infos%add &
01284                           ,  pack=il_pack )
01285              call psmile_flushstd
01286             else if(no_of_blocks .gt. 1) then
01287               call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01288                           ,Fields(id_varid)%io_infos%p_mpp_io%field(ii) &
01289                           ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01290                           ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01291                           ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01292                           ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1)   &
01293                           ,  Fields(id_varid)%io_infos%p_mpp_io%t_axis(1)/) &
01294                           ,  trim(cl_field(ii))                    &
01295                           ,  trim(Fields(id_varid)%io_infos%units) &
01296                           ,  trim(Fields(id_varid)%io_infos%long_name) &
01297                           ,  min=Fields(id_varid)%io_infos%valid_min &
01298                           ,  max=Fields(id_varid)%io_infos%valid_max &
01299                           ,  missing=Fields(id_varid)%io_infos%missing_value &
01300                           ,  fill=Fields(id_varid)%io_infos%fill_value &
01301                           ,  scale=Fields(id_varid)%io_infos%scale &
01302                           ,  add=Fields(id_varid)%io_infos%add &
01303                           ,  pack=il_pack)
01304             endif
01305           else
01306             if(no_of_blocks.eq.1) then
01307               call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01308                           ,Fields(id_varid)%io_infos%p_mpp_io%field(ii) &
01309                           ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01310                           ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01311                           ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01312                           ,  Fields(id_varid)%io_infos%p_mpp_io%b_axis(1) &
01313                           ,  Fields(id_varid)%io_infos%p_mpp_io%t_axis(1)/) &
01314                           ,  trim(cl_field(ii))                    &
01315                           ,  trim(Fields(id_varid)%io_infos%units) &
01316                           ,  trim(Fields(id_varid)%io_infos%long_name) &
01317                           ,  min=Fields(id_varid)%io_infos%valid_min &
01318                           ,  max=Fields(id_varid)%io_infos%valid_max &
01319                           ,  missing=Fields(id_varid)%io_infos%missing_value &
01320                           ,  fill=Fields(id_varid)%io_infos%fill_value &
01321                           ,  scale=Fields(id_varid)%io_infos%scale &
01322                           ,  add=Fields(id_varid)%io_infos%add &
01323                           ,  pack=Fields(id_varid)%io_infos%pack_mode )
01324             else if(no_of_blocks .gt. 1) then
01325               call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01326                           ,Fields(id_varid)%io_infos%p_mpp_io%field(ii) &
01327                           ,(/Fields(id_varid)%io_infos%p_mpp_io%x_axis(1) &
01328                           ,  Fields(id_varid)%io_infos%p_mpp_io%y_axis(1)   &
01329                           ,  Fields(id_varid)%io_infos%p_mpp_io%z_axis(1)   &
01330                           ,  Fields(id_varid)%io_infos%p_mpp_io%b_axis(1) &
01331                           ,  Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1) &
01332                           ,  Fields(id_varid)%io_infos%p_mpp_io%t_axis(1)/) &
01333                           ,  trim(cl_field(ii))                    &
01334                           ,  trim(Fields(id_varid)%io_infos%units) &
01335                           ,  trim(Fields(id_varid)%io_infos%long_name) &
01336                           ,  min=Fields(id_varid)%io_infos%valid_min &
01337                           ,  max=Fields(id_varid)%io_infos%valid_max &
01338                           ,  missing=Fields(id_varid)%io_infos%missing_value &
01339                           ,  fill=Fields(id_varid)%io_infos%fill_value &
01340                           ,  scale=Fields(id_varid)%io_infos%scale &
01341                           ,  add=Fields(id_varid)%io_infos%add &
01342                           ,  pack=Fields(id_varid)%io_infos%pack_mode )
01343             endif
01344           endif
01345           if(nvcomp.eq.1) then
01346           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01347                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%field(ii)) &
01348                              ,'standard_name' &
01349                           ,cval=trim(Fields(id_varid)%io_infos%standard_name))
01350           else
01351           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01352                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%field(ii)) &
01353                              ,'standard_name' &
01354                           ,cval=trim(Fields(id_varid)%io_infos%vcmp_names(ii)))
01355           endif
01356           call mpp_write_meta(Fields(id_varid)%io_infos%file_unit &
01357                     ,mpp_get_id(Fields(id_varid)%io_infos%p_mpp_io%field(ii)) &
01358                              ,'coordinates' &
01359                              ,cval=trim(cl_lonij(ii))//' '//trim(cl_latij(ii)) &
01360                                   //' '//trim(cl_vertij(ii)) )
01361           
01362           
01363         enddo
01364         
01365 
01366         
01367 !
01368 !-----------------------------------------------------------------------------
01369 !    Here is the end of the NetCDF header section.
01370 !
01371 !    Now dump the x_axis,y_axis,z_axis,lons, lats, the verts &
01372 !    and masks - if any - to the file.
01373 !
01374 !
01375 !    The common axis
01376 !
01377 !       X
01378         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01379                       ,Fields(id_varid)%io_infos%p_mpp_io%x_axis(1))
01380 !       Y
01381         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01382                       ,Fields(id_varid)%io_infos%p_mpp_io%y_axis(1))
01383 !       Z
01384         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01385                       ,Fields(id_varid)%io_infos%p_mpp_io%z_axis(1))
01386 !       NVERTICES
01387         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01388                       ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(1))
01389         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01390                       ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(2))
01391         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01392                       ,Fields(id_varid)%io_infos%p_mpp_io%crnaxis(3))
01393 !       PRISM_GRIDTYPE
01394         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01395                       ,Fields(id_varid)%io_infos%p_mpp_io%x_axis(2))
01396         
01397 !       B
01398         if(is_bundle) then
01399         call mpp_write(Fields(id_varid)%io_infos%file_unit &
01400                       ,Fields(id_varid)%io_infos%p_mpp_io%b_axis(1))
01401         endif
01402 !      BLOCK
01403        if(no_of_blocks.gt.1) then
01404          call mpp_write(Fields(id_varid)%io_infos%file_unit &
01405                       ,Fields(id_varid)%io_infos%p_mpp_io%blk_axis(1))
01406          myashape(1,4)=1
01407          myashape(2,4)=no_of_blocks
01408          myvshape(1,4)=1
01409          myvshape(2,4)=no_of_blocks
01410 !
01411 !        Stitching together the blocks of lons, lats and verts
01412 !
01413          allocate(fdbles(no_of_blocks,nvcomp,3),stat=ierror)
01414          if (ierror > 0) then
01415             ierrp (1) = ierror
01416             ierrp (2) = 1
01417             ierror = PRISM_Error_Alloc
01418             call psmile_error ( ierror, 'fdbles', &
01419                             ierrp, 2, __FILE__, __LINE__ )
01420             return
01421          endif
01422 !
01423          allocate(freals(no_of_blocks,nvcomp,3),stat=ierror)
01424          if (ierror > 0) then
01425             ierrp (1) = ierror
01426             ierrp (2) = 1
01427             ierror = PRISM_Error_Alloc
01428             call psmile_error ( ierror, 'freals', &
01429                             ierrp, 2, __FILE__, __LINE__ )
01430             return
01431          endif
01432 
01433          allocate(flogs(no_of_blocks,nvcomp),stat=ierror)
01434          if (ierror > 0) then
01435             ierrp (1) = ierror
01436             ierrp (2) = 1
01437             ierror = PRISM_Error_Alloc
01438             call psmile_error ( ierror, 'flogs', &
01439                             ierrp, 2, __FILE__, __LINE__ )
01440             return
01441          endif
01442 !
01443          do ii=1,nvcomp
01444            do jj=1,no_of_blocks
01445              il_id=Fields(id_varid)%io_infos%related_ids(jj)
01446              blkid=Fields(il_id)%io_infos%block_id
01447 
01448              vmsk_id(ii)=PRISM_UNDEFINED
01449              if(nvcomp.gt.1) then
01450                vcomp_id=Methods(Fields(il_id)%method_id)%vector_pointer &
01451                      %array_of_point_ids(ii)
01452              else
01453                vcomp_id=Fields(il_id)%method_id
01454                vmsk_id(ii) =Fields(il_id)%mask_id
01455              endif
01456 
01457 #ifdef VERBOSE
01458       print*,trim(ch_id),' :  psmile_write_meta_byid: Stitching blocks:' &
01459             ,'vector component, block, block_id :',ii,jj,blkid
01460       call psmile_flushstd
01461 #endif
01462              if(associated( &
01463                 Methods(vcomp_id)%coords_pointer%coords_dble(1)%vector))then 
01464                 fdbles(blkid,ii,1)%fdble => Methods(vcomp_id)%coords_pointer &
01465                                                           %coords_dble(1)%vector
01466              else if(associated( &
01467                 Methods(vcomp_id)%coords_pointer%coords_real(1)%vector))then
01468                 freals(blkid,ii,1)%freal => Methods(vcomp_id)%coords_pointer &
01469                                                           %coords_real(1)%vector
01470              endif
01471              if(associated( &
01472                 Methods(vcomp_id)%coords_pointer%coords_dble(2)%vector))then 
01473                 fdbles(blkid,ii,2)%fdble => Methods(vcomp_id)%coords_pointer &
01474                                                           %coords_dble(2)%vector
01475              else if(associated( &
01476                 Methods(vcomp_id)%coords_pointer%coords_real(2)%vector))then
01477                 freals(blkid,ii,2)%freal => Methods(vcomp_id)%coords_pointer &
01478                                                           %coords_real(2)%vector
01479              endif
01480              if(associated( &
01481                 Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector))then 
01482                 fdbles(blkid,ii,3)%fdble => Methods(vcomp_id)%coords_pointer &
01483                                                           %coords_dble(3)%vector
01484              else if(associated( &
01485                 Methods(vcomp_id)%coords_pointer%coords_real(3)%vector))then
01486                 freals(blkid,ii,3)%freal => Methods(vcomp_id)%coords_pointer &
01487                                                           %coords_real(3)%vector
01488              endif
01489              if(vmsk_id(ii).ne.PRISM_UNDEFINED) then
01490                flogs(blkid,ii)%flog => Masks(vmsk_id(ii))%mask_array
01491              endif
01492            enddo
01493          enddo
01494        endif
01495 !
01496 !      Writing the bounds for longitudes and latitudes
01497 !
01498        if(associated(corner_pointer%corners_real(1)%vector)) then
01499 
01500          if(is_regular) then
01501            allocate(bound_lonr(nvertices(1),ncells(1),ncells(2)),stat=ierror)
01502            if (ierror > 0) then
01503               ierrp (1) = ierror
01504               ierrp (2) = 1
01505               ierror = PRISM_Error_Alloc
01506               call psmile_error ( ierror, 'bound_lonr', &
01507                               ierrp, 2, __FILE__, __LINE__ )
01508               return
01509            endif
01510   
01511            allocate(bound_latr(nvertices(2),ncells(1),ncells(2)),stat=ierror)
01512            if (ierror > 0) then
01513               ierrp (1) = ierror
01514               ierrp (2) = 1
01515               ierror = PRISM_Error_Alloc
01516               call psmile_error ( ierror, 'bound_latr', &
01517                               ierrp, 2, __FILE__, __LINE__ )
01518               return
01519            endif
01520 
01521            if (lenaz .gt. 1) then
01522              if(is_regvrt) then
01523                allocate(bound_vertr(nvertices(3),ncells(3),1,1) &
01524                    ,stat=ierror)
01525               else
01526                 allocate(bound_vertr(nvertices(3),ncells(1),ncells(2) &
01527                         ,ncells(3)) ,stat=ierror)
01528               endif
01529            if (ierror > 0) then
01530               ierrp (1) = ierror
01531               ierrp (2) = 1
01532               ierror = PRISM_Error_Alloc
01533               call psmile_error ( ierror, 'bound_latr', &
01534                               ierrp, 2, __FILE__, __LINE__ )
01535               return
01536            endif
01537            endif
01538 !
01539          else
01540 !
01541            allocate(bound_lonr(nvertices(1),ncells(1),1),stat=ierror)
01542            if (ierror > 0) then
01543               ierrp (1) = ierror
01544               ierrp (2) = 1
01545               ierror = PRISM_Error_Alloc
01546               call psmile_error ( ierror, 'bound_lonr', &
01547                               ierrp, 2, __FILE__, __LINE__ )
01548               return
01549            endif
01550   
01551            allocate(bound_latr(nvertices(2),ncells(2),1),stat=ierror)
01552            if (ierror > 0) then
01553               ierrp (1) = ierror
01554               ierrp (2) = 1
01555               ierror = PRISM_Error_Alloc
01556               call psmile_error ( ierror, 'bound_latr', &
01557                               ierrp, 2, __FILE__, __LINE__ )
01558               return
01559            endif
01560 
01561            if (lenaz .gt. 1) then
01562            allocate(bound_vertr(nvertices(3),ncells(3),1,1) &
01563                    ,stat=ierror)
01564            if (ierror > 0) then
01565               ierrp (1) = ierror
01566               ierrp (2) = 1
01567               ierror = PRISM_Error_Alloc
01568               call psmile_error ( ierror, 'bound_latr', &
01569                               ierrp, 2, __FILE__, __LINE__ )
01570               return
01571            endif
01572            endif
01573 !
01574          endif
01575 
01576 #ifdef DEBUG
01577      print*,trim(ch_id),' :  psmile_write_meta_byid: ','is_regular ',is_regular
01578      print*,trim(ch_id),' :  psmile_write_meta_byid: '  &
01579               ,'ih-il+1,jh-jl+1,nvertices(1),ncells(1),nvertices(2),ncells(2)' &
01580               ,ih-il+1,jh-jl+1,nvertices(1),ncells(1),nvertices(2),ncells(2)
01581      print*,trim(ch_id),' :  psmile_write_meta_byid: ' &
01582                        ,'corner_pointer%corner_shape ' &
01583                        ,corner_pointer%corner_shape
01584       call psmile_flushstd
01585 #endif
01586 !
01587 !        Branch for all logical rectangular grids
01588 !
01589          if(is_regular) then
01590 
01591            if( il_grid_type == PRISM_Reglonlatvrt .or.  &
01592                il_grid_type == PRISM_Reglonlat_sigmavrt ) then
01593 
01594              lbackward=.false.
01595              do iloc=1,ncells(2)
01596                do ii=1,ncells(1)
01597                  ll=0
01598                do jj=1,nvertices(1)/nof(1)
01599                  lbackward=mod(jj-1,2).eq.0
01600                  if(.not.lbackward)then
01601                    do kk=1,nof(1)
01602                      ll=ll+1
01603                      bound_lonr(ll,ii,iloc)= &
01604                      corner_pointer%corners_real(1)%vector((kk-1)*ncells(1)+ii)
01605                    enddo
01606                  else
01607                    do kk=nof(1),1,-1
01608                      ll=ll+1
01609                      bound_lonr(ll,ii,iloc)= &
01610                      corner_pointer%corners_real(1)%vector((kk-1)*ncells(1)+ii)
01611                    enddo
01612                  endif
01613                enddo
01614               enddo
01615              enddo
01616   
01617              kkj=0
01618              do iloc=1,ncells(1)
01619                do ii=1,ncells(2)
01620                  ll=0
01621                  do jj=1,nvertices(2)/nof(2)
01622                    kkj=kkj+1
01623                    do kk=1,nof(2)
01624                      ll=ll+1
01625                      bound_latr(ll,iloc,ii)= &
01626                      corner_pointer%corners_real(2)%vector((kkj-1)*ncells(2)+ii)
01627                    enddo
01628                    if(kkj.eq.nof(2))kkj=0
01629                  enddo
01630 
01631                enddo
01632              enddo
01633 
01634            else
01635 
01636              stride = ncells(1)*ncells(2)
01637 
01638              ii = 0
01639              do jl=1,ncells(2)
01640                 do il=1,ncells(1)
01641                    ii = ii + 1
01642                    ll=0
01643                    do jj=1,nvertices(1)/nof(1)
01644                       do kk=1,nof(1)
01645                          ll=ll+1
01646                          bound_lonr(ll,il,jl)= &
01647                          corner_pointer%corners_real(1)%vector((kk-1)*stride+ii)
01648                       enddo
01649                    enddo
01650                 enddo
01651              enddo
01652 
01653              stride = ncells(1)*ncells(2)
01654 
01655              ii = 0
01656              do jl=1,ncells(2)
01657                 do il=1,ncells(1)
01658                    ii = ii + 1
01659                    ll = 0
01660                    do jj=1,nvertices(2)/nof(2)
01661                       do kk=1,nof(2)
01662                          ll=ll+1
01663                          bound_latr(ll,il,jl)= &
01664                          corner_pointer%corners_real(2)%vector((kk-1)*stride+ii)
01665                       enddo
01666                    enddo
01667                 enddo
01668              enddo
01669 
01670 
01671            endif ! il_grid_type == PRISM_Reglonlatvrt ||  &
01672                  ! il_grid_type == PRISM_Reglonlat_sigmavrt 
01673 !
01674 !  Extraction of height data for grids with logical rectangular
01675 !  horizontal layers.
01676 !
01677            if (lenaz .gt. 1 ) then
01678            if( il_grid_type == PRISM_Reglonlatvrt .or.  &
01679                il_grid_type == PRISM_Irrlonlat_regvrt ) then
01680 
01681              do ii=1,ncells(3)
01682                    ll=0
01683                    do jj=1,nvertices(3)/nof(3)
01684                      do kk=1,nof(3)
01685                        ll=ll+1
01686                        bound_vertr(ll,ii,1,1)= &
01687                        corner_pointer%corners_real(3) &
01688                        %vector((kk-1)*ncells(3)+ii)
01689                      enddo
01690                    enddo
01691              enddo
01692 
01693            else
01694 
01695              stride = ncells(1)*ncells(2)*ncells(3)
01696 
01697              ii = 0
01698              do kl=1,ncells(3)
01699                do jl=1,ncells(2)
01700                  do il=1,ncells(1)
01701                    ii = ii + 1
01702                    ll = 0
01703                    do jj=1,nvertices(3)/nof(3)
01704                       do kk=1,nof(3)
01705                          ll=ll+1
01706                          bound_vertr(ll,il,jl,kl)= &
01707                          corner_pointer%corners_real(3)%vector((kk-1)*stride+ii)
01708                       enddo
01709                    enddo
01710                  enddo
01711                enddo
01712              enddo
01713 
01714            endif
01715            endif
01716 
01717 !
01718 !       Branch for all grids which are not (logical) rectangular.
01719 !
01720         else
01721 
01722            !Rene, do something here for reordering!!!
01723 
01724            if (il_grid_type == PRISM_Gaussreduced_regvrt ) then
01725 
01726               do ii=1,ncells(1)
01727                  ll=0
01728                  do jj=1,nof(1)
01729                     bound_lonr(ll+1,ii,1) = &
01730                          corner_pointer%corners_real(1)%vector((1-1)*ncells(1)+ii)
01731                     bound_lonr(ll+2,ii,1) = &
01732                          corner_pointer%corners_real(1)%vector((2-1)*ncells(1)+ii)
01733                     bound_lonr(ll+3,ii,1) = &
01734                          corner_pointer%corners_real(1)%vector((2-1)*ncells(1)+ii)
01735                     bound_lonr(ll+4,ii,1) = &
01736                          corner_pointer%corners_real(1)%vector((1-1)*ncells(1)+ii)
01737                     ll=ll+4
01738                  enddo
01739               enddo
01740 
01741               do ii=1,ncells(2)
01742                  ll=0
01743                  do jj=1,nof(2)
01744                     bound_latr(ll+1,ii,1)= &
01745                          corner_pointer%corners_real(2)%vector((1-1)*ncells(2)+ii)
01746                     bound_latr(ll+2,ii,1)= &
01747                          corner_pointer%corners_real(2)%vector((1-1)*ncells(2)+ii)
01748                     bound_latr(ll+3,ii,1)= &
01749                          corner_pointer%corners_real(2)%vector((2-1)*ncells(2)+ii)
01750                     bound_latr(ll+4,ii,1)= &
01751                          corner_pointer%corners_real(2)%vector((2-1)*ncells(2)+ii)
01752                     ll=ll+4
01753                  enddo
01754               enddo
01755 
01756            else
01757 
01758               do ii=1,ncells(1)
01759                  ll=0
01760                  do jj=1,nvertices(1)/nof(1)
01761                     do kk=1,nof(1)
01762                        ll=ll+1
01763                        bound_lonr(ll,ii,1)= &
01764                             corner_pointer%corners_real(1)%vector((kk-1)*ncells(1)+ii)
01765                     enddo
01766                  enddo
01767               enddo
01768 
01769               do ii=1,ncells(2)
01770                  ll=0
01771                  do jj=1,nvertices(2)/nof(2)
01772                     do kk=1,nof(2)
01773                        ll=ll+1
01774                        bound_latr(ll,ii,1)= &
01775                             corner_pointer%corners_real(2)%vector((kk-1)*ncells(2)+ii)
01776                     enddo
01777                  enddo
01778               enddo
01779 
01780            endif
01781 
01782            if (lenaz .gt. 1 ) then
01783            if (il_grid_type == PRISM_Unstructlonlat_regvrt .or. &
01784                il_grid_type == PRISM_Gaussreduced_regvrt   ) then
01785 
01786              do ii=1,ncells(3)
01787                ll=0
01788                do jj=1,nvertices(3)/nof(3)
01789                  do kk=1,nof(3)
01790                    ll=ll+1
01791                    bound_vertr(ll,ii,1,1)= &
01792                    corner_pointer%corners_real(3)%vector((kk-1)*ncells(3)+ii)
01793                  enddo
01794                enddo
01795              enddo
01796 
01797            elseif  (il_grid_type == PRISM_Unstructlonlat_sigmavrt .or. &
01798                     il_grid_type == PRISM_Gaussreduced_sigmavrt ) then
01799 
01800              stride = ncells(2)*ncells(3)
01801 
01802              ii = 0
01803              do kl=1,ncells(3)
01804                do jl=1,ncells(2)
01805                    ii = ii + 1
01806                    ll = 0
01807                    do jj=1,nvertices(3)/nof(3)
01808                       do kk=1,nof(3)
01809                          ll=ll+1
01810                          bound_vertr(ll,jl,1,kl)= &
01811                          corner_pointer%corners_real(3)%vector((kk-1)*stride+ii)
01812                       enddo
01813                    enddo
01814                enddo
01815              enddo
01816 
01817            else
01818 
01819              do ii=1,ncells(3)
01820                ll=0
01821                do jj=1,nvertices(3)/nof(3)
01822                  do kk=1,nof(3)
01823                    ll=ll+1
01824                    bound_vertr(ll,ii,1,1)= &
01825                    corner_pointer%corners_real(3)%vector((kk-1)*ncells(3)+ii)
01826                  enddo
01827                enddo
01828              enddo
01829 
01830            endif
01831            endif
01832 
01833          endif
01834 
01835 !
01836 !        corner_shape must match grid's valid shape
01837 !
01838          if(is_regular) then
01839            myashape(1,1)=nvertices(1)*(corner_pointer%corner_shape(1,1)-1)+1
01840            myashape(2,1)=nvertices(1)*corner_pointer%corner_shape(2,1)
01841            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
01842 
01843            myvshape(1,1)=nvertices(1)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01844            myvshape(2,1)=nvertices(1)*Grids(il_grid_id)%grid_shape(2,1)
01845            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
01846 
01847            call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
01848                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
01849                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
01850                ,bound_lonr &
01851                ,myashape &
01852                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01853 
01854            myashape(1,1)=nvertices(2)*(corner_pointer%corner_shape(1,1)-1)+1
01855            myashape(2,1)=nvertices(2)*corner_pointer%corner_shape(2,1)
01856            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
01857 
01858            myvshape(1,1)=nvertices(2)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01859            myvshape(2,1)=nvertices(2)*Grids(il_grid_id)%grid_shape(2,1)
01860            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
01861 
01862            call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
01863                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
01864                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
01865                ,bound_latr &
01866                ,myashape &
01867                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01868            if(lenaz.gt.1) then
01869            if(is_regvrt) then
01870            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,3)-1)+1
01871            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,3)
01872            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,3)-1)+1
01873            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,3)
01874            call psmile_write_1d_real(Fields(id_varid)%io_infos%file_unit &
01875                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
01876                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
01877                ,bound_vertr &
01878                ,myashape &
01879                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01880            else
01881            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
01882            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
01883            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
01884            myashape(1:2,3)=corner_pointer%corner_shape(1:2,3)
01885 
01886            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01887            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
01888            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
01889            myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
01890 
01891            call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
01892                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
01893                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
01894                ,bound_vertr &
01895                ,myashape &
01896                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01897            endif
01898            endif
01899          else
01900 
01901            myashape(1,1)=nvertices(1)*(corner_pointer%corner_shape(1,1)-1)+1
01902            myashape(2,1)=nvertices(1)*corner_pointer%corner_shape(2,1)
01903            myashape(1:2,2)=1
01904 
01905            myvshape(1,1)=nvertices(1)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01906            myvshape(2,1)=nvertices(1)*Grids(il_grid_id)%grid_shape(2,1)
01907            myvshape(1:2,2)=1
01908 
01909            call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
01910                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
01911                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
01912                ,bound_lonr &
01913                ,myashape &
01914                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01915 
01916            myashape(1,1)=nvertices(2)*(corner_pointer%corner_shape(1,1)-1)+1
01917            myashape(2,1)=nvertices(2)*corner_pointer%corner_shape(2,1)
01918            myashape(1:2,2)=1
01919 
01920            myvshape(1,1)=nvertices(2)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01921            myvshape(2,1)=nvertices(2)*Grids(il_grid_id)%grid_shape(2,1)
01922            myvshape(1:2,2)=1
01923 
01924            call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
01925                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
01926                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
01927                ,bound_latr &
01928                ,myashape &
01929                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01930            if (lenaz .gt. 1) then
01931            if(il_grid_type == PRISM_Unstructlonlat_regvrt .or. &
01932               il_grid_type == PRISM_Gaussreduced_regvrt ) then
01933            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,3)-1)+1
01934            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,3)
01935            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,3)-1)+1
01936            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,3)
01937            call psmile_write_1d_real(Fields(id_varid)%io_infos%file_unit &
01938                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
01939                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
01940                ,bound_vertr &
01941                ,myashape &
01942                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01943            
01944            else if( il_grid_type == PRISM_Unstructlonlat_sigmavrt .or. &
01945                     il_grid_type == PRISM_Gaussreduced_sigmavrt ) then
01946 
01947            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
01948            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
01949            myashape(1:2,2)=1
01950            myashape(1:2,3)=corner_pointer%corner_shape(1:2,2)
01951 
01952            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01953            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
01954            myvshape(1:2,2)=1
01955            myvshape(1:2,3)=corner_pointer%corner_shape(1:2,2)
01956            call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
01957                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
01958                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
01959                ,bound_vertr &
01960                ,myashape &
01961                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01962 
01963            else
01964            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
01965            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
01966            myashape(1:2,2)=1
01967            myashape(1:2,3)=1
01968 
01969            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
01970            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
01971            myvshape(1:2,2)=1
01972            myvshape(1:2,3)=1
01973            call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
01974                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
01975                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
01976                ,bound_vertr &
01977                ,myashape &
01978                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
01979            endif
01980            endif
01981          endif
01982 
01983          if(associated(bound_lonr)) deallocate(bound_lonr,stat=ierror)
01984          if (ierror > 0) then
01985             ierrp (1) = ierror
01986             ierrp (2) = 1
01987             ierror = PRISM_Error_Alloc
01988             call psmile_error ( ierror, 'bound_lonr', &
01989                             ierrp, 2, __FILE__, __LINE__ )
01990             return
01991          endif
01992 
01993          if(associated(bound_latr)) deallocate(bound_latr,stat=ierror)
01994          if (ierror > 0) then
01995             ierrp (1) = ierror
01996             ierrp (2) = 1
01997             ierror = PRISM_Error_Alloc
01998             call psmile_error ( ierror, 'bound_latr', &
01999                             ierrp, 2, __FILE__, __LINE__ )
02000             return
02001          endif
02002 
02003          if(associated(bound_vertr)) deallocate(bound_vertr,stat=ierror)
02004          if (ierror > 0) then
02005             ierrp (1) = ierror
02006             ierrp (2) = 1
02007             ierror = PRISM_Error_Alloc
02008             call psmile_error ( ierror, 'bound_vertr', &
02009                             ierrp, 2, __FILE__, __LINE__ )
02010             return
02011          endif
02012 !
02013        else if(associated(corner_pointer%corners_dble(1)%vector)) then
02014 !
02015          if(is_regular) then
02016            allocate(bound_lond(nvertices(1),ncells(1),ncells(2)),stat=ierror)
02017            if (ierror > 0) then
02018               ierrp (1) = ierror
02019               ierrp (2) = 1
02020               ierror = PRISM_Error_Alloc
02021               call psmile_error ( ierror, 'bound_lond', &
02022                               ierrp, 2, __FILE__, __LINE__ )
02023               return
02024            endif
02025   
02026            allocate(bound_latd(nvertices(2),ncells(1),ncells(2)),stat=ierror)
02027            if (ierror > 0) then
02028               ierrp (1) = ierror
02029               ierrp (2) = 1
02030               ierror = PRISM_Error_Alloc
02031               call psmile_error ( ierror, 'bound_latd', &
02032                               ierrp, 2, __FILE__, __LINE__ )
02033               return
02034            endif
02035 
02036            if (lenaz .gt. 1 ) then
02037              if(is_regvrt) then
02038                allocate(bound_vertd(nvertices(3),ncells(3),1,1) &
02039                    ,stat=ierror)
02040               else
02041                 allocate(bound_vertd(nvertices(3),ncells(1),ncells(2) &
02042                         ,ncells(3)) ,stat=ierror)
02043               endif
02044            if (ierror > 0) then
02045               ierrp (1) = ierror
02046               ierrp (2) = 1
02047               ierror = PRISM_Error_Alloc
02048               call psmile_error ( ierror, 'bound_latd', &
02049                               ierrp, 2, __FILE__, __LINE__ )
02050               return
02051            endif
02052            endif
02053 !
02054          else
02055 !
02056            allocate(bound_lond(nvertices(1),ncells(1),1),stat=ierror)
02057            if (ierror > 0) then
02058               ierrp (1) = ierror
02059               ierrp (2) = 1
02060               ierror = PRISM_Error_Alloc
02061               call psmile_error ( ierror, 'bound_lond', &
02062                               ierrp, 2, __FILE__, __LINE__ )
02063               return
02064            endif
02065   
02066            allocate(bound_latd(nvertices(2),ncells(2),1),stat=ierror)
02067            if (ierror > 0) then
02068               ierrp (1) = ierror
02069               ierrp (2) = 1
02070               ierror = PRISM_Error_Alloc
02071               call psmile_error ( ierror, 'bound_latd', &
02072                               ierrp, 2, __FILE__, __LINE__ )
02073               return
02074            endif
02075 
02076            if (lenaz .gt. 1 ) then
02077            allocate(bound_vertd(nvertices(3),ncells(3),1,1),stat=ierror)
02078            if (ierror > 0) then
02079               ierrp (1) = ierror
02080               ierrp (2) = 1
02081               ierror = PRISM_Error_Alloc
02082               call psmile_error ( ierror, 'bound_latd', &
02083                               ierrp, 2, __FILE__, __LINE__ )
02084               return
02085            endif
02086            endif
02087 !
02088          endif
02089 
02090 #ifdef DEBUG
02091      print*,trim(ch_id),' :  psmile_write_meta_byid: ','is_regular ',is_regular
02092      print*,trim(ch_id),' :  psmile_write_meta_byid: '  &
02093               ,'ih-il+1,jh-jl+1,nvertices(1),ncells(1),nvertices(2),ncells(2)' &
02094               ,ih-il+1,jh-jl+1,nvertices(1),ncells(1),nvertices(2),ncells(2)
02095      print*,trim(ch_id),' :  psmile_write_meta_byid: ' &
02096                        ,'corner_pointer%corner_shape ' &
02097                        ,corner_pointer%corner_shape
02098       call psmile_flushstd
02099 #endif
02100 
02101 !
02102 !        Branch for all logical rectangular grids
02103 !
02104          if(is_regular) then
02105 
02106            if( il_grid_type == PRISM_Reglonlatvrt .or.  &
02107                il_grid_type == PRISM_Reglonlat_sigmavrt ) then
02108 
02109              lbackward=.false.
02110              do iloc=1,ncells(2)
02111                do ii=1,ncells(1)
02112                  ll=0
02113                do jj=1,nvertices(1)/nof(1)
02114                  lbackward=mod(jj-1,2).eq.0
02115                  if(.not.lbackward)then
02116                  do kk=1,nof(1)
02117                    ll=ll+1
02118                    bound_lond(ll,ii,iloc)= &
02119                     corner_pointer%corners_dble(1)%vector((kk-1)*ncells(1)+ii)
02120                  enddo
02121                  else
02122                  do kk=nof(1),1,-1
02123                    ll=ll+1
02124                    bound_lond(ll,ii,iloc)= &
02125                     corner_pointer%corners_dble(1)%vector((kk-1)*ncells(1)+ii)
02126                  enddo
02127                  endif
02128                enddo
02129               enddo
02130              enddo
02131   
02132              kkj=0
02133              do iloc=1,ncells(1)
02134                do ii=1,ncells(2)
02135                  ll=0
02136                  do jj=1,nvertices(2)/nof(2)
02137                    kkj=kkj+1
02138                    do kk=1,nof(2)
02139                      ll=ll+1
02140                      bound_latd(ll,iloc,ii)= &
02141                      corner_pointer%corners_dble(2)%vector((kkj-1)*ncells(2)+ii)
02142                    enddo
02143                    if(kkj.eq.nof(2))kkj=0
02144                  enddo
02145                enddo
02146              enddo
02147 
02148 
02149            else
02150 
02151              stride = ncells(1)*ncells(2)
02152 
02153              ii = 0
02154              do jl=1,ncells(2)
02155                 do il=1,ncells(1)
02156                    ii = ii + 1
02157                    ll=0
02158                    do jj=1,nvertices(1)/nof(1)
02159                       do kk=1,nof(1)
02160                          ll=ll+1
02161                          bound_lond(ll,il,jl)= &
02162                          corner_pointer%corners_dble(1)%vector((kk-1)*stride+ii)
02163                       enddo
02164                    enddo
02165                 enddo
02166              enddo
02167 
02168              stride = ncells(1)*ncells(2)
02169 
02170              ii = 0
02171              do jl=1,ncells(2)
02172                 do il=1,ncells(1)
02173                    ii = ii + 1
02174                    ll = 0
02175                    do jj=1,nvertices(2)/nof(2)
02176                       do kk=1,nof(2)
02177                          ll=ll+1
02178                          bound_latd(ll,il,jl)= &
02179                          corner_pointer%corners_dble(2)%vector((kk-1)*stride+ii)
02180                       enddo
02181                    enddo
02182                 enddo
02183              enddo
02184 
02185            endif ! il_grid_type == PRISM_Reglonlatvrt ||  &
02186                  ! il_grid_type == PRISM_Reglonlat_sigmavrt 
02187 
02188 !
02189 !  Extraction of height data for grids with logical rectangular 
02190 !  horizontal layers.
02191 !
02192            if (lenaz .gt. 1 ) then
02193            if( il_grid_type == PRISM_Reglonlatvrt .or.  &
02194                il_grid_type == PRISM_Irrlonlat_regvrt ) then
02195 
02196              do ii=1,ncells(3)
02197                    ll=0
02198                    do jj=1,nvertices(3)/nof(3)
02199                      do kk=1,nof(3)
02200                        ll=ll+1
02201                        bound_vertd(ll,ii,1,1)= &
02202                        corner_pointer%corners_dble(3) &
02203                        %vector((kk-1)*ncells(3)+ii)
02204                      enddo
02205                    enddo
02206              enddo
02207 
02208            else
02209 
02210              stride = ncells(1)*ncells(2)*ncells(3)
02211 
02212              ii = 0
02213              do kl=1,ncells(3)
02214                do jl=1,ncells(2)
02215                  do il=1,ncells(1)
02216                    ii = ii + 1
02217                    ll = 0
02218                    do jj=1,nvertices(3)/nof(3)
02219                       do kk=1,nof(3)
02220                          ll=ll+1
02221                          bound_vertd(ll,il,jl,kl)= &
02222                          corner_pointer%corners_dble(3)%vector((kk-1)*stride+ii)
02223                       enddo
02224                    enddo
02225                  enddo
02226                enddo
02227              enddo
02228 
02229            endif
02230            endif
02231 
02232 !
02233 !       Branch for all grids which are not (logical) rectangular.
02234 !
02235          else
02236 
02237            if (il_grid_type == PRISM_Gaussreduced_regvrt ) then
02238 
02239               do ii=1,ncells(1)
02240                  ll=0
02241                  do jj=1,nof(1)
02242                     bound_lond(ll+1,ii,1) = &
02243                          corner_pointer%corners_dble(1)%vector((1-1)*ncells(1)+ii)
02244                     bound_lond(ll+2,ii,1) = &
02245                          corner_pointer%corners_dble(1)%vector((2-1)*ncells(1)+ii)
02246                     bound_lond(ll+3,ii,1) = &
02247                          corner_pointer%corners_dble(1)%vector((2-1)*ncells(1)+ii)
02248                     bound_lond(ll+4,ii,1) = &
02249                          corner_pointer%corners_dble(1)%vector((1-1)*ncells(1)+ii)
02250                     ll=ll+4
02251                  enddo
02252               enddo
02253 
02254               do ii=1,ncells(2)
02255                  ll=0
02256                  do jj=1,nof(2)
02257                     bound_latd(ll+1,ii,1)= &
02258                          corner_pointer%corners_dble(2)%vector((1-1)*ncells(2)+ii)
02259                     bound_latd(ll+2,ii,1)= &
02260                          corner_pointer%corners_dble(2)%vector((1-1)*ncells(2)+ii)
02261                     bound_latd(ll+3,ii,1)= &
02262                          corner_pointer%corners_dble(2)%vector((2-1)*ncells(2)+ii)
02263                     bound_latd(ll+4,ii,1)= &
02264                          corner_pointer%corners_dble(2)%vector((2-1)*ncells(2)+ii)
02265                     ll=ll+4
02266                  enddo
02267               enddo
02268 
02269            else
02270 
02271               do ii=1,ncells(1)
02272                  ll=0
02273                  do jj=1,nvertices(1)/nof(1)
02274                     do kk=1,nof(1)
02275                        ll=ll+1
02276                        bound_lond(ll,ii,1)= &
02277                             corner_pointer%corners_dble(1)%vector((kk-1)*ncells(1)+ii)
02278                     enddo
02279                  enddo
02280               enddo
02281 
02282               do ii=1,ncells(2)
02283                  ll=0
02284                  do jj=1,nvertices(2)/nof(2)
02285                     do kk=1,nof(2)
02286                        ll=ll+1
02287                        bound_latd(ll,ii,1)= &
02288                             corner_pointer%corners_dble(2)%vector((kk-1)*ncells(2)+ii)
02289                     enddo
02290                  enddo
02291               enddo
02292 
02293            endif
02294 
02295            if (lenaz .gt. 1 ) then
02296            if (il_grid_type == PRISM_Unstructlonlat_regvrt .or. &
02297                il_grid_type == PRISM_Gaussreduced_regvrt ) then
02298 
02299              do ii=1,ncells(3)
02300                ll=0
02301                do jj=1,nvertices(3)/nof(3)
02302                  do kk=1,nof(3)
02303                    ll=ll+1
02304                    bound_vertd(ll,ii,1,1)= &
02305                    corner_pointer%corners_dble(3)%vector((kk-1)*ncells(3)+ii)
02306                  enddo
02307                enddo
02308              enddo
02309 
02310            elseif  (il_grid_type == PRISM_Unstructlonlat_sigmavrt .or. &
02311                     il_grid_type == PRISM_Gaussreduced_sigmavrt ) then
02312 
02313              stride = ncells(2)*ncells(3)
02314 
02315              ii = 0
02316              do kl=1,ncells(3)
02317                do jl=1,ncells(2)
02318                    ii = ii + 1
02319                    ll = 0
02320                    do jj=1,nvertices(3)/nof(3)
02321                       do kk=1,nof(3)
02322                          ll=ll+1
02323                          bound_vertd(ll,jl,1,kl)= &
02324                          corner_pointer%corners_dble(3)%vector((kk-1)*stride+ii)
02325                       enddo
02326                    enddo
02327                enddo
02328              enddo
02329 
02330            else
02331 
02332              do ii=1,ncells(3)
02333                ll=0
02334                do jj=1,nvertices(3)/nof(3)
02335                  do kk=1,nof(3)
02336                    ll=ll+1
02337                    bound_vertd(ll,ii,1,1)= &
02338                    corner_pointer%corners_dble(3)%vector((kk-1)*ncells(3)+ii)
02339                  enddo
02340                enddo
02341              enddo
02342 
02343            endif
02344            endif
02345 
02346          endif
02347 
02348 !
02349 !        corner_shape must match grid's valid shape
02350 !
02351          if(is_regular) then
02352            myashape(1,1)=nvertices(1)*(corner_pointer%corner_shape(1,1)-1)+1
02353            myashape(2,1)=nvertices(1)*corner_pointer%corner_shape(2,1)
02354            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
02355 
02356            myvshape(1,1)=nvertices(1)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02357            myvshape(2,1)=nvertices(1)*Grids(il_grid_id)%grid_shape(2,1)
02358            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02359 
02360            call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02361                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
02362                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
02363                ,bound_lond &
02364                ,myashape &
02365                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02366 
02367            myashape(1,1)=nvertices(2)*(corner_pointer%corner_shape(1,1)-1)+1
02368            myashape(2,1)=nvertices(2)*corner_pointer%corner_shape(2,1)
02369            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
02370 
02371            myvshape(1,1)=nvertices(2)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02372            myvshape(2,1)=nvertices(2)*Grids(il_grid_id)%grid_shape(2,1)
02373            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02374 
02375            call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02376                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
02377                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
02378                ,bound_latd &
02379                ,myashape &
02380                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02381 
02382            if(lenaz.gt.1) then
02383            if(is_regvrt) then
02384            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,3)-1)+1
02385            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,3)
02386            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,3)-1)+1
02387            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,3)
02388            
02389            call psmile_write_1d_dble(Fields(id_varid)%io_infos%file_unit &
02390                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
02391                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
02392                ,bound_vertd &
02393                ,myashape &
02394                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02395            else
02396            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
02397            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
02398            myashape(1:2,2)=corner_pointer%corner_shape(1:2,2)
02399            myashape(1:2,3)=corner_pointer%corner_shape(1:2,3)
02400 
02401            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02402            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
02403            myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02404            myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
02405 
02406            call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02407                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
02408                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
02409                ,bound_vertd &
02410                ,myashape &
02411                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02412            endif
02413            endif
02414 
02415          else
02416 
02417            myashape(1,1)=nvertices(1)*(corner_pointer%corner_shape(1,1)-1)+1
02418            myashape(2,1)=nvertices(1)*corner_pointer%corner_shape(2,1)
02419            myashape(1:2,2)=1
02420 
02421            myvshape(1,1)=nvertices(1)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02422            myvshape(2,1)=nvertices(1)*Grids(il_grid_id)%grid_shape(2,1)
02423            myvshape(1:2,2)=1
02424 
02425            call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02426                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(1) &
02427                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
02428                ,bound_lond &
02429                ,myashape &
02430                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02431 
02432            myashape(1,1)=nvertices(2)*(corner_pointer%corner_shape(1,1)-1)+1
02433            myashape(2,1)=nvertices(2)*corner_pointer%corner_shape(2,1)
02434            myashape(1:2,2)=1
02435 
02436            myvshape(1,1)=nvertices(2)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02437            myvshape(2,1)=nvertices(2)*Grids(il_grid_id)%grid_shape(2,1)
02438            myvshape(1:2,2)=1
02439 
02440            call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02441                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(2) &
02442                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(2) &
02443                ,bound_latd &
02444                ,myashape &
02445                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02446            if (lenaz .gt. 1) then
02447            if(il_grid_type == PRISM_Unstructlonlat_regvrt .or. &
02448               il_grid_type == PRISM_Gaussreduced_regvrt ) then
02449            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,3)-1)+1
02450            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,3)
02451            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,3)-1)+1
02452            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,3)
02453            call psmile_write_1d_dble(Fields(id_varid)%io_infos%file_unit &
02454                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
02455                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
02456                ,bound_vertd &
02457                ,myashape &
02458                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02459            
02460            else if( il_grid_type == PRISM_Unstructlonlat_sigmavrt .or. &
02461                     il_grid_type == PRISM_Gaussreduced_sigmavrt) then
02462            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
02463            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
02464            myashape(1:2,2)=1
02465            myashape(1:2,3)=corner_pointer%corner_shape(1:2,2)
02466 
02467            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02468            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
02469            myvshape(1:2,2)=1
02470            myvshape(1:2,3)=corner_pointer%corner_shape(1:2,2)
02471            call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02472                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
02473                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
02474                ,bound_vertd &
02475                ,myashape &
02476                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02477 
02478            else
02479            myashape(1,1)=nvertices(3)*(corner_pointer%corner_shape(1,1)-1)+1
02480            myashape(2,1)=nvertices(3)*corner_pointer%corner_shape(2,1)
02481            myashape(1:2,2)=1
02482            myashape(1:2,3)=1
02483 
02484            myvshape(1,1)=nvertices(3)*(Grids(il_grid_id)%grid_shape(1,1)-1)+1
02485            myvshape(2,1)=nvertices(3)*Grids(il_grid_id)%grid_shape(2,1)
02486            myvshape(1:2,2)=1
02487            myvshape(1:2,3)=1
02488            call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02489                                ,Fields(id_varid)%io_infos%p_mpp_io%crnij(3) &
02490                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(3) &
02491                ,bound_vertd &
02492                ,myashape &
02493                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02494            endif
02495            endif
02496          endif
02497 
02498          if(associated(bound_lond)) deallocate(bound_lond,stat=ierror)
02499          if (ierror > 0) then
02500             ierrp (1) = ierror
02501             ierrp (2) = 1
02502             ierror = PRISM_Error_Alloc
02503             call psmile_error ( ierror, 'bound_lond', &
02504                             ierrp, 2, __FILE__, __LINE__ )
02505             return
02506          endif
02507 
02508          if(associated(bound_latd)) deallocate(bound_latd,stat=ierror)
02509          if (ierror > 0) then
02510             ierrp (1) = ierror
02511             ierrp (2) = 1
02512             ierror = PRISM_Error_Alloc
02513             call psmile_error ( ierror, 'bound_latd', &
02514                             ierrp, 2, __FILE__, __LINE__ )
02515             return
02516          endif
02517 
02518          if(associated(bound_vertd))deallocate(bound_vertd,stat=ierror)
02519          if (ierror > 0) then
02520             ierrp (1) = ierror
02521             ierrp (2) = 1
02522             ierror = PRISM_Error_Alloc
02523             call psmile_error ( ierror, 'bound_latd', &
02524                             ierrp, 2, __FILE__, __LINE__ )
02525             return
02526          endif
02527 
02528        endif
02529 
02530 
02531 !
02532 !       Loop over components of vector fields
02533 !
02534       do ii=1,nvcomp
02535 !
02536           if(nvcomp.gt.1) then
02537             vcomp_id=Methods(Fields(id_varid)%method_id)%vector_pointer &
02538                      %array_of_point_ids(ii)
02539           else
02540             vcomp_id=Fields(id_varid)%method_id
02541           endif
02542           if(il_grid_type == PRISM_Unstructlonlatvrt) then
02543 
02544             myashape(1:2,1)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,1)
02545             myashape(1:2,2)=1
02546             myashape(1:2,3)=1
02547 !
02548             myvshape(1:2,1)=Grids(il_grid_id)%grid_shape(1:2,1)
02549             myvshape(1:2,2)=1
02550             myvshape(1:2,3)=1
02551 #ifdef VERBOSE
02552     print*,trim(ch_id),' : psmile_write_meta_byid: PRISM_Unstructlonlatvrt: ' &
02553             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02554             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02555     call psmile_flushstd
02556        
02557 #endif
02558           else if((il_grid_type .eq. PRISM_Unstructlonlat_regvrt) .or. &
02559                   (il_grid_type .eq. PRISM_Gaussreduced_regvrt) .or. &  
02560                   ( il_grid_type .eq. PRISM_Gaussreduced_sigmavrt) .or. &  
02561                  (il_grid_type .eq. PRISM_Unstructlonlat_sigmavrt)) then
02562 !           Lon and lat are a 1d array of length of number of pairs lat-lon
02563             myashape(1:2,1)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,1)
02564             myashape(1:2,2)=1
02565 !           Vert is a 1d array.
02566             myashape(1:2,3)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,3)
02567 !
02568             myvshape(1:2,1)=Grids(il_grid_id)%grid_shape(1:2,1)
02569             myvshape(1:2,2)=1
02570             myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
02571 #ifdef VERBOSE
02572     print*,trim(ch_id),' : psmile_write_meta_byid:' &
02573                       ,' PRISM_Unstructlonlat_vrt|PRISM_Gaussreduced_vrt: ' &
02574             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02575             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02576     call psmile_flushstd
02577        
02578 #endif
02579 
02580           else if(il_grid_type .eq. PRISM_Irrlonlatvrt) then
02581 !           Lon Lats Verts are arrays in I,j and K, means the grid is logical
02582 !           rectangular in 3 dimensions with respect to the indices:
02583 !           y=f(i,j,k) where y is lat,lon or vert
02584 !
02585             myashape(1:2,1)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,1)
02586             myashape(1:2,2)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,2)
02587             myashape(1:2,3)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,3)
02588 !
02589             myvshape(1:2,1)=Grids(il_grid_id)%grid_shape(1:2,1)
02590             myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02591             myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
02592 #ifdef VERBOSE
02593       print*,trim(ch_id),' :  psmile_write_meta_byid:  PRISM_Irrlonlatvrt: ' &
02594             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02595             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02596       call psmile_flushstd
02597        
02598 #endif
02599 
02600           else if((il_grid_type .eq. PRISM_Irrlonlat_sigmavrt) .or. &
02601                   (il_grid_type .eq. PRISM_Irrlonlat_regvrt)) then
02602 
02603 !           Lon and Lats are matrices in I and J
02604             myashape(1:2,1)=Methods(vcomp_id)%coords_pointer%coords_shape(1:2,1)
02605             myashape(1:2,2)=Methods(vcomp_id)%coords_pointer%coords_shape(1:2,2)
02606 !           Vertical is a simple 1d array
02607             myashape(1:2,3)=Methods(vcomp_id)%coords_pointer%coords_shape(1:2,3)
02608 !
02609             myvshape(1:2,1)=Grids(il_grid_id)%grid_shape(1:2,1)
02610             myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02611             myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
02612 #ifdef VERBOSE
02613       print*,trim(ch_id),' :  psmile_write_meta_byid:  PRISM_Irrlonlat_vrt: ' &
02614             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02615             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02616       call psmile_flushstd
02617        
02618 #endif
02619 
02620           else if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02621             myashape(1:2,1)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,1)
02622             myashape(1:2,2)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,2)
02623             myashape(1:2,3)=Methods(vcomp_id)%coords_pointer%actual_shape(1:2,3)
02624 !
02625             myvshape(1:2,1)=Grids(il_grid_id)%grid_shape(1:2,1)
02626             myvshape(1:2,2)=Grids(il_grid_id)%grid_shape(1:2,2)
02627             myvshape(1:2,3)=Grids(il_grid_id)%grid_shape(1:2,3)
02628 #ifdef VERBOSE
02629       print*,trim(ch_id),' :  psmile_write_meta_byid:  PRISM_Reglonlatvrt: ' &
02630             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02631             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02632       call psmile_flushstd
02633        
02634 #endif
02635           endif
02636 !
02637 !    Longitudes
02638 !
02639       if(no_of_blocks.eq.1) then
02640 !
02641         if(associated( &
02642                   Methods(vcomp_id)%coords_pointer%coords_dble(1)%vector))then 
02643             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02644               allocate(lond((myashape(2,1)-myashape(1,1)+1)* &
02645                         (myashape(2,2)-myashape(1,2)+1)))
02646               iloc=1
02647               do jc=myashape(1,2),myashape(2,2)
02648 !rv                do ic=myashape(1,1),myashape(2,1)
02649                 do ic=1,myashape(2,1)-myashape(1,1)+1
02650                   lond(iloc)=Methods(vcomp_id) &
02651                              %coords_pointer%coords_dble(1)%vector(ic)
02652                   iloc=iloc+1
02653                 enddo
02654               enddo
02655             else
02656               lond => Methods(vcomp_id) &
02657                            %coords_pointer%coords_dble(1)%vector
02658             endif
02659 
02660 #ifdef VERBOSE
02661       print*,trim(ch_id),' :  psmile_write_meta_byid:  Writing lond: ' &
02662             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02663             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02664       call psmile_flushstd
02665        
02666 #endif
02667             call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02668                                 ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
02669                                 ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02670                ,lond &
02671                ,myashape &
02672                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02673             if(il_grid_type .eq. PRISM_Reglonlatvrt) deallocate(lond)
02674         else
02675             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02676               allocate(lonr((myashape(2,1)-myashape(1,1)+1)* &
02677                         (myashape(2,2)-myashape(1,2)+1)))
02678               iloc=1
02679               do jc=myashape(1,2),myashape(2,2)
02680 !rv                do ic=myashape(1,1),myashape(2,1)
02681                 do ic=1,myashape(2,1)-myashape(1,1)+1
02682                   lonr(iloc)=Methods(vcomp_id) &
02683                              %coords_pointer%coords_real(1)%vector(ic)
02684                   iloc=iloc+1
02685                 enddo
02686               enddo
02687             else
02688               lonr => Methods(vcomp_id) &
02689                            %coords_pointer%coords_real(1)%vector
02690             endif
02691 #ifdef VERBOSE
02692       print*,trim(ch_id),' :  psmile_write_meta_byid:  Writing lonr: ' &
02693             ,'nvcomp, vcomp_id: myashape, myvshape:' &
02694             ,nvcomp,vcomp_id,':',myashape(1:2,1:3), myvshape(1:2,1:3)
02695       call psmile_flushstd
02696        
02697 #endif
02698             call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
02699                                  ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
02700                                 ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02701                ,lonr &
02702                ,myashape &
02703                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02704 #ifdef VERBOSE
02705       print*,trim(ch_id),' :  psmile_write_meta_byid:  Writing lonr done. ' 
02706       call psmile_flushstd
02707        
02708 #endif
02709             if(il_grid_type .eq. PRISM_Reglonlatvrt) deallocate(lonr)
02710         endif
02711 !
02712       else if(no_of_blocks.gt.1) then
02713 !
02714         if(associated( &
02715              Methods(vcomp_id)%coords_pointer%coords_dble(1)%vector))then 
02716 
02717             allocate(londb((myashape(2,1)-myashape(1,1)+1) &
02718             *(myashape(2,2)-myashape(1,2)+1)*(myashape(2,4)-myashape(1,4)+1)))
02719 
02720             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02721               iloc=1
02722               do kc=myashape(1,4),myashape(2,4)
02723                 do jc=myashape(1,2),myashape(2,2)
02724                   do ic=myashape(1,1),myashape(2,1)
02725                     londb(iloc)=fdbles(kc,ii,1)%fdble(ic)
02726                     iloc=iloc+1
02727                   enddo
02728                 enddo
02729               enddo
02730             else
02731               londb = (/(fdbles(kc,ii,1)%fdble,kc=1,no_of_blocks)/)
02732             endif
02733             
02734 
02735             call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02736                                ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
02737                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02738                , londb &
02739                ,myashape &
02740                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02741 
02742             deallocate(londb)
02743 
02744         else
02745             allocate(lonrb((myashape(2,1)-myashape(1,1)+1) &
02746             *(myashape(2,2)-myashape(1,2)+1)*(myashape(2,4)-myashape(1,4)+1)))
02747             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02748               iloc=1
02749               do kc=myashape(1,4),myashape(2,4)
02750                 do jc=myashape(1,2),myashape(2,2)
02751                   do ic=myashape(1,1),myashape(2,1)
02752                     lonrb(iloc)=freals(kc,ii,1)%freal(ic)
02753                     iloc=iloc+1
02754                   enddo
02755                 enddo
02756               enddo
02757             else
02758               lonrb = (/(freals(kc,ii,1)%freal,kc=1,no_of_blocks)/)
02759             endif
02760             call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
02761                                  ,Fields(id_varid)%io_infos%p_mpp_io%lonij(ii) &
02762                                  ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02763                , lonrb &
02764                ,myashape &
02765                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02766             deallocate(lonrb)
02767         endif
02768 !
02769       endif
02770 !
02771 !    Latitudes
02772 !
02773       if(no_of_blocks.eq.1) then
02774 !
02775         if(associated( &
02776            Methods(vcomp_id)%coords_pointer%coords_dble(2)%vector))then 
02777 
02778             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02779               allocate(latd((myashape(2,1)-myashape(1,1)+1)* &
02780                         (myashape(2,2)-myashape(1,2)+1)))
02781               iloc=1
02782 !rv              do jc=myashape(1,2),myashape(2,2)
02783               do jc=1,myashape(2,2)-myashape(1,2)+1
02784                 do ic=myashape(1,1),myashape(2,1)
02785                   latd(iloc)=Methods(vcomp_id) &
02786                              %coords_pointer%coords_dble(2)%vector(jc)
02787                   iloc=iloc+1
02788                 enddo
02789               enddo
02790             else
02791               latd => Methods(vcomp_id) &
02792                            %coords_pointer%coords_dble(2)%vector
02793             endif
02794 
02795                 call psmile_write_2d_dble(Fields(id_varid)%io_infos%file_unit &
02796                                  ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
02797                                  ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02798                , latd &
02799                ,myashape &
02800                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02801 
02802             if(il_grid_type .eq. PRISM_Reglonlatvrt) deallocate(latd)
02803 
02804         else
02805 
02806             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02807               allocate(latr((myashape(2,1)-myashape(1,1)+1)* &
02808                         (myashape(2,2)-myashape(1,2)+1)))
02809               iloc=1
02810 !rv              do jc=myashape(1,2),myashape(2,2)
02811               do jc=1,myashape(2,2)-myashape(1,2)+1
02812                 do ic=myashape(1,1),myashape(2,1)
02813                   latr(iloc)=Methods(vcomp_id) &
02814                              %coords_pointer%coords_real(2)%vector(jc)
02815                   iloc=iloc+1
02816                 enddo
02817               enddo
02818             else
02819               latr => Methods(vcomp_id) &
02820                            %coords_pointer%coords_real(2)%vector
02821             endif
02822             call psmile_write_2d_real(Fields(id_varid)%io_infos%file_unit &
02823                              ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
02824                              ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02825                ,latr &
02826                ,myashape &
02827                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02828 
02829             if(il_grid_type .eq. PRISM_Reglonlatvrt) deallocate(latr)
02830 
02831         endif
02832 !
02833       else if(no_of_blocks.gt.1) then
02834 !
02835         if(associated( &
02836            Methods(vcomp_id)%coords_pointer%coords_dble(2)%vector))then 
02837 
02838             allocate(latdb((myashape(2,1)-myashape(1,1)+1) &
02839             *(myashape(2,2)-myashape(1,2)+1)*(myashape(2,4)-myashape(1,4)+1)))
02840             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02841               iloc=1
02842               do kc=myashape(1,4),myashape(2,4)
02843                 do jc=myashape(1,2),myashape(2,2)
02844                   do ic=myashape(1,1),myashape(2,1)
02845                     latdb(iloc)=fdbles(kc,ii,2)%fdble(ic)
02846                     iloc=iloc+1
02847                   enddo
02848                 enddo
02849               enddo
02850             else
02851               latdb = (/(fdbles(kc,ii,2)%fdble,kc=1,no_of_blocks)/)
02852             endif
02853 
02854                 call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02855                                  ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
02856                                  ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02857                ,(/(fdbles(il_i,ii,2)%fdble,il_i=1,no_of_blocks)/) &
02858                ,myashape &
02859                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02860             deallocate(latdb)
02861 
02862         else
02863             allocate(latrb((myashape(2,1)-myashape(1,1)+1) &
02864             *(myashape(2,2)-myashape(1,2)+1)*(myashape(2,4)-myashape(1,4)+1)))
02865             if(il_grid_type .eq. PRISM_Reglonlatvrt) then
02866               iloc=1
02867               do kc=myashape(1,4),myashape(2,4)
02868                 do jc=myashape(1,2),myashape(2,2)
02869                   do ic=myashape(1,1),myashape(2,1)
02870                     latrb(iloc)=freals(kc,ii,2)%freal(ic)
02871                     iloc=iloc+1
02872                   enddo
02873                 enddo
02874               enddo
02875             else
02876               latrb = (/(freals(kc,ii,2)%freal,kc=1,no_of_blocks)/)
02877             endif
02878 
02879             call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
02880                                  ,Fields(id_varid)%io_infos%p_mpp_io%latij(ii) &
02881                                  ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02882                ,latrb &
02883                ,myashape &
02884                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02885             deallocate(latrb)
02886         endif
02887       endif
02888 !
02889 !     Vertical
02890 !
02891       if((il_grid_type .eq.PRISM_Unstructlonlatvrt) .or. &
02892          (il_grid_type .eq.PRISM_Irrlonlatvrt)) then
02893         if(no_of_blocks.eq.1) then
02894 !
02895           if(associated( &
02896              Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector))then 
02897 
02898                 call psmile_write_3d_dble(Fields(id_varid)%io_infos%file_unit &
02899                                 ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02900                                 ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02901                ,Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector &
02902                ,myashape &
02903                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02904           else
02905                 call psmile_write_3d_real(Fields(id_varid)%io_infos%file_unit &
02906                            ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02907                            ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02908                ,Methods(vcomp_id)%coords_pointer%coords_real(3)%vector &
02909                ,myashape &
02910                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02911           endif
02912 !
02913         else if(no_of_blocks.gt.1) then
02914 !
02915           if(associated( &
02916              Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector))then 
02917 
02918                 call psmile_write_4d_dble(Fields(id_varid)%io_infos%file_unit &
02919                            ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02920                            ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02921                ,(/(fdbles(il_i,ii,3)%fdble,il_i=1,no_of_blocks)/) &
02922                ,myashape &
02923                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02924           else
02925                 call psmile_write_4d_real(Fields(id_varid)%io_infos%file_unit &
02926                            ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02927                            ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02928                ,(/(freals(il_i,ii,3)%freal,il_i=1,no_of_blocks)/) &
02929                ,myashape &
02930                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02931           endif
02932 !
02933         endif
02934 !
02935       else
02936 !
02937 !          We have a separate axis for z.
02938 !
02939         if(no_of_blocks.eq.1) then
02940 !
02941           if(associated( &
02942              Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector))then 
02943             call psmile_write_1d_dble(Fields(id_varid)%io_infos%file_unit &
02944                        ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02945                        ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02946                        ,Methods(vcomp_id)%coords_pointer%coords_dble(3) &
02947                                   %vector &
02948                ,myashape(1,3) &
02949                ,myvshape(1,3),dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02950 
02951           else
02952             call psmile_write_1d_real(Fields(id_varid)%io_infos%file_unit &
02953                        ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02954                        ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
02955                        ,Methods(vcomp_id)%coords_pointer%coords_real(3) &
02956                                   %vector &
02957                ,myashape(1,3) &
02958                ,myvshape(1,3),dl_time, .FALSE.,ilbl,.FALSE.,ierror )
02959 
02960           endif
02961 !
02962         else if(no_of_blocks.gt.1) then
02963 !
02964           if(associated( &
02965              Methods(vcomp_id)%coords_pointer%coords_dble(3)%vector))then 
02966             allocate(vertdb(myashape(1,3):myashape(2,3) &
02967                            ,myashape(1,4):myashape(2,4)))
02968 
02969             do kc=myashape(1,4),myashape(2,4)
02970               vertdb(myashape(1,3):myashape(2,3),kc)=fdbles(kc,ii,3)%fdble
02971             enddo
02972             call mpp_write(Fields(id_varid)%io_infos%file_unit &
02973                       ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02974             ,vertdb(myvshape(1,3):myvshape(2,3),myvshape(1,4):myvshape(2,4)))
02975             deallocate(vertdb)
02976           else
02977             allocate(vertdb(myashape(1,3):myashape(2,3) &
02978                            ,myashape(1,4):myashape(2,4)))
02979             do kc=myashape(1,4),myashape(2,4)
02980               vertdb(myashape(1,3):myashape(2,3),kc)=freals(kc,ii,3)%freal
02981             enddo
02982             call mpp_write(Fields(id_varid)%io_infos%file_unit &
02983                       ,Fields(id_varid)%io_infos%p_mpp_io%vertij(ii) &
02984             ,vertdb(myvshape(1,3):myvshape(2,3),myvshape(1,4):myvshape(2,4)))
02985             deallocate(vertdb)
02986           endif
02987 !
02988         endif
02989 
02990       endif
02991 !
02992 !     Masks
02993 !
02994       if(vmsk_id(ii).ne.PRISM_UNDEFINED) then
02995         myashape = 1
02996         myashape(1:2,1:ndim_3d) = Masks(vmsk_id(ii))%mask_shape
02997         if(no_of_blocks.eq.1) then
02998           call psmile_write_3d_log(Fields(id_varid)%io_infos%file_unit &
02999                                ,Fields(id_varid)%io_infos%p_mpp_io%maskij(ii) &
03000                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(1)  &
03001                                ,Masks(vmsk_id(ii))%mask_array &
03002                                ,myashape &
03003                                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
03004 
03005         else if(no_of_blocks.gt.1) then
03006           call psmile_write_4d_log(Fields(id_varid)%io_infos%file_unit &
03007                                ,Fields(id_varid)%io_infos%p_mpp_io%maskij(ii) &
03008                                ,Fields(id_varid)%io_infos%p_mpp_io%domain(1) &
03009                                ,(/(flogs(il_i,ii)%flog,il_i=1,no_of_blocks)/) &
03010                                ,myashape &
03011                                ,myvshape,dl_time, .FALSE.,ilbl,.FALSE.,ierror )
03012         endif
03013       endif
03014 !
03015 !       End of loop over components of vector fields
03016 !
03017           
03018       enddo
03019 
03020 #ifdef DEBUG
03021         ! Flush header information for debugging session
03022         call mpp_flush(Fields(id_varid)%io_infos%file_unit)
03023 #endif           
03024 
03025 !-----------------------------------------------------------------------------
03026 !    End of dumping the grid informations for a vector field
03027 !
03028 !
03029      if(associated(fdbles)) deallocate(fdbles)
03030      if(associated(freals)) deallocate(freals)
03031      if(associated(flogs)) deallocate(flogs)
03032         
03033 
03034 
03035 #ifdef VERBOSE
03036       print*,trim(ch_id),' :  psmile_write_meta_byid: end'
03037       call psmile_flushstd
03038 
03039 #endif
03040 #endif  /*   __PSMILE_WITH_IO  */
03041       end subroutine psmile_write_meta_byid

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1