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