Changeset 2299 for LMDZ5/trunk/libf/dyn3d
- Timestamp:
- Jun 15, 2015, 8:48:31 PM (10 years ago)
- Location:
- LMDZ5/trunk/libf/dyn3d
- Files:
-
- 1 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ5/trunk/libf/dyn3d/dynetat0.f90
r2298 r2299 109 109 CALL get_var2("cv" ,cv) 110 110 CALL get_var2("aire" ,aire) 111 CALL get_var2("phisinit",phis)112 111 var="temps" 113 112 IF(NF90_INQ_VARID(fID,var,vID)/=NF90_NoErr) THEN … … 117 116 END IF 118 117 CALL err(NF90_GET_VAR(fID,vID,time),"get",var) 118 CALL get_var2("phisinit",phis) 119 119 CALL get_var3("ucov",ucov) 120 120 CALL get_var3("vcov",vcov) … … 126 126 DO iq=1,nqtot 127 127 var=tname(iq) 128 IF(NF90_INQ_VARID(fID,var,vID)/=NF90_NoErr) THEN 129 WRITE(lunout,*)TRIM(modname)//": Tracer <"//TRIM(var)//"> is missing" 130 WRITE(lunout,*)" It is hence initialized to zero" 131 q(:,:,:,iq)=0. 132 ELSE 133 CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",var) 128 IF(NF90_INQ_VARID(fID,var,vID)==NF90_NoErr) THEN 129 CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",var); CYCLE 130 END IF 131 WRITE(lunout,*)TRIM(modname)//": Tracer <"//TRIM(var)//"> is missing" 132 WRITE(lunout,*)" It is hence initialized to zero" 133 q(:,:,:,iq)=0. 134 !--- CRisi: for isotops, theoretical initialization using very simplified 135 ! Rayleigh distillation las. 136 IF(ok_isotopes.AND.iso_num(iq)>0) THEN 137 IF(zone_num(iq)==0) q(:,:,:,iq)=q(:,:,:,iqpere(iq))*tnat(iso_num(iq)) & 138 & *(q(:,:,:,iqpere(iq))/30.e-3)**(alpha_ideal(iso_num(iq))-1) 139 IF(zone_num(iq)==1) q(:,:,:,iq)=q(:,:,:,iqiso(iso_indnum(iq),phase_num(iq))) 134 140 END IF 135 141 END DO … … 158 164 SUBROUTINE get_var1(var,v) 159 165 CHARACTER(LEN=*), INTENT(IN) :: var 160 #ifdef NC_DOUBLE161 DOUBLE PRECISION, INTENT(OUT) :: v(:)162 #else163 166 REAL, INTENT(OUT) :: v(:) 164 #endif165 167 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 166 168 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) … … 170 172 SUBROUTINE get_var2(var,v) 171 173 CHARACTER(LEN=*), INTENT(IN) :: var 172 #ifdef NC_DOUBLE173 DOUBLE PRECISION, INTENT(OUT) :: v(:,:)174 #else175 174 REAL, INTENT(OUT) :: v(:,:) 176 #endif177 175 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 178 176 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) … … 182 180 SUBROUTINE get_var3(var,v) 183 181 CHARACTER(LEN=*), INTENT(IN) :: var 184 #ifdef NC_DOUBLE185 DOUBLE PRECISION, INTENT(OUT) :: v(:,:,:)186 #else187 182 REAL, INTENT(OUT) :: v(:,:,:) 188 #endif189 183 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 190 184 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) -
LMDZ5/trunk/libf/dyn3d/dynredem.F90
r2293 r2299 8 8 #endif 9 9 USE infotrac 10 USE netcdf, ONLY: NF90_CREATE, NF90_DEF_DIM, NF90_REDEF, NF90_INQ_VARID, & 11 NF90_CLOBBER, NF90_CLOSE, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_ATT, & 12 NF90_UNLIMITED, NF90_GLOBAL, NF90_FLOAT, NF90_DOUBLE 13 USE netcdf95, ONLY: NF95_PUT_VAR 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 14 13 IMPLICIT NONE 15 14 include "dimensions.h" … … 21 20 include "ener.h" 22 21 include "logic.h" 23 include "netcdf.inc"24 22 include "description.h" 25 23 include "serre.h" … … 35 33 INTEGER, PARAMETER :: length=100 36 34 REAL :: tab_cntrl(length) !--- RUN PARAMETERS TABLE 37 CHARACTER(LEN=20) :: modname38 35 ! For NetCDF: 39 36 CHARACTER(LEN=30) :: unites … … 42 39 INTEGER :: sID, sigID, nID, vID, timID 43 40 INTEGER :: yyears0, jjour0, mmois0 44 REAL :: zan0, zjulian, hours45 !=============================================================================== 46 modname='dynredem0' 41 REAL :: zan0, zjulian, hours 42 !=============================================================================== 43 modname='dynredem0'; fil=fichnom 47 44 #ifdef CPP_IOIPSL 48 45 CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) … … 102 99 ! start_time: start_time of simulation (not necessarily 0.) 103 100 tab_cntrl(32) = start_time 104 !.........................................................105 101 106 102 !--- File creation … … 121 117 122 118 !--- Define and save invariant fields 123 CALL put_var1( "controle","Parametres de controle" ,[indexID],tab_cntrl)124 CALL put_var1( "rlonu" ,"Longitudes des points U",[rlonuID],rlonu)125 CALL put_var1( "rlatu" ,"Latitudes des points U" ,[rlatuID],rlatu)126 CALL put_var1( "rlonv" ,"Longitudes des points V",[rlonvID],rlonv)127 CALL put_var1( "rlatv" ,"Latitudes des points V" ,[rlatvID],rlatv)128 CALL put_var1( "nivsigs" ,"Numero naturel des couches s" ,[sID] ,nivsigs)129 CALL put_var1( "nivsig" ,"Numero naturel des couches sigma",[sigID],nivsig)130 CALL put_var1( "ap" ,"Coefficient A pour hybride" ,[sigID],ap)131 CALL put_var1( "bp" ,"Coefficient B pour hybride" ,[sigID],bp)132 CALL put_var1( "presnivs","" ,[sID] ,presnivs)119 CALL put_var1(nid,"controle","Parametres de controle" ,[indexID],tab_cntrl) 120 CALL put_var1(nid,"rlonu" ,"Longitudes des points U",[rlonuID],rlonu) 121 CALL put_var1(nid,"rlatu" ,"Latitudes des points U" ,[rlatuID],rlatu) 122 CALL put_var1(nid,"rlonv" ,"Longitudes des points V",[rlonvID],rlonv) 123 CALL put_var1(nid,"rlatv" ,"Latitudes des points V" ,[rlatvID],rlatv) 124 CALL put_var1(nid,"nivsigs" ,"Numero naturel des couches s" ,[sID] ,nivsigs) 125 CALL put_var1(nid,"nivsig" ,"Numero naturel des couches sigma",[sigID],nivsig) 126 CALL put_var1(nid,"ap" ,"Coefficient A pour hybride" ,[sigID],ap) 127 CALL put_var1(nid,"bp" ,"Coefficient B pour hybride" ,[sigID],bp) 128 CALL put_var1(nid,"presnivs","" ,[sID] ,presnivs) 133 129 ! covariant <-> contravariant <-> natural conversion coefficients 134 CALL put_var2( "cu","Coefficient de passage pour U",[rlonuID,rlatuID],cu)135 CALL put_var2( "cv","Coefficient de passage pour V",[rlonvID,rlatvID],cv)136 CALL put_var2( "aire","Aires de chaque maille" ,[rlonvID,rlatuID],aire)137 CALL put_var2( "phisinit","Geopotentiel au sol" ,[rlonvID,rlatuID],phis)130 CALL put_var2(nid,"cu","Coefficient de passage pour U",[rlonuID,rlatuID],cu) 131 CALL put_var2(nid,"cv","Coefficient de passage pour V",[rlonvID,rlatvID],cv) 132 CALL put_var2(nid,"aire","Aires de chaque maille" ,[rlonvID,rlatuID],aire) 133 CALL put_var2(nid,"phisinit","Geopotentiel au sol" ,[rlonvID,rlatuID],phis) 138 134 139 135 !--- Define fields saved later 140 136 WRITE(unites,"('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')"),& 141 137 yyears0,mmois0,jjour0 142 CALL put_var0("temps","Temps de simulation",[timID],unites)143 CALL put_var0("ucov" ,"Vitesse U" ,[rlonuID,rlatuID,sID,timID])144 CALL put_var0("vcov" ,"Vitesse V" ,[rlonvID,rlatvID,sID,timID])145 CALL put_var0("teta" ,"Temperature",[rlonvID,rlatuID,sID,timID])138 CALL cre_var(nid,"temps","Temps de simulation",[timID],unites) 139 CALL cre_var(nid,"ucov" ,"Vitesse U" ,[rlonuID,rlatuID,sID,timID]) 140 CALL cre_var(nid,"vcov" ,"Vitesse V" ,[rlonvID,rlatvID,sID,timID]) 141 CALL cre_var(nid,"teta" ,"Temperature",[rlonvID,rlatuID,sID,timID]) 146 142 DO iq=1,nqtot 147 CALL put_var0(tname(iq),ttext(iq),[rlonvID,rlatuID,sID,timID])143 CALL cre_var(nid,tname(iq),ttext(iq),[rlonvID,rlatuID,sID,timID]) 148 144 END DO 149 CALL put_var0("masse","Masse d air" ,[rlonvID,rlatuID,sID,timID]) 150 CALL put_var0("ps" ,"Pression au sol",[rlonvID,rlatuID ,timID]) 151 CALL err(NF90_ENDDEF(nid)) 145 CALL cre_var(nid,"masse","Masse d air" ,[rlonvID,rlatuID,sID,timID]) 146 CALL cre_var(nid,"ps" ,"Pression au sol",[rlonvID,rlatuID ,timID]) 152 147 CALL err(NF90_CLOSE (nid)) 153 148 … … 155 150 WRITE(lunout,*)TRIM(modname)//': rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa 156 151 157 158 CONTAINS159 160 161 SUBROUTINE put_var0(var,title,did,units)162 CHARACTER(LEN=*), INTENT(IN) :: var, title163 INTEGER, INTENT(IN) :: did(:)164 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units165 #ifdef NC_DOUBLE166 CALL err(NF90_DEF_VAR(nid,var,NF90_DOUBLE,did,vID),var)167 #else168 CALL err(NF90_DEF_VAR(nid,var,NF90_FLOAT,did,vID),var)169 #endif170 IF(title/="") CALL err(NF90_PUT_ATT(nid,vID,"title",title),var)171 IF(PRESENT(units)) CALL err(NF90_PUT_ATT(nid,vID,"units",units),var)172 END SUBROUTINE put_var0173 174 175 SUBROUTINE put_var1(var,title,did,v,units)176 CHARACTER(LEN=*), INTENT(IN) :: var, title177 INTEGER, INTENT(IN) :: did(1)178 #ifdef NC_DOUBLE179 DOUBLE PRECISION, INTENT(IN) :: v(:)180 #else181 REAL, INTENT(IN) :: v(:)182 #endif183 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units184 #ifdef NC_DOUBLE185 CALL err(NF90_DEF_VAR(nid,var,NF90_DOUBLE,did,vID),var)186 #else187 CALL err(NF90_DEF_VAR(nid,var,NF90_FLOAT,did,vID),var)188 #endif189 IF(title/="") CALL err(NF90_PUT_ATT(nid,vID,"title",title),var)190 IF(PRESENT(units)) CALL err(NF90_PUT_ATT(nid,vID,"units",units),var)191 CALL err(NF90_ENDDEF(nid))192 CALL NF95_PUT_VAR(nid,vID,v)193 CALL err(NF90_REDEF(nid))194 END SUBROUTINE put_var1195 196 197 SUBROUTINE put_var2(var,title,did,v,units)198 CHARACTER(LEN=*), INTENT(IN) :: var, title199 INTEGER, INTENT(IN) :: did(2)200 #ifdef NC_DOUBLE201 DOUBLE PRECISION, INTENT(IN) :: v(:,:)202 #else203 REAL, INTENT(IN) :: v(:,:)204 #endif205 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units206 #ifdef NC_DOUBLE207 CALL err(NF90_DEF_VAR(nid,var,NF90_DOUBLE,did,vID),var)208 #else209 CALL err(NF90_DEF_VAR(nid,var,NF90_FLOAT,did,vID),var)210 #endif211 IF(title/="") CALL err(NF90_PUT_ATT(nid,vID,"title",title),var)212 IF(PRESENT(units)) CALL err(NF90_PUT_ATT(nid,vID,"units",units),var)213 CALL err(NF90_ENDDEF(nid))214 CALL NF95_PUT_VAR(nid,vID,v)215 CALL err(NF90_REDEF(nid))216 217 END SUBROUTINE put_var2218 219 220 SUBROUTINE err(ierr,var)221 USE netcdf, ONLY: NF90_STRERROR, NF90_NOERR222 IMPLICIT NONE223 INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE224 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: var !--- VARIABLE NAME225 CHARACTER(LEN=256) :: file, msg226 IF(ierr==NF90_NoERR) RETURN227 msg='Error in "'//TRIM(modname)//'" for file "'//TRIM(fichnom)//'"'228 IF(PRESENT(var)) msg=TRIM(msg)//'" and variable "'//TRIM(var)//'"'229 WRITE(lunout,*)TRIM(msg)//': '//NF90_STRERROR(ierr)230 231 END SUBROUTINE err232 233 152 END SUBROUTINE dynredem0 234 153 ! … … 245 164 USE infotrac 246 165 USE control_mod 247 USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_ INQ_VARID, NF90_NoErr,&248 NF90_CLOSE, NF90_WRITE, NF90_ GET_VAR249 USE netcdf95, ONLY: NF95_PUT_VAR250 USE assert_eq_m, ONLY: assert_eq166 USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_GET_VAR, NF90_INQ_VARID, & 167 NF90_CLOSE, NF90_WRITE, NF90_PUT_VAR, NF90_NoErr 168 USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, & 169 err, modname, fil, msg 251 170 IMPLICIT NONE 252 #include "dimensions.h"253 #include "paramet.h"254 #include "description.h"255 #include "comvert.h"256 #include "comgeom.h"257 #include "temps.h"258 #include "iniprint.h"171 include "dimensions.h" 172 include "paramet.h" 173 include "description.h" 174 include "comvert.h" 175 include "comgeom.h" 176 include "temps.h" 177 include "iniprint.h" 259 178 !=============================================================================== 260 179 ! Arguments: 261 CHARACTER(LEN=*), INTENT(IN) :: fichnom !-- FILE NAME262 REAL, INTENT(IN) :: time !-- TIME263 REAL, INTENT(IN) :: vcov(iip1,jjm, llm) !-- V COVARIANT WIND264 REAL, INTENT(IN) :: ucov(iip1,jjp1,llm) !-- U COVARIANT WIND265 REAL, INTENT(IN) :: teta(iip1,jjp1,llm) !-- POTENTIAL TEMPERATURE266 REAL, INTENT(IN ) :: q(iip1,jjp1,llm,nqtot) !-- TRACERS267 REAL, INTENT(IN) :: masse(iip1,jjp1,llm) !-- MASS PER CELL268 REAL, INTENT(IN) :: ps(iip1,jjp1) !-- GROUND PRESSURE180 CHARACTER(LEN=*), INTENT(IN) :: fichnom !-- FILE NAME 181 REAL, INTENT(IN) :: time !-- TIME 182 REAL, INTENT(IN) :: vcov(iip1,jjm, llm) !-- V COVARIANT WIND 183 REAL, INTENT(IN) :: ucov(iip1,jjp1,llm) !-- U COVARIANT WIND 184 REAL, INTENT(IN) :: teta(iip1,jjp1,llm) !-- POTENTIAL TEMPERATURE 185 REAL, INTENT(INOUT) :: q(iip1,jjp1,llm,nqtot) !-- TRACERS 186 REAL, INTENT(IN) :: masse(iip1,jjp1,llm) !-- MASS PER CELL 187 REAL, INTENT(IN) :: ps(iip1,jjp1) !-- GROUND PRESSURE 269 188 !=============================================================================== 270 189 ! Local variables: 271 INTEGER :: l, iq, nid, vID, nid_trac, vID_trac190 INTEGER :: l, iq, nid, vID, ierr, nid_trac, vID_trac 272 191 INTEGER, SAVE :: nb=0 273 192 INTEGER, PARAMETER :: length=100 274 #ifdef NC_DOUBLE275 DOUBLE PRECISION :: trac_tmp(ip1jmp1,llm)276 #else277 REAL :: trac_tmp(ip1jmp1,llm)278 #endif279 193 REAL :: tab_cntrl(length) ! tableau des parametres du run 280 CHARACTER(LEN=256) :: modname, var, fil281 LOGICAL :: exist_file282 !=============================================================================== 283 modname='dynredem1' 284 fil=fichnom194 CHARACTER(LEN=256) :: var, dum 195 LOGICAL :: lread_inca 196 !=============================================================================== 197 198 modname='dynredem1'; fil=fichnom 285 199 CALL err(NF90_OPEN(fil,NF90_WRITE,nid),"open",fil) 286 200 287 201 !--- Write/extend time coordinate 288 202 nb = nb + 1 289 CALL sav_var1("temps",[time],nb) 203 var="temps" 204 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 205 CALL err(NF90_PUT_VAR(nid,vID,[time]),"put",var) 290 206 WRITE(lunout,*)TRIM(modname)//": Saving for ", nb, time 291 207 292 208 !--- Rewrite control table (itaufin undefined in dynredem0) 293 209 var="controle" 294 CALL get_var1(var,tab_cntrl); tab_cntrl(31)=DBLE(itau_dyn + itaufin)295 210 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 296 CALL NF95_PUT_VAR(nid,vID,tab_cntrl) 211 CALL err(NF90_GET_VAR(nid,vID,tab_cntrl),"get",var) 212 tab_cntrl(31)=DBLE(itau_dyn + itaufin) 213 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 214 CALL err(NF90_PUT_VAR(nid,vID,tab_cntrl),"put",var) 297 215 298 216 !--- Save fields 299 CALL sav_var3("ucov",ucov)300 CALL sav_var3("vcov",vcov)301 CALL sav_var3("teta",teta)302 CALL sav_var3("masse",masse)303 CALL sav_var2("ps" ,ps)217 CALL dynredem_write_u(nid,"ucov" ,ucov ,llm) 218 CALL dynredem_write_v(nid,"vcov" ,vcov ,llm) 219 CALL dynredem_write_u(nid,"teta" ,teta ,llm) 220 CALL dynredem_write_u(nid,"masse",masse,llm) 221 CALL dynredem_write_u(nid,"ps" ,ps ,1) 304 222 305 223 !--- Tracers in file "start_trac.nc" (added by Anne) 306 IF (type_trac == 'inca') THEN 307 fil="start_trac.nc"; INQUIRE(FILE=fil,EXIST=exist_file) 308 IF(.NOT.exist_file) CALL war(-1,"open",fil) 309 END IF 310 DO iq=1,nqtot; var=tname(iq) 311 312 !--- Usual case 313 IF(type_trac/='inca') THEN 314 CALL sav_var3(var,q(:,:,:,iq)); CYCLE 224 lread_inca=.FALSE.; fil="start_trac.nc" 225 IF(type_trac=='inca') INQUIRE(FILE=fil,EXIST=lread_inca) 226 IF(lread_inca) CALL err(NF90_OPEN(fil,NF90_NOWRITE,nid_trac),"open") 227 228 !--- Save tracers 229 DO iq=1,nqtot; var=tname(iq); ierr=-1 230 IF(lread_inca) THEN !--- Possibly read from "start_trac.nc" 231 fil="start_trac.nc" 232 ierr=NF90_INQ_VARID(nid_trac,var,vID_trac) 233 dum='inq'; IF(ierr==NF90_NoErr) dum='fnd' 234 WRITE(lunout,*)msg(dum,var) 235 236 237 IF(ierr==NF90_NoErr) CALL dynredem_read_u(nid_trac,var,q(:,:,:,iq),llm) 315 238 END IF 316 317 !--- Special case for INCA tracer read from "start_trac.nc" 318 IF(NF90_INQ_VARID(nid_trac,var,vID_trac)/=NF90_NoErr) THEN 319 CALL war(-1,"inq",var,fil) 320 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var,fil) 321 CALL NF95_PUT_VAR(nid,vID,q(:,:,:,iq)) 322 ELSE 323 WRITE(lunout,*)TRIM(modname)//": <"//TRIM(var)//"> found in "//fil 324 CALL err(NF90_GET_VAR(nid_trac,vID_trac,trac_tmp),"get",var,fil) 325 END IF 326 CALL sav_var3(var,RESHAPE(trac_tmp,SHAPE=[iip1,jjp1,llm])) 239 fil=fichnom 240 CALL dynredem_write_u(nid,var,q(:,:,:,iq),llm) 327 241 END DO 328 CALL err(NF90_CLOSE(nid),"close",fichnom) 329 330 331 CONTAINS 332 333 334 SUBROUTINE get_var1(var,v) 335 CHARACTER(LEN=*), INTENT(IN) :: var 336 REAL, INTENT(OUT) :: v(:) 337 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 338 CALL err(NF90_GET_VAR(nid,vID,v),"get",var) 339 END SUBROUTINE get_var1 340 341 342 SUBROUTINE sav_var1(var,v,start) 343 CHARACTER(LEN=*), INTENT(IN) :: var 344 #ifdef NC_DOUBLE 345 DOUBLE PRECISION, INTENT(IN) :: v(:) 346 #else 347 REAL, INTENT(IN) :: v(:) 348 #endif 349 INTEGER, OPTIONAL, INTENT(IN) :: start 350 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 351 IF(PRESENT(start)) THEN 352 CALL NF95_PUT_VAR(nid,vID,v,start=[start]) 353 ELSE 354 CALL NF95_PUT_VAR(nid,vID,v) 355 END IF 356 END SUBROUTINE sav_var1 357 358 359 SUBROUTINE sav_var2(var,v) 360 CHARACTER(LEN=*), INTENT(IN) :: var 361 #ifdef NC_DOUBLE 362 DOUBLE PRECISION, INTENT(IN) :: v(:,:) 363 #else 364 REAL, INTENT(IN) :: v(:,:) 365 #endif 366 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 367 CALL NF95_PUT_VAR(nid,vID,v) 368 END SUBROUTINE sav_var2 369 370 371 SUBROUTINE sav_var3(var,v) 372 CHARACTER(LEN=*), INTENT(IN) :: var 373 #ifdef NC_DOUBLE 374 DOUBLE PRECISION, INTENT(IN) :: v(:,:,:) 375 #else 376 REAL, INTENT(IN) :: v(:,:,:) 377 #endif 378 379 print*,'var='//TRIM(var) 380 print*,SHAPE(v) 381 CALL err(NF90_INQ_VARID(nid,var,vID),"inq",var) 382 CALL NF95_PUT_VAR(nid,vID,v) 383 END SUBROUTINE sav_var3 384 385 386 FUNCTION msg(typ,nam,fil) 387 IMPLICIT NONE 388 CHARACTER(LEN=256) :: msg !--- STANDARDIZED MESSAGE 389 CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION 390 CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD NAME 391 CHARACTER(LEN=*), INTENT(IN) :: fil !--- FILE NAME 392 SELECT CASE(typ) 393 CASE('inq'); msg="Missing field <"//TRIM(nam)//">" 394 CASE('get'); msg="Reading failed for <"//TRIM(nam)//">" 395 CASE('open'); msg="Opening failed for <"//TRIM(nam)//">" 396 CASE('close'); msg="Closing failed for <"//TRIM(nam)//">" 397 END SELECT 398 msg=TRIM(modname)//": "//TRIM(msg) 399 IF(typ=="inq".AND.fil/="") msg=TRIM(msg)//" in file <"//TRIM(fil)//">" 400 401 END FUNCTION msg 402 403 404 SUBROUTINE err(ierr,typ,nam,fil) 405 IMPLICIT NONE 406 INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE 407 CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION 408 CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD NAME 409 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fil !--- FILE NAME 410 CHARACTER(LEN=256) :: file 411 IF(ierr==NF90_NoERR) RETURN 412 file=""; IF(PRESENT(fil)) file=fil 413 CALL ABORT_gcm(modname,msg(typ,nam,file),ierr) 414 END SUBROUTINE err 415 416 417 SUBROUTINE war(ierr,typ,nam,fil) 418 IMPLICIT NONE 419 INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE 420 CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION 421 CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD NAME 422 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fil !--- FILE NAME 423 CHARACTER(LEN=256) :: file 424 IF(ierr==NF90_NoERR) RETURN 425 file=""; IF(PRESENT(fil)) file=fil 426 WRITE(lunout,*)msg(typ,nam,file) 427 END SUBROUTINE war 428 242 CALL err(NF90_CLOSE(nid),"close") 243 fil="start_trac.nc" 244 IF(lread_inca) CALL err(NF90_CLOSE(nid_trac),"close") 429 245 430 246 END SUBROUTINE dynredem1 -
LMDZ5/trunk/libf/dyn3d/etat0dyn_netcdf.F90
r2293 r2299 12 12 ! routine (to be called after restget): 13 13 ! CALL startget_dyn3d(varname, lon_in, lat_in, pls, workvar,& 14 ! champ, val_exp, lon_in2, lat_in2, ibar)14 ! champ, lon_in2, lat_in2, ibar) 15 15 ! 16 16 ! * Variables should have the following names in the NetCDF files: … … 87 87 USE infotrac 88 88 USE filtreg_mod 89 !#endif90 89 IMPLICIT NONE 91 90 !------------------------------------------------------------------------------- … … 120 119 !******************************************************************************* 121 120 CALL infotrac_init 122 ALLOCATE(q3d(iip1,jjp1,llm,nqtot))123 121 CALL inifilr() 124 122 … … 154 152 ! Update uvent, vvent, t3d and tpot 155 153 !******************************************************************************* 156 uvent(:,:,:) = 0.0 ; t3d (:,:,:) = 0.0 157 vvent(:,:,:) = 0.0 ; tpot(:,:,:) = 0.0 158 CALL startget_dyn3d('u' ,rlonu,rlatu,pls,y ,uvent,0.0,rlonv,rlatv,ib) 159 CALL startget_dyn3d('v' ,rlonv,rlatv,pls(:,:jjm,:),y(:,:jjm,:),vvent,0.0, & 154 uvent(:,:,:) = 0.0 ; vvent(:,:,:) = 0.0 ; t3d (:,:,:) = 0.0 155 CALL startget_dyn3d('u' ,rlonu,rlatu,pls,y ,uvent,rlonv,rlatv,ib) 156 CALL startget_dyn3d('v' ,rlonv,rlatv,pls(:,:jjm,:),y(:,:jjm,:),vvent, & 160 157 & rlonu,rlatu(:jjm),ib) 161 CALL startget_dyn3d('t' ,rlonv,rlatu,pls,y ,t3d , 0.0,rlonu,rlatv,ib)162 tpot =t3d163 CALL startget_dyn3d('tpot',rlonv,rlatu,pls,pk,tpot, 0.0,rlonu,rlatv,ib)158 CALL startget_dyn3d('t' ,rlonv,rlatu,pls,y ,t3d ,rlonu,rlatv,ib) 159 tpot(:,:,:)=t3d(:,:,:) 160 CALL startget_dyn3d('tpot',rlonv,rlatu,pls,pk,tpot,rlonu,rlatv,ib) 164 161 165 162 WRITE(lunout,*) 'T3D min,max:',MINVAL(t3d(:,:,:)),MAXVAL(t3d(:,:,:)) … … 174 171 ! WRITE(lunout,*) 'QSAT :',qsat(10,20,:) 175 172 qd (:,:,:) = 0.0 176 CALL startget_dyn3d('q',rlonv,rlatu,pls,qsat,qd,0.0,rlonu,rlatv,ib) 177 q3d(:,:,:,:) = 0.0 ; q3d(:,:,:,1) = qd(:,:,:) 178 173 CALL startget_dyn3d('q',rlonv,rlatu,pls,qsat,qd,rlonu,rlatv,ib) 174 ALLOCATE(q3d(iip1,jjp1,llm,nqtot)); q3d(:,:,:,:)=0.0 ; q3d(:,:,:,1)=qd(:,:,:) 179 175 CALL flinclo(fid_dyn) 180 176 181 177 #ifdef CPP_PHYS 178 #ifdef CPP_EARTH 182 179 ! Parameterization of ozone chemistry: 183 180 !******************************************************************************* … … 190 187 q3d(:,:,:,i)=q3d(:,:,:,i)*48./ 29. !--- Mole->mass fraction 191 188 END IF 189 192 190 #endif 191 #endif 192 q3d(iip1,:,:,:)=q3d(1,:,:,:) 193 193 194 194 ! Intermediate computation … … 204 204 masse(:,jjp1,l)=xps 205 205 END DO 206 q3d(iip1,:,:,:)=q3d(1,:,:,:)207 206 208 207 ! Writing … … 234 233 235 234 !#endif 236 ! #endif of #ifdef CPP_EARTH235 ! of ifdef CPP_EARTH 237 236 238 237 END SUBROUTINE etat0dyn_netcdf … … 244 243 !------------------------------------------------------------------------------- 245 244 ! 246 SUBROUTINE startget_dyn3d(var, 247 champ, val_exp, lon_in2, lat_in2, ibar)245 SUBROUTINE startget_dyn3d(var, lon_in, lat_in, pls, workvar,& 246 champ, lon_in2, lat_in2, ibar) 248 247 !------------------------------------------------------------------------------- 249 248 IMPLICIT NONE … … 253 252 !------------------------------------------------------------------------------- 254 253 ! Note: An input auxilliary field "workvar" has to be specified in two cases: 255 ! * for "q": 256 ! * for "t opot": the Exner function.254 ! * for "q": the saturated humidity. 255 ! * for "tpot": the Exner function. 257 256 !=============================================================================== 258 257 ! Arguments: … … 263 262 REAL, INTENT(IN) :: workvar(:, :, :) ! dim (iml, jml, lml) 264 263 REAL, INTENT(INOUT) :: champ (:, :, :) ! dim (iml, jml, lml) 265 REAL, INTENT(IN) :: val_exp266 264 REAL, INTENT(IN) :: lon_in2(:) ! dim (iml) 267 265 REAL, INTENT(IN) :: lat_in2(:) ! dim (jml2) … … 274 272 REAL :: xppn, xpps 275 273 !------------------------------------------------------------------------------- 276 IF(MINVAL(champ)==MAXVAL(champ).AND.MINVAL(champ)==val_exp) THEN 277 iml = assert_eq([SIZE(lon_in),SIZE(pls,1),SIZE(workvar,1),SIZE(champ,1), & 278 & SIZE(lon_in2)],TRIM(modname)//" iml") 279 jml = assert_eq( SIZE(lat_in),SIZE(pls,2),SIZE(workvar,2),SIZE(champ,2), & 280 & TRIM(modname)//" jml") 281 lml = assert_eq( SIZE(pls,3),SIZE(workvar,3),SIZE(champ,3), & 282 & TRIM(modname)//" lml") 283 jml2 = SIZE(lat_in2) 284 285 !--- CHECK IF THE FIELD IS KNOWN 286 SELECT CASE(var) 287 CASE('u'); vname='U' 288 CASE('v'); vname='V' 289 CASE('t'); vname='TEMP' 290 CASE('q'); vname='R'; msg='humidity as the saturated humidity' 291 CASE('tpot'); vname='TEMP'; msg='potential temperature as the Exner function' 292 CASE DEFAULT; msg='No rule to extract variable '//TRIM(var) 293 CALL abort_gcm(modname,TRIM(msg)//' from any data set',1) 294 END SELECT 295 296 !--- CHECK IF SOMETHING IS MISSING 297 IF((var=='tpot'.OR.var=='q').AND.MINVAL(workvar)==MAXVAL(workvar)) THEN 298 msg='Could not compute '//TRIM(msg)//' is missing or constant.' 299 CALL abort_gcm(modname,TRIM(msg),1) 300 END IF 301 302 !--- INTERPOLATE 3D FIELD IF NEEDED 303 IF(var/='tpot') CALL start_inter_3d(TRIM(vname),lon_in,lat_in,lon_in2, & 304 lat_in2,pls,champ,ibar) 305 306 !--- COMPUTE THE REQUIRED FILED 307 SELECT CASE(var) 308 CASE('u'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cu(:,1:jml); END DO 309 champ(iml,:,:)=champ(1,:,:) !--- Eastward wind 310 311 CASE('v'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cv(:,1:jml); END DO 312 champ(iml,:,:)=champ(1,:,:) !--- Northward wind 313 314 CASE('tpot','q') 315 IF(var=='tpot') THEN; champ=champ*cpp/workvar !--- Temperature 316 ELSE; champ=champ*.01*workvar !--- Relat. humidity 317 WHERE(champ<0.) champ=1.0E-10 318 END IF 319 DO il=1,lml 320 xppn = SUM(aire(:,1 )*champ(:,1 ,il))/apoln 321 xpps = SUM(aire(:,jml)*champ(:,jml,il))/apols 322 champ(:,1 ,il) = xppn 323 champ(:,jml,il) = xpps 324 END DO 325 END SELECT 274 iml=assert_eq([SIZE(lon_in),SIZE(pls,1),SIZE(workvar,1),SIZE(champ,1), & 275 & SIZE(lon_in2)], TRIM(modname)//" iml") 276 jml=assert_eq( SIZE(lat_in),SIZE(pls,2),SIZE(workvar,2),SIZE(champ,2), & 277 & TRIM(modname)//" jml") 278 lml=assert_eq( SIZE(pls,3),SIZE(workvar,3),SIZE(champ,3), & 279 & TRIM(modname)//" lml") 280 jml2=SIZE(lat_in2) 281 282 !--- CHECK IF THE FIELD IS KNOWN 283 SELECT CASE(var) 284 CASE('u'); vname='U' 285 CASE('v'); vname='V' 286 CASE('t'); vname='TEMP' 287 CASE('q'); vname='R'; msg='humidity as the saturated humidity' 288 CASE('tpot'); msg='potential temperature as the Exner function' 289 CASE DEFAULT; msg='No rule to extract variable '//TRIM(var) 290 CALL abort_gcm(modname,TRIM(msg)//' from any data set',1) 291 END SELECT 292 293 !--- CHECK IF SOMETHING IS MISSING 294 IF((var=='tpot'.OR.var=='q').AND.MINVAL(workvar)==MAXVAL(workvar)) THEN 295 msg='Could not compute '//TRIM(msg)//' is missing or constant.' 296 CALL abort_gcm(modname,TRIM(msg),1) 326 297 END IF 298 299 !--- INTERPOLATE 3D FIELD IF NEEDED 300 IF(var/='tpot') CALL start_inter_3d(TRIM(vname),lon_in,lat_in,lon_in2, & 301 lat_in2,pls,champ,ibar) 302 303 !--- COMPUTE THE REQUIRED FILED 304 SELECT CASE(var) 305 CASE('u'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cu(:,1:jml); END DO 306 champ(iml,:,:)=champ(1,:,:) !--- Eastward wind 307 308 CASE('v'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cv(:,1:jml); END DO 309 champ(iml,:,:)=champ(1,:,:) !--- Northward wind 310 311 CASE('tpot','q') 312 IF(var=='tpot') THEN; champ=champ*cpp/workvar !--- Potential temperature 313 ELSE; champ=champ*.01*workvar !--- Relative humidity 314 WHERE(champ<0.) champ=1.0E-10 315 END IF 316 DO il=1,lml 317 xppn = SUM(aire(:,1 )*champ(:,1 ,il))/apoln 318 xpps = SUM(aire(:,jml)*champ(:,jml,il))/apols 319 champ(:,1 ,il) = xppn 320 champ(:,jml,il) = xpps 321 END DO 322 END SELECT 327 323 328 324 END SUBROUTINE startget_dyn3d … … 768 764 769 765 !#endif 770 ! of #ifdef CPP_EARTH766 ! of ifdef CPP_EARTH 771 767 772 768 END MODULE etat0dyn
Note: See TracChangeset
for help on using the changeset viewer.