/[MITgcm]/MITgcm/pkg/mdsio/mdsio_writemeta.F
ViewVC logotype

Contents of /MITgcm/pkg/mdsio/mdsio_writemeta.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download)
Sun Jul 20 12:26:10 2008 UTC (15 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62a, checkpoint62, checkpoint61f, checkpoint61n, checkpoint61q, checkpoint61z, checkpoint61e, checkpoint61g, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61x, checkpoint61y
Changes since 1.4: +3 -4 lines
PARAMS.h no longer needed

1 C $Header: /u/gcmpack/MITgcm/pkg/mdsio/mdsio_writemeta.F,v 1.4 2005/08/19 22:42:02 heimbach Exp $
2 C $Name: $
3
4 #include "MDSIO_OPTIONS.h"
5
6 SUBROUTINE MDSWRITEMETA(
7 I mFileName,
8 I dFileName,
9 I filePrec,
10 I ndims,
11 I dimList,
12 I nrecords,
13 I myIter,
14 I mythid )
15
16 C IN:
17 C mFileName string - complete name of meta-file
18 C dFileName string - complete name of data-file
19 C ndims integer - number of dimensions
20 C dimList integer - array of dimensions, etc.
21 C nrecords integer - record number
22 C myIter integer - time-step number
23 C mythid integer - thread id
24 C OUT:
25 C
26 C Created: 03/20/99 adcroft@mit.edu
27
28 implicit none
29
30 C Global variables / common blocks
31 #include "SIZE.h"
32 #include "EEPARAMS.h"
33
34 C Arguments
35 character*(*) mFileName
36 character*(*) dFileName
37 integer filePrec
38 integer ndims
39 integer dimList(3,ndims)
40 integer nrecords
41 integer myIter
42 integer mythid
43
44 C Functions
45
46 C Local
47 integer i,ii,mUnit
48 logical ex
49 character*(max_len_mbuf) msgbuf
50 C ------------------------------------------------------------------
51
52 C We should *read* the met-file if it exists to check
53 C that the information we are writing is consistent
54 C with the current contents
55 inquire( file=mFileName, exist=ex )
56 C However, it is bloody difficult to parse files
57 C in fortran so someone else can do this.
58 C For now, we will assume everything is ok
59 C and that the last record is written to the
60 C last consecutive record in the file.
61
62 C Assign a free unit number as the I/O channel for this subroutine
63 call MDSFINDUNIT( mUnit, mythid )
64
65 C Open meta-file
66 open( mUnit, file=mFileName, status='unknown',
67 & form='formatted' )
68
69 C Write the number of dimensions
70 write(mUnit,'(1x,a,i3,a)') 'nDims = [ ',ndims,' ];'
71
72 C For each dimension, write the following:
73 C 1 global size (ie. the size of the global dimension of all files)
74 C 2 global start (ie. the global position of the start of this file)
75 C 3 global end (ie. the global position of the end of this file)
76
77 write(mUnit,'(1x,a)') 'dimList = ['
78 do ii=1,ndims
79 if (ii.lt.ndims) then
80 write(mUnit,'(10x,3(i5,","))') (dimList(i,ii),i=1,3)
81 else
82 write(mUnit,'(10x,i5,",",i5,",",i5)') (dimList(i,ii),i=1,3)
83 endif
84 enddo
85 write(mUnit,'(10x,a)') '];'
86
87 C Record the precision of the file
88 if (filePrec .EQ. precFloat32) then
89 write(mUnit,'(1x,a)') "format = [ 'float32' ];"
90 elseif (filePrec .EQ. precFloat64) then
91 write(mUnit,'(1x,a)') "format = [ 'float64' ];"
92 else
93 write(msgbuf,'(a)')
94 & ' MDSWRITEMETA: invalid filePrec'
95 call print_error( msgbuf, mythid )
96 stop 'ABNORMAL END: S/R MDSWRITEMETA'
97 endif
98
99 C Record the current record number
100 C This is a proxy for the actual number of records in the file.
101 C If we could read the file then we could do this properly.
102 write(mUnit,'(1x,a,i5,a)') 'nrecords = [ ',nrecords,' ];'
103
104 C Record the file-name for the binary data
105 Cveto ii=ILNBLNK( dFileName )
106 Cveto write(mUnit,'(1x,3a)') 'binarydatafile = [ ',dFileName(1:ii),' ];'
107
108 C Write the integer time (integer iteration number) for later record
109 C keeping. If the timestep number is less than 0 then we assume
110 C that the information is superfluous and do not write it.
111 if (myIter .ge. 0)
112 & write(mUnit,'(1x,a,i10,a)') 'timeStepNumber = [ ',myIter,' ];'
113
114 C Close meta-file
115 close(mUnit)
116
117 C ------------------------------------------------------------------
118 return
119 end

  ViewVC Help
Powered by ViewVC 1.1.22