Changeset 1700
- Timestamp:
- 2009-11-03T09:56:07+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMO/OPA_SRC/DIA/dianam.F90
r1152 r1700 4 4 !! Ocean diagnostics: Builds output file name 5 5 !!===================================================================== 6 !! History : OPA ! 1999-02 (E. Guilyardi) Creation for 30 days/month 7 !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module 8 !! 3.2 ! 2009-11 (S. Masson) complete rewriting, works for all calendars... 9 !!---------------------------------------------------------------------- 6 10 7 11 !!---------------------------------------------------------------------- 8 12 !! dia_nam : Builds output file name 9 13 !!---------------------------------------------------------------------- 10 !! * Modules used11 14 USE dom_oce ! ocean space and time domain 12 15 USE phycst ! physical constants 13 16 USE in_out_manager ! I/O manager 14 17 USE daymod ! calendar 18 USE ioipsl, ONLY : ju2ymds ! for calendar 15 19 16 20 IMPLICIT NONE 17 21 PRIVATE 18 22 19 !! * Routine accessibility20 PUBLIC dia_nam ! routine called by step.F90 23 PUBLIC dia_nam 24 21 25 !!---------------------------------------------------------------------- 22 !! OPA 9.0 , LOCEAN-IPSL (2005)26 !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 23 27 !! $Id$ 24 28 !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt … … 34 38 !! 35 39 !! ** Method : File name is a function of date and output frequency 36 !! cdfnam=<cexper>_<clave>_<idtbeg>_<idtend>_ grid_<cdsuff>40 !! cdfnam=<cexper>_<clave>_<idtbeg>_<idtend>_<cdsuff> 37 41 !! <clave> = averaging frequency (DA, MO, etc...) 38 42 !! <idtbeg>,<idtend> date of beginning and end of run 39 43 !! 40 !! History :41 !! ! 99-02 (E. Guilyardi) Creation for 30 days/month42 !! 8.5 ! 02-06 (G. Madec) F90: Free form and module43 44 !!---------------------------------------------------------------------- 44 !! * Arguments 45 CHARACTER (len=*), INTENT( out ) :: cdfnam ! file name 46 CHARACTER (len=*), INTENT( in ) :: cdsuff ! ??? 47 INTEGER, INTENT( in ) :: kfreq ! ??? 48 49 !! * Local declarations 50 CHARACTER (len=2) :: clave 51 CHARACTER (len=5) :: clout 52 INTEGER :: jt ! dummy loop indices 53 INTEGER :: ig, ijjmm, iout ! temporary integers 54 INTEGER :: iyear1, imonth1, iday1 ! " " 55 INTEGER :: iyear2, imonth2, iday2 ! " " 56 REAL(wp) :: z5j, znbsec, zdate1, zdate2, zdrun, zdt ! temporary scalars 45 CHARACTER (len=*), INTENT( out) :: cdfnam ! file name 46 CHARACTER (len=*), INTENT(in ) :: cdsuff ! to be added at the end of the file name 47 INTEGER, INTENT(in ) :: kfreq ! output frequency (in time-step): < 0 for monthly outputs 48 ! 0 if no frequency 49 CHARACTER (len=20) :: clfmt, clfmt0 ! writing format 50 CHARACTER (len=20) :: clave ! name for output frequency 51 CHARACTER (len=20) :: cldate1 ! date of the beginning of run 52 CHARACTER (len=20) :: cldate2 ! date of the end of run 53 INTEGER :: iyear1, imonth1, iday1 ! year, month, day of the first day of the run 54 INTEGER :: iyear2, imonth2, iday2 ! year, month, day of the last day of the run 55 INTEGER :: indg ! number of digits needed to write a number 56 INTEGER :: inbsec, inbmn, inbhr, inbday ! output frequency in seconds, minutes, hours and days 57 INTEGER :: iddss, ihhss, immss ! number of seconds in 1 day, 1 hour and 1 minute 58 REAL(wp) :: zsec1, zsec2 ! not used 59 REAL(wp) :: zdrun, zjul ! temporary scalars 57 60 !!---------------------------------------------------------------------- 58 61 … … 62 65 IF(lwp) WRITE(numout,*) 63 66 64 ! 0. Initialisation 65 ! ----------------- 67 ! name for output frequency 66 68 67 cdfnam = '' 68 69 ! number of seconds of the run 70 71 z5j = 5*rjjss 72 zdt = rdt 73 IF( nacc == 1 ) zdt = rdtmin 74 zdrun = FLOAT( nitend - nit000 ) * zdt 75 76 ! date of beginning of run 77 78 iyear1 = ndastp/10000 79 imonth1 = ndastp/100 - iyear1*100 80 iday1 = ndastp - imonth1*100 - iyear1*10000 81 IF( nleapy == 1) THEN 82 ijjmm=0 83 IF( MOD( iyear1, 4 ) == 0 ) THEN 84 DO jt = 1, imonth1-1 85 ijjmm = ijjmm + nbiss(jt) 86 END DO 87 ELSE 88 DO jt = 1, imonth1-1 89 ijjmm = ijjmm + nobis(jt) 90 END DO 91 ENDIF 92 ijjmm = ijjmm + (iyear1-1)/4 93 zdate1 = ( (iyear1-1)*365 + ijjmm +iday1-1 ) * rjjss 94 ELSE IF( nleapy == 0 ) THEN 95 ijjmm = 0 96 DO jt = 1, imonth1-1 97 ijjmm = ijjmm + nobis(jt) 98 END DO 99 zdate1 = ( (iyear1-1)*raajj + ijjmm + iday1-1)* rjjss 100 ELSE 101 zdate1 = ( (iyear1-1)*nleapy*raamo + (imonth1-1)*nleapy + iday1-1)* rjjss 69 inbsec = kfreq * NINT( rdttra(1) ) ! output frequency in seconds 70 iddss = NINT( rday ) ! number of seconds in 1 day 71 ihhss = NINT( rmmss * rhhmm ) ! number of seconds in 1 hour 72 immss = NINT( rmmss ) ! number of seconds in 1 minute 73 clfmt0 = "('(a,i',i1,',a)')" ! format '(a,ix,a)' with x to be defined 74 ! 75 IF( inbsec == 0 ) THEN ; clave = '' ! no frequency 76 ELSEIF( inbsec < 0 ) THEN ; clave = '_1m' ! frequency in month 77 ELSEIF( MOD( inbsec, iddss ) == 0 ) THEN ! frequency in days 78 inbday = inbsec / iddss 79 indg = INT(LOG10(REAL(inbday,wp))) + 1 ! number of digits needed to write days frequency 80 WRITE(clfmt, clfmt0) indg ; WRITE(clave, clfmt) '_', inbday, 'd' 81 IF( inbday == nmonth_len(nmonth) ) clave = '_1m' 82 IF( inbday == nyear_len(1 ) ) clave = '_1y' 83 ELSEIF( MOD( inbsec, ihhss ) == 0 ) THEN ! frequency in hours 84 inbhr = inbsec / ihhss 85 indg = INT(LOG10(REAL(inbhr ,wp))) + 1 ! number of digits needed to write hours frequency 86 WRITE(clfmt, clfmt0) indg ; WRITE(clave, clfmt) '_', inbhr, 'h' 87 ELSEIF( MOD( inbsec, immss ) == 0 ) THEN ! frequency in minutes 88 inbmn = inbsec / immss 89 indg = INT(LOG10(REAL(inbmn ,wp))) + 1 ! number of digits needed to write minutes frequency 90 WRITE(clfmt, clfmt0) indg ; WRITE(clave, clfmt) '_', inbmn, 'mn' 91 ELSE ! frequency in seconds 92 indg = INT(LOG10(REAL(inbsec,wp))) + 1 ! number of digits needed to write seconds frequency 93 WRITE(clfmt, clfmt0) indg ; WRITE(clave, clfmt) '_', inbsec, 's' 102 94 ENDIF 103 95 104 ! date of end of run (= date of beginning of next run)96 ! date of the beginning and the end of the run 105 97 106 zdate2 = zdate1 + zdrun 107 IF( nleapy == 1 ) THEN 108 iyear2 = zdate2/(365.25*rjjss)+1 109 ijjmm = INT(zdate2/rjjss)-365*(iyear2-1)-(iyear2-1)/4 110 IF( ijjmm < 0 ) THEN 111 iyear2 = iyear2-1 112 ijjmm = zdate2/rjjss-365.*(iyear2-1)-(iyear2-1)/4 113 ENDIF 114 IF( MOD( iyear2, 4 ) == 0 ) THEN 115 DO jt = 1, 12 116 ijjmm = ijjmm - nbiss(jt) 117 IF( ijjmm <= 0 ) go to 10 118 END DO 119 jt = 12 120 10 CONTINUE 121 imonth2 = jt 122 ijjmm = 0 123 DO jt = 1, jt-1 124 ijjmm = ijjmm + nbiss(jt) 125 END DO 126 ELSE 127 DO jt = 1, 12 128 ijjmm = ijjmm - nobis(jt) 129 IF( ijjmm <= 0 ) go to 15 130 END DO 131 jt = 12 132 15 CONTINUE 133 imonth2 = jt 134 ijjmm = 0 135 DO jt = 1, jt-1 136 ijjmm = ijjmm + nobis(jt) 137 END DO 138 ENDIF 139 iday2 = zdate2/rjjss-365.*(iyear2-1)-ijjmm+1-(iyear2-1)/4 140 ELSE IF( nleapy == 0 ) THEN 141 iyear2 = zdate2/raass+1 142 ijjmm = zdate2/rjjss-raajj*(iyear2-1) 143 DO jt = 1, 12 144 ijjmm = ijjmm - nobis(jt) 145 IF(ijjmm <= 0) go to 20 146 END DO 147 jt = 12 148 20 CONTINUE 149 imonth2 = jt 150 ijjmm = 0 151 DO jt = 1, jt-1 152 ijjmm = ijjmm + nobis(jt) 153 END DO 154 iday2 = zdate2/rjjss-raajj*(iyear2-1)-ijjmm+1 155 ELSE 156 zdate2 = zdate2 / rjjss 157 imonth2 = zdate2/FLOAT(nleapy) 158 iday2 = zdate2 - imonth2*FLOAT(nleapy) + 1. 159 iyear2 = imonth2/12 160 imonth2 = imonth2 - iyear2*12 161 imonth2 = imonth2 + 1 162 iyear2 = iyear2 + 1 163 IF( iday2 == 0 ) THEN 164 iday2 = nleapy 165 imonth2 = imonth2 - 1 166 IF( imonth2 == 0 ) THEN 167 imonth2 = 12 168 iyear2 = iyear2 - 1 169 ENDIF 170 ENDIF 98 zdrun = rdttra(1) / rday * REAL( nitend - nit000, wp ) ! length of the run in days 99 zjul = fjulday - rdttra(1) / rday 100 CALL ju2ymds( zjul , iyear1, imonth1, iday1, zsec1 ) ! year/month/day of the beginning of run 101 CALL ju2ymds( zjul + zdrun, iyear2, imonth2, iday2, zsec2 ) ! year/month/day of the end of run 102 103 IF( iyear2 < 10000 ) THEN ; clfmt = "(i4.4,2i2.2)" ! format used to write the date 104 ELSE ; WRITE(clfmt, "('(i',i1,',2i2.2)')") INT(LOG10(REAL(iyear2,wp))) + 1 171 105 ENDIF 172 106 173 174 ! 1. Define time averaging period <nn><type> 175 ! --------------------------------------- 176 177 iout = 0 178 #if defined key_diainstant 179 clave = 'IN' 180 IF( iyear2 <= 99 ) THEN 181 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 182 ELSE IF( iyear2 <= 999 ) THEN 183 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 184 ELSE IF( iyear2 <= 9999 ) THEN 185 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 186 ELSE 187 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 188 ENDIF 189 #else 190 191 znbsec=kfreq*zdt 192 ! daily output 193 IF( znbsec == rjjss ) THEN 194 clave = '1d' 195 IF( iyear2 <= 99 ) THEN 196 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 197 ELSE IF( iyear2 <= 999 ) THEN 198 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 199 ELSE IF( iyear2 <= 9999 ) THEN 200 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 201 ELSE 202 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 203 ENDIF 204 ! 5 day output 205 ELSE IF( znbsec == z5j ) THEN 206 clave='5d' 207 IF( iyear2 <= 99 ) THEN 208 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 209 ELSE IF( iyear2 <= 999 ) THEN 210 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 211 ELSE IF( iyear2 <= 9999 ) THEN 212 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 213 ELSE 214 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 215 ENDIF 216 ! monthly ouput 217 ELSE IF( (znbsec == rmoss .AND. nleapy > 1) .OR. & 218 (znbsec >= 28*rjjss .AND. znbsec <= 31*rjjss .AND. nleapy <= 1) ) THEN 219 clave = '1m' 220 IF( iyear2 <= 99 ) THEN 221 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 222 ELSE IF( iyear2 <= 999 ) THEN 223 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 224 ELSE IF( iyear2 <= 9999 ) THEN 225 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 226 ELSE 227 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 228 ENDIF 229 ! annual output 230 ELSE IF( (znbsec == raass .AND. nleapy > 1) .OR. & 231 (znbsec >= 365*rjjss .AND. znbsec <= 366*rjjss .AND. nleapy <= 1) ) THEN 232 clave = '1y' 233 IF( iyear2 <= 99 ) THEN 234 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 235 ELSE IF( iyear2 <= 999 ) THEN 236 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 237 ELSE IF( iyear2 <= 9999 ) THEN 238 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 239 ELSE 240 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 241 ENDIF 242 ELSE 243 ! others 244 iout = kfreq 245 ig = 0 246 clout = '' 247 IF( iout <= 9 ) THEN 248 ig = 1 249 WRITE(clout,'(i1.1)') iout 250 ELSE IF( iout <= 99 ) THEN 251 ig = 2 252 WRITE(clout,'(i2.2)') iout 253 ELSE IF( iout <= 999 ) THEN 254 ig = 3 255 WRITE(clout,'(i3.3)') iout 256 ELSE IF( iout <= 9999 ) THEN 257 ig = 4 258 WRITE(clout,'(i4.4)') iout 259 ELSE 260 ig = 5 261 WRITE(clout,'(i5.5)') iout 262 ENDIF 263 clave = 'CU' 264 IF( iyear2 <= 99 ) THEN 265 WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 266 ELSE IF( iyear2 <= 999 ) THEN 267 WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 268 ELSE IF( iyear2 <= 9999 ) THEN 269 WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 270 ELSE 271 WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 272 ENDIF 273 ENDIF 274 #endif 275 IF( iout == 0 ) THEN 276 cdfnam = TRIM(cexper)//"_"//clave//TRIM(cdfnam)//TRIM(cdsuff) 277 ELSE 278 cdfnam = TRIM(cexper)//"_"//clave//TRIM(clout)//TRIM(cdfnam)//TRIM(cdsuff) 279 ENDIF 107 WRITE(cldate1, clfmt) iyear1, imonth1, iday1 ! date of the beginning of run 108 WRITE(cldate2, clfmt) iyear2, imonth2, iday2 ! date of the end of run 109 110 cdfnam = TRIM(cexper)//TRIM(clave)//"_"//TRIM(cldate1)//"_"//TRIM(cldate2)//"_"//TRIM(cdsuff) 280 111 #if defined key_agrif 281 112 if ( .NOT. Agrif_Root() ) cdfnam = TRIM(Agrif_CFixed())//'_'//TRIM(cdfnam) 282 113 #endif 114 283 115 IF(lwp) WRITE(numout,*) cdfnam 284 116 IF(lwp) WRITE(numout,*) 285 286 ! FORMATS287 288 9001 FORMAT("_",I4.4,2I2.2,"_",I4.4,2I2.2,"_")289 9002 FORMAT("_",I4.4,2I2.2,"_",I4.4,2I2.2,"_")290 9003 FORMAT("_",I4.4,2I2.2,"_",I4.4,2I2.2,"_")291 9004 FORMAT("_",I6.6,2I2.2,"_",I6.6,2I2.2,"_")292 9011 FORMAT("_",I4.4,I2.2,"_",I4.4,I2.2,"_")293 9012 FORMAT("_",I4.4,I2.2,"_",I4.4,I2.2,"_")294 9013 FORMAT("_",I4.4,I2.2,"_",I4.4,I2.2,"_")295 9014 FORMAT("_",I6.6,I2.2,"_",I6.6,I2.2,"_")296 9021 FORMAT("_",I4.4,"_",I4.4,"_")297 9022 FORMAT("_",I4.4,"_",I4.4,"_")298 9023 FORMAT("_",I4.4,"_",I4.4,"_")299 9024 FORMAT("_",I6.6,"_",I6.6,"_")300 117 301 118 END SUBROUTINE dia_nam
Note: See TracChangeset
for help on using the changeset viewer.