/[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.3 - (hide annotations) (download)
Thu May 19 21:46:15 2005 UTC (19 years, 1 month ago) by ce107
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57i_post, checkpoint57n_post, checkpoint57l_post, checkpoint57p_post, checkpoint57j_post, checkpoint57o_post, checkpoint57k_post
Changes since 1.2: +8 -8 lines
Minor fixes of datatypes, format descriptors, logical operators etc. to
get MITgcm to build and run successfully on AMD64 using GFortran (GCC 4.0.0).
Same changes would be necessary for other GFortran platforms.

Note: please use .NEQV. instead of the less portable .XOR. relational
operator that does not exist for F90/95.

1 ce107 1.3 C $Header: /u/gcmpack/MITgcm/pkg/mdsio/mdsio_writemeta.F,v 1.2 2001/08/29 14:16:24 adcroft Exp $
2 adcroft 1.2 C $Name: $
3 adcroft 1.1
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     C Arguments
30     character*(*) mFileName
31     character*(*) dFileName
32     integer filePrec
33     integer ndims
34     integer dimList(3,ndims)
35     integer nrecords
36     integer myIter
37     integer mythid
38    
39     C Global variables / common blocks
40     #include "SIZE.h"
41     #include "EEPARAMS.h"
42     #include "PARAMS.h"
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    
117     C ------------------------------------------------------------------
118     return
119     end

  ViewVC Help
Powered by ViewVC 1.1.22