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

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

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


Revision 1.6 - (hide annotations) (download)
Sat Jan 16 22:33:46 2010 UTC (14 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +1 -1 lines
FILE REMOVED
remove unused S/R (MDS_WRITE_META replaces MDSWRITEMETA)

1 jmc 1.6 C $Header: /u/gcmpack/MITgcm/pkg/mdsio/mdsio_writemeta.F,v 1.5 2008/07/20 12:26:10 jmc Exp $
2 adcroft 1.2 C $Name: $
3 adcroft 1.1
4     #include "MDSIO_OPTIONS.h"
5    
6 jmc 1.5 SUBROUTINE MDSWRITEMETA(
7 adcroft 1.1 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 heimbach 1.4
30     C Global variables / common blocks
31     #include "SIZE.h"
32     #include "EEPARAMS.h"
33    
34 adcroft 1.1 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 ce107 1.3 write(mUnit,'(1x,a,i3,a)') 'nDims = [ ',ndims,' ];'
71 adcroft 1.1
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 ce107 1.3 write(mUnit,'(1x,a)') 'dimList = ['
78 adcroft 1.1 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 ce107 1.3 write(mUnit,'(1x,a)') "format = [ 'float32' ];"
90 adcroft 1.1 elseif (filePrec .EQ. precFloat64) then
91 ce107 1.3 write(mUnit,'(1x,a)') "format = [ 'float64' ];"
92 adcroft 1.1 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 ce107 1.3 write(mUnit,'(1x,a,i5,a)') 'nrecords = [ ',nrecords,' ];'
103 adcroft 1.1
104     C Record the file-name for the binary data
105     Cveto ii=ILNBLNK( dFileName )
106 ce107 1.3 Cveto write(mUnit,'(1x,3a)') 'binarydatafile = [ ',dFileName(1:ii),' ];'
107 adcroft 1.1
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 ce107 1.3 & write(mUnit,'(1x,a,i10,a)') 'timeStepNumber = [ ',myIter,' ];'
113 adcroft 1.1
114     C Close meta-file
115     close(mUnit)
116 jmc 1.5
117 adcroft 1.1 C ------------------------------------------------------------------
118     return
119     end

  ViewVC Help
Powered by ViewVC 1.1.22