Changeset 1508 for trunk/LMDZ.COMMON/libf/dyn3d_common/dynredem.F90
- Timestamp:
- Jan 15, 2016, 8:27:16 AM (9 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/dyn3d_common/dynredem.F90
r1506 r1508 2 2 ! $Id: dynredem.F 1635 2012-07-12 11:37:16Z lguez $ 3 3 ! 4 c 5 4 ! 5 SUBROUTINE dynredem0(fichnom,iday_end,phis) 6 6 #ifdef CPP_IOIPSL 7 7 USE IOIPSL 8 8 #endif 9 USE infotrac 10 use netcdf95, only: NF95_PUT_VAR 11 use control_mod, only : planet_type 12 USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt,pa,preff, 13 . nivsig,nivsigs 14 USE comconst_mod, ONLY: daysec,dtvr,rad,omeg,g,cpp,kappa,pi 15 USE logic_mod, ONLY: fxyhypb,ysinus 16 USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy, 17 . taux,tauy 18 USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn,itaufin, 19 . start_time,hour_ini 20 USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0 21 22 IMPLICIT NONE 23 c======================================================================= 24 c Ecriture du fichier de redemarrage sous format NetCDF (initialisation) 25 c======================================================================= 26 c Declarations: 27 c ------------- 28 #include "dimensions.h" 29 #include "paramet.h" 30 #include "comgeom2.h" 31 #include "netcdf.inc" 32 #include "iniprint.h" 33 34 c Arguments: 35 c ---------- 36 INTEGER iday_end 37 REAL phis(iip1, jjp1) 38 CHARACTER*(*) fichnom 39 40 c Local: 41 c ------ 42 INTEGER iq,l 43 INTEGER length 44 PARAMETER (length = 100) 45 REAL tab_cntrl(length) ! tableau des parametres du run 46 INTEGER ierr 47 character*20 modname 48 character*80 abort_message 49 50 c Variables locales pour NetCDF: 51 c 52 INTEGER dims2(2), dims3(3), dims4(4) 53 INTEGER idim_index 54 INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv 55 INTEGER idim_s, idim_sig 56 INTEGER idim_tim 57 INTEGER nid,nvarid 58 59 REAL zan0,zjulian,hours 60 INTEGER yyears0,jjour0, mmois0 61 character*30 unites 62 63 character(len=12) :: start_file_type="earth" ! default start file type 64 INTEGER idecal 65 66 c----------------------------------------------------------------------- 67 modname='dynredem0' 9 USE infotrac, ONLY: nqtot, tname, ttext 10 USE netcdf, ONLY: NF90_CREATE, NF90_DEF_DIM, NF90_INQ_VARID, NF90_GLOBAL, & 11 NF90_CLOSE, NF90_PUT_ATT, NF90_UNLIMITED, NF90_CLOBBER 12 USE dynredem_mod, ONLY: cre_var, put_var1, put_var2, err, modname, fil 13 use netcdf95, only: NF95_PUT_VAR 14 use control_mod, only : planet_type 15 USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt,pa,preff, & 16 nivsig,nivsigs 17 USE comconst_mod, ONLY: daysec,dtvr,rad,omeg,g,cpp,kappa,pi 18 USE logic_mod, ONLY: fxyhypb,ysinus 19 USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy, & 20 taux,tauy 21 USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn,itaufin, & 22 start_time,hour_ini 23 USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0 24 25 IMPLICIT NONE 26 !======================================================================= 27 ! Writting the NetCDF restart file (initialisation) 28 !======================================================================= 29 ! Declarations: 30 ! ------------- 31 include "dimensions.h" 32 include "paramet.h" 33 include "comgeom2.h" 34 include "netcdf.inc" 35 include "iniprint.h" 36 37 !=============================================================================== 38 ! Arguments: 39 CHARACTER(LEN=*), INTENT(IN) :: fichnom !--- FILE NAME 40 INTEGER, INTENT(IN) :: iday_end !--- 41 REAL, INTENT(IN) :: phis(iip1, jjp1) !--- GROUND GEOPOTENTIAL 42 !=============================================================================== 43 ! Local variables: 44 INTEGER :: iq,l 45 INTEGER, PARAMETER :: length=100 46 REAL :: tab_cntrl(length) ! run parameters 47 INTEGER :: ierr 48 CHARACTER(LEN=80) :: abort_message 49 50 ! For NetCDF: 51 CHARACTER(LEN=30) :: unites 52 INTEGER :: indexID 53 INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID 54 INTEGER :: sID, sigID, nID, vID, timID 55 INTEGER :: yyears0, jjour0, mmois0 56 REAL :: zan0, zjulian, hours 57 58 CHARACTER(len=12) :: start_file_type="earth" ! default start file type 59 INTEGER :: idecal 60 61 !=============================================================================== 62 ! fill dynredem_mod module variables 63 modname='dynredem0'; fil=fichnom 68 64 69 65 #ifdef CPP_IOIPSL 70 71 66 call ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) 67 call ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) 72 68 #else 73 69 ! set yyears0, mmois0, jjour0 to 0,1,1 (hours is not used) 74 75 76 70 yyears0=0 71 mmois0=1 72 jjour0=1 77 73 #endif 78 74 79 !!! AS: idecal is a hack to be able to read planeto starts... 80 !!! .... while keeping everything OK for LMDZ EARTH 81 if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then 82 write(lunout,*) trim(modname),' : Planeto-like start file' 83 start_file_type="planeto" 84 idecal = 4 85 else 86 write(lunout,*) trim(modname),' : Earth-like start file' 87 idecal = 5 88 endif 89 90 DO l=1,length 91 tab_cntrl(l) = 0. 92 ENDDO 93 tab_cntrl(1) = REAL(iim) 94 tab_cntrl(2) = REAL(jjm) 95 tab_cntrl(3) = REAL(llm) 96 if (start_file_type.eq."earth") then 97 tab_cntrl(4)=REAL(day_ref) 98 else 99 !tab_cntrl(4)=REAL(day_end) 100 tab_cntrl(4)=REAL(iday_end) 101 endif 102 tab_cntrl(5) = REAL(annee_ref) 103 tab_cntrl(idecal+1) = rad 104 tab_cntrl(idecal+2) = omeg 105 tab_cntrl(idecal+3) = g 106 tab_cntrl(idecal+4) = cpp 107 tab_cntrl(idecal+5) = kappa 108 tab_cntrl(idecal+6) = daysec 109 tab_cntrl(idecal+7) = dtvr 110 tab_cntrl(idecal+8) = etot0 111 tab_cntrl(idecal+9) = ptot0 112 tab_cntrl(idecal+10) = ztot0 113 tab_cntrl(idecal+11) = stot0 114 tab_cntrl(idecal+12) = ang0 115 tab_cntrl(idecal+13) = pa 116 tab_cntrl(idecal+14) = preff 117 c 118 c ..... parametres pour le zoom ...... 119 120 tab_cntrl(idecal+15) = clon 121 tab_cntrl(idecal+16) = clat 122 tab_cntrl(idecal+17) = grossismx 123 tab_cntrl(idecal+18) = grossismy 124 c 125 IF ( fxyhypb ) THEN 126 tab_cntrl(idecal+19) = 1. 127 tab_cntrl(idecal+20) = dzoomx 128 tab_cntrl(idecal+21) = dzoomy 129 tab_cntrl(idecal+22) = 0. 130 tab_cntrl(idecal+23) = taux 131 tab_cntrl(idecal+24) = tauy 132 ELSE 133 tab_cntrl(idecal+19) = 0. 134 tab_cntrl(idecal+20) = dzoomx 135 tab_cntrl(idecal+21) = dzoomy 136 tab_cntrl(idecal+22) = 0. 137 tab_cntrl(idecal+23) = 0. 138 tab_cntrl(idecal+24) = 0. 139 IF( ysinus ) tab_cntrl(idecal+22) = 1. 140 ENDIF 141 142 if (start_file_type.eq."earth") then 143 tab_cntrl(idecal+25) = REAL(iday_end) 144 tab_cntrl(idecal+26) = REAL(itau_dyn + itaufin) 145 c start_time: start_time of simulation (not necessarily 0.) 146 tab_cntrl(idecal+27) = start_time 147 endif 148 149 if (planet_type=="mars") then ! For Mars only 150 tab_cntrl(29)=hour_ini 151 endif 152 c 153 c ......................................................... 154 c 155 c Creation du fichier: 156 c 157 ierr = NF_CREATE(fichnom, NF_CLOBBER, nid) 158 IF (ierr.NE.NF_NOERR) THEN 159 write(lunout,*)"dynredem0: Pb d ouverture du fichier " 160 & //trim(fichnom) 161 write(lunout,*)' ierr = ', ierr 162 CALL ABORT_GCM("DYNREDEM0", "", 1) 163 ENDIF 164 c 165 c Preciser quelques attributs globaux: 166 c 167 ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 27, 168 . "Fichier demmarage dynamique") 169 c 170 c Definir les dimensions du fichiers: 171 c 172 if (start_file_type.eq."earth") then 173 ierr = NF_DEF_DIM (nid, "index", length, idim_index) 174 ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) 175 ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu) 176 ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv) 177 ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) 178 ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s) 179 ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig) 180 ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim) 181 else 182 ierr = NF_DEF_DIM (nid, "index", length, idim_index) 183 ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) 184 ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu) 185 ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv) 186 ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) 187 ierr = NF_DEF_DIM (nid, "altitude", llm, idim_s) 188 ierr = NF_DEF_DIM (nid, "interlayer", llmp1, idim_sig) 189 ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_tim) 190 endif 191 c 192 ierr = NF_ENDDEF(nid) ! sortir du mode de definition 193 c 194 c Definir et enregistrer certains champs invariants: 195 c 196 ierr = NF_REDEF (nid) 197 cIM 220306 BEG 198 #ifdef NC_DOUBLE 199 ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid) 200 #else 201 ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid) 202 #endif 203 cIM 220306 END 204 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, 205 . "Parametres de controle") 206 ierr = NF_ENDDEF(nid) 207 call NF95_PUT_VAR(nid,nvarid,tab_cntrl) 208 c 209 ierr = NF_REDEF (nid) 210 cIM 220306 BEG 211 #ifdef NC_DOUBLE 212 ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid) 213 #else 214 ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid) 215 #endif 216 cIM 220306 END 217 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, 218 . "Longitudes des points U") 219 ierr = NF_ENDDEF(nid) 220 call NF95_PUT_VAR(nid,nvarid,rlonu) 221 c 222 ierr = NF_REDEF (nid) 223 cIM 220306 BEG 224 #ifdef NC_DOUBLE 225 ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid) 226 #else 227 ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid) 228 #endif 229 cIM 220306 END 230 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, 231 . "Latitudes des points U") 232 ierr = NF_ENDDEF(nid) 233 call NF95_PUT_VAR (nid,nvarid,rlatu) 234 c 235 ierr = NF_REDEF (nid) 236 cIM 220306 BEG 237 #ifdef NC_DOUBLE 238 ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid) 239 #else 240 ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid) 241 #endif 242 cIM 220306 END 243 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, 244 . "Longitudes des points V") 245 ierr = NF_ENDDEF(nid) 246 call NF95_PUT_VAR(nid,nvarid,rlonv) 247 c 248 ierr = NF_REDEF (nid) 249 cIM 220306 BEG 250 #ifdef NC_DOUBLE 251 ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid) 252 #else 253 ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid) 254 #endif 255 cIM 220306 END 256 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, 257 . "Latitudes des points V") 258 ierr = NF_ENDDEF(nid) 259 call NF95_PUT_VAR(nid,nvarid,rlatv) 260 c 261 if (start_file_type.eq."earth") then 262 ierr = NF_REDEF (nid) 263 cIM 220306 BEG 264 #ifdef NC_DOUBLE 265 ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid) 266 #else 267 ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid) 268 #endif 269 cIM 220306 END 270 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 28, 271 . "Numero naturel des couches s") 272 ierr = NF_ENDDEF(nid) 273 call NF95_PUT_VAR(nid,nvarid,nivsigs) 274 c 275 ierr = NF_REDEF (nid) 276 cIM 220306 BEG 277 #ifdef NC_DOUBLE 278 ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid) 279 #else 280 ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid) 281 #endif 282 cIM 220306 END 283 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 32, 284 . "Numero naturel des couches sigma") 285 ierr = NF_ENDDEF(nid) 286 call NF95_PUT_VAR(nid,nvarid,nivsig) 287 endif ! of if (start_file_type.eq."earth") 288 c 289 ierr = NF_REDEF (nid) 290 cIM 220306 BEG 291 #ifdef NC_DOUBLE 292 ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid) 293 #else 294 ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid) 295 #endif 296 cIM 220306 END 297 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26, 298 . "Coefficient A pour hybride") 299 ierr = NF_ENDDEF(nid) 300 call NF95_PUT_VAR(nid,nvarid,ap) 301 c 302 ierr = NF_REDEF (nid) 303 cIM 220306 BEG 304 #ifdef NC_DOUBLE 305 ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid) 306 #else 307 ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid) 308 #endif 309 cIM 220306 END 310 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26, 311 . "Coefficient B pour hybride") 312 ierr = NF_ENDDEF(nid) 313 call NF95_PUT_VAR(nid,nvarid,bp) 314 c 315 if (start_file_type.ne."earth") then 316 ierr = NF_REDEF (nid) 317 cIM 220306 BEG 318 #ifdef NC_DOUBLE 319 ierr = NF_DEF_VAR (nid,"aps",NF_DOUBLE,1,idim_s,nvarid) 320 #else 321 ierr = NF_DEF_VAR (nid,"aps",NF_FLOAT,1,idim_s,nvarid) 322 #endif 323 cIM 220306 END 324 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 37, 325 . "Coef AS: hybrid pressure at midlayers") 326 ierr = NF_ENDDEF(nid) 327 call NF95_PUT_VAR(nid,nvarid,aps) 328 c 329 ierr = NF_REDEF (nid) 330 cIM 220306 BEG 331 #ifdef NC_DOUBLE 332 ierr = NF_DEF_VAR (nid,"bps",NF_DOUBLE,1,idim_s,nvarid) 333 #else 334 ierr = NF_DEF_VAR (nid,"bps",NF_FLOAT,1,idim_s,nvarid) 335 #endif 336 cIM 220306 END 337 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 34, 338 . "Coef BS: hybrid sigma at midlayers") 339 ierr = NF_ENDDEF(nid) 340 call NF95_PUT_VAR(nid,nvarid,bps) 341 endif ! of if (start_file_type.ne."earth") 342 c 343 ierr = NF_REDEF (nid) 344 cIM 220306 BEG 345 #ifdef NC_DOUBLE 346 ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid) 347 #else 348 ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid) 349 #endif 350 cIM 220306 END 351 ierr = NF_ENDDEF(nid) 352 call NF95_PUT_VAR(nid,nvarid,presnivs) 353 c 354 if (start_file_type.ne."earth") then 75 !!! AS: idecal is a hack to be able to read planeto starts... 76 !!! .... while keeping everything OK for LMDZ EARTH 77 if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then 78 write(lunout,*) trim(modname),' : Planeto-like start file' 79 start_file_type="planeto" 80 idecal = 4 81 else 82 write(lunout,*) trim(modname),' : Earth-like start file' 83 idecal = 5 84 endif 85 86 tab_cntrl(:) = 0. 87 tab_cntrl(1) = REAL(iim) 88 tab_cntrl(2) = REAL(jjm) 89 tab_cntrl(3) = REAL(llm) 90 if (start_file_type.eq."earth") then 91 tab_cntrl(4)=REAL(day_ref) 92 else 93 !tab_cntrl(4)=REAL(day_end) 94 tab_cntrl(4)=REAL(iday_end) 95 endif 96 tab_cntrl(5) = REAL(annee_ref) 97 tab_cntrl(idecal+1) = rad 98 tab_cntrl(idecal+2) = omeg 99 tab_cntrl(idecal+3) = g 100 tab_cntrl(idecal+4) = cpp 101 tab_cntrl(idecal+5) = kappa 102 tab_cntrl(idecal+6) = daysec 103 tab_cntrl(idecal+7) = dtvr 104 tab_cntrl(idecal+8) = etot0 105 tab_cntrl(idecal+9) = ptot0 106 tab_cntrl(idecal+10) = ztot0 107 tab_cntrl(idecal+11) = stot0 108 tab_cntrl(idecal+12) = ang0 109 tab_cntrl(idecal+13) = pa 110 tab_cntrl(idecal+14) = preff 111 112 ! ..... parameters for the zoom ...... 113 tab_cntrl(idecal+15) = clon 114 tab_cntrl(idecal+16) = clat 115 tab_cntrl(idecal+17) = grossismx 116 tab_cntrl(idecal+18) = grossismy 117 ! 118 IF ( fxyhypb ) THEN 119 tab_cntrl(idecal+19) = 1. 120 tab_cntrl(idecal+20) = dzoomx 121 tab_cntrl(idecal+21) = dzoomy 122 tab_cntrl(idecal+22) = 0. 123 tab_cntrl(idecal+23) = taux 124 tab_cntrl(idecal+24) = tauy 125 ELSE 126 tab_cntrl(idecal+19) = 0. 127 tab_cntrl(idecal+20) = dzoomx 128 tab_cntrl(idecal+21) = dzoomy 129 tab_cntrl(idecal+22) = 0. 130 tab_cntrl(idecal+23) = 0. 131 tab_cntrl(idecal+24) = 0. 132 IF( ysinus ) tab_cntrl(idecal+22) = 1. 133 ENDIF 134 135 if (start_file_type.eq."earth") then 136 tab_cntrl(idecal+25) = REAL(iday_end) 137 tab_cntrl(idecal+26) = REAL(itau_dyn + itaufin) 138 ! start_time: start_time of simulation (not necessarily 0.) 139 tab_cntrl(idecal+27) = start_time 140 endif 141 142 if (planet_type=="mars") then ! For Mars only 143 tab_cntrl(29)=hour_ini 144 endif 145 146 !--- File creation 147 CALL err(NF90_CREATE(fichnom,NF90_CLOBBER,nid)) 148 149 !--- Some global attributes 150 CALL err(NF90_PUT_ATT(nid,NF90_GLOBAL,"title","Fichier demarrage dynamique")) 151 152 !--- Dimensions 153 if (start_file_type.eq."earth") then 154 CALL err(NF90_DEF_DIM(nid,"index", length, indexID)) 155 CALL err(NF90_DEF_DIM(nid,"rlonu", iip1, rlonuID)) 156 CALL err(NF90_DEF_DIM(nid,"rlatu", jjp1, rlatuID)) 157 CALL err(NF90_DEF_DIM(nid,"rlonv", iip1, rlonvID)) 158 CALL err(NF90_DEF_DIM(nid,"rlatv", jjm, rlatvID)) 159 CALL err(NF90_DEF_DIM(nid,"sigs", llm, sID)) 160 CALL err(NF90_DEF_DIM(nid,"sig", llmp1, sigID)) 161 CALL err(NF90_DEF_DIM(nid,"temps", NF90_UNLIMITED, timID)) 162 else 163 CALL err(NF90_DEF_DIM(nid,"index", length, indexID)) 164 CALL err(NF90_DEF_DIM(nid,"rlonu", iip1, rlonuID)) 165 CALL err(NF90_DEF_DIM(nid,"latitude", jjp1, rlatuID)) 166 CALL err(NF90_DEF_DIM(nid,"longitude", iip1, rlonvID)) 167 CALL err(NF90_DEF_DIM(nid,"rlatv", jjm, rlatvID)) 168 CALL err(NF90_DEF_DIM(nid,"altitude", llm, sID)) 169 CALL err(NF90_DEF_DIM(nid,"interlayer", llmp1, sigID)) 170 CALL err(NF90_DEF_DIM(nid,"Time", NF90_UNLIMITED, timID)) 171 endif 172 173 !--- Define and save invariant fields 174 CALL put_var1(nid,"controle","Parametres de controle" ,[indexID],tab_cntrl) 175 CALL put_var1(nid,"rlonu" ,"Longitudes des points U",[rlonuID],rlonu) 176 CALL put_var1(nid,"rlatu" ,"Latitudes des points U" ,[rlatuID],rlatu) 177 CALL put_var1(nid,"rlonv" ,"Longitudes des points V",[rlonvID],rlonv) 178 CALL put_var1(nid,"rlatv" ,"Latitudes des points V" ,[rlatvID],rlatv) 179 if (start_file_type.eq."earth") then 180 CALL put_var1(nid,"nivsigs" ,"Numero naturel des couches s" ,[sID] ,nivsigs) 181 CALL put_var1(nid,"nivsig" ,"Numero naturel des couches sigma",[sigID],nivsig) 182 endif ! of if (start_file_type.eq."earth") 183 CALL put_var1(nid,"ap" ,"Coefficient A pour hybride" ,[sigID],ap) 184 CALL put_var1(nid,"bp" ,"Coefficient B pour hybride" ,[sigID],bp) 185 if (start_file_type.ne."earth") then 186 CALL put_var1(nid,"aps","Coef AS: hybrid pressure at midlayers",[sID],aps) 187 CALL put_var1(nid,"bps","Coef BS: hybrid sigma at midlayers",[sID],bps) 188 endif ! of if (start_file_type.eq."earth") 189 CALL put_var1(nid,"presnivs","" ,[sID] ,presnivs) 190 if (start_file_type.ne."earth") then 355 191 ierr = NF_REDEF (nid) 356 192 #ifdef NC_DOUBLE 357 ierr = NF_DEF_VAR(nid,"latitude",NF_DOUBLE,1, idim_rlatu,nvarid)193 ierr = NF_DEF_VAR(nid,"latitude",NF_DOUBLE,1,rlatuID,vID) 358 194 #else 359 ierr = NF_DEF_VAR(nid,"latitude",NF_FLOAT,1, idim_rlatu,nvarid)195 ierr = NF_DEF_VAR(nid,"latitude",NF_FLOAT,1,rlatuID,vID) 360 196 #endif 361 ierr =NF_PUT_ATT_TEXT(nid, nvarid,'units',13,"degrees_north")362 ierr = NF_PUT_ATT_TEXT (nid, nvarid,"long_name", 14,363 ."North latitude")197 ierr =NF_PUT_ATT_TEXT(nid,vID,'units',13,"degrees_north") 198 ierr = NF_PUT_ATT_TEXT (nid,vID,"long_name", 14, & 199 "North latitude") 364 200 ierr = NF_ENDDEF(nid) 365 call NF95_PUT_VAR(nid, nvarid,rlatu*180/pi)366 c 201 call NF95_PUT_VAR(nid,vID,rlatu*180/pi) 202 ! 367 203 ierr = NF_REDEF (nid) 368 204 #ifdef NC_DOUBLE 369 ierr=NF_DEF_VAR(nid,"longitude",NF_DOUBLE,1, idim_rlonv,nvarid)205 ierr=NF_DEF_VAR(nid,"longitude",NF_DOUBLE,1,rlonvID,vID) 370 206 #else 371 ierr=NF_DEF_VAR(nid,"longitude",NF_FLOAT,1, idim_rlonv,nvarid)207 ierr=NF_DEF_VAR(nid,"longitude",NF_FLOAT,1,rlonvID,vID) 372 208 #endif 373 ierr = NF_PUT_ATT_TEXT (nid, nvarid,"long_name", 14,374 ."East longitude")375 ierr = NF_PUT_ATT_TEXT(nid, nvarid,'units',12,"degrees_east")209 ierr = NF_PUT_ATT_TEXT (nid,vID,"long_name", 14, & 210 "East longitude") 211 ierr = NF_PUT_ATT_TEXT(nid,vID,'units',12,"degrees_east") 376 212 ierr = NF_ENDDEF(nid) 377 call NF95_PUT_VAR(nid, nvarid,rlonv*180/pi)378 c 213 call NF95_PUT_VAR(nid,vID,rlonv*180/pi) 214 ! 379 215 ierr = NF_REDEF (nid) 380 216 #ifdef NC_DOUBLE 381 ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, 382 . idim_s,nvarid)217 ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, & 218 sID,vID) 383 219 #else 384 ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, 385 . idim_s,nvarid)220 ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, & 221 sID,vID) 386 222 #endif 387 ierr = NF_PUT_ATT_TEXT(nid, nvarid,"long_name",10,"pseudo-alt")388 ierr = NF_PUT_ATT_TEXT (nid, nvarid,'units',2,"km")389 ierr = NF_PUT_ATT_TEXT (nid, nvarid,'positive',2,"up")223 ierr = NF_PUT_ATT_TEXT(nid,vID,"long_name",10,"pseudo-alt") 224 ierr = NF_PUT_ATT_TEXT (nid,vID,'units',2,"km") 225 ierr = NF_PUT_ATT_TEXT (nid,vID,'positive',2,"up") 390 226 ierr = NF_ENDDEF(nid) 391 call NF95_PUT_VAR(nid,nvarid,pseudoalt) 392 endif ! of if (start_file_type.ne."earth") 393 c 394 c Coefficients de passage cov. <-> contra. <--> naturel 395 c 396 ierr = NF_REDEF (nid) 397 dims2(1) = idim_rlonu 398 dims2(2) = idim_rlatu 399 cIM 220306 BEG 400 #ifdef NC_DOUBLE 401 ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid) 402 #else 403 ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid) 404 #endif 405 cIM 220306 END 406 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29, 407 . "Coefficient de passage pour U") 408 ierr = NF_ENDDEF(nid) 409 call NF95_PUT_VAR(nid,nvarid,cu) 410 c 411 ierr = NF_REDEF (nid) 412 dims2(1) = idim_rlonv 413 dims2(2) = idim_rlatv 414 cIM 220306 BEG 415 #ifdef NC_DOUBLE 416 ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid) 417 #else 418 ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid) 419 #endif 420 cIM 220306 END 421 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29, 422 . "Coefficient de passage pour V") 423 ierr = NF_ENDDEF(nid) 424 call NF95_PUT_VAR(nid,nvarid,cv) 425 c 426 c Aire de chaque maille: 427 c 428 ierr = NF_REDEF (nid) 429 dims2(1) = idim_rlonv 430 dims2(2) = idim_rlatu 431 cIM 220306 BEG 432 #ifdef NC_DOUBLE 433 ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid) 434 #else 435 ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid) 436 #endif 437 cIM 220306 END 438 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, 439 . "Aires de chaque maille") 440 ierr = NF_ENDDEF(nid) 441 call NF95_PUT_VAR(nid,nvarid,aire) 442 c 443 c Geopentiel au sol: 444 c 445 ierr = NF_REDEF (nid) 446 dims2(1) = idim_rlonv 447 dims2(2) = idim_rlatu 448 cIM 220306 BEG 449 #ifdef NC_DOUBLE 450 ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid) 451 #else 452 ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid) 453 #endif 454 cIM 220306 END 455 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, 456 . "Geopotentiel au sol") 457 ierr = NF_ENDDEF(nid) 458 call NF95_PUT_VAR(nid,nvarid,phis) 459 c 460 c Definir les variables pour pouvoir les enregistrer plus tard: 461 c 462 ierr = NF_REDEF (nid) ! entrer dans le mode de definition 463 c 464 if (start_file_type.eq."earth") then 465 cIM 220306 BEG 466 #ifdef NC_DOUBLE 467 ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid) 468 #else 469 ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid) 470 #endif 471 cIM 220306 END 472 else ! start_file_type=="planeto" 473 #ifdef NC_DOUBLE 474 ierr = NF_DEF_VAR (nid,"Time",NF_DOUBLE,1,idim_tim,nvarid) 475 #else 476 ierr = NF_DEF_VAR (nid,"Time",NF_FLOAT,1,idim_tim,nvarid) 477 #endif 478 endif ! of if (start_file_type.eq."earth") 479 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, 480 . "Temps de simulation") 481 write(unites,200)yyears0,mmois0,jjour0 482 200 format('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00') 483 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "units", 30, 484 . unites) 485 486 c 487 dims4(1) = idim_rlonu 488 dims4(2) = idim_rlatu 489 dims4(3) = idim_s 490 dims4(4) = idim_tim 491 cIM 220306 BEG 492 #ifdef NC_DOUBLE 493 ierr = NF_DEF_VAR (nid,"ucov",NF_DOUBLE,4,dims4,nvarid) 494 #else 495 ierr = NF_DEF_VAR (nid,"ucov",NF_FLOAT,4,dims4,nvarid) 496 #endif 497 cIM 220306 END 498 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, 499 . "Vitesse U") 500 c 501 dims4(1) = idim_rlonv 502 dims4(2) = idim_rlatv 503 dims4(3) = idim_s 504 dims4(4) = idim_tim 505 cIM 220306 BEG 506 #ifdef NC_DOUBLE 507 ierr = NF_DEF_VAR (nid,"vcov",NF_DOUBLE,4,dims4,nvarid) 508 #else 509 ierr = NF_DEF_VAR (nid,"vcov",NF_FLOAT,4,dims4,nvarid) 510 #endif 511 cIM 220306 END 512 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, 513 . "Vitesse V") 514 c 515 dims4(1) = idim_rlonv 516 dims4(2) = idim_rlatu 517 dims4(3) = idim_s 518 dims4(4) = idim_tim 519 cIM 220306 BEG 520 #ifdef NC_DOUBLE 521 ierr = NF_DEF_VAR (nid,"teta",NF_DOUBLE,4,dims4,nvarid) 522 #else 523 ierr = NF_DEF_VAR (nid,"teta",NF_FLOAT,4,dims4,nvarid) 524 #endif 525 cIM 220306 END 526 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 11, 527 . "Temperature") 528 c 529 dims4(1) = idim_rlonv 530 dims4(2) = idim_rlatu 531 dims4(3) = idim_s 532 dims4(4) = idim_tim 533 IF(nqtot.GE.1) THEN 534 DO iq=1,nqtot 535 cIM 220306 BEG 536 #ifdef NC_DOUBLE 537 ierr = NF_DEF_VAR (nid,tname(iq),NF_DOUBLE,4,dims4,nvarid) 538 #else 539 ierr = NF_DEF_VAR (nid,tname(iq),NF_FLOAT,4,dims4,nvarid) 540 #endif 541 cIM 220306 END 542 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,ttext(iq)) 543 ENDDO 544 ENDIF 545 c 546 dims4(1) = idim_rlonv 547 dims4(2) = idim_rlatu 548 dims4(3) = idim_s 549 dims4(4) = idim_tim 550 cIM 220306 BEG 551 #ifdef NC_DOUBLE 552 ierr = NF_DEF_VAR (nid,"masse",NF_DOUBLE,4,dims4,nvarid) 553 #else 554 ierr = NF_DEF_VAR (nid,"masse",NF_FLOAT,4,dims4,nvarid) 555 #endif 556 cIM 220306 END 557 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12, 558 . "C est quoi ?") 559 c 560 dims3(1) = idim_rlonv 561 dims3(2) = idim_rlatu 562 dims3(3) = idim_tim 563 cIM 220306 BEG 564 #ifdef NC_DOUBLE 565 ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid) 566 #else 567 ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid) 568 #endif 569 cIM 220306 END 570 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 15, 571 . "Pression au sol") 572 c 573 ierr = NF_ENDDEF(nid) ! sortir du mode de definition 574 ierr = NF_CLOSE(nid) ! fermer le fichier 575 576 write(lunout,*)'dynredem0: iim,jjm,llm,iday_end', 577 & iim,jjm,llm,iday_end 578 write(lunout,*)'dynredem0: rad,omeg,g,cpp,kappa', 579 & rad,omeg,g,cpp,kappa 580 581 RETURN 582 END 227 call NF95_PUT_VAR(nid,vID,pseudoalt) 228 CALL err(NF_REDEF(nid)) 229 endif ! of if (start_file_type.ne."earth") 230 231 ! covariant <-> contravariant <-> natural conversion coefficients 232 CALL put_var2(nid,"cu","Coefficient de passage pour U",[rlonuID,rlatuID],cu) 233 CALL put_var2(nid,"cv","Coefficient de passage pour V",[rlonvID,rlatvID],cv) 234 CALL put_var2(nid,"aire","Aires de chaque maille" ,[rlonvID,rlatuID],aire) 235 CALL put_var2(nid,"phisinit","Geopotentiel au sol" ,[rlonvID,rlatuID],phis) 236 237 238 ! Define variables that will be stored later: 239 WRITE(unites,"('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')"),& 240 yyears0,mmois0,jjour0 241 IF (planet_type.eq."earth") THEN 242 CALL cre_var(nid,"temps","Temps de simulation",[timID],unites) 243 ELSE 244 CALL cre_var(nid,"Time","Temps de simulation",[timID],unites) 245 ENDIF 246 247 CALL cre_var(nid,"ucov" ,"Vitesse U" ,[rlonuID,rlatuID,sID,timID]) 248 CALL cre_var(nid,"vcov" ,"Vitesse V" ,[rlonvID,rlatvID,sID,timID]) 249 CALL cre_var(nid,"teta" ,"Temperature",[rlonvID,rlatuID,sID,timID]) 250 251 IF(nqtot.GE.1) THEN 252 DO iq=1,nqtot 253 CALL cre_var(nid,tname(iq),ttext(iq),[rlonvID,rlatuID,sID,timID]) 254 END DO 255 ENDIF 256 257 CALL cre_var(nid,"masse","Masse d air" ,[rlonvID,rlatuID,sID,timID]) 258 CALL cre_var(nid,"ps" ,"Pression au sol",[rlonvID,rlatuID ,timID]) 259 260 CALL err(NF90_CLOSE (nid)) ! close file 261 262 WRITE(lunout,*)TRIM(modname)//': iim,jjm,llm,iday_end',iim,jjm,llm,iday_end 263 WRITE(lunout,*)TRIM(modname)//': rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa 264 265 END SUBROUTINE dynredem0 583 266 584 267 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 585 268 586 SUBROUTINE dynredem1(fichnom,time, 587 . vcov,ucov,teta,q,masse,ps) 588 USE infotrac 589 USE control_mod, only : planet_type 590 use netcdf, only: NF90_get_VAR 591 use netcdf95, only: NF95_PUT_VAR 592 USE temps_mod, ONLY: itaufin,itau_dyn 269 SUBROUTINE dynredem1(fichnom,time,vcov,ucov,teta,q,masse,ps) 270 ! 271 !------------------------------------------------------------------------------- 272 ! Purpose: Write the NetCDF restart file (append). 273 !------------------------------------------------------------------------------- 274 USE infotrac, ONLY: nqtot, tname, type_trac 275 USE control_mod, only : planet_type 276 USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_GET_VAR, NF90_INQ_VARID, & 277 NF90_CLOSE, NF90_WRITE, NF90_PUT_VAR, NF90_NoErr 278 use netcdf95, only: NF95_PUT_VAR 279 USE temps_mod, ONLY: itaufin,itau_dyn 280 USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, & 281 err, modname, fil, msg 593 282 594 IMPLICIT NONE 595 c================================================================= 596 c Ecriture du fichier de redemarrage sous format NetCDF 597 c================================================================= 598 #include "dimensions.h" 599 #include "paramet.h" 600 #include "netcdf.inc" 601 #include "comgeom.h" 602 #include "iniprint.h" 603 604 605 INTEGER l 606 REAL vcov(iip1,jjm,llm),ucov(iip1, jjp1,llm) 607 REAL teta(iip1, jjp1,llm) 608 REAL ps(iip1, jjp1),masse(iip1, jjp1,llm) 609 REAL q(iip1, jjp1, llm, nqtot) 610 CHARACTER*(*) fichnom 611 612 REAL time 613 INTEGER nid, nvarid, nid_trac, nvarid_trac 614 REAL trac_tmp(ip1jmp1,llm) 615 INTEGER ierr, ierr_file 616 INTEGER iq 617 INTEGER length 618 PARAMETER (length = 100) 619 REAL tab_cntrl(length) ! tableau des parametres du run 620 character(len=*),parameter :: modname='dynredem1' 621 character*80 abort_message 622 c 623 INTEGER nb 624 SAVE nb 625 DATA nb / 0 / 626 character(len=12) :: start_file_type="earth" ! default start file type 627 628 if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then 629 write(lunout,*) trim(modname),' : Planeto-like start file' 630 start_file_type="planeto" 631 else 632 write(lunout,*) trim(modname),' : Earth-like start file' 633 endif 634 635 ierr = NF_OPEN(fichnom, NF_WRITE, nid) 636 IF (ierr .NE. NF_NOERR) THEN 637 PRINT*, "dynredem1: Pb. d ouverture "//trim(fichnom) 638 CALL abort_gcm("dynredem1", "", 1) 639 ENDIF 640 641 c Ecriture/extension de la coordonnee temps 642 643 nb = nb + 1 644 if (start_file_type.eq."earth") then 645 ierr = NF_INQ_VARID(nid, "temps", nvarid) 283 IMPLICIT NONE 284 include "dimensions.h" 285 include "paramet.h" 286 include "netcdf.inc" 287 include "comgeom.h" 288 include "iniprint.h" 289 !=============================================================================== 290 ! Arguments: 291 CHARACTER(LEN=*), INTENT(IN) :: fichnom !-- FILE NAME 292 REAL, INTENT(IN) :: time !-- TIME 293 REAL, INTENT(IN) :: vcov(iip1,jjm, llm) !-- V COVARIANT WIND 294 REAL, INTENT(IN) :: ucov(iip1,jjp1,llm) !-- U COVARIANT WIND 295 REAL, INTENT(IN) :: teta(iip1,jjp1,llm) !-- POTENTIAL TEMPERATURE 296 REAL, INTENT(INOUT) :: q(iip1,jjp1,llm,nqtot) !-- TRACERS 297 REAL, INTENT(IN) :: masse(iip1,jjp1,llm) !-- MASS PER CELL 298 REAL, INTENT(IN) :: ps(iip1,jjp1) !-- GROUND PRESSURE 299 !=============================================================================== 300 ! Local variables: 301 INTEGER :: l, iq, nid, vID, ierr, nid_trac, vID_trac 302 INTEGER,SAVE :: nb=0 303 INTEGER, PARAMETER :: length=100 304 REAL :: tab_cntrl(length) ! tableau des parametres du run 305 CHARACTER(LEN=256) :: var, dum 306 LOGICAL :: lread_inca 307 CHARACTER(LEN=80) :: abort_message 308 CHARACTER(len=12) :: start_file_type="earth" ! default start file type 309 310 ! fill dynredem_mod module variables 311 modname='dynredem1'; fil=fichnom 312 313 if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then 314 write(lunout,*) trim(modname),' : Planeto-like start file' 315 start_file_type="planeto" 316 else 317 write(lunout,*) trim(modname),' : Earth-like start file' 318 endif 319 320 CALL err(NF90_OPEN(fil,NF90_WRITE,nid),"open",fil) 321 322 !--- Write/extend time coordinate 323 nb = nb + 1 324 if (start_file_type.eq."earth") then 325 ierr = NF_INQ_VARID(nid, "temps", vID) 646 326 IF (ierr .NE. NF_NOERR) THEN 647 327 write(lunout,*) NF_STRERROR(ierr) … … 649 329 CALL abort_gcm(modname,abort_message,ierr) 650 330 ENDIF 651 652 ierr = NF_INQ_VARID(nid,"Time", nvarid)331 else 332 ierr = NF_INQ_VARID(nid,"Time", vID) 653 333 IF (ierr .NE. NF_NOERR) THEN 654 334 write(lunout,*) NF_STRERROR(ierr) … … 656 336 CALL abort_gcm(modname,abort_message,ierr) 657 337 ENDIF 658 endif ! of if (start_file_type.eq."earth") 659 call NF95_PUT_VAR(nid,nvarid,time,start=(/nb/)) 660 write(lunout,*) "dynredem1: Enregistrement pour ", nb, time 661 662 c 663 c Re-ecriture du tableau de controle, itaufin n'est plus defini quand 664 c on passe dans dynredem0 665 ierr = NF_INQ_VARID (nid, "controle", nvarid) 666 IF (ierr .NE. NF_NOERR) THEN 667 abort_message="dynredem1: Le champ <controle> est absent" 668 ierr = 1 669 CALL abort_gcm(modname,abort_message,ierr) 670 ENDIF 671 ierr = NF90_GET_VAR(nid, nvarid, tab_cntrl) 672 if (start_file_type=="earth") then 673 tab_cntrl(31) = REAL(itau_dyn + itaufin) 674 else 675 tab_cntrl(31) = 0 676 endif 677 call NF95_PUT_VAR(nid,nvarid,tab_cntrl) 678 679 c Ecriture des champs 680 c 681 ierr = NF_INQ_VARID(nid, "ucov", nvarid) 682 IF (ierr .NE. NF_NOERR) THEN 683 abort_message="Variable ucov n est pas definie" 684 ierr=1 685 CALL abort_gcm(modname,abort_message,ierr) 686 ENDIF 687 call NF95_PUT_VAR(nid,nvarid,ucov,start=(/1,1,1,nb/)) 688 689 ierr = NF_INQ_VARID(nid, "vcov", nvarid) 690 IF (ierr .NE. NF_NOERR) THEN 691 abort_message="Variable vcov n est pas definie" 692 ierr=1 693 CALL abort_gcm(modname,abort_message,ierr) 694 ENDIF 695 call NF95_PUT_VAR(nid,nvarid,vcov,start=(/1,1,1,nb/)) 696 697 ierr = NF_INQ_VARID(nid, "teta", nvarid) 698 IF (ierr .NE. NF_NOERR) THEN 699 abort_message="Variable teta n est pas definie" 700 ierr=1 701 CALL abort_gcm(modname,abort_message,ierr) 702 ENDIF 703 call NF95_PUT_VAR(nid,nvarid,teta,start=(/1,1,1,nb/)) 704 705 IF (type_trac == 'inca') THEN 706 ! Ajout Anne pour lecture valeurs traceurs dans un fichier start_trac.nc 707 ierr_file = NF_OPEN ("start_trac.nc", NF_NOWRITE,nid_trac) 708 IF (ierr_file .NE.NF_NOERR) THEN 709 write(lunout,*)'dynredem1: Pb d''ouverture du fichier', 710 & ' start_trac.nc' 711 write(lunout,*)' ierr = ', ierr_file 712 ENDIF 713 END IF 714 715 IF(nqtot.GE.1) THEN 716 do iq=1,nqtot 717 718 IF (type_trac /= 'inca') THEN 719 ierr = NF_INQ_VARID(nid, tname(iq), nvarid) 720 IF (ierr .NE. NF_NOERR) THEN 721 abort_message="Variable tname(iq) n est pas definie" 722 ierr=1 723 CALL abort_gcm(modname,abort_message,ierr) 724 ENDIF 725 call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),start=(/1,1,1,nb/)) 726 ELSE ! type_trac = inca 727 ! lecture de la valeur du traceur dans start_trac.nc 728 IF (ierr_file .ne. 2) THEN 729 ierr = NF_INQ_VARID (nid_trac, tname(iq), nvarid_trac) 730 IF (ierr .NE. NF_NOERR) THEN 731 write(lunout,*) "dynredem1: ",trim(tname(iq)), 732 & " est absent de start_trac.nc" 733 ierr = NF_INQ_VARID(nid, tname(iq), nvarid) 734 IF (ierr .NE. NF_NOERR) THEN 735 abort_message="dynredem1: Variable "// 736 & trim(tname(iq))//" n est pas definie" 737 ierr=1 738 CALL abort_gcm(modname,abort_message,ierr) 739 ENDIF 740 call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq)) 741 742 ELSE 743 write(lunout,*) "dynredem1: ",trim(tname(iq)), 744 & " est present dans start_trac.nc" 745 ierr = NF90_GET_VAR(nid_trac, nvarid_trac, trac_tmp) 746 IF (ierr .NE. NF_NOERR) THEN 747 abort_message="dynredem1: Lecture echouee pour"// 748 & trim(tname(iq)) 749 ierr=1 750 CALL abort_gcm(modname,abort_message,ierr) 751 ENDIF 752 ierr = NF_INQ_VARID(nid, tname(iq), nvarid) 753 IF (ierr .NE. NF_NOERR) THEN 754 abort_message="dynredem1: Variable "// 755 & trim(tname(iq))//" n est pas definie" 756 ierr=1 757 CALL abort_gcm(modname,abort_message,ierr) 758 ENDIF 759 call NF95_PUT_VAR(nid, nvarid, trac_tmp) 760 761 ENDIF ! IF (ierr .NE. NF_NOERR) 762 ! fin lecture du traceur 763 ELSE ! si il n'y a pas de fichier start_trac.nc 764 ! print *, 'il n y a pas de fichier start_trac' 765 ierr = NF_INQ_VARID(nid, tname(iq), nvarid) 766 IF (ierr .NE. NF_NOERR) THEN 767 abort_message="dynredem1: Variable "// 768 & trim(tname(iq))//" n est pas definie" 769 ierr=1 770 CALL abort_gcm(modname,abort_message,ierr) 771 ENDIF 772 call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq), 773 & start=(/1,1,1,nb/)) 774 ENDIF ! (ierr_file .ne. 2) 775 END IF !type_trac 776 777 ENDDO 778 ENDIF 779 c 780 ierr = NF_INQ_VARID(nid, "masse", nvarid) 781 IF (ierr .NE. NF_NOERR) THEN 782 abort_message="dynredem1: Variable masse n est pas definie" 783 ierr=1 784 CALL abort_gcm(modname,abort_message,ierr) 785 ENDIF 786 call NF95_PUT_VAR(nid,nvarid,masse,start=(/1,1,1,nb/)) 787 c 788 ierr = NF_INQ_VARID(nid, "ps", nvarid) 789 IF (ierr .NE. NF_NOERR) THEN 790 abort_message="dynredem1: Variable ps n est pas definie" 791 ierr=1 792 CALL abort_gcm(modname,abort_message,ierr) 793 ENDIF 794 call NF95_PUT_VAR(nid,nvarid,ps,start=(/1,1,nb/)) 795 796 ierr = NF_CLOSE(nid) 797 c 798 RETURN 799 END 800 338 endif ! of if (start_file_type.eq."earth") 339 call NF95_PUT_VAR(nid,vID,time,start=(/nb/)) 340 WRITE(lunout,*)TRIM(modname)//": Saving for ", nb, time 341 342 !--- Rewrite control table (itaufin undefined in dynredem0) 343 var="controle" 344 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 345 CALL err(NF90_GET_VAR(nid,vID,tab_cntrl),"get",var) 346 if (start_file_type=="earth") then 347 tab_cntrl(31) = REAL(itau_dyn + itaufin) 348 else 349 tab_cntrl(31) = 0 350 endif 351 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 352 CALL err(NF90_PUT_VAR(nid,vID,tab_cntrl),"put",var) 353 354 !--- Save fields 355 CALL dynredem_write_u(nid,"ucov" ,ucov ,llm, nb) 356 CALL dynredem_write_v(nid,"vcov" ,vcov ,llm, nb) 357 CALL dynredem_write_u(nid,"teta" ,teta ,llm, nb) 358 CALL dynredem_write_u(nid,"masse",masse,llm, nb) 359 CALL dynredem_write_u(nid,"ps" ,ps ,1, nb) 360 361 !--- Tracers in file "start_trac.nc" (added by Anne) 362 lread_inca=.FALSE.; fil="start_trac.nc" 363 IF(type_trac=='inca') INQUIRE(FILE=fil,EXIST=lread_inca) 364 IF(lread_inca) CALL err(NF90_OPEN(fil,NF90_NOWRITE,nid_trac),"open") 365 366 !--- Save tracers 367 IF(nqtot.GE.1) THEN 368 DO iq=1,nqtot 369 var=tname(iq); ierr=-1 370 IF(lread_inca) THEN !--- Possibly read from "start_trac.nc" 371 fil="start_trac.nc" 372 ierr=NF90_INQ_VARID(nid_trac,var,vID_trac) 373 dum='inq'; IF(ierr==NF90_NoErr) dum='fnd' 374 WRITE(lunout,*)msg(dum,var) 375 376 377 IF(ierr==NF90_NoErr) CALL dynredem_read_u(nid_trac,var,q(:,:,:,iq),llm) 378 END IF ! of IF(lread_inca) 379 fil=fichnom 380 CALL dynredem_write_u(nid,var,q(:,:,:,iq),llm,nb) 381 END DO ! of DO iq=1,nqtot 382 ENDIF ! of IF(nqtot.GE.1) 383 384 CALL err(NF90_CLOSE(nid),"close") 385 fil="start_trac.nc" 386 IF(lread_inca) CALL err(NF90_CLOSE(nid_trac),"close") 387 388 END SUBROUTINE dynredem1 389
Note: See TracChangeset
for help on using the changeset viewer.