File indexing completed on 2019-05-17 05:10:35 UTC
view on githubraw file Latest commit 66046ae6 on 2019-05-16 21:26:21 UTC
e62a71baf9 Jean*0001 #include "MDSIO_OPTIONS.h"
0002
0003
0004
0005
0006 SUBROUTINE MDS_WRITE_META(
0007 I mFileName,
0008 I dFileName,
0009 I simulName,
0010 I titleLine,
0011 I filePrec,
20b1679b8a Jean*0012 I nDims, dimList, map2gl,
e62a71baf9 Jean*0013 I nFlds, fldList,
4774f70820 Jean*0014 I nTimRec, timList, misVal,
e62a71baf9 Jean*0015 I nrecords, myIter, myThid )
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 IMPLICIT NONE
0026
0027
0028 #include "SIZE.h"
0029 #include "EEPARAMS.h"
0030
0031
0032
0033
0034
20b1679b8a Jean*0035
e62a71baf9 Jean*0036
0037
0038
20b1679b8a Jean*0039
e62a71baf9 Jean*0040
0041
0042
0043
4774f70820 Jean*0044
e62a71baf9 Jean*0045
0046
0047
0048
0049
0050
0051 CHARACTER*(*) mFileName
0052 CHARACTER*(*) dFileName
0053 CHARACTER*(*) simulName
0054 CHARACTER*(*) titleLine
0055 INTEGER filePrec
0056 INTEGER nDims
0057 INTEGER dimList(3,nDims)
20b1679b8a Jean*0058 INTEGER map2gl(2)
e62a71baf9 Jean*0059 INTEGER nFlds
0060 CHARACTER*(8) fldList(*)
0061 INTEGER nTimRec
0062 _RL timList(*)
4774f70820 Jean*0063 _RL misVal
e62a71baf9 Jean*0064 INTEGER nrecords
0065 INTEGER myIter
0066 INTEGER myThid
0067
0068
0069
0070 INTEGER ILNBLNK
0071 EXTERNAL ILNBLNK
0072
0073
079512f56f Jean*0074 INTEGER i,j,ii,iL
e62a71baf9 Jean*0075 INTEGER mUnit
0076
0077 CHARACTER*(MAX_LEN_MBUF) msgBuf
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 CALL MDSFINDUNIT( mUnit, myThid )
0092
0093
0094 OPEN( mUnit, file=mFileName, status='unknown',
0095 & form='formatted' )
0096
0097
0098 iL = ILNBLNK(simulName)
0099 IF ( iL.GT.0 ) THEN
0100 WRITE(mUnit,'(3A)') " simulation = { '",simulName(1:iL),"' };"
0101 ENDIF
0102
0103
0104 WRITE(mUnit,'(1X,A,I3,A)') 'nDims = [ ',nDims,' ];'
0105
0106
0107
0108
0109
0110
079512f56f Jean*0111 ii = 0
0112 DO j=1,nDims
0113 ii = MAX(dimList(1,j),ii)
e62a71baf9 Jean*0114 ENDDO
079512f56f Jean*0115 WRITE(mUnit,'(1X,A)') 'dimList = ['
0116 IF ( ii.LT.10000 ) THEN
0117
0118 DO j=1,nDims
0119 IF (j.LT.nDims) THEN
0120 WRITE(mUnit,'(1X,3(I5,","))') (dimList(i,j),i=1,3)
0121 ELSE
0122 WRITE(mUnit,'(1X,2(I5,","),I5)') (dimList(i,j),i=1,3)
0123 ENDIF
0124 ENDDO
0125 ELSE
0126
0127 DO j=1,nDims
0128 IF (j.LT.nDims) THEN
0129 WRITE(mUnit,'(1X,3(I10,","))') (dimList(i,j),i=1,3)
0130 ELSE
0131 WRITE(mUnit,'(1X,2(I10,","),I10)') (dimList(i,j),i=1,3)
0132 ENDIF
0133 ENDDO
0134 ENDIF
e62a71baf9 Jean*0135 WRITE(mUnit,'(1X,A)') '];'
20b1679b8a Jean*0136
0137 IF ( map2gl(1).NE.0 .OR. map2gl(2).NE.1 ) THEN
0138 WRITE(mUnit,'(1X,2(A,I5),A)') 'map2glob = [ ',
0139 & map2gl(1),',',map2gl(2),' ];'
0140 ENDIF
e62a71baf9 Jean*0141
0142
0143 IF (filePrec .EQ. precFloat32) THEN
0144 WRITE(mUnit,'(1X,A)') "dataprec = [ 'float32' ];"
0145 ELSEIF (filePrec .EQ. precFloat64) THEN
0146 WRITE(mUnit,'(1X,A)') "dataprec = [ 'float64' ];"
0147 ELSE
0148 WRITE(msgBuf,'(A)')
0149 & ' MDSWRITEMETA: invalid filePrec'
0150 CALL PRINT_ERROR( msgBuf, myThid )
0151 STOP 'ABNORMAL END: S/R MDSWRITEMETA'
0152 ENDIF
0153
0154
0155
0156
66046ae6a1 Brun*0157 WRITE(mUnit,'(1X,A,I10,A)') 'nrecords = [ ',nrecords,' ];'
e62a71baf9 Jean*0158
0159
0160
0161
0162
0163
0164
0165
0166 IF ( myIter.GE.0 )
0167 & WRITE(mUnit,'(1X,A,I10,A)') 'timeStepNumber = [ ',myIter,' ];'
0168
0169
0170
20b1679b8a Jean*0171
e62a71baf9 Jean*0172 IF ( nTimRec.GT.0 ) THEN
0173 ii = MIN(nTimRec,20)
0174 WRITE(msgBuf,'(1P20E20.12)') (timList(i),i=1,ii)
47d9634d91 Jean*0175 WRITE(mUnit,'(1X,3A)') 'timeInterval = [', msgBuf(1:20*ii),' ];'
e62a71baf9 Jean*0176 ENDIF
0177
4774f70820 Jean*0178
0179 IF ( misVal.NE.oneRL ) THEN
0180 WRITE(mUnit,'(1X,A,1PE21.14,A)')
0181 & 'missingValue = [ ',misVal,' ];'
0182 ENDIF
0183
e62a71baf9 Jean*0184
0185 IF ( nFlds.GT.0 ) THEN
0186 WRITE(mUnit,'(1X,A,I4,A)') 'nFlds = [ ', nFlds, ' ];'
0187 WRITE(mUnit,'(1X,A)') 'fldList = {'
0188 WRITE(mUnit,'(20(A2,A8,A1))')
0189 & (" '",fldList(i),"'",i=1,nFlds)
0190 WRITE(mUnit,'(1X,A)') '};'
0191 ENDIF
0192
0193
0194 iL = ILNBLNK(titleLine)
0195 IF ( iL.GT.0 ) THEN
0196 WRITE(mUnit,'(3A)')' /* ', titleLine(1:iL), ' */'
0197 ENDIF
0198
0199
0200 CLOSE(mUnit)
0201
0202
0203
0204 RETURN
0205 END