- Timestamp:
- Apr 3, 2014, 9:09:47 AM (11 years ago)
- Location:
- trunk/LMDZ.GENERIC
- Files:
-
- 14 added
- 42 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.GENERIC/README
r1122 r1216 1001 1001 == 05/12/2013 == JL 1002 1002 - corrected sugascorrk to work in the two band gray aproximation with -b 1x1 and NGAUSS=2 1003 1004 == 03/04/2014 == EM 1005 Major cleanup, in order to ease the use of LMDZ.GENERIC with (parallel) dynamics 1006 in LMDZ.COMMON: (NB: this will break LMDZ.UNIVERSAL, which should be thrashed 1007 in the near future) 1008 - Updated makegcm_* scripts (and makdim) and added the "-full" (to enforce 1009 full recomputation of the model) option 1010 - In dyn3d: converted control.h to module control_mod.F90 and converted 1011 iniadvtrac.F to module infotrac.F90 1012 - Added module mod_const_mpi.F90 in dyn3d (not used in serial mode) 1013 - Rearanged input/outputs routines everywhere to handle serial/MPI cases. 1014 physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write 1015 routines for startfi files are gathered in module iostart.F90 1016 - added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, 1017 dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, 1018 mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, 1019 mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, 1020 mod_phys_lmdz_transfert_para.F90 in phymars 1021 and mod_const_mpi.F90 in dyn3d (for compliance with parallelism) 1022 - added created generic routines 'planetwide_maxval' and 'planetwide_minval', 1023 in module "planetwide_mod", that enable obtaining the max and min of a field 1024 over the whole planet. This should be further imroved with computation of 1025 means (possibly area weighed), etc. -
trunk/LMDZ.GENERIC/libf/dyn3d/calfis.F
r787 r1216 6 6 c Auteur : P. Le Van, F. Hourdin 7 7 c ......... 8 8 USE infotrac, ONLY: tname, nqtot 9 9 IMPLICIT NONE 10 10 c======================================================================= … … 71 71 #include "comvert.h" 72 72 #include "comgeom2.h" 73 #include "control.h"74 75 #include "advtrac.h"73 !#include "control.h" 74 75 !#include "advtrac.h" 76 76 !! this is to get tnom (tracers name) 77 77 … … 85 85 REAL pteta(iip1,jjp1,llm) 86 86 REAL pmasse(iip1,jjp1,llm) 87 REAL pq(iip1,jjp1,llm,nq mx)87 REAL pq(iip1,jjp1,llm,nqtot) 88 88 REAL pphis(iip1,jjp1) 89 89 REAL pphi(iip1,jjp1,llm) … … 92 92 REAL pducov(iip1,jjp1,llm) 93 93 REAL pdteta(iip1,jjp1,llm) 94 REAL pdq(iip1,jjp1,llm,nq mx)94 REAL pdq(iip1,jjp1,llm,nqtot) 95 95 c 96 96 REAL pw(iip1,jjp1,llm) … … 103 103 REAL pdufi(iip1,jjp1,llm) 104 104 REAL pdhfi(iip1,jjp1,llm) 105 REAL pdqfi(iip1,jjp1,llm,nq mx)105 REAL pdqfi(iip1,jjp1,llm,nqtot) 106 106 REAL pdpsfi(iip1,jjp1) 107 107 logical tracer … … 116 116 c 117 117 REAL zufi(ngridmx,llm), zvfi(ngridmx,llm) 118 REAL ztfi(ngridmx,llm),zqfi(ngridmx,llm,nq mx)118 REAL ztfi(ngridmx,llm),zqfi(ngridmx,llm,nqtot) 119 119 c 120 120 REAL zvervel(ngridmx,llm) 121 121 c 122 122 REAL zdufi(ngridmx,llm),zdvfi(ngridmx,llm) 123 REAL zdtfi(ngridmx,llm),zdqfi(ngridmx,llm,nq mx)123 REAL zdtfi(ngridmx,llm),zdqfi(ngridmx,llm,nqtot) 124 124 REAL zdpsrf(ngridmx) 125 125 c … … 170 170 171 171 c 172 IF (firstcal) THEN173 latfi(1)=rlatu(1)174 lonfi(1)=0.175 DO j=2,jjm176 DO i=1,iim177 latfi((j-2)*iim+1+i)= rlatu(j)178 lonfi((j-2)*iim+1+i)= rlonv(i)179 ENDDO180 ENDDO181 latfi(ngridmx)= rlatu(jjp1)182 lonfi(ngridmx)= 0.183 184 ! build airefi(), mesh area on physics grid185 CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)186 ! Poles are single points on physics grid187 airefi(1)=airefi(1)*iim188 airefi(ngridmx)=airefi(ngridmx)*iim189 190 CALL inifis(ngridmx,llm,day_ini,daysec,dtphys,191 . latfi,lonfi,airefi,rad,g,r,cpp)192 ENDIF172 ! IF (firstcal) THEN 173 ! latfi(1)=rlatu(1) 174 ! lonfi(1)=0. 175 ! DO j=2,jjm 176 ! DO i=1,iim 177 ! latfi((j-2)*iim+1+i)= rlatu(j) 178 ! lonfi((j-2)*iim+1+i)= rlonv(i) 179 ! ENDDO 180 ! ENDDO 181 ! latfi(ngridmx)= rlatu(jjp1) 182 ! lonfi(ngridmx)= 0. 183 ! 184 ! ! build airefi(), mesh area on physics grid 185 ! CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi) 186 ! ! Poles are single points on physics grid 187 ! airefi(1)=airefi(1)*iim 188 ! airefi(ngridmx)=airefi(ngridmx)*iim 189 ! 190 ! CALL inifis(ngridmx,llm,day_ini,daysec,dtphys, 191 ! . latfi,lonfi,airefi,rad,g,r,cpp) 192 ! ENDIF 193 193 194 194 c … … 278 278 c 43.bis Taceurs (en kg/kg) 279 279 c -------------------------- 280 DO iq=1,nq mx280 DO iq=1,nqtot 281 281 DO l=1,llm 282 282 zqfi(1,l,iq) = pq(1,1,l,iq) … … 425 425 426 426 CALL physiq (ngridmx,llm,nq, 427 . tn om,427 . tname, 428 428 , debut,lafin, 429 429 , rday_ecri,heure,dtphys, … … 467 467 468 468 469 c 62. humidite specifique469 c 62. traceurs 470 470 c --------------------- 471 471 472 DO iq=1,nq mx472 DO iq=1,nqtot 473 473 DO l=1,llm 474 474 DO i=1,iip1 -
trunk/LMDZ.GENERIC/libf/dyn3d/control_mod.F90
r1214 r1216 1 !-----------------------------------------------------------------------2 ! INCLUDE 'control.h'3 ! For Fortran 77/Fortran 90 compliance always use line continuation4 ! symbols '&' in columns 73 and 65 !6 1 7 COMMON/control/nday,day_step, & 8 & iperiod,iconser,idissip,iphysiq , & 9 & periodav,ecritphy,anneeref 2 module control_mod 10 3 11 INTEGER nday,day_step,iperiod,iconser, & 12 & idissip,iphysiq,anneeref 13 REAL periodav, ecritphy 4 implicit none 14 5 15 !----------------------------------------------------------------------- 6 integer,save :: nday ! # of days to run 7 integer,save :: day_step ! # of dynamical time steps per day 8 integer,save :: iperiod ! make a Matsuno step before avery iperiod-1 LF steps 9 integer,save :: iconser ! 10 integer,save :: idissip ! apply dissipation every idissip dynamical step 11 integer,save :: iphysiq ! call physics every iphysiq dynamical steps 12 integer,save :: anneeref ! reference year # ! not used 13 real,save :: periodav 14 integer,save :: ecritphy ! output data in "diagfi.nc" every ecritphy dynamical steps 15 16 end module control_mod -
trunk/LMDZ.GENERIC/libf/dyn3d/defrun_new.F
r1006 r1216 38 38 USE ioipsl_getincom 39 39 use sponge_mod,only: callsponge,nsponge,mode_sponge,tetasponge 40 use control_mod,only: nday, day_step, iperiod, anneeref, 41 & iconser, idissip, iphysiq, ecritphy 40 42 IMPLICIT NONE 41 43 42 44 #include "dimensions.h" 43 45 #include "paramet.h" 44 #include "control.h"46 !#include "control.h" 45 47 #include "logic.h" 46 48 #include "serre.h" -
trunk/LMDZ.GENERIC/libf/dyn3d/dynetat0.F
r993 r1216 1 1 SUBROUTINE dynetat0(fichnom,nq,vcov,ucov, 2 2 . teta,q,masse,ps,phis,time) 3 use infotrac, only: tname, nqtot 3 4 IMPLICIT NONE 4 5 … … 30 31 #include "serre.h" 31 32 #include "logic.h" 32 #include"advtrac.h"33 !#include"advtrac.h" 33 34 34 35 c Arguments: … … 328 329 ! WRITE(str3(2:3),'(i2.2)') iq 329 330 ! ierr = NF_INQ_VARID (nid, str3, nvarid) 330 ! NB: tracers are now read in using their name ('tn om' from advtrac.h)331 ! write(*,*) " loading tracer:",trim(tn om(iq))332 ierr=NF_INQ_VARID(nid,tn om(iq),nvarid)331 ! NB: tracers are now read in using their name ('tname' from infotrac) 332 ! write(*,*) " loading tracer:",trim(tname(iq)) 333 ierr=NF_INQ_VARID(nid,tname(iq),nvarid) 333 334 IF (ierr .NE. NF_NOERR) THEN 334 335 ! PRINT*, "dynetat0: Le champ <"//str3//"> est absent" 335 PRINT*, "dynetat0: Le champ <"//trim(tn om(iq))//336 PRINT*, "dynetat0: Le champ <"//trim(tname(iq))// 336 337 & "> est absent" 337 338 PRINT*, " Il est donc initialise a zero" … … 346 347 IF (ierr .NE. NF_NOERR) THEN 347 348 ! PRINT*, "dynetat0: Lecture echouee pour "//str3 348 PRINT*, "dynetat0: Lecture echouee pour "//trim(tnom(iq))349 PRINT*,"dynetat0: Lecture echouee pour "//trim(tname(iq)) 349 350 CALL abort 350 351 ENDIF … … 354 355 c case when new tracer are added in addition to old ones 355 356 write(*,*)'tracers 1 to ', nqold,'were already present' 356 write(*,*)'tracers ', nqold+1,' to ', nq mx,'are new'357 write(*,*)'tracers ', nqold+1,' to ', nqtot,'are new' 357 358 write(*,*)' and initialized to zero' 358 q(:,:,:,nqold+1:nq mx)=0.0359 q(:,:,:,nqold+1:nqtot)=0.0 359 360 ! yes=' ' 360 361 ! do while ((yes.ne.'y').and.(yes.ne.'n')) -
trunk/LMDZ.GENERIC/libf/dyn3d/dynredem.F
r993 r1216 1 1 SUBROUTINE dynredem0(fichnom,idayref,anneeref,phis,nq) 2 use infotrac, only: tname 2 3 IMPLICIT NONE 3 4 c======================================================================= … … 16 17 #include "netcdf.inc" 17 18 #include "serre.h" 18 #include "advtrac.h"19 !#include "advtrac.h" 19 20 c Arguments: 20 21 c ---------- … … 902 903 ! ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12, 903 904 ! . "Traceurs "//str3) 904 txt="Traceur "//trim(tn om(iq))905 #ifdef NC_DOUBLE 906 ierr=NF_DEF_VAR(nid,tn om(iq),NF_DOUBLE,4,dims4,nvarid)907 #else 908 ierr=NF_DEF_VAR(nid,tn om(iq),NF_FLOAT,4,dims4,nvarid)905 txt="Traceur "//trim(tname(iq)) 906 #ifdef NC_DOUBLE 907 ierr=NF_DEF_VAR(nid,tname(iq),NF_DOUBLE,4,dims4,nvarid) 908 #else 909 ierr=NF_DEF_VAR(nid,tname(iq),NF_FLOAT,4,dims4,nvarid) 909 910 #endif 910 911 ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title", … … 954 955 SUBROUTINE dynredem1(fichnom,time, 955 956 . vcov,ucov,teta,q,nq,masse,ps) 957 use infotrac, only: nqtot, tname 956 958 IMPLICIT NONE 957 959 c================================================================= … … 963 965 #include "comvert.h" 964 966 #include "comgeom.h" 965 #include"advtrac.h"967 !#include"advtrac.h" 966 968 967 969 INTEGER nq, l … … 969 971 REAL teta(ip1jmp1,llm) 970 972 REAL ps(ip1jmp1),masse(ip1jmp1,llm) 971 REAL q(iip1,jjp1,llm,nq mx)973 REAL q(iip1,jjp1,llm,nqtot) 972 974 REAL q3d(iip1,jjp1,llm) !temporary variable 973 975 CHARACTER*(*) fichnom … … 1052 1054 ! WRITE(str3(2:3),'(i2.2)') iq 1053 1055 ! ierr = NF_INQ_VARID(nid, str3, nvarid) 1054 ierr=NF_INQ_VARID(nid,tn om(iq),nvarid)1056 ierr=NF_INQ_VARID(nid,tname(iq),nvarid) 1055 1057 IF (ierr .NE. NF_NOERR) THEN 1056 1058 ! PRINT*, "Variable "//str3//" n est pas definie" 1057 PRINT*, "Variable "//trim(tnom(iq))//" n est pas definie"1059 PRINT*,"Variable "//trim(tname(iq))//" n est pas definie" 1058 1060 CALL abort 1059 1061 ENDIF -
trunk/LMDZ.GENERIC/libf/dyn3d/gcm.F
r1006 r1216 1 1 PROGRAM gcm 2 2 3 use infotrac, only: iniadvtrac, nqtot, iadv 3 4 use sponge_mod,only: callsponge,mode_sponge,sponge 5 use control_mod, only: nday, day_step, iperiod, iphysiq, 6 & iconser, ecritphy, idissip 7 use comgeomphy, only: initcomgeomphy 4 8 IMPLICIT NONE 5 9 … … 42 46 #include "logic.h" 43 47 #include "temps.h" 44 #include "control.h"48 !#include "control.h" 45 49 #include "ener.h" 46 50 #include "netcdf.inc" 47 51 #include "serre.h" 48 52 #include "tracstoke.h" 49 #include"advtrac.h"53 !#include"advtrac.h" 50 54 51 55 INTEGER*4 iday ! jour julien … … 56 60 REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants 57 61 real, dimension(ip1jmp1,llm) :: teta ! temperature potentielle 58 REAL q(ip1jmp1,llm,nqmx)! champs advectes62 REAL,allocatable :: q(:,:,:) ! champs advectes 59 63 REAL ps(ip1jmp1) ! pression au sol 60 64 REAL pext(ip1jmp1) ! pression extensive … … 79 83 c tendances dynamiques 80 84 REAL dv(ip1jm,llm),du(ip1jmp1,llm) 81 REAL dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqmx),dp(ip1jmp1) 85 REAL dteta(ip1jmp1,llm),dp(ip1jmp1) 86 REAL,ALLOCATABLE :: dq(:,:,:) 82 87 83 88 c tendances de la dissipation … … 87 92 c tendances physiques 88 93 REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm) 89 REAL dhfi(ip1jmp1,llm),dqfi(ip1jmp1,llm,nqmx),dpfi(ip1jmp1) 94 REAL dhfi(ip1jmp1,llm),dpfi(ip1jmp1) 95 REAL,ALLOCATABLE :: dqfi(:,:,:) 90 96 91 97 c variables pour le fichier histoire … … 123 129 LOGICAL tracer 124 130 data tracer/.true./ 125 INTEGER nq131 ! INTEGER nq 126 132 127 133 C Calendrier … … 150 156 REAL vnat(ip1jm,llm),unat(ip1jmp1,llm) 151 157 158 c----------------------------------------------------------------------- 159 c variables pour l'initialisation de la physique : 160 c ------------------------------------------------ 161 INTEGER ngridmx 162 PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm ) 163 REAL zcufi(ngridmx),zcvfi(ngridmx) 164 REAL latfi(ngridmx),lonfi(ngridmx) 165 REAL airefi(ngridmx) 166 SAVE latfi, lonfi, airefi 167 INTEGER i,j 152 168 153 169 c----------------------------------------------------------------------- … … 159 175 160 176 c----------------------------------------------------------------------- 161 c Initialize tracers using iniadvtrac (Ehouarn, oct 2008) 162 CALL iniadvtrac(nq,numvanle) 163 164 165 CALL dynetat0("start.nc",nqmx,vcov,ucov, 177 CALL defrun_new( 99, .TRUE. ) 178 179 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 180 ! FH 2008/05/02 181 ! A nettoyer. On ne veut qu'une ou deux routines d'interface 182 ! dynamique -> physique pour l'initialisation 183 !#ifdef CPP_PHYS 184 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 185 call initcomgeomphy 186 !#endif 187 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 188 189 ! Initialize tracers 190 CALL iniadvtrac(nqtot,numvanle) 191 ! Allocation de la tableau q : champs advectes 192 allocate(q(ip1jmp1,llm,nqtot)) 193 allocate(dq(ip1jmp1,llm,nqtot)) 194 allocate(dqfi(ip1jmp1,llm,nqtot)) 195 196 CALL dynetat0("start.nc",nqtot,vcov,ucov, 166 197 . teta,q,masse,ps,phis, time_0) 167 168 CALL defrun_new( 99, .TRUE. )169 198 170 199 c on recalcule eventuellement le pas de temps … … 196 225 * tetagdiv, tetagrot , tetatemp ) 197 226 c 227 228 c----------------------------------------------------------------------- 229 c Initialisation de la physique : 230 c ------------------------------- 231 232 ! IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN 233 latfi(1)=rlatu(1) 234 lonfi(1)=0. 235 zcufi(1) = cu(1) 236 zcvfi(1) = cv(1) 237 DO j=2,jjm 238 DO i=1,iim 239 latfi((j-2)*iim+1+i)= rlatu(j) 240 lonfi((j-2)*iim+1+i)= rlonv(i) 241 zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i) 242 zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i) 243 ENDDO 244 ENDDO 245 latfi(ngridmx)= rlatu(jjp1) 246 lonfi(ngridmx)= 0. 247 zcufi(ngridmx) = cu(ip1jm+1) 248 zcvfi(ngridmx) = cv(ip1jm-iim) 249 250 ! build airefi(), mesh area on physics grid 251 CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi) 252 ! Poles are single points on physics grid 253 airefi(1)=airefi(1)*iim 254 airefi(ngridmx)=airefi(ngridmx)*iim 255 256 ! Initialisation de la physique: pose probleme quand on tourne 257 ! SANS physique, car iniphysiq.F est dans le repertoire phy[]... 258 ! Il faut une cle CPP_PHYS 259 !#ifdef CPP_PHYS 260 ! CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys, 261 CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys, 262 & latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp, 263 & 1) 264 ! & iflag_phys) 265 !#endif 266 ! call_iniphys=.false. 267 ! ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1)) 198 268 199 269 CALL pression ( ip1jmp1, ap, bp, ps, p ) … … 229 299 . 'c''est a dire du jour',i7,3x,'au jour',i7//) 230 300 231 CALL dynredem0("restart.nc",day_end,anne_ini,phis,nq mx)301 CALL dynredem0("restart.nc",day_end,anne_ini,phis,nqtot) 232 302 233 303 ecripar = .TRUE. … … 237 307 238 308 c Quelques initialisations pour les traceurs 239 call initial0(ijp1llm*nq mx,dq)309 call initial0(ijp1llm*nqtot,dq) 240 310 c istdyn=day_step/4 ! stockage toutes les 6h=1jour/4 241 311 c istphy=istdyn/iphysiq … … 328 398 IF( forward. OR . leapf ) THEN 329 399 330 DO iq = 1, nq mx400 DO iq = 1, nqtot 331 401 c 332 402 IF ( iadv(iq).EQ.1.OR.iadv(iq).EQ.2 ) THEN 333 403 CALL traceur( iq,iadv,q,teta,pk,w, pbaru, pbarv, dq ) 334 404 335 ELSE IF( iq.EQ. nq mx) THEN405 ELSE IF( iq.EQ. nqtot ) THEN 336 406 c 337 407 iapp_tracvl = 5 … … 341 411 c 342 412 343 CALL vanleer(numvanle,iapp_tracvl,nq mx,q,pbaru,pbarv,413 CALL vanleer(numvanle,iapp_tracvl,nqtot,q,pbaru,pbarv, 344 414 * p, masse, dq, iadv(1), teta, pk ) 345 415 … … 413 483 414 484 415 CALL calfis( nq mx, lafin ,rdayvrai,rday_ecri,time ,485 CALL calfis( nqtot, lafin ,rdayvrai,rday_ecri,time , 416 486 $ ucov,vcov,teta,q,masse,ps,p,pk,phis,phi , 417 487 $ du,dv,dteta,dq,w, dufi,dvfi,dhfi,dqfi,dpfi,tracer) … … 421 491 c ------------------------------ 422 492 ! if(1.eq.2)then 423 CALL addfi( nq mx, dtphys, leapf, forward ,493 CALL addfi( nqtot, dtphys, leapf, forward , 424 494 $ ucov, vcov, teta , q ,ps , masse, 425 495 $ dufi, dvfi, dhfi , dqfi ,dpfi ) … … 556 626 c iav=0 557 627 c ENDIF 558 c CALL writedynav(histaveid, nq mx, itau,vcov ,628 c CALL writedynav(histaveid, nqtot, itau,vcov , 559 629 c , ucov,teta,pk,phi,q,masse,ps,phis) 560 630 c ENDIF … … 569 639 CALL test_period ( ucov,vcov,teta,q,p,phis ) 570 640 CALL dynredem1("restart.nc",0.0, 571 . vcov,ucov,teta,q,nq mx,masse,ps)641 . vcov,ucov,teta,q,nqtot,masse,ps) 572 642 573 643 CLOSE(99) … … 636 706 iav=0 637 707 ENDIF 638 c CALL writedynav(histaveid, nq mx, itau,vcov ,708 c CALL writedynav(histaveid, nqtot, itau,vcov , 639 709 c , ucov,teta,pk,phi,q,masse,ps,phis) 640 710 … … 644 714 IF(itau.EQ.itaufin) 645 715 . CALL dynredem1("restart.nc",0.0, 646 . vcov,ucov,teta,q,nq mx,masse,ps)716 . vcov,ucov,teta,q,nqtot,masse,ps) 647 717 648 718 forward = .TRUE. -
trunk/LMDZ.GENERIC/libf/dyn3d/infotrac.F90
r1214 r1216 1 MODULE infotrac 2 3 IMPLICIT NONE 4 ! nqtot : total number of tracers and higher order of moment, water vapor and liquid included 5 INTEGER, SAVE :: nqtot 6 INTEGER,allocatable :: iadv(:) ! tracer advection scheme number 7 CHARACTER(len=20),allocatable :: tname(:) ! tracer name 8 9 CONTAINS 10 1 11 subroutine iniadvtrac(nq,numvanle) 2 12 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 8 18 IMPLICIT NONE 9 19 10 #include "dimensions.h"11 #include "advtrac.h"12 #include "control.h"20 !#include "dimensions.h" 21 !#include "advtrac.h" 22 !#include "control.h" 13 23 14 24 ! routine arguments: … … 20 30 INTEGER :: iq 21 31 INTEGER :: ierr 22 23 24 if (nqmx > 0) then 32 CHARACTER(len=3) :: qname 25 33 26 34 ! Look for file traceur.def 27 OPEN(90,file='traceur.def',form='formatted',status='old', 28 &iostat=ierr)35 OPEN(90,file='traceur.def',form='formatted',status='old', & 36 iostat=ierr) 29 37 IF (ierr.eq.0) THEN 30 38 write(*,*) "iniadvtrac: Reading file traceur.def" … … 35 43 write(*,*) " (first line of traceur.def) " 36 44 stop 37 else38 ! check that the number of tracers is indeed nqmx39 if (nq.ne.nqmx) then40 write(*,*) "iniadvtrac: error, wrong number of tracers:"41 write(*,*) "nq=",nq," whereas nqmx=",nqmx42 stop43 endif44 45 endif 46 47 ! allocate arrays: 48 allocate(iadv(nq)) 49 allocate(tname(nq)) 45 50 46 51 ! initialize advection schemes to Van-Leer for all tracers … … 49 54 enddo 50 55 51 52 53 ! MODIFICATION TO TEST OTHER SCHEMES BY RDW54 ! do iq=1,nq55 ! iadv(iq)=156 ! enddo57 ! print*,'IADV SET TO 1 IN iniadvtrac!!!!'58 59 56 do iq=1,nq 60 57 ! minimal version, just read in the tracer names, 1 per line 61 read(90,*,iostat=ierr) tn om(iq)58 read(90,*,iostat=ierr) tname(iq) 62 59 if (ierr.ne.0) then 63 60 write(*,*) 'iniadvtrac: error reading tracer names...' … … 65 62 endif 66 63 enddo !of do iq=1,nq 67 ELSE 68 write(*,*) "iniadvtrac: can't find file traceur.def..." 69 stop 64 close(90) ! done reading tracer names, close file 70 65 ENDIF ! of IF (ierr.eq.0) 71 66 72 c .... Choix des shemas d'advection pour l'eau et les traceurs ... 73 c ................................................................... 74 c 75 c iadv = 1 shema transport type "humidite specifique LMD" 76 c iadv = 2 shema amont 77 c iadv = 3 shema Van-leer 78 c iadv = 4 schema Van-leer + humidite specifique 79 c Modif F.Codron 80 c 81 c 82 DO iq = 1, nqmx 83 IF( iadv(iq).EQ.1 ) PRINT *,' Choix du shema humidite specifique' 84 * ,' pour le traceur no ', iq 85 IF( iadv(iq).EQ.2 ) PRINT *,' Choix du shema amont',' pour le' 86 87 * ,' traceur no ', iq 88 IF( iadv(iq).EQ.3 ) PRINT *,' Choix du shema Van-Leer ',' pour' 89 * ,'le traceur no ', iq 67 ! .... Choix des shemas d'advection pour l'eau et les traceurs ... 68 ! ................................................................... 69 ! 70 ! iadv = 1 shema transport type "humidite specifique LMD" 71 ! iadv = 2 shema amont 72 ! iadv = 3 shema Van-leer 73 ! iadv = 4 schema Van-leer + humidite specifique 74 ! Modif F.Codron 75 ! 76 ! 77 DO iq = 1, nq-1 78 IF( iadv(iq).EQ.1 ) PRINT *,' Choix du shema humidite specifique'& 79 ,' pour le traceur no ', iq 80 IF( iadv(iq).EQ.2 ) PRINT *,' Choix du shema amont',' pour le' & 81 ,' traceur no ', iq 82 IF( iadv(iq).EQ.3 ) PRINT *,' Choix du shema Van-Leer ',' pour' & 83 ,'le traceur no ', iq 90 84 91 85 IF( iadv(iq).EQ.4 ) THEN 92 PRINT *,' Le shema Van-Leer + humidite specifique ', 93 *' est uniquement pour la vapeur d eau .'86 PRINT *,' Le shema Van-Leer + humidite specifique ', & 87 ' est uniquement pour la vapeur d eau .' 94 88 PRINT *,' Corriger iadv( ',iq, ') et repasser ! ' 95 89 CALL ABORT … … 97 91 98 92 IF( iadv(iq).LE.0.OR.iadv(iq).GT.4 ) THEN 99 PRINT *,' Erreur dans le choix de iadv (nq mx).Corriger et '100 *,' repasser car iadv(iq) = ', iadv(iq)93 PRINT *,' Erreur dans le choix de iadv (nqtot).Corriger et ' & 94 ,' repasser car iadv(iq) = ', iadv(iq) 101 95 CALL ABORT 102 96 ENDIF 103 97 ENDDO 104 98 105 !!!! AS: compiler complains about iadv(nqmx) when there is nqmx=0 106 !!!! AS: so I commented those lines and changed nqmx-1 for nqmx above 107 ! IF( iadv(nqmx).EQ.1 ) PRINT *,' Choix du shema humidite ' 108 ! * ,'specifique pour la vapeur d''eau' 109 ! IF( iadv(nqmx).EQ.2 ) PRINT *,' Choix du shema amont',' pour la' 110 ! * ,' vapeur d''eau ' 111 ! IF( iadv(nqmx).EQ.3 ) PRINT *,' Choix du shema Van-Leer ' 112 ! * ,' pour la vapeur d''eau' 113 ! IF( iadv(nqmx).EQ.4 ) PRINT *,' Choix du shema Van-Leer + ' 114 ! * ,' humidite specifique pour la vapeur d''eau' 99 IF( iadv(nq).EQ.1 ) PRINT *,' Choix du shema humidite ' & 100 ,'specifique pour la vapeur d''eau' 101 IF( iadv(nq).EQ.2 ) PRINT *,' Choix du shema amont',' pour la' & 102 ,' vapeur d''eau ' 103 IF( iadv(nq).EQ.3 ) PRINT *,' Choix du shema Van-Leer ' & 104 ,' pour la vapeur d''eau' 105 IF( iadv(nq).EQ.4 ) PRINT *,' Choix du shema Van-Leer + ' & 106 ,' humidite specifique pour la vapeur d''eau' 115 107 ! 116 !c 117 !! IF( (iadv(nqmx).LE.0).OR.(iadv(nqmx).GT.4) ) THEN 118 !! MODIFICATION TO TEST WITHOUT TRACER ADVECTION BY RDW 119 ! IF( (iadv(nqmx).LT.0).OR.(iadv(nqmx).GT.4) ) THEN 120 ! PRINT *,' Erreur dans le choix de iadv (nqmx).Corriger et ' 121 ! * ,' repasser car iadv(nqmx) = ', iadv(nqmx) 122 ! CALL ABORT 123 ! ENDIF 108 IF( (iadv(nq).LE.0).OR.(iadv(nq).GT.4) ) THEN 109 PRINT *,' Erreur dans le choix de iadv (nqtot).Corriger et ' & 110 ,' repasser car iadv(nqtot) = ', iadv(nqtot) 111 CALL ABORT 112 ENDIF 124 113 125 114 first = .TRUE. 126 numvanle = nq mx+ 1127 DO iq = 1, nq mx115 numvanle = nq + 1 116 DO iq = 1, nq 128 117 IF(((iadv(iq).EQ.3).OR.(iadv(iq).EQ.4)).AND.first ) THEN 129 118 numvanle = iq … … 131 120 ENDIF 132 121 ENDDO 133 c 134 DO iq = 1, nq mx122 ! 123 DO iq = 1, nq 135 124 136 125 IF( (iadv(iq).NE.3.AND.iadv(iq).NE.4).AND.iq.GT.numvanle ) THEN 137 PRINT *,' Il y a discontinuite dans le choix du shema de ', 138 *'Van-leer pour les traceurs . Corriger et repasser . '126 PRINT *,' Il y a discontinuite dans le choix du shema de ', & 127 'Van-leer pour les traceurs . Corriger et repasser . ' 139 128 CALL ABORT 140 129 ENDIF 141 130 142 131 ENDDO 143 c 144 end if ! of if nqmx > 0132 ! 133 end subroutine iniadvtrac 145 134 146 end 135 END MODULE infotrac -
trunk/LMDZ.GENERIC/libf/dyn3d/iniconst.F
r135 r1216 1 1 SUBROUTINE iniconst 2 2 3 use control_mod, only: iphysiq, idissip 3 4 IMPLICIT NONE 4 5 c … … 13 14 #include "comconst.h" 14 15 #include "temps.h" 15 #include "control.h"16 !#include "control.h" 16 17 #include "comvert.h" 17 18 -
trunk/LMDZ.GENERIC/libf/dyn3d/inidissip.F
r253 r1216 8 8 c ------------- 9 9 10 use control_mod, only: idissip, iperiod 10 11 IMPLICIT NONE 11 12 #include "dimensions.h" … … 14 15 #include "comconst.h" 15 16 #include "comvert.h" 16 #include "control.h"17 !#include "control.h" 17 18 18 19 LOGICAL lstardis -
trunk/LMDZ.GENERIC/libf/dyn3d/logic.h
r253 r1216 3 3 4 4 COMMON/logic/ purmats,physic,forward,leapf,apphys,grireg, 5 * statcl,conser,apdiss,apdelq,saison,ecripar,fxyhypb,ysinus,hybrid,autozlevs 5 * statcl,conser,apdiss,apdelq,saison,ecripar,fxyhypb,ysinus, 6 & hybrid,autozlevs 6 7 7 8 LOGICAL purmats,physic,forward,leapf,apphys,grireg,statcl,conser, -
trunk/LMDZ.GENERIC/libf/dyn3d/test_period.F
r135 r1216 1 1 SUBROUTINE test_period ( ucov, vcov, teta, q, p, phis ) 2 3 USE infotrac, ONLY: nqtot 4 IMPLICIT NONE 2 5 c 3 6 c Auteur : P. Le Van … … 14 17 c 15 18 REAL ucov(ip1jmp1,llm), vcov(ip1jm,llm), teta(ip1jmp1,llm) , 16 , q(ip1jmp1,llm,nq mx), p(ip1jmp1,llmp1), phis(ip1jmp1)19 , q(ip1jmp1,llm,nqtot), p(ip1jmp1,llmp1), phis(ip1jmp1) 17 20 c 18 21 c ..... Variables locales ..... … … 51 54 52 55 c 53 DO nq =1, nq mx56 DO nq =1, nqtot 54 57 DO l =1, llm 55 58 DO ij = 1, ip1jmp1, iip1 -
trunk/LMDZ.GENERIC/libf/grid/dimension/makdim
r135 r1216 1 1 #!/bin/bash 2 2 3 nqmx=$14 shift3 #nqmx=$1 4 #shift 5 5 for i in $* ; do 6 6 list=$list.$i 7 7 done 8 9 fichdim=dimensions${list}.t${nqmx}8 fichdim=dimensions${list} 9 #fichdim=dimensions${list}.t${nqmx} 10 10 11 11 echo $fichdim … … 18 18 jm=$2 19 19 lm=$3 20 n2=$120 # n2=$1 21 21 ndm=1 22 22 … … 51 51 ! INCLUDE 'dimensions.h' 52 52 ! 53 ! dimensions.h contient les dimensions du modele 54 ! ndm est tel que iim=2**ndm 55 ! nqmx est la dimension de la variable traceur q 53 ! dimensions.h contains the model dimensions 54 ! 56 55 !----------------------------------------------------------------------- 57 56 58 INTEGER, parameter :: iim= 57 INTEGER, parameter :: iim=$im 59 58 INTEGER, parameter :: jjm=$jm 60 59 INTEGER, parameter :: llm=$lm 61 60 INTEGER, parameter :: ndm=$ndm 62 63 integer, parameter :: nqmx=$nqmx64 61 65 62 !----------------------------------------------------------------------- -
trunk/LMDZ.GENERIC/libf/phystd/callkeys.h
r1194 r1216 3 3 ! symbols '&' in columns 73 and 6 4 4 ! 5 COMMON/callkeys/callrad,corrk,calldifv,UseTurbDiff,calladj & 5 ! Group commons according to their type for minimal performance impact 6 7 COMMON/callkeys_l/callrad,corrk,calldifv,UseTurbDiff,calladj & 6 8 & , co2cond,callsoil & 7 & , season,diurnal,tlocked,rings_shadow, iradia,lwrite&8 & , iaervar,iddist,topdustref,callstats,calleofdump&9 & , season,diurnal,tlocked,rings_shadow,lwrite & 10 & , callstats,calleofdump & 9 11 & , enertest & 10 12 & , callgasvis,continuum,H2Ocont_simple,graybody & 11 & , Nmix_co2, radfixed, dusttau&13 & , radfixed & 12 14 & , meanOLR, specOLR & 13 & , kastprof , Tstrat&14 & , nosurf, intheat, flatten, oblate&15 & , newtonian, t au_relax, testradtimes&15 & , kastprof & 16 & , nosurf, oblate & 17 & , newtonian, testradtimes & 16 18 & , check_cpp_match, force_cpp & 17 19 & , rayleigh & 18 & , stelbbody, stelTbb & 19 & , tplanet & 20 & , obs_tau_col_tropo & 21 & , obs_tau_col_strato & 22 & , pres_bottom_tropo & 23 & , pres_top_tropo & 24 & , pres_bottom_strato & 25 & , pres_top_strato & 26 & , size_tropo & 27 & , size_strato & 28 & , startype, Fat1AU & 20 & , stelbbody & 29 21 & , nearco2cond & 30 & , tracer, mass_redistrib, varactive, varfixed , satval&22 & , tracer, mass_redistrib, varactive, varfixed & 31 23 & , sedimentation,water,watercond,waterrain & 32 24 & , aeroco2,aeroh2o,aeroh2so4,aeroback2lay & 33 25 & , aerofixco2,aerofixh2o & 34 & , hydrology, sourceevol, icetstep, albedosnow & 35 & , maxicethick, Tsaldiff & 36 & , CLFfixval, CLFvarying & 37 & , n2mixratio & 38 & , co2supsat & 39 & , cloudlvl & 40 & , pceil & 41 & , Rmean, J2, MassPlanet & 26 & , hydrology, sourceevol & 27 & , CLFvarying & 42 28 & , strictboundcorrk 43 29 30 COMMON/callkeys_i/iaervar,iddist,iradia,startype 31 32 COMMON/callkeys_r/topdustref,Nmix_co2,dusttau,Fat1AU,stelTbb, & 33 & Tstrat,tplanet,obs_tau_col_tropo, & 34 & obs_tau_col_strato,pres_bottom_tropo, & 35 & pres_top_tropo,pres_bottom_strato, & 36 & pres_top_strato,size_tropo,size_strato,satval, & 37 & CLFfixval,n2mixratio,co2supsat,pceil,albedosnow,& 38 & maxicethick,Tsaldiff,tau_relax,cloudlvl, & 39 & icetstep,intheat,flatten,Rmean,J2,MassPlanet 40 44 41 logical callrad,corrk,calldifv,UseTurbDiff & 45 42 & , calladj,co2cond,callsoil & -
trunk/LMDZ.GENERIC/libf/phystd/comsoil_h.F90
r787 r1216 1 module comsoil_h 1 2 2 module comsoil_h 3 implicit none 4 ! nsoilmx : number of subterranean layers 5 !integer, parameter :: nsoilmx = 18 ! for z1=0.0002 m, depth = 18 m => mars case 6 !integer, parameter :: nsoilmx = 13 ! for z1=0.03 m, depth = 104.8 m => earth case 7 integer, parameter :: nsoilmx = 18 3 8 4 implicit none 9 real,save,allocatable,dimension(:) :: layer ! soil layer depths 10 real,save,allocatable,dimension(:) :: mlayer ! soil mid-layer depths 11 real,save,allocatable,dimension(:,:) :: inertiedat ! soil thermal inertia 12 real,save :: volcapa ! soil volumetric heat capacity 13 ! NB: volcapa is read fromn control(35) from physicq start file 14 ! in physdem (or set via tabfi, or initialized in 15 ! soil_settings.F) 5 16 6 real,allocatable,dimension(:) :: layer ! soil layer depths 7 real,allocatable,dimension(:) :: mlayer ! soil mid-layer depths 8 real,allocatable,dimension(:,:) :: inertiedat ! soil thermal inertia 9 real volcapa ! soil volumetric heat capacitya 17 contains 10 18 11 end module comsoil_h 19 subroutine ini_comsoil_h(ngrid) 20 21 implicit none 22 integer,intent(in) :: ngrid ! number of atmospheric columns 23 24 if (.not.allocated(layer)) allocate(layer(nsoilmx)) !soil layer depths 25 if (.not.allocated(mlayer)) allocate(mlayer(0:nsoilmx-1)) ! soil mid-layer depths 26 if (.not.allocated(inertiedat)) allocate(inertiedat(ngrid,nsoilmx)) ! soil thermal inertia 27 28 end subroutine ini_comsoil_h 12 29 30 end module comsoil_h 31 -
trunk/LMDZ.GENERIC/libf/phystd/condense_cloud.F90
r869 r1216 7 7 8 8 use radinc_h, only : naerkind 9 use gases_h 9 use gases_h, only: gfrac, igas_co2 10 10 use radii_mod, only : co2_reffrad 11 11 use aerosol_mod, only : iaero_co2 12 USE surfdat_h 13 USE comgeomfi_h 14 USE tracer_h 12 USE surfdat_h, only: albedodat, albedice, emisice, emissiv 13 USE comgeomfi_h, only: lati 14 USE tracer_h, only: noms, rho_co2 15 15 16 16 … … 453 453 ! -------------------------------------------------------------------- 454 454 DO ig=1,ngrid 455 IF( ig.GT.ngrid/2+1) THEN456 icap=2 455 IF(lati(ig).LT.0.) THEN 456 icap=2 ! Southern Hemisphere 457 457 ELSE 458 icap=1 458 icap=1 ! Nortnern hemisphere 459 459 ENDIF 460 460 -
trunk/LMDZ.GENERIC/libf/phystd/dimphys.h
r863 r1216 7 7 ! nlayermx : number of atmospheric layers 8 8 integer, parameter :: nlayermx = llm 9 ! nsoilmx : number of subterranean layers 9 ! nsoilmx : number of subterranean layers ! nsoilmx is now in comsoil_h 10 10 !integer, parameter :: nsoilmx = 4 ! for a test 11 integer, parameter :: nsoilmx = 18 ! for z1=0.0002 m, depth = 18 m => mars case11 !integer, parameter :: nsoilmx = 18 ! for z1=0.0002 m, depth = 18 m => mars case 12 12 !integer, parameter :: nsoilmx = 13 ! for z1=0.03 m, depth = 104.8 m => earth case 13 13 !----------------------------------------------------------------------- -
trunk/LMDZ.GENERIC/libf/phystd/ini_archive.F
r993 r1216 36 36 37 37 USE comsoil_h 38 38 ! use control_mod 39 39 implicit none 40 40 … … 49 49 #include "logic.h" 50 50 #include "serre.h" 51 #include "control.h"51 !#include "control.h" 52 52 53 53 #include "netcdf.inc" -
trunk/LMDZ.GENERIC/libf/phystd/inifis.F
r1194 r1216 1 SUBROUTINE inifis(ngrid,nlayer, 1 SUBROUTINE inifis(ngrid,nlayer,nq, 2 2 $ day_ini,pdaysec,ptimestep, 3 3 $ plat,plon,parea, … … 6 6 use radinc_h, only : naerkind 7 7 use datafile_mod, only: datadir 8 use comdiurn_h 9 10 !! to be conservative, but why this include here? 11 use surfdat_h 12 use comsaison_h 13 14 USE comgeomfi_h 8 use comdiurn_h, only: sinlat, coslat, sinlon, coslon 9 use comgeomfi_h, only: long, lati, area, totarea 10 use comsoil_h, only: ini_comsoil_h 11 use control_mod, only: ecritphy 15 12 16 13 !======================================================================= … … 61 58 62 59 63 REAL prad,pg,pr,pcpp,pdaysec,ptimestep60 REAL,INTENT(IN) :: prad,pg,pr,pcpp,pdaysec,ptimestep 64 61 65 INTEGER ngrid,nlayer66 REAL plat(ngrid),plon(ngrid),parea(ngrid)62 INTEGER,INTENT(IN) :: ngrid,nlayer,nq 63 REAL,INTENT(IN) :: plat(ngrid),plon(ngrid),parea(ngrid) 67 64 integer day_ini 68 65 INTEGER ig,ierr … … 102 99 STOP 103 100 ENDIF 101 102 ! read in 'ecritphy' (frequency of calls to physics, in dynamical steps) 103 ! (also done in dyn3d/defrun_new but not in LMDZ.COMMON) 104 call getin("ecritphy",ecritphy) 104 105 105 106 ! -------------------------------------------------------------- … … 691 692 coslon(ig)=cos(plon(ig)) 692 693 ENDDO 693 694 694 695 pi=2.*asin(1.) ! NB: pi is a common in comcstfi.h 695 696 696 RETURN 697 ! allocate "comsoil_h" arrays 698 call ini_comsoil_h(ngrid) 699 697 700 END -
trunk/LMDZ.GENERIC/libf/phystd/inistats.F
r965 r1216 1 1 subroutine inistats(ierr) 2 2 3 #ifdef CPP_PARA4 3 use mod_phys_lmdz_para, only : is_master 5 #endif6 4 implicit none 7 5 … … 14 12 #include "netcdf.inc" 15 13 16 #ifndef CPP_PARA17 logical,parameter :: is_master=.true.18 #endif19 14 integer,intent(out) :: ierr 20 15 integer :: nid … … 32 27 nsteppd=nint(daysec/dtphys) 33 28 write (*,*) 'nsteppd=',nsteppd 34 write (*,*) 'istime=',istime35 36 37 38 29 if (abs(float(nsteppd)-daysec/dtphys).gt.1.e-8*daysec) 39 , stop'Dans Instat: 1jour .ne. n pas physiques' 40 30 & stop'Dans Instat: 1jour .ne. n pas physiques' 41 31 42 32 if(mod(nsteppd,istime).ne.0) 43 ,stop'Dans Instat: 1jour .ne. n*istime pas physiques'33 & stop'Dans Instat: 1jour .ne. n*istime pas physiques' 44 34 45 35 istats=nsteppd/istime … … 57 47 ! only the master needs do this 58 48 59 ierr = NF_CREATE("stats.nc", NF_CLOBBER,nid)49 ierr = NF_CREATE("stats.nc",IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid) 60 50 if (ierr.ne.NF_NOERR) then 61 51 write (*,*) NF_STRERROR(ierr) … … 70 60 71 61 ierr = NF_ENDDEF(nid) 72 call def_var (nid,"Time","Time",73 ."days since 0000-00-0 00:00:00",1,74 .idim_time,nvarid,ierr)62 call def_var_stats(nid,"Time","Time", 63 & "days since 0000-00-0 00:00:00",1, 64 & idim_time,nvarid,ierr) 75 65 ! Time is initialised later by mkstats subroutine 76 66 77 call def_var (nid,"latitude","latitude","degrees_north",1,78 .idim_lat,nvarid,ierr)67 call def_var_stats(nid,"latitude","latitude", 68 & "degrees_north",1,idim_lat,nvarid,ierr) 79 69 #ifdef NC_DOUBLE 80 70 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180) … … 82 72 ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180) 83 73 #endif 84 call def_var (nid,"longitude","East longitude","degrees_east",1,85 .idim_lon,nvarid,ierr)74 call def_var_stats(nid,"longitude","East longitude", 75 & "degrees_east",1,idim_lon,nvarid,ierr) 86 76 #ifdef NC_DOUBLE 87 77 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180) … … 106 96 ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt) 107 97 #endif 108 call def_var (nid,"aps","hybrid pressure at midlayers"," ",109 .1,idim_llm,nvarid,ierr)98 call def_var_stats(nid,"aps","hybrid pressure at midlayers" 99 & ," ",1,idim_llm,nvarid,ierr) 110 100 #ifdef NC_DOUBLE 111 101 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps) … … 114 104 #endif 115 105 116 call def_var (nid,"bps","hybrid sigma at midlayers"," ",117 .1,idim_llm,nvarid,ierr)106 call def_var_stats(nid,"bps","hybrid sigma at midlayers" 107 & ," ",1,idim_llm,nvarid,ierr) 118 108 #ifdef NC_DOUBLE 119 109 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps) … … 125 115 126 116 endif ! of if (is_master) 127 end 117 end subroutine inistats 118 -
trunk/LMDZ.GENERIC/libf/phystd/iniwrite.F
r993 r1216 1 1 SUBROUTINE iniwrite(nid,idayref,phis) 2 2 3 USE comsoil_h 4 3 use comsoil_h, only: mlayer, nsoilmx 5 4 IMPLICIT NONE 6 5 … … 23 22 #include "dimensions.h" 24 23 #include "paramet.h" 25 !include "comconst.h"26 24 #include "comcstfi.h" 27 25 #include "comvert.h" 28 26 #include "comgeom.h" 29 #include "temps.h"30 27 #include "ener.h" 31 28 #include "logic.h" 32 29 #include "netcdf.inc" 33 30 #include "serre.h" 34 #include"dimphys.h"35 31 36 32 c Arguments: 37 33 c ---------- 38 34 39 integer nid ! NetCDF file ID40 INTEGER*4 idayref ! date (initial date for this run)41 REALphis(ip1jmp1) ! surface geopotential35 integer,intent(in) :: nid ! NetCDF file ID 36 INTEGER*4,intent(in) :: idayref ! date (initial date for this run) 37 real,intent(in) :: phis(ip1jmp1) ! surface geopotential 42 38 43 39 c Local: … … 57 53 tab_cntrl(l)=0. 58 54 ENDDO 59 tab_cntrl(1) = FLOAT(iim)60 tab_cntrl(2) = FLOAT(jjm)61 tab_cntrl(3) = FLOAT(llm)62 tab_cntrl(4) = FLOAT(idayref)55 tab_cntrl(1) = real(iim) 56 tab_cntrl(2) = real(jjm) 57 tab_cntrl(3) = real(llm) 58 tab_cntrl(4) = real(idayref) 63 59 tab_cntrl(5) = rad 64 60 tab_cntrl(6) = omeg … … 252 248 253 249 !------------------------------- 254 ! (soil) depth variable mlayer() (known from comsoil .h)250 ! (soil) depth variable mlayer() (known from comsoil_h) 255 251 !------------------------------- 256 252 ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode -
trunk/LMDZ.GENERIC/libf/phystd/iniwritesoil.F90
r965 r1216 1 1 subroutine iniwritesoil(nid,ngrid) 2 3 use comsoil_h, only : inertiedat, mlayer4 #ifdef CPP_PARA5 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather6 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo7 #endif8 2 9 3 ! initialization routine for 'writediagoil'. Here we create/define … … 11 5 ! (time-independent) parameters. 12 6 7 use comsoil_h, only: mlayer, inertiedat, nsoilmx 8 13 9 implicit none 14 10 15 11 #include"dimensions.h" 16 #include"dimphys.h"17 12 #include"paramet.h" 18 13 #include"comcstfi.h" … … 38 33 integer :: i,j,l,ig0 39 34 40 #ifdef CPP_PARA41 ! Added to work in parallel mode42 real dx3_glop(klon_glo,nsoilmx)43 real dx3_glo(iim,jjp1,nsoilmx) ! to store a global 3D data set44 #else45 logical,parameter :: is_master=.true.46 logical,parameter :: is_mpi_root=.true.47 #endif48 49 35 ! 1. Define the dimensions 50 if (is_master) then51 36 ! Switch to NetCDF define mode 52 37 ierr=NF_REDEF(nid) … … 170 155 ierr=NF_PUT_VAR_REAL(nid,varid,mlayer) 171 156 #endif 172 ! Note mlayer(0:nsoilmx-1) known from comsoil .h157 ! Note mlayer(0:nsoilmx-1) known from comsoil_h 173 158 if (ierr.ne.NF_NOERR) then 174 159 write(*,*)"iniwritesoil: Error, could not write depth variable" … … 197 182 ! Note no need to write time variable here; it is done in writediagsoil. 198 183 199 endif ! of if (is_master)200 201 184 ! 3. Other variables to be included 202 185 203 186 ! 3.1 mesh area surrounding each horizontal point 204 if (is_master) then205 187 ierr=NF_REDEF(nid) ! switch to NetCDF define mode 206 188 … … 236 218 endif 237 219 238 endif ! of if (is_master)239 240 241 220 ! 3.2 Thermal inertia 242 if (is_master) then243 221 ierr=NF_REDEF(nid) ! switch to NetCDF define mode 244 222 … … 262 240 ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text) 263 241 264 endif !of if (is_master)265 266 242 ! Recast data along 'dynamics' grid 267 #ifdef CPP_PARA 268 ! gather field on a "global" (without redundant longitude) array 269 call Gather(inertiedat,dx3_glop) 270 !$OMP MASTER 271 if (is_mpi_root) then 272 call Grid1Dto2D_glo(dx3_glop,dx3_glo) 273 ! copy dx3_glo() to dx3(:) and add redundant longitude 274 data3(1:iim,:,:)=dx3_glo(1:iim,:,:) 275 data3(iip1,:,:)=data3(1,:,:) 276 endif 277 !$OMP END MASTER 278 !$OMP BARRIER 279 #else 280 ! Note: inertiedat is known from comsoil.h 243 ! Note: inertiedat is known from comsoil_h 244 281 245 do l=1,nsoilmx 282 246 ! handle the poles … … 294 258 enddo 295 259 enddo ! of do l=1,nsoilmx 296 #endif 297 298 ! Write data3 to file 299 if (is_master) then 300 ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode 301 ! Write 302 #ifdef NC_DOUBLE 303 ierr=NF_PUT_VAR_DOUBLE(nid,varid,data3) 304 #else 305 ierr=NF_PUT_VAR_REAL(nid,varid,data3) 306 #endif 307 if (ierr.ne.NF_NOERR) then 260 261 ! Write data2 to file 262 ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode 263 ! Write 264 #ifdef NC_DOUBLE 265 ierr=NF_PUT_VAR_DOUBLE(nid,varid,data3) 266 #else 267 ierr=NF_PUT_VAR_REAL(nid,varid,data3) 268 #endif 269 if (ierr.ne.NF_NOERR) then 308 270 write(*,*)"iniwritesoil: Error, could not write th_inertia variable" 309 endif 310 endif ! of if (is_master) 271 endif 311 272 312 273 end subroutine iniwritesoil -
trunk/LMDZ.GENERIC/libf/phystd/kcm1d.F90
r787 r1216 1 1 program kcm1d 2 2 3 use infotrac, only: nqtot 3 4 use radinc_h, only: NAERKIND 4 5 use radcommon_h, only: L_NSPECTI, L_NSPECTV, sigma 5 6 use watercommon_h, only: mH2O 6 use ioipsl_getincom 7 use comsaison_h 7 use ioipsl_getincom, only: getin 8 use comsaison_h, only: mu0, fract, dist_star 9 ! use control_mod 8 10 9 11 implicit none … … 32 34 #include "comcstfi.h" 33 35 #include "planete.h" 34 #include "control.h"36 !#include "control.h" 35 37 36 38 ! -------------------------------------------------------------- … … 44 46 real plev(nlayermx+1) ! Intermediate pressure levels [Pa] 45 47 real temp(nlayermx) ! temperature at the middle of the layers [K] 46 real q(nlayermx,nqmx) ! tracer mixing ratio [kg/kg]47 real vmr(nlayermx,nqmx) ! tracer mixing ratio [mol/mol]48 real qsurf(nqmx) ! tracer surface budget [kg/kg] ????48 real,allocatable :: q(:,:) ! tracer mixing ratio [kg/kg] 49 real,allocatable :: vmr(:,:) ! tracer mixing ratio [mol/mol] 50 real,allocatable :: qsurf(:) ! tracer surface budget [kg/kg] ???? 49 51 real psurf,psurf_n,tsurf 50 52 … … 77 79 logical firstcall,lastcall,global1d 78 80 79 character*20 nametrac(nqmx) ! name of the tracer (no need for adv trac common)81 character*20,allocatable :: nametrac(:) ! name of the tracer (no need for adv trac common) 80 82 81 83 ! -------------- … … 219 221 write(*,*) " (first line of traceur.def) " 220 222 stop 221 else222 ! check that the number of tracers is indeed nqmx223 if (nq.ne.nqmx) then224 write(*,*) "kcm1d: error, wrong number of tracers:"225 write(*,*) "nq=",nq," whereas nqmx=",nqmx226 stop227 endif228 223 endif 224 nqtot=nq 225 ! allocate arrays which depend on number of tracers 226 allocate(nametrac(nq)) 227 allocate(q(nlayermx,nq)) 228 allocate(vmr(nlayermx,nq)) 229 allocate(qsurf(nq)) 229 230 230 231 do iq=1,nq -
trunk/LMDZ.GENERIC/libf/phystd/lect_start_archive.F
r993 r1216 3 3 & q,qsurf,surfith,nid) 4 4 5 USE surfdat_h 6 USE comsoil_h 7 USE tracer_h 5 ! USE surfdat_h 6 USE comsoil_h, ONLY: nsoilmx, layer, mlayer, volcapa, inertiedat 7 USE tracer_h, ONLY: igcm_co2_ice 8 USE infotrac, ONLY: tname, nqtot 9 ! USE control_mod 8 10 9 11 c======================================================================= … … 26 28 #include "dimensions.h" 27 29 #include "dimphys.h" 28 #include "planete.h"30 !#include "planete.h" 29 31 #include "paramet.h" 30 32 #include "comconst.h" 31 33 #include "comvert.h" 32 34 #include "comgeom2.h" 33 #include "control.h"34 #include "logic.h"35 !#include "control.h" 36 !#include "logic.h" 35 37 #include "ener.h" 36 38 #include "temps.h" 37 39 #include "netcdf.inc" 38 #include"advtrac.h"40 !#include"advtrac.h" 39 41 c======================================================================= 40 42 c Declarations … … 79 81 REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants 80 82 REAL h(iip1,jjp1,llm),ps(iip1,jjp1) 81 REAL q(iip1,jjp1,llm,nq mx),qtot(iip1,jjp1,llm)83 REAL q(iip1,jjp1,llm,nqtot),qtot(iip1,jjp1,llm) 82 84 83 85 c autre variables dynamique nouvelle grille … … 97 99 REAL co2ice(ngridmx) ! CO2 ice layer 98 100 REAL emis(ngridmx) 99 REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nq mx)101 REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqtot) 100 102 c REAL phisfi(ngridmx) 101 103 … … 119 121 real co2iceS(iip1,jjp1) 120 122 real emisS(iip1,jjp1) 121 REAL q2S(iip1,jjp1,llm+1),qsurfS(iip1,jjp1,nq mx)123 REAL q2S(iip1,jjp1,llm+1),qsurfS(iip1,jjp1,nqtot) 122 124 123 125 real ptotal, co2icetotal … … 283 285 allocate(psold(imold+1,jmold+1)) 284 286 allocate(phisold(imold+1,jmold+1)) 285 allocate(qold(imold+1,jmold+1,lmold,nq mx))287 allocate(qold(imold+1,jmold+1,lmold,nqtot)) 286 288 allocate(co2iceold(imold+1,jmold+1)) 287 289 allocate(tsurfold(imold+1,jmold+1)) … … 296 298 allocate(surfithold(imold+1,jmold+1)) 297 299 allocate(mlayerold(nsoilold)) 298 allocate(qsurfold(imold+1,jmold+1,nq mx))300 allocate(qsurfold(imold+1,jmold+1,nqtot)) 299 301 300 302 allocate(var (imold+1,jmold+1,llm)) … … 703 705 704 706 ! Surface tracers: 705 do iq=1,nq mx707 do iq=1,nqtot 706 708 ! initialize all surface tracers to zero 707 709 call initial0((jmold+1)*(imold+1), qsurfold(1,1,iq)) … … 709 711 710 712 711 ! print*,'tn om=',tnom713 ! print*,'tname=',tname 712 714 ! print*,'nid',nid 713 715 ! print*,'nvarid',nvarid 714 716 ! stop 715 717 716 DO iq=1,nq mx717 txt=trim(tn om(iq))//"_surf"718 DO iq=1,nqtot 719 txt=trim(tname(iq))//"_surf" 718 720 if (txt.eq."h2o_vap") then 719 721 ! There is no surface tracer for h2o_vap; … … 748 750 ENDIF 749 751 750 ENDDO ! of DO iq=1,nq mx752 ENDDO ! of DO iq=1,nqtot 751 753 752 754 … … 894 896 895 897 ! Tracers: 896 do iq=1,nq mx898 do iq=1,nqtot 897 899 call initial0((jmold+1)*(imold+1)*lmold,qold(1,1,1,iq) ) 898 900 enddo 899 901 900 DO iq=1,nq mx901 txt=tn om(iq)902 DO iq=1,nqtot 903 txt=tname(iq) 902 904 write(*,*)"lect_start_archive: loading tracer ",trim(txt) 903 905 ierr = NF_INQ_VARID (nid,txt,nvarid) … … 925 927 ENDIF 926 928 927 ENDDO ! of DO iq=1,nq mx929 ENDDO ! of DO iq=1,nqtot 928 930 929 931 … … 1254 1256 c write(49,*) 'ucov',vcov 1255 1257 1256 if (nq mx.gt. 0) then1258 if (nqtot .gt. 0) then 1257 1259 c traceurs surface 1258 do iq = 1, nq mx1260 do iq = 1, nqtot 1259 1261 call interp_horiz(qsurfold(1,1,iq) ,qsurfs(1,1,iq), 1260 1262 & imold,jmold,iim,jjm,1, … … 1262 1264 enddo 1263 1265 1264 call gr_dyn_fi (nq mx,iim+1,jjm+1,ngridmx,qsurfs,qsurf)1266 call gr_dyn_fi (nqtot,iim+1,jjm+1,ngridmx,qsurfs,qsurf) 1265 1267 1266 1268 c traceurs 3D 1267 do iq = 1, nq mx1269 do iq = 1, nqtot 1268 1270 call interp_vert(qold(1,1,1,iq),var,lmold,llm, 1269 1271 & apsold,bpsold,aps,bps,psold,(imold+1)*(jmold+1)) … … 1305 1307 1306 1308 c Periodicite : 1307 do iq = 1, nq mx1309 do iq = 1, nqtot 1308 1310 do l=1, llm 1309 1311 do j = 1, jjp1 … … 1316 1318 ! no need to transfer "co2ice" any more; it is in qsurf(igcm_co2_ice) 1317 1319 1318 endif !! if nq mx.ne. 01320 endif !! if nqtot .ne. 0 1319 1321 1320 1322 c----------------------------------------------------------------------- -
trunk/LMDZ.GENERIC/libf/phystd/mkstat.F90
r965 r1216 1 1 subroutine mkstats(ierr) 2 2 3 3 4 ! … … 9 10 ! Yann W. july 2003 10 11 11 #ifdef CPP_PARA12 12 use mod_phys_lmdz_para, only : is_master 13 #endif14 13 15 14 implicit none … … 35 34 integer :: meanid,sdid 36 35 !integer, dimension(4) :: dimout 37 #ifndef CPP_PARA38 logical,parameter :: is_master=.true.39 #endif40 36 41 37 ! Incrementation of count for the last step, which is not done in wstats -
trunk/LMDZ.GENERIC/libf/phystd/newstart.F
r1023 r1216 15 15 c======================================================================= 16 16 17 USE tracer_h 18 USE comsoil_h 19 USE surfdat_h 20 USE comgeomfi_h 17 use infotrac, only: iniadvtrac, nqtot, tname 18 USE tracer_h, ONLY: igcm_co2_ice, igcm_h2o_vap, igcm_h2o_ice 19 USE comsoil_h, ONLY: nsoilmx, layer, mlayer, inertiedat 20 USE surfdat_h, ONLY: phisfi, albedodat, 21 & zmea, zstd, zsig, zgam, zthe 22 USE comgeomfi_h, ONLY: lati, long, area 21 23 use datafile_mod, only: datadir 22 24 ! to use 'getin' 23 25 USE ioipsl_getincom, only: getin 26 use control_mod, only: day_step, iphysiq, anneeref 27 use phyredem, only: physdem0, physdem1 28 use iostart, only: open_startphy 29 use comgeomphy, only: initcomgeomphy 24 30 implicit none 25 31 … … 31 37 #include "comvert.h" 32 38 #include "comgeom2.h" 33 #include "control.h"39 !#include "control.h" 34 40 #include "logic.h" 35 41 #include "ener.h" … … 38 44 #include "serre.h" 39 45 #include "netcdf.inc" 40 #include "advtrac.h"46 !#include "advtrac.h" 41 47 c======================================================================= 42 48 c Declarations … … 64 70 REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants 65 71 REAL phis(iip1,jjp1) 66 REAL q(iip1,jjp1,llm,nqmx) ! champs advectes72 REAL,ALLOCATABLE :: q(:,:,:,:) ! champs advectes 67 73 68 74 c autre variables dynamique nouvelle grille … … 90 96 REAL emis(ngridmx) ! surface emissivity 91 97 real emisread ! added by RW 92 REAL qsurf(ngridmx,nqmx)98 REAL,ALLOCATABLE :: qsurf(:,:) 93 99 REAL q2(ngridmx,nlayermx+1) 94 100 ! REAL rnaturfi(ngridmx) … … 176 182 pa = 0. ! to ensure disaster rather than minor error if we don`t 177 183 ! make deliberate choice of these values elsewhere. 184 185 ! initialize "serial/parallel" related stuff 186 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 187 call initcomgeomphy 188 189 ! Load tracer number and names: 190 call iniadvtrac(nqtot,numvanle) 191 ! allocate arrays 192 allocate(q(iip1,jjp1,llm,nqtot)) 193 allocate(qsurf(ngridmx,nqtot)) 178 194 179 195 c======================================================================= … … 243 259 c INITIALISATIONS DIVERSES 244 260 c======================================================================= 245 ! Load tracer names:246 call iniadvtrac(nq,numvanle)247 ! tnom(:) now contains tracer names248 ! JL12 we will need the tracer names to read start in dyneta0249 261 250 262 ! Initialize global tracer indexes (stored in tracer.h) 251 263 ! ... this has to be done before phyetat0 252 call initracer(ngridmx,nq mx,tnom)264 call initracer(ngridmx,nqtot,tname) 253 265 254 266 ! Take care of arrays in common modules … … 320 332 write(*,*) 'Reading file START' 321 333 fichnom = 'start.nc' 322 CALL dynetat0(fichnom,nq mx,vcov,ucov,teta,q,masse,334 CALL dynetat0(fichnom,nqtot,vcov,ucov,teta,q,masse, 323 335 . ps,phis,time) 324 336 325 337 write(*,*) 'Reading file STARTFI' 326 338 fichnom = 'startfi.nc' 327 CALL phyetat0 (ngridmx,fichnom,tab0,Lmodif,nsoilmx,nq mx,339 CALL phyetat0 (ngridmx,fichnom,tab0,Lmodif,nsoilmx,nqtot, 328 340 . day_ini,time, 329 341 . tsurf,tsoil,emis,q2,qsurf, !) ! temporary modif by RDW … … 387 399 c----------------------------------------------------------------------- 388 400 if (choix_1.eq.0) then 401 ! tabfi requires that input file be first opened by open_startphy(fichnom) 402 fichnom = 'start_archive.nc' 403 call open_startphy(fichnom) 389 404 call tabfi (ngridmx,nid,Lmodif,tab0,day_ini,lllm,p_rad, 390 405 . p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time) 391 406 else if (choix_1.eq.1) then 407 fichnom = 'startfi.nc' 408 call open_startphy(fichnom) 392 409 Lmodif=1 ! Lmodif set to 1 to allow modifications in phyeta0 393 410 call tabfi (ngridmx,nid_fi,Lmodif,tab0,day_ini,lllm,p_rad, … … 434 451 airefi(1)=airefi(1)*iim 435 452 airefi(ngridmx)=airefi(ngridmx)*iim 453 454 ! also initialize various physics flags/settings which might be needed 455 ! (for instance initracer needs to know about some flags, and/or 456 ! 'datafile' path may be changed by user) 457 call inifis(ngridmx,llm,nqtot,day_ini,daysec,dtphys, 458 & latfi,lonfi,airefi,rad,g,r,cpp) 436 459 437 460 c======================================================================= … … 574 597 575 598 read(*,fmt='(a20)') modif 576 if (modif(1:1) .eq. ' ') exit ! exit loop on changes 599 if (modif(1:1) .eq. ' ')then 600 exit ! exit loop on changes 601 endif 577 602 578 603 write(*,*) … … 774 799 if (yes.eq.'y') then 775 800 write(*,*) 'OK : conservation of tracer total mass' 776 DO iq =1, nq mx801 DO iq =1, nqtot 777 802 DO l=1,llm 778 803 DO j=1,jjp1 … … 827 852 do while (yes.eq.'y') 828 853 write(*,*) 'Which tracer name do you want to change ?' 829 do iq=1,nq mx830 write(*,'(i3,a3,a20)')iq,' : ',trim(tn om(iq))854 do iq=1,nqtot 855 write(*,'(i3,a3,a20)')iq,' : ',trim(tname(iq)) 831 856 enddo 832 857 write(*,'(a35,i3)') 833 & '(enter tracer number; between 1 and ',nq mx858 & '(enter tracer number; between 1 and ',nqtot 834 859 write(*,*)' or any other value to quit this option)' 835 860 read(*,*) iq 836 if ((iq.ge.1).and.(iq.le.nq mx)) then837 write(*,*)'Change tracer name ',trim(tn om(iq)),' to ?'861 if ((iq.ge.1).and.(iq.le.nqtot)) then 862 write(*,*)'Change tracer name ',trim(tname(iq)),' to ?' 838 863 read(*,*) txt 839 tn om(iq)=txt864 tname(iq)=txt 840 865 write(*,*)'Do you want to change another tracer name (y/n)?' 841 866 read(*,'(a)') yes … … 843 868 ! inapropiate value of iq; quit this option 844 869 yes='n' 845 endif ! of if ((iq.ge.1).and.(iq.le.nq mx))870 endif ! of if ((iq.ge.1).and.(iq.le.nqtot)) 846 871 enddo ! of do while (yes.ne.'y') 847 872 … … 851 876 c mise a 0 des q (traceurs) 852 877 write(*,*) 'Tracers set to 0 (1.E-30 in fact)' 853 DO iq =1, nq mx878 DO iq =1, nqtot 854 879 DO l=1,llm 855 880 DO j=1,jjp1 … … 862 887 863 888 c set surface tracers to zero 864 DO iq =1, nq mx889 DO iq =1, nqtot 865 890 DO ig=1,ngridmx 866 891 qsurf(ig,iq)=0. … … 872 897 else if (trim(modif).eq.'q=x') then 873 898 write(*,*) 'Which tracer do you want to modify ?' 874 do iq=1,nq mx875 write(*,*)iq,' : ',trim(tn om(iq))899 do iq=1,nqtot 900 write(*,*)iq,' : ',trim(tname(iq)) 876 901 enddo 877 write(*,*) '(choose between 1 and ',nq mx,')'902 write(*,*) '(choose between 1 and ',nqtot,')' 878 903 read(*,*) iq 879 write(*,*)'mixing ratio of tracer ',trim(tn om(iq)),904 write(*,*)'mixing ratio of tracer ',trim(tname(iq)), 880 905 & ' ? (kg/kg)' 881 906 read(*,*) val … … 887 912 ENDDO 888 913 ENDDO 889 write(*,*) 'SURFACE value of tracer ',trim(tn om(iq)),914 write(*,*) 'SURFACE value of tracer ',trim(tname(iq)), 890 915 & ' ? (kg/m2)' 891 916 read(*,*) val … … 942 967 write(*,*) "followed by 2nd, etc. up to top of atmosphere)" 943 968 write(*,*) 'Which tracer do you want to set?' 944 do iq=1,nq mx945 write(*,*)iq,' : ',trim(tn om(iq))969 do iq=1,nqtot 970 write(*,*)iq,' : ',trim(tname(iq)) 946 971 enddo 947 write(*,*) '(choose between 1 and ',nq mx,')'972 write(*,*) '(choose between 1 and ',nqtot,')' 948 973 read(*,*) iq 949 if ((iq.lt.1).or.(iq.gt.nq mx)) then974 if ((iq.lt.1).or.(iq.gt.nqtot)) then 950 975 ! wrong value for iq, go back to menu 951 976 write(*,*) "wrong input value:",iq … … 953 978 endif 954 979 ! look for input file 'profile_tracer' 955 txt="profile_"//trim(tn om(iq))980 txt="profile_"//trim(tname(iq)) 956 981 open(41,file=trim(txt),status='old',form='formatted', 957 982 & iostat=ierr) … … 970 995 q(:,:,l,iq)=profile(l+1) 971 996 enddo 972 write(*,*)'OK, tracer ',trim(tn om(iq)),' initialized ',973 & 997 write(*,*)'OK, tracer ',trim(tname(iq)),' initialized ' 998 & ,'using values from file ',trim(txt) 974 999 else 975 1000 write(*,*)'problem reading file ',trim(txt),' !' 976 write(*,*)'No modifications to tracer ',trim(tn om(iq))1001 write(*,*)'No modifications to tracer ',trim(tname(iq)) 977 1002 endif 978 1003 else 979 1004 write(*,*)'Could not find file ',trim(txt),' !' 980 write(*,*)'No modifications to tracer ',trim(tn om(iq))1005 write(*,*)'No modifications to tracer ',trim(tname(iq)) 981 1006 endif 982 1007 … … 1504 1529 1505 1530 1506 CALL dynredem0("restart.nc",day_ini,anneeref,phis,nq mx)1507 CALL dynredem1("restart.nc",0.0,vcov,ucov,teta,q,nq mx,masse,ps)1531 CALL dynredem0("restart.nc",day_ini,anneeref,phis,nqtot) 1532 CALL dynredem1("restart.nc",0.0,vcov,ucov,teta,q,nqtot,masse,ps) 1508 1533 C 1509 1534 C Ecriture etat initial physique 1510 1535 C 1511 1536 1512 ! do ig=1,ngridmx 1513 ! print*,'surface ice in newstart=',qsurf(ig,igcm_h2o_ice) 1514 ! print*,'surface liq in newstart=',qsurf(ig,igcm_h2o_vap) 1515 ! enddo 1516 ! stop 1517 1518 1519 call physdem1(ngridmx,"restartfi.nc",lonfi,latfi,nsoilmx,nqmx, 1520 . dtphys,float(day_ini), 1521 . time,tsurf,tsoil,emis,q2,qsurf, 1522 . airefi,albfi,ithfi,zmea,zstd,zsig,zgam,zthe, 1523 . cloudfrac,totalfrac,hice,tnom) 1537 call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,ngridmx,llm, 1538 & nqtot,dtphys,real(day_ini),0.0, 1539 & airefi,albfi,ithfi,zmea,zstd,zsig,zgam,zthe) 1540 call physdem1("restartfi.nc",nsoilmx,ngridmx,llm,nq, 1541 & dtphys,real(day_ini), 1542 & tsurf,tsoil,emis,q2,qsurf, 1543 & cloudfrac,totalfrac,hice) 1524 1544 1525 1545 c======================================================================= … … 1534 1554 *rage est differente de la valeur parametree llm =',i4//) 1535 1555 1556 write(*,*) "newstart: All is well that ends well." 1557 1536 1558 end 1537 1559 -
trunk/LMDZ.GENERIC/libf/phystd/phyetat0.F90
r1214 r1216 1 SUBROUTINE phyetat0 (ngrid,fichnom,tab0,Lmodif,nsoil,nq, 2 . day_ini,time, 3 . tsurf,tsoil,emis,q2,qsurf,cloudfrac,totcloudfrac,hice) 4 5 USE surfdat_h 6 USE comgeomfi_h 7 USE tracer_h 8 9 implicit none 10 11 c====================================================================== 12 c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818 13 c Adaptation à Mars : Yann Wanherdrick 14 c Objet: Lecture de l etat initial pour la physique 15 c====================================================================== 1 subroutine phyetat0 (ngrid,fichnom,tab0,Lmodif,nsoil,nq, & 2 day_ini,time,tsurf,tsoil, & 3 emis,q2,qsurf,cloudfrac,totcloudfrac,hice) 4 5 USE infotrac, ONLY: tname 6 USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe 7 use iostart, only: nid_start, open_startphy, close_startphy, & 8 get_field, get_var, inquire_field, & 9 inquire_dimension, inquire_dimension_length 10 11 implicit none 12 13 !====================================================================== 14 ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818 15 ! Adaptation à Mars : Yann Wanherdrick 16 ! Objet: Lecture de l etat initial pour la physique 17 !====================================================================== 16 18 #include "netcdf.inc" 17 19 #include "dimensions.h" … … 20 22 #include "comcstfi.h" 21 23 22 INTEGER ngrid 23 c====================================================================== 24 INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4 25 PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille 24 !====================================================================== 25 ! INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4 26 ! PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille 26 27 !====================================================================== 27 28 ! Arguments: 28 29 ! --------- 29 30 ! inputs: 30 character*(*) fichnom ! "startfi.nc" file 31 integer tab0 32 integer Lmodif 33 integer nsoil ! # of soil layers 34 integer nq 35 integer day_ini 36 real time 31 integer,intent(in) :: ngrid 32 character*(*),intent(in) :: fichnom ! "startfi.nc" file 33 integer,intent(in) :: tab0 34 integer,intent(in) :: Lmodif 35 integer,intent(in) :: nsoil ! # of soil layers 36 integer,intent(in) :: nq 37 integer,intent(in) :: day_ini 38 real,intent(in) :: time 37 39 38 40 ! outputs: 39 real tsurf(ngrid,nbsrf) ! surface temperature 40 real tsoil(ngrid,nsoil,nbsrf) ! soil temperature 41 real emis(ngrid) ! surface emissivity 42 real q2(ngrid, llm+1) ! 43 real qsurf(ngrid,nq) ! tracers on surface 44 ! real co2ice(ngrid) ! co2 ice cover 45 real cloudfrac(ngrid,nlayermx) 46 real hice(ngrid), totcloudfrac(ngrid) 47 41 real,intent(out) :: tsurf(ngrid) ! surface temperature 42 real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature 43 real,intent(out) :: emis(ngrid) ! surface emissivity 44 real,intent(out) :: q2(ngrid, llm+1) ! 45 real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface 46 ! real co2ice(ngrid) ! co2 ice cover 47 real,intent(out) :: cloudfrac(ngrid,nlayermx) 48 real,intent(out) :: hice(ngrid), totcloudfrac(ngrid) 48 49 49 50 !====================================================================== … … 55 56 56 57 real xmin,xmax ! to display min and max of a field 57 c 58 ! 58 59 INTEGER ig,iq,lmax 59 60 INTEGER nid, nvarid … … 65 66 CHARACTER*2 str2 66 67 CHARACTER*1 yes 67 c 68 ! 68 69 REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec 69 70 INTEGER nqold 70 71 71 72 ! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...) 72 logical :: oldtracernames=.false.73 ! logical :: oldtracernames=.false. 73 74 integer :: count 74 75 character(len=30) :: txt ! to store some text 76 77 INTEGER :: indextime=1 ! index of selected time, default value=1 78 logical :: found 75 79 76 80 !! added variables by AS to allow to read only slices of startfi 77 real :: toto(ngrid) 78 integer :: sta !! subscript in starti where we start to read 79 integer, dimension(2) :: sta2d 80 integer, dimension(2) :: siz2d 81 82 c AS: get the cursor that is stored in dimphys.h 83 c ... this allows to read only a part of startfi horiz grid 84 sta = cursor 85 86 c 87 c ALLOCATE ARRAYS IN surfdat_h 88 c 89 IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid)) 90 IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid)) 91 IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid)) 92 IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid)) 93 IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid)) 94 IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid)) 95 IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid)) 96 97 c 98 c Ouvrir le fichier contenant l etat initial: 99 c 100 101 ierr = NF_OPEN (fichnom, NF_NOWRITE,nid) 102 IF (ierr.NE.NF_NOERR) THEN 103 write(6,*)' Pb d''ouverture du fichier '//fichnom 104 CALL ABORT 105 ENDIF 106 107 ! Preliminary stuff: check if tracers follow old naming convention (qsurf01, 108 ! qsurf02, ...) 109 count=0 110 do iq=1,nq 111 txt= " " 112 write(txt,'(a5,i2.2)')'qsurf',iq 113 ierr=NF_INQ_VARID(nid,txt,nvarid) 114 if (ierr.ne.NF_NOERR) then 115 ! did not find old tracer name 116 exit ! might as well stop here 117 else 118 ! found old tracer name 119 count=count+1 120 endif 121 enddo 122 if (count.eq.nq) then 123 write(*,*) "phyetat0:tracers seem to follow old naming ", 124 & "convention (qsurf01,qsurf02,...)" 125 write(*,*) " => will work for now ... " 126 write(*,*) " but you should run newstart to rename them" 127 oldtracernames=.true. 128 endif 129 130 c modifications possibles des variables de tab_cntrl 131 write(*,*) 'TABFI de phyeta0',Lmodif,tab0 132 call tabfi (ngrid,nid,Lmodif,tab0,day_ini,lmax,p_rad, 133 . p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time) 134 135 c 136 c Lecture des latitudes (coordonnees): 137 c 138 ierr = NF_INQ_VARID (nid, "latitude", nvarid) 139 IF (ierr.NE.NF_NOERR) THEN 140 PRINT*, 'phyetat0: Le champ <latitude> est absent' 141 CALL abort 142 ENDIF 143 #ifdef NC_DOUBLE 144 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,lati) 145 #else 146 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,lati) 147 #endif 148 IF (ierr.NE.NF_NOERR) THEN 149 PRINT*, 'phyetat0: Lecture echouee pour <latitude>' 150 CALL abort 151 ENDIF 152 c 153 c Lecture des longitudes (coordonnees): 154 c 155 ierr = NF_INQ_VARID (nid, "longitude", nvarid) 156 IF (ierr.NE.NF_NOERR) THEN 157 PRINT*, 'phyetat0: Le champ <longitude> est absent' 158 CALL abort 159 ENDIF 160 #ifdef NC_DOUBLE 161 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,long) 162 #else 163 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,long) 164 #endif 165 IF (ierr.NE.NF_NOERR) THEN 166 PRINT*, 'phyetat0: Lecture echouee pour <longitude>' 167 CALL abort 168 ENDIF 169 c 170 c Lecture des aires des mailles: 171 c 172 ierr = NF_INQ_VARID (nid, "area", nvarid) 173 IF (ierr.NE.NF_NOERR) THEN 174 PRINT*, 'phyetat0: Le champ <area> est absent' 175 CALL abort 176 ENDIF 177 #ifdef NC_DOUBLE 178 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,area) 179 #else 180 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,area) 181 #endif 182 IF (ierr.NE.NF_NOERR) THEN 183 PRINT*, 'phyetat0: Lecture echouee pour <area>' 184 CALL abort 185 ENDIF 186 xmin = 1.0E+20 187 xmax = -1.0E+20 188 xmin = MINVAL(area) 189 xmax = MAXVAL(area) 190 PRINT*,'Aires des mailles <area>:', xmin, xmax 191 c 192 c Lecture du geopotentiel au sol: 193 c 194 ierr = NF_INQ_VARID (nid, "phisfi", nvarid) 195 IF (ierr.NE.NF_NOERR) THEN 196 PRINT*, 'phyetat0: Le champ <phisfi> est absent' 197 CALL abort 198 ENDIF 199 #ifdef NC_DOUBLE 200 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,phisfi) 201 #else 202 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,phisfi) 203 #endif 204 IF (ierr.NE.NF_NOERR) THEN 205 PRINT*, 'phyetat0: Lecture echouee pour <phisfi>' 206 CALL abort 207 ENDIF 208 xmin = 1.0E+20 209 xmax = -1.0E+20 210 xmin = MINVAL(phisfi) 211 xmax = MAXVAL(phisfi) 212 PRINT*,'Geopotentiel au sol <phisfi>:', xmin, xmax 213 c 214 c Lecture de l''albedo du sol nu: 215 c 216 ierr = NF_INQ_VARID (nid, "albedodat", nvarid) 217 IF (ierr.NE.NF_NOERR) THEN 218 PRINT*, 'phyetat0: Le champ <albedodat> est absent' 219 CALL abort 220 ENDIF 221 #ifdef NC_DOUBLE 222 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,albedodat) 223 #else 224 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,albedodat) 225 #endif 226 IF (ierr.NE.NF_NOERR) THEN 227 PRINT*, 'phyetat0: Lecture echouee pour <albedodat>' 228 CALL abort 229 ENDIF 230 xmin = 1.0E+20 231 xmax = -1.0E+20 232 xmin = MINVAL(albedodat) 233 xmax = MAXVAL(albedodat) 234 PRINT*,'Albedo du sol nu <albedodat>:', xmin, xmax 235 c 236 c ZMEA 237 c 238 ierr = NF_INQ_VARID (nid, "ZMEA", nvarid) 239 IF (ierr.NE.NF_NOERR) THEN 240 PRINT*, 'phyetat0: Le champ <ZMEA> est absent' 241 CALL abort 242 ENDIF 243 #ifdef NC_DOUBLE 244 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,zmea) 245 #else 246 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,zmea) 247 #endif 248 IF (ierr.NE.NF_NOERR) THEN 249 PRINT*, 'phyetat0: Lecture echouee pour <ZMEA>' 250 CALL abort 251 ENDIF 252 xmin = 1.0E+20 253 xmax = -1.0E+20 254 DO i = 1, ngrid 255 xmin = MIN(zmea(i),xmin) 256 xmax = MAX(zmea(i),xmax) 257 ENDDO 258 PRINT*,'<zmea>:', xmin, xmax 259 c 260 c ZSTD 261 c 262 ierr = NF_INQ_VARID (nid, "ZSTD", nvarid) 263 IF (ierr.NE.NF_NOERR) THEN 264 PRINT*, 'phyetat0: Le champ <ZSTD> est absent' 265 CALL abort 266 ENDIF 267 #ifdef NC_DOUBLE 268 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,zstd) 269 #else 270 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,zstd) 271 #endif 272 IF (ierr.NE.NF_NOERR) THEN 273 PRINT*, 'phyetat0: Lecture echouee pour <ZSTD>' 274 CALL abort 275 ENDIF 276 xmin = 1.0E+20 277 xmax = -1.0E+20 278 DO i = 1, ngrid 279 xmin = MIN(zstd(i),xmin) 280 xmax = MAX(zstd(i),xmax) 281 ENDDO 282 PRINT*,'<zstd>:', xmin, xmax 283 c 284 c ZSIG 285 c 286 ierr = NF_INQ_VARID (nid, "ZSIG", nvarid) 287 IF (ierr.NE.NF_NOERR) THEN 288 PRINT*, 'phyetat0: Le champ <ZSIG> est absent' 289 CALL abort 290 ENDIF 291 #ifdef NC_DOUBLE 292 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,zsig) 293 #else 294 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,zsig) 295 #endif 296 IF (ierr.NE.NF_NOERR) THEN 297 PRINT*, 'phyetat0: Lecture echouee pour <ZSIG>' 298 CALL abort 299 ENDIF 300 xmin = 1.0E+20 301 xmax = -1.0E+20 302 DO i = 1, ngrid 303 xmin = MIN(zsig(i),xmin) 304 xmax = MAX(zsig(i),xmax) 305 ENDDO 306 PRINT*,'<zsig>:', xmin, xmax 307 c 308 c ZGAM 309 c 310 ierr = NF_INQ_VARID (nid, "ZGAM", nvarid) 311 IF (ierr.NE.NF_NOERR) THEN 312 PRINT*, 'phyetat0: Le champ <ZGAM> est absent' 313 CALL abort 314 ENDIF 315 #ifdef NC_DOUBLE 316 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,zgam) 317 #else 318 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,zgam) 319 #endif 320 IF (ierr.NE.NF_NOERR) THEN 321 PRINT*, 'phyetat0: Lecture echouee pour <ZGAM>' 322 CALL abort 323 ENDIF 324 xmin = 1.0E+20 325 xmax = -1.0E+20 326 DO i = 1, ngrid 327 xmin = MIN(zgam(i),xmin) 328 xmax = MAX(zgam(i),xmax) 329 ENDDO 330 PRINT*,'<zgam>:', xmin, xmax 331 c 332 c ZTHE 333 c 334 ierr = NF_INQ_VARID (nid, "ZTHE", nvarid) 335 IF (ierr.NE.NF_NOERR) THEN 336 PRINT*, 'phyetat0: Le champ <ZTHE> est absent' 337 CALL abort 338 ENDIF 339 #ifdef NC_DOUBLE 340 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,zthe) 341 #else 342 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,zthe) 343 #endif 344 IF (ierr.NE.NF_NOERR) THEN 345 PRINT*, 'phyetat0: Lecture echouee pour <ZTHE>' 346 CALL abort 347 ENDIF 348 xmin = 1.0E+20 349 xmax = -1.0E+20 350 DO i = 1, ngrid 351 xmin = MIN(zthe(i),xmin) 352 xmax = MAX(zthe(i),xmax) 353 ENDDO 354 PRINT*,'<zthe>:', xmin, xmax 355 c 356 c CO2 ice cover 357 c 358 ! Ehouarn: from now on, there is no "co2ice" standalone field; it is supposed 359 ! to be with stored in qsurf(i_co2_ice) 360 ! ierr = NF_INQ_VARID (nid, "co2ice", nvarid) 361 ! IF (ierr.NE.NF_NOERR) THEN 362 ! PRINT*, 'phyetat0: Le champ <co2ice> est absent' 81 ! real :: toto(ngrid) 82 ! integer :: sta !! subscript in starti where we start to read 83 ! integer, dimension(2) :: sta2d 84 ! integer, dimension(2) :: siz2d 85 86 ! AS: get the cursor that is stored in dimphys.h 87 ! ... this allows to read only a part of startfi horiz grid 88 !sta = cursor 89 90 ! 91 ! ALLOCATE ARRAYS IN surfdat_h 92 ! 93 IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid)) 94 IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid)) 95 IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid)) 96 IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid)) 97 IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid)) 98 IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid)) 99 IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid)) 100 101 ! open physics initial state file: 102 call open_startphy(fichnom) 103 104 105 ! possibility to modify tab_cntrl in tabfi 106 write(*,*) 107 write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0 108 call tabfi (ngrid,nid_start,Lmodif,tab0,day_ini,lmax,p_rad, & 109 p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time) 110 111 !c 112 !c Lecture des latitudes (coordonnees): 113 !c 114 ! ierr = NF_INQ_VARID (nid, "latitude", nvarid) 115 ! IF (ierr.NE.NF_NOERR) THEN 116 ! PRINT*, 'phyetat0: Le champ <latitude> est absent' 363 117 ! CALL abort 364 118 ! ENDIF 365 119 !#ifdef NC_DOUBLE 366 ! ierr = NF_GET_VAR _DOUBLE(nid, nvarid, co2ice)120 ! ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,lati) 367 121 !#else 368 ! ierr = NF_GET_VAR _REAL(nid, nvarid, co2ice)122 ! ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,lati) 369 123 !#endif 370 124 ! IF (ierr.NE.NF_NOERR) THEN 371 ! PRINT*, 'phyetat0: Lecture echouee pour <co2ice>' 125 ! PRINT*, 'phyetat0: Lecture echouee pour <latitude>' 126 ! CALL abort 127 ! ENDIF 128 !c 129 !c Lecture des longitudes (coordonnees): 130 !c 131 ! ierr = NF_INQ_VARID (nid, "longitude", nvarid) 132 ! IF (ierr.NE.NF_NOERR) THEN 133 ! PRINT*, 'phyetat0: Le champ <longitude> est absent' 134 ! CALL abort 135 ! ENDIF 136 !#ifdef NC_DOUBLE 137 ! ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,long) 138 !#else 139 ! ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,long) 140 !#endif 141 ! IF (ierr.NE.NF_NOERR) THEN 142 ! PRINT*, 'phyetat0: Lecture echouee pour <longitude>' 143 ! CALL abort 144 ! ENDIF 145 !c 146 !c Lecture des aires des mailles: 147 !c 148 ! ierr = NF_INQ_VARID (nid, "area", nvarid) 149 ! IF (ierr.NE.NF_NOERR) THEN 150 ! PRINT*, 'phyetat0: Le champ <area> est absent' 151 ! CALL abort 152 ! ENDIF 153 !#ifdef NC_DOUBLE 154 ! ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,area) 155 !#else 156 ! ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,area) 157 !#endif 158 ! IF (ierr.NE.NF_NOERR) THEN 159 ! PRINT*, 'phyetat0: Lecture echouee pour <area>' 372 160 ! CALL abort 373 161 ! ENDIF 374 162 ! xmin = 1.0E+20 375 163 ! xmax = -1.0E+20 376 ! xmin = MINVAL(co2ice) 377 ! xmax = MAXVAL(co2ice) 378 ! PRINT*,'CO2 ice cover <co2ice>:', xmin, xmax 379 c 380 c Lecture des temperatures du sol: 381 c 382 ierr = NF_INQ_VARID (nid, "tsurf", nvarid) 383 IF (ierr.NE.NF_NOERR) THEN 384 PRINT*, 'phyetat0: Le champ <tsurf> est absent' 385 PRINT*, ' Mais je vais essayer de lire TS**' 386 IF (nbsrf.GT.99) THEN 387 PRINT*, "Trop de sous-mailles" 388 CALL abort 389 ENDIF 390 DO nsrf = 1, nbsrf 391 WRITE(str2,'(i2.2)') nsrf 392 ierr = NF_INQ_VARID (nid, "TS"//str2, nvarid) 393 IF (ierr.NE.NF_NOERR) THEN 394 PRINT*, "phyetat0: Le champ <TS"//str2//"> est absent" 395 CALL abort 396 ENDIF 397 #ifdef NC_DOUBLE 398 ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsurf(1,nsrf)) 399 #else 400 ierr = NF_GET_VAR_REAL(nid, nvarid, tsurf(1,nsrf)) 401 #endif 402 IF (ierr.NE.NF_NOERR) THEN 403 PRINT*, "phyetat0: Lecture echouee pour <TS"//str2//">" 404 CALL abort 405 ENDIF 406 xmin = 1.0E+20 407 xmax = -1.0E+20 408 xmin = MINVAL(tsurf) 409 xmax = MAXVAL(tsurf) 410 PRINT*,'Temperature du sol TS**:', nsrf, xmin, xmax 411 ENDDO 412 ELSE 413 PRINT*, 'phyetat0: Le champ <tsurf> est present' 414 PRINT*, ' J ignore donc les autres temperatures TS**' 415 #ifdef NC_DOUBLE 416 ierr = NF_GET_VARA_DOUBLE(nid, nvarid, sta, ngrid, tsurf) 417 #else 418 ierr = NF_GET_VARA_REAL(nid, nvarid, sta, ngrid, tsurf) 419 #endif 420 IF (ierr.NE.NF_NOERR) THEN 421 PRINT*, "phyetat0: Lecture echouee pour <TSURF>" 422 CALL abort 423 ENDIF 424 xmin = 1.0E+20 425 xmax = -1.0E+20 426 xmin = MINVAL(tsurf) 427 xmax = MAXVAL(tsurf) 428 PRINT*,'Temperature du sol <tsurf>', xmin, xmax 429 IF (nbsrf >= 2) THEN 430 DO nsrf = 2, nbsrf 431 DO i = 1, ngrid 432 tsurf(i,nsrf) = tsurf(i,1) 433 ENDDO 434 ENDDO 435 ENDIF 436 ENDIF 437 c 438 c Lecture des temperatures du sol profond: 439 c 440 ! IF (nsoil.GT.99 .OR. nbsrf.GT.99) THEN 441 ! PRINT*, "Trop de couches ou sous-mailles" 442 ! CALL abort 443 ! ENDIF 444 ! DO nsrf = 1, nbsrf 445 ! DO isoil=1, nsoil 446 ! WRITE(str7,'(i2.2,"srf",i2.2)') isoil, nsrf 447 ! ierr = NF_INQ_VARID (nid, 'tsoil', nvarid) 448 ! IF (ierr.NE.NF_NOERR) THEN 449 ! PRINT*, "phyetat0: Le champ <tsoil> est absent" 450 ! PRINT*, " Il prend donc la valeur de surface" 451 ! DO i=1, ngrid 452 ! tsoil(i,isoil,nsrf)=tsurf(i,nsrf) 453 ! ENDDO 454 ! ELSE 455 !#ifdef NC_DOUBLE 456 ! ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsoil(1,1,nsrf)) 457 !#else 458 ! ierr = NF_GET_VAR_REAL(nid, nvarid, tsoil(1,1,nsrf)) 459 !#endif 460 ! IF (ierr.NE.NF_NOERR) THEN 461 ! PRINT*, "Lecture echouee pour <tsoil>" 462 ! CALL abort 463 ! ENDIF 464 ! ENDIF 465 ! ENDDO 466 ! ENDDO 467 ! xmin = 1.0E+20 468 ! xmax = -1.0E+20 469 ! xmin = MINVAL(tsoil) 470 ! xmax = MAXVAL(tsoil) 471 ! PRINT*,'Temperatures du sol profond <tsoil>', xmin, xmax 472 c 473 c Surface emissivity 474 c 475 ierr = NF_INQ_VARID (nid, "emis", nvarid) 476 IF (ierr.NE.NF_NOERR) THEN 477 PRINT*, 'phyetat0: Le champ <emis> est absent' 478 CALL abort 479 ENDIF 480 #ifdef NC_DOUBLE 481 ierr = NF_GET_VARA_DOUBLE(nid, nvarid, sta,ngrid, emis) 482 #else 483 ierr = NF_GET_VARA_REAL(nid, nvarid,sta,ngrid, emis) 484 #endif 485 IF (ierr.NE.NF_NOERR) THEN 486 PRINT*, 'phyetat0: Lecture echouee pour <emis>' 487 CALL abort 488 ENDIF 489 xmin = 1.0E+20 490 xmax = -1.0E+20 491 xmin = MINVAL(emis) 492 xmax = MAXVAL(emis) 493 PRINT*,'Surface emissivity <emis>:', xmin, xmax 494 495 c 496 c Cloud fraction (added by BC 2010) 497 c 498 ierr = NF_INQ_VARID (nid, "cloudfrac", nvarid) 499 IF (ierr.NE.NF_NOERR) THEN 500 PRINT*, 'phyetat0: Le champ <cloudfrac> est absent' 501 cloudfrac(:,:)=0.5 502 ! CALL abort 503 ENDIF 504 sta2d = (/sta,1/) 505 siz2d = (/ngrid, nlayermx/) 506 #ifdef NC_DOUBLE 507 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,cloudfrac) 508 #else 509 ierr = NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,cloudfrac) 510 #endif 511 IF (ierr.NE.NF_NOERR) THEN 512 PRINT*, 'phyetat0: Lecture echouee pour <cloudfrac>' 513 CALL abort 514 ENDIF 515 xmin = 1.0E+20 516 xmax = -1.0E+20 517 xmin = MINVAL(cloudfrac) 518 xmax = MAXVAL(cloudfrac) 519 PRINT*,'Cloud fraction <cloudfrac>:', xmin, xmax 520 521 522 c 523 c Total cloud fraction (added by BC 2010) 524 c 525 ierr = NF_INQ_VARID (nid, "totcloudfrac", nvarid) 526 ! ierr = NF_INQ_VARID (nid, "totalfrac", nvarid) 527 IF (ierr.NE.NF_NOERR) THEN 528 PRINT*, 'phyetat0: Le champ <totcloudfrac> est absent' 529 totcloudfrac(:)=0.5 530 ! CALL abort 531 ENDIF 532 #ifdef NC_DOUBLE 533 ierr = NF_GET_VARA_DOUBLE(nid, nvarid,sta,ngrid, totcloudfrac) 534 #else 535 ierr = NF_GET_VARA_REAL(nid, nvarid,sta,ngrid, totcloudfrac) 536 #endif 537 IF (ierr.NE.NF_NOERR) THEN 538 PRINT*, 'phyetat0: Lecture echouee pour <totcloudfrac>' 539 !CALL abort 540 ENDIF 541 xmin = 1.0E+20 542 xmax = -1.0E+20 543 xmin = MINVAL(totcloudfrac) 544 xmax = MAXVAL(totcloudfrac) 545 PRINT*,'Cloud fraction <totcloudfrac>:', xmin, xmax 546 547 548 549 c 550 c Height of oceanic ice (added by BC 2010) 551 c 552 ierr = NF_INQ_VARID (nid, "hice", nvarid) 553 IF (ierr.NE.NF_NOERR) THEN 554 PRINT*, 'phyetat0: Le champ <hice> est absent' 555 CALL abort 556 ENDIF 557 #ifdef NC_DOUBLE 558 ierr = NF_GET_VARA_DOUBLE(nid, nvarid,sta,ngrid, hice) 559 #else 560 ierr = NF_GET_VARA_REAL(nid, nvarid,sta,ngrid, hice) 561 #endif 562 IF (ierr.NE.NF_NOERR) THEN 563 PRINT*, 'phyetat0: Lecture echouee pour <hice>' 564 CALL abort 565 ENDIF 566 xmin = 1.0E+20 567 xmax = -1.0E+20 568 xmin = MINVAL(hice) 569 xmax = MAXVAL(hice) 570 PRINT*,'Height of oceanic ice <hice>:', xmin, xmax 571 572 573 c 574 c pbl wind variance 575 c 576 ierr = NF_INQ_VARID (nid, "q2", nvarid) 577 IF (ierr.NE.NF_NOERR) THEN 578 PRINT*, 'phyetat0: Le champ <q2> est absent' 579 CALL abort 580 ENDIF 581 sta2d = (/sta,1/) 582 siz2d = (/ngrid, llm+1/) 583 #ifdef NC_DOUBLE 584 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,q2) 585 #else 586 ierr = NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,q2) 587 #endif 588 IF (ierr.NE.NF_NOERR) THEN 589 PRINT*, 'phyetat0: Lecture echouee pour <q2>' 590 CALL abort 591 ENDIF 592 xmin = 1.0E+20 593 xmax = -1.0E+20 594 xmin = MINVAL(q2) 595 xmax = MAXVAL(q2) 596 PRINT*,'pbl wind variance <q2>:', xmin, xmax 597 c 598 c tracer on surface 599 c 600 601 IF(nq.GE.1) THEN 602 nqold=nq 603 DO iq=1,nq 604 ! str7(1:5)='qsurf' 605 ! WRITE(str7(6:7),'(i2.2)') iq 606 ! ierr = NF_INQ_VARID (nid,str7,nvarid) 607 IF (oldtracernames) THEN 608 txt=" " 609 write(txt,'(a5,i2.2)')'qsurf',iq 610 ELSE 611 txt=noms(iq) 612 ! if (txt.eq."h2o_vap") then 613 ! There is no surface tracer for h2o_vap; 614 ! "h2o_ice" should be loaded instead 615 ! txt="h2o_ice" 616 ! write(*,*) 'phyetat0: loading surface tracer', 617 ! & ' h2o_ice instead of h2o_vap' 618 ! endif 619 ENDIF ! of IF (oldtracernames) THEN 620 ierr=NF_INQ_VARID(nid,txt,nvarid) 621 IF (ierr.NE.NF_NOERR) THEN 622 write(*,*) 'PHYETAT0: WARNING : surface tracer',trim(txt), 623 & ' not found in file' 624 write(*,*) trim(txt), ' set to 0' 625 do ig=1,ngrid 626 qsurf(ig,iq)=0. 627 end do 628 nqold=min(iq-1,nqold) 629 ELSE 630 toto(:) = 0. 631 #ifdef NC_DOUBLE 632 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,toto) 633 #else 634 ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,toto) 635 #endif 636 IF (ierr.NE.NF_NOERR) THEN 637 PRINT*, 'phyetat0: Lecture echouee pour <',trim(txt),'>' 638 CALL abort 639 ENDIF 640 qsurf(1:ngrid,iq) = toto(1:ngrid) 641 ENDIF 642 xmin = 1.0E+20 643 xmax = -1.0E+20 644 xmin = MINVAL(qsurf(1:ngrid,iq)) 645 xmax = MAXVAL(qsurf(1:ngrid,iq)) 646 PRINT*,'tracer on surface <',trim(txt),'>:',xmin,xmax 647 ENDDO 648 if ((nqold.lt.nq).and.(nqold.ge.1)) then 649 c case when new tracer are added in addition to old ones 650 write(*,*)'qsurf 1 to ', nqold,'were already present' 651 write(*,*)'qsurf ', nqold+1,' to ', nq,'are new' 652 write(*,*)' and initialized to zero' 653 qsurf(:,nqold+1:nq)=0.0 654 ! yes=' ' 655 ! do while ((yes.ne.'y').and.(yes.ne.'n')) 656 ! write(*,*) 'Would you like to reindex qsurf # 1 ->',nqold 657 ! write(*,*) 'to #',nq-nqold+1,'->', nq,' (y or n) ?' 658 ! read(*,fmt='(a)') yes 659 ! end do 660 ! if (yes.eq.'y') then 661 ! write(*,*) 'OK, let s reindex qsurf' 662 ! do ig=1,ngrid 663 ! do iq=nq,nq-nqold+1,-1 664 ! qsurf(ig,iq)=qsurf(ig,iq-nq+nqold) 665 ! end do 666 ! do iq=nq-nqold,1,-1 667 ! qsurf(ig,iq)= 0. 668 ! end do 669 ! end do 670 ! end if 671 end if ! of if ((nqold.lt.nq).and.(nqold.ge.1)) 672 ENDIF ! of IF(nq.GE.1) 164 ! xmin = MINVAL(area) 165 ! xmax = MAXVAL(area) 166 ! PRINT*,'Aires des mailles <area>:', xmin, xmax 167 168 ! Load surface geopotential: 169 call get_field("phisfi",phisfi,found) 170 if (.not.found) then 171 write(*,*) "phyetat0: Failed loading <phisfi>" 172 call abort 173 else 174 write(*,*) "phyetat0: surface geopotential <phisfi> range:", & 175 minval(phisfi), maxval(phisfi) 176 endif 177 178 ! Load bare ground albedo: 179 call get_field("albedodat",albedodat,found) 180 if (.not.found) then 181 write(*,*) "phyetat0: Failed loading <albedodat>" 182 call abort 183 else 184 write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", & 185 minval(albedodat), maxval(albedodat) 186 endif 187 188 ! ZMEA 189 call get_field("ZMEA",zmea,found) 190 if (.not.found) then 191 write(*,*) "phyetat0: Failed loading <ZMEA>" 192 call abort 193 else 194 write(*,*) "phyetat0: <ZMEA> range:", & 195 minval(zmea), maxval(zmea) 196 endif 197 198 ! ZSTD 199 call get_field("ZSTD",zstd,found) 200 if (.not.found) then 201 write(*,*) "phyetat0: Failed loading <ZSTD>" 202 call abort 203 else 204 write(*,*) "phyetat0: <ZSTD> range:", & 205 minval(zstd), maxval(zstd) 206 endif 207 208 ! ZSIG 209 call get_field("ZSIG",zsig,found) 210 if (.not.found) then 211 write(*,*) "phyetat0: Failed loading <ZSIG>" 212 call abort 213 else 214 write(*,*) "phyetat0: <ZSIG> range:", & 215 minval(zsig), maxval(zsig) 216 endif 217 218 ! ZGAM 219 call get_field("ZGAM",zgam,found) 220 if (.not.found) then 221 write(*,*) "phyetat0: Failed loading <ZGAM>" 222 call abort 223 else 224 write(*,*) "phyetat0: <ZGAM> range:", & 225 minval(zgam), maxval(zgam) 226 endif 227 228 ! ZTHE 229 call get_field("ZTHE",zthe,found) 230 if (.not.found) then 231 write(*,*) "phyetat0: Failed loading <ZTHE>" 232 call abort 233 else 234 write(*,*) "phyetat0: <ZTHE> range:", & 235 minval(zthe), maxval(zthe) 236 endif 237 238 ! Surface temperature : 239 call get_field("tsurf",tsurf,found,indextime) 240 if (.not.found) then 241 write(*,*) "phyetat0: Failed loading <tsurf>" 242 call abort 243 else 244 write(*,*) "phyetat0: Surface temperature <tsurf> range:", & 245 minval(tsurf), maxval(tsurf) 246 endif 247 248 ! Surface emissivity 249 call get_field("emis",emis,found,indextime) 250 if (.not.found) then 251 write(*,*) "phyetat0: Failed loading <emis>" 252 call abort 253 else 254 write(*,*) "phyetat0: Surface emissivity <emis> range:", & 255 minval(emis), maxval(emis) 256 endif 257 258 ! Cloud fraction (added by BC 2010) 259 call get_field("cloudfrac",cloudfrac,found,indextime) 260 if (.not.found) then 261 write(*,*) "phyetat0: Failed loading <cloudfrac>" 262 call abort 263 else 264 write(*,*) "phyetat0: Cloud fraction <cloudfrac> range:", & 265 minval(cloudfrac), maxval(cloudfrac) 266 endif 267 268 ! Total cloud fraction (added by BC 2010) 269 call get_field("totcloudfrac",totcloudfrac,found,indextime) 270 if (.not.found) then 271 write(*,*) "phyetat0: Failed loading <totcloudfrac>" 272 call abort 273 else 274 write(*,*) "phyetat0: Total cloud fraction <totcloudfrac> range:", & 275 minval(totcloudfrac), maxval(totcloudfrac) 276 endif 277 278 ! Height of oceanic ice (added by BC 2010) 279 call get_field("hice",hice,found,indextime) 280 if (.not.found) then 281 write(*,*) "phyetat0: Failed loading <hice>" 282 call abort 283 else 284 write(*,*) "phyetat0: Height of oceanic ice <hice> range:", & 285 minval(hice), maxval(hice) 286 endif 287 288 ! pbl wind variance 289 call get_field("q2",q2,found,indextime) 290 if (.not.found) then 291 write(*,*) "phyetat0: Failed loading <q2>" 292 call abort 293 else 294 write(*,*) "phyetat0: PBL wind variance <q2> range:", & 295 minval(q2), maxval(q2) 296 endif 297 298 ! tracer on surface 299 if (nq.ge.1) then 300 do iq=1,nq 301 txt=tname(iq) 302 if (txt.eq."h2o_vap") then 303 ! There is no surface tracer for h2o_vap; 304 ! "h2o_ice" should be loaded instead 305 txt="h2o_ice" 306 write(*,*) 'phyetat0: loading surface tracer', & 307 ' h2o_ice instead of h2o_vap' 308 endif 309 call get_field(txt,qsurf(:,iq),found,indextime) 310 if (.not.found) then 311 write(*,*) "phyetat0: Failed loading <",trim(txt),">" 312 write(*,*) " ",trim(txt)," is set to zero" 313 else 314 write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", & 315 minval(qsurf(:,iq)), maxval(qsurf(:,iq)) 316 endif 317 enddo 318 endif ! of if (nq.ge.1) 673 319 674 320 ! Call to soil_settings, in order to read soil temperatures, 675 321 ! as well as thermal inertia and volumetric heat capacity 676 322 677 PRINT*,'SOIL INIT' 678 call soil_settings(nid,ngrid,nsoil,tsurf,tsoil) 679 c 680 c Fermer le fichier: 681 c 682 ierr = NF_CLOSE(nid) 683 c 684 685 RETURN 686 END 323 call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime) 324 325 ! 326 ! close file: 327 ! 328 call close_startphy 329 330 END SUBROUTINE phyetat0 -
trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90
r1214 r1216 1 subroutine physdem1(ngrid,filename,lonfi,latfi,nsoil,nq, 2 . phystep,day_ini, 3 . time,tsurf,tsoil,emis,q2,qsurf, 4 . airefi,alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe, 5 . cloudfrac,totcloudfrac,hice,nametrac) 6 7 use surfdat_h 8 use comsoil_h 9 USE comgeomfi_h 10 11 implicit none 12 13 !================================================================== 14 ! 15 ! Purpose 16 ! ------- 17 ! Create physics (re-)start data file "restartfi.nc" 18 ! 19 ! Called by 20 ! --------- 21 ! rcm1d.F90 22 ! physiq.F90 23 ! newstart.F 24 ! 25 ! Calls 26 ! ----- 27 ! none 28 ! 29 !================================================================== 30 31 #include "dimensions.h" 32 #include "paramet.h" 33 #include "comvert.h" 34 #include "comgeom2.h" 35 #include "control.h" 36 #include "comdissnew.h" 37 #include "logic.h" 38 #include "ener.h" 39 #include "netcdf.inc" 40 #include "dimphys.h" 41 #include"callkeys.h" 42 43 INTEGER :: ngrid 44 45 INTEGER nid,iq 46 INTEGER, parameter :: ivap=1 47 REAL, parameter :: qsolmax= 150.0 48 character (len=*) :: filename 49 character (len=7) :: str7 50 51 REAL day_ini 52 INTEGER nsoil,nq 53 integer ierr,idim1,idim2,idim3,idim4,idim5,idim6,nvarid 54 55 REAL phystep,time 56 REAL latfi(ngrid), lonfi(ngrid) 57 ! REAL champhys(ngrid) 58 REAL tsurf(ngrid) 59 INTEGER length 60 PARAMETER (length=100) 61 REAL tab_cntrl(length) 62 63 ! added by BC 64 REAL hice(ngrid),cloudfrac(ngrid,nlayermx) 65 REAL totcloudfrac(ngrid) 66 67 ! AS: name of tracers added as an argument to avoid using nqmx in commons (i.e. adv trac) 68 ! nota: physdem1 is used both in physiq and newstart. 69 character*20 nametrac(nq) ! name of the tracer 70 71 72 ! EXTERNAL defrun_new,iniconst,geopot,inigeom,massdair,pression 73 ! EXTERNAL exner_hyb , SSUM 74 75 #include "serre.h" 76 #include "fxyprim.h" 1 module phyredem 2 3 implicit none 4 5 contains 6 7 subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, & 8 phystep,day_ini,time,airefi, & 9 alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe) 10 ! create physics restart file and write time-independent variables 11 use comsoil_h, only: inertiedat, volcapa, mlayer 12 use comgeomfi_h, only: area 13 use surfdat_h, only: albedodat, zmea, zstd, zsig, zgam, zthe, & 14 albedice, emisice, emissiv, & 15 iceradius, dtemisice, phisfi 16 use iostart, only : open_restartphy, close_restartphy, & 17 put_var, put_field, length 18 use mod_grid_phy_lmdz, only : klon_glo 19 20 implicit none 77 21 #include "planete.h" 78 22 #include "comcstfi.h" 79 80 real tsoil(ngrid,nsoil),emis(ngrid) 81 real q2(ngrid, llm+1),qsurf(ngrid,nq) 82 real airefi(ngrid) 83 real alb(ngrid),ith(ngrid,nsoil) 84 real pzmea(ngrid),pzstd(ngrid) 85 real pzsig(ngrid),pzgam(ngrid),pzthe(ngrid) 86 integer ig 87 88 ! flag which identifies if we are using old tracer names (qsurf01,...) 89 logical :: oldtracernames=.false. 90 integer :: count 91 character(len=30) :: txt ! to store some text 92 ! indexes of water vapour & water ice tracers (if any): 93 integer :: i_h2o_vap=0 94 integer :: i_h2o_ice=0 95 c----------------------------------------------------------------------- 96 97 ! copy airefi(:) to area(:) 98 CALL SCOPY(ngrid,airefi,1,area,1) 99 ! note: area() is defined in comgeomfi.h 100 101 DO ig=1,ngrid 102 albedodat(ig)=alb(ig) ! note: albedodat() is defined in surfdat.h 103 zmea(ig)=pzmea(ig) ! note: zmea() is defined in surfdat.h 104 zstd(ig)=pzstd(ig) ! note: zstd() is defined in surfdat.h 105 zsig(ig)=pzsig(ig) ! note: zsig() is defined in surfdat.h 106 zgam(ig)=pzgam(ig) ! note: zgam() is defined in surfdat.h 107 zthe(ig)=pzthe(ig) ! note: zthe() is defined in surfdat.h 108 ENDDO 109 110 inertiedat(:,:)=ith(:,:) ! note inertiedat() is defined in comsoil.h 111 c 112 c things to store in the physics start file: 113 c 114 ierr = NF_CREATE(adjustl(filename),NF_CLOBBER, nid) 115 IF (ierr.NE.NF_NOERR) THEN 116 WRITE(6,*)'physdem1: Problem creating file ',adjustl(filename) 117 write(6,*) NF_STRERROR(ierr) 118 CALL ABORT 119 ENDIF 120 c 121 print*,'we got this far' 122 123 ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 18, 124 . "Physics start file") 125 c 126 ierr = NF_DEF_DIM (nid,"index",length,idim1) 127 if (ierr.ne.NF_NOERR) then 128 WRITE(6,*)'physdem1: Problem defining index dimension' 129 write(6,*) NF_STRERROR(ierr) 130 call abort 131 endif 132 c 133 ierr = NF_DEF_DIM (nid,"physical_points",ngrid,idim2) 134 if (ierr.ne.NF_NOERR) then 135 WRITE(6,*)'physdem1: Problem defining physical_points dimension' 136 write(6,*) NF_STRERROR(ierr) 137 call abort 138 endif 139 c 140 ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoil,idim3) 141 if (ierr.ne.NF_NOERR) then 142 WRITE(6,*)'physdem1: Problem defining subsurface_layers dimension' 143 write(6,*) NF_STRERROR(ierr) 144 call abort 145 endif 146 c 147 ierr = NF_DEF_DIM (nid,"nlayer_plus_1",llm+1,idim4) 148 if (ierr.ne.NF_NOERR) then 149 WRITE(6,*)'physdem1: Problem defining nlayer+1 dimension' 150 write(6,*) NF_STRERROR(ierr) 151 call abort 152 endif 153 c 154 ierr = NF_DEF_DIM (nid,"number_of_advected_fields",nq,idim5) 155 if (ierr.ne.NF_NOERR) then 156 WRITE(6,*)'physdem1: Problem defining advected fields dimension' 157 WRITE(6,*)' nq = ',nq,' and ierr = ', ierr 158 write(6,*) NF_STRERROR(ierr) 159 endif 160 161 ierr = NF_DEF_DIM (nid,"nlayer",llm,idim6) 162 if (ierr.ne.NF_NOERR) then 163 WRITE(6,*)'physdem1: Problem defining nlayer dimension' 164 write(6,*) NF_STRERROR(ierr) 165 call abort 166 endif 167 168 ierr = NF_ENDDEF(nid) ! exit NetCDF define mode 169 170 c clear tab_cntrl(:) array 171 DO ierr = 1, length 172 tab_cntrl(ierr) = 0.0 173 ENDDO 174 175 write(*,*) "physdem1: ngrid: ",ngrid 176 177 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 178 c Fill control array tab_cntrl(:) with paramleters for this run 179 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 180 c Informations on the physics grid 181 tab_cntrl(1) = float(ngrid) ! number of nodes on physics grid 182 tab_cntrl(2) = float(nlayermx) ! number of atmospheric layers 183 tab_cntrl(3) = day_ini + int(time) ! initial day 184 tab_cntrl(4) = time -int(time) ! initiale time of day 185 186 c Informations about Mars, used by dynamics and physics 187 tab_cntrl(5) = rad ! radius of Mars (m) ~3397200 188 tab_cntrl(6) = omeg ! rotation rate (rad.s-1) 189 tab_cntrl(7) = g ! gravity (m.s-2) ~3.72 190 tab_cntrl(8) = mugaz ! Molar mass of the atmosphere (g.mol-1) ~43.49 191 tab_cntrl(9) = rcp ! = r/cp ~0.256793 (=kappa dans dynamique) 192 tab_cntrl(10) = daysec ! length of a sol (s) ~88775 193 194 tab_cntrl(11) = phystep ! time step in the physics 195 tab_cntrl(12) = 0. 196 tab_cntrl(13) = 0. 197 198 c Informations about Mars, only for physics 199 tab_cntrl(14) = year_day ! length of year (sols) ~668.6 200 tab_cntrl(15) = periastr ! min. star-planet distance (AU) 201 tab_cntrl(16) = apoastr ! max. star-planet distance (AU) 202 tab_cntrl(17) = peri_day ! date of periastron (sols since N. spring) 203 tab_cntrl(18) = obliquit ! Obliquity of the planet (deg) ~23.98 204 205 c Boundary layer and turbulence 206 tab_cntrl(19) = z0 ! surface roughness (m) ~0.01 207 tab_cntrl(20) = lmixmin ! mixing length ~100 208 tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8 209 210 c Optical properties of polar caps and ground emissivity 211 tab_cntrl(22) = albedice(1) ! Albedo of northern cap ~0.5 212 tab_cntrl(23) = albedice(2) ! Albedo of southern cap ~0.5 213 tab_cntrl(24) = emisice(1) ! Emissivity of northern cap ~0.95 214 tab_cntrl(25) = emisice(2) ! Emissivity of southern cap ~0.95 215 tab_cntrl(26) = emissiv ! Emissivity of martian soil ~.95 216 tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north) 217 tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south) 218 tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north) 219 tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south) 220 221 tab_cntrl(28) = 0. 222 tab_cntrl(29) = 0. 223 tab_cntrl(30) = 0. 23 character(len=*), intent(in) :: filename 24 real,intent(in) :: lonfi(ngrid) 25 real,intent(in) :: latfi(ngrid) 26 integer,intent(in) :: nsoil 27 integer,intent(in) :: ngrid 28 integer,intent(in) :: nlay 29 integer,intent(in) :: nq 30 real,intent(in) :: phystep 31 real,intent(in) :: day_ini 32 real,intent(in) :: time 33 real,intent(in) :: airefi(ngrid) 34 real,intent(in) :: alb(ngrid) 35 real,intent(in) :: ith(ngrid,nsoil) 36 real,intent(in) :: pzmea(ngrid) 37 real,intent(in) :: pzstd(ngrid) 38 real,intent(in) :: pzsig(ngrid) 39 real,intent(in) :: pzgam(ngrid) 40 real,intent(in) :: pzthe(ngrid) 41 42 real :: tab_cntrl(length) ! nb "length=100" defined in iostart module 43 44 ! Create physics start file 45 call open_restartphy(filename) 46 47 ! tab_cntrl() contains run parameters 48 tab_cntrl(:)=0 ! initialization 49 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 50 ! Fill control array tab_cntrl(:) with paramleters for this run 51 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 52 ! Informations on the physics grid 53 tab_cntrl(1) = float(klon_glo) ! number of nodes on physics grid 54 tab_cntrl(2) = float(nlay) ! number of atmospheric layers 55 tab_cntrl(3) = day_ini + int(time) ! final day 56 tab_cntrl(4) = time -int(time) ! final time of day 57 58 ! Informations about Mars, used by dynamics and physics 59 tab_cntrl(5) = rad ! radius of Mars (m) ~3397200 60 tab_cntrl(6) = omeg ! rotation rate (rad.s-1) 61 tab_cntrl(7) = g ! gravity (m.s-2) ~3.72 62 tab_cntrl(8) = mugaz ! Molar mass of the atmosphere (g.mol-1) ~43.49 63 tab_cntrl(9) = rcp ! = r/cp ~0.256793 (=kappa dans dynamique) 64 tab_cntrl(10) = daysec ! length of a sol (s) ~88775 65 66 tab_cntrl(11) = phystep ! time step in the physics 67 tab_cntrl(12) = 0. 68 tab_cntrl(13) = 0. 69 70 ! Informations about Mars, only for physics 71 tab_cntrl(14) = year_day ! length of year (sols) ~668.6 72 tab_cntrl(15) = periastr ! min. star-planet distance (AU) 73 tab_cntrl(16) = apoastr ! max. star-planet distance (AU) 74 tab_cntrl(17) = peri_day ! date of periastron (sols since N. spring) 75 tab_cntrl(18) = obliquit ! Obliquity of the planet (deg) ~23.98 76 77 ! Boundary layer and turbulence 78 tab_cntrl(19) = z0 ! surface roughness (m) ~0.01 79 tab_cntrl(20) = lmixmin ! mixing length ~100 80 tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8 81 82 ! Optical properties of polar caps and ground emissivity 83 tab_cntrl(22) = albedice(1) ! Albedo of northern cap ~0.5 84 tab_cntrl(23) = albedice(2) ! Albedo of southern cap ~0.5 85 tab_cntrl(24) = emisice(1) ! Emissivity of northern cap ~0.95 86 tab_cntrl(25) = emisice(2) ! Emissivity of southern cap ~0.95 87 tab_cntrl(26) = emissiv ! Emissivity of martian soil ~.95 88 tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north) 89 tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south) 90 tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north) 91 tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south) 92 93 tab_cntrl(28) = 0. 94 tab_cntrl(29) = 0. 95 tab_cntrl(30) = 0. 224 96 225 97 ! Soil properties: 226 tab_cntrl(35) = volcapa ! soil volumetric heat capacity 227 228 229 ! write(*,*) "physdem1: tab_cntrl():",tab_cntrl 230 231 ierr = NF_REDEF (nid) ! Enter NetCDF (re-)define mode 232 IF (ierr.NE.NF_NOERR) THEN 233 PRINT*, 'physdem1: Failed to swich to NetCDF define mode' 234 CALL abort 235 ENDIF 236 ! define variable 237 #ifdef NC_DOUBLE 238 ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, idim1,nvarid) 239 #else 240 ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, idim1,nvarid) 241 #endif 242 IF (ierr.NE.NF_NOERR) THEN 243 PRINT*, 'physdem1: Failed to define controle' 244 CALL abort 245 ENDIF 246 ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18, 247 . "Control parameters") 248 IF (ierr.NE.NF_NOERR) THEN 249 PRINT*, 'physdem1: Failed to define controle title attribute' 250 CALL abort 251 ENDIF 252 ierr = NF_ENDDEF(nid) ! Leave NetCDF define mode 253 IF (ierr.NE.NF_NOERR) THEN 254 PRINT*, 'physdem1: Failed to swich out of NetCDF define mode' 255 CALL abort 256 ENDIF 257 ! write variable 258 #ifdef NC_DOUBLE 259 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl) 260 #else 261 ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl) 262 #endif 263 IF (ierr.NE.NF_NOERR) THEN 264 PRINT*, 'physdem1: Failed to write controle data' 265 CALL abort 266 ENDIF 267 268 ! write mid-layer depths mlayer() !known from comsoil.h 269 270 ierr = NF_REDEF (nid) ! Enter NetCDF (re-)define mode 271 ! define variable 272 #ifdef NC_DOUBLE 273 ierr = NF_DEF_VAR (nid,"soildepth",NF_DOUBLE,1,idim3,nvarid) 274 #else 275 ierr = NF_DEF_VAR (nid,"soildepth",NF_FLOAT,1,idim3,nvarid) 276 #endif 277 ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20, 278 . "Soil mid-layer depth") 279 ierr = NF_ENDDEF(nid) ! Leave NetCDF define mode 280 ! write variable 281 #ifdef NC_DOUBLE 282 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer) 283 #else 284 ierr = NF_PUT_VAR_REAL (nid,nvarid,mlayer) 285 #endif 286 287 c 288 289 ierr = NF_REDEF (nid) 290 #ifdef NC_DOUBLE 291 ierr = NF_DEF_VAR (nid, "longitude", NF_DOUBLE, 1, idim2,nvarid) 292 #else 293 ierr = NF_DEF_VAR (nid, "longitude", NF_FLOAT, 1, idim2,nvarid) 294 #endif 295 ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 26, 296 . "Longitudes of physics grid") 297 ierr = NF_ENDDEF(nid) 298 299 #ifdef NC_DOUBLE 300 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lonfi) 301 #else 302 ierr = NF_PUT_VAR_REAL (nid,nvarid,lonfi) 303 #endif 304 305 c 306 307 ierr = NF_REDEF (nid) 308 #ifdef NC_DOUBLE 309 ierr = NF_DEF_VAR (nid, "latitude", NF_DOUBLE, 1, idim2,nvarid) 310 #else 311 ierr = NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim2,nvarid) 312 #endif 313 ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 25, 314 . "Latitudes of physics grid") 315 ierr = NF_ENDDEF(nid) 316 #ifdef NC_DOUBLE 317 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,latfi) 318 #else 319 ierr = NF_PUT_VAR_REAL (nid,nvarid,latfi) 320 #endif 321 322 c 323 324 ierr = NF_REDEF (nid) 325 #ifdef NC_DOUBLE 326 ierr = NF_DEF_VAR (nid, "area", NF_DOUBLE, 1, idim2,nvarid) 327 #else 328 ierr = NF_DEF_VAR (nid, "area", NF_FLOAT, 1, idim2,nvarid) 329 #endif 330 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, 331 . "Mesh area") 332 ierr = NF_ENDDEF(nid) 333 #ifdef NC_DOUBLE 334 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area) 335 #else 336 ierr = NF_PUT_VAR_REAL (nid,nvarid,area) 337 #endif 338 339 c 340 341 ierr = NF_REDEF (nid) 342 #ifdef NC_DOUBLE 343 ierr = NF_DEF_VAR (nid, "phisfi", NF_DOUBLE, 1, idim2,nvarid) 344 #else 345 ierr = NF_DEF_VAR (nid, "phisfi", NF_FLOAT, 1, idim2,nvarid) 346 #endif 347 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27, 348 . "Geopotential at the surface") 349 ierr = NF_ENDDEF(nid) 350 #ifdef NC_DOUBLE 351 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phisfi) 352 #else 353 ierr = NF_PUT_VAR_REAL (nid,nvarid,phisfi) 354 #endif 355 356 c 357 358 ierr = NF_REDEF (nid) 359 #ifdef NC_DOUBLE 360 ierr = NF_DEF_VAR (nid, "albedodat", NF_DOUBLE, 1, idim2,nvarid) 361 #else 362 ierr = NF_DEF_VAR (nid, "albedodat", NF_FLOAT, 1, idim2,nvarid) 363 #endif 364 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 21, 365 . "Albedo of bare ground") 366 ierr = NF_ENDDEF(nid) 367 #ifdef NC_DOUBLE 368 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,albedodat) 369 #else 370 ierr = NF_PUT_VAR_REAL (nid,nvarid,albedodat) 371 #endif 372 373 c 374 c some data for Francois Lott's programs 375 c 376 377 ierr = NF_REDEF (nid) 378 #ifdef NC_DOUBLE 379 ierr = NF_DEF_VAR (nid, "ZMEA", NF_DOUBLE, 1, idim2,nvarid) 380 #else 381 ierr = NF_DEF_VAR (nid, "ZMEA", NF_FLOAT, 1, idim2,nvarid) 382 #endif 383 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, 384 . "Relief: mean relief") 385 ierr = NF_ENDDEF(nid) 386 #ifdef NC_DOUBLE 387 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zmea) 388 #else 389 ierr = NF_PUT_VAR_REAL (nid,nvarid,zmea) 390 #endif 391 c 392 ierr = NF_REDEF (nid) 393 #ifdef NC_DOUBLE 394 ierr = NF_DEF_VAR (nid, "ZSTD", NF_DOUBLE, 1, idim2,nvarid) 395 #else 396 ierr = NF_DEF_VAR (nid, "ZSTD", NF_FLOAT, 1, idim2,nvarid) 397 #endif 398 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26, 399 . "Relief: standard deviation") 400 ierr = NF_ENDDEF(nid) 401 #ifdef NC_DOUBLE 402 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zstd) 403 #else 404 ierr = NF_PUT_VAR_REAL (nid,nvarid,zstd) 405 #endif 406 c 407 ierr = NF_REDEF (nid) 408 #ifdef NC_DOUBLE 409 ierr = NF_DEF_VAR (nid, "ZSIG", NF_DOUBLE, 1, idim2,nvarid) 410 #else 411 ierr = NF_DEF_VAR (nid, "ZSIG", NF_FLOAT, 1, idim2,nvarid) 412 #endif 413 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, 414 . "Relief: sigma parameter") 415 ierr = NF_ENDDEF(nid) 416 #ifdef NC_DOUBLE 417 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zsig) 418 #else 419 ierr = NF_PUT_VAR_REAL (nid,nvarid,zsig) 420 #endif 421 c 422 ierr = NF_REDEF (nid) 423 #ifdef NC_DOUBLE 424 ierr = NF_DEF_VAR (nid, "ZGAM", NF_DOUBLE, 1, idim2,nvarid) 425 #else 426 ierr = NF_DEF_VAR (nid, "ZGAM", NF_FLOAT, 1, idim2,nvarid) 427 #endif 428 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, 429 . "Relief: gamma parameter") 430 ierr = NF_ENDDEF(nid) 431 #ifdef NC_DOUBLE 432 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zgam) 433 #else 434 ierr = NF_PUT_VAR_REAL (nid,nvarid,zgam) 435 #endif 436 c 437 ierr = NF_REDEF (nid) 438 #ifdef NC_DOUBLE 439 ierr = NF_DEF_VAR (nid, "ZTHE", NF_DOUBLE, 1, idim2,nvarid) 440 #else 441 ierr = NF_DEF_VAR (nid, "ZTHE", NF_FLOAT, 1, idim2,nvarid) 442 #endif 443 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, 444 . "Relief: theta parameter") 445 ierr = NF_ENDDEF(nid) 446 #ifdef NC_DOUBLE 447 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zthe) 448 #else 449 ierr = NF_PUT_VAR_REAL (nid,nvarid,zthe) 450 #endif 451 452 c Write the physical fields 453 454 455 ! Soil Thermal inertia 456 457 ierr = NF_REDEF (nid) 458 #ifdef NC_DOUBLE 459 ierr = NF_DEF_VAR (nid,"inertiedat",NF_DOUBLE, 460 & 2,(/idim2,idim3/),nvarid) 461 #else 462 ierr = NF_DEF_VAR (nid,"inertiedat",NF_FLOAT, 463 & 2,(/idim2,idim3/),nvarid) 464 #endif 465 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 20, 466 . "Soil thermal inertia") 467 ierr = NF_ENDDEF(nid) 468 #ifdef NC_DOUBLE 469 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,inertiedat) 470 #else 471 ierr = NF_PUT_VAR_REAL (nid,nvarid,inertiedat) 472 #endif 473 474 475 476 477 ! Surface temperature 478 479 ierr = NF_REDEF (nid) 480 #ifdef NC_DOUBLE 481 ierr = NF_DEF_VAR (nid, "tsurf", NF_DOUBLE, 1, idim2,nvarid) 482 #else 483 ierr = NF_DEF_VAR (nid, "tsurf", NF_FLOAT, 1, idim2,nvarid) 484 #endif 485 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, 486 . "Surface temperature") 487 ierr = NF_ENDDEF(nid) 488 #ifdef NC_DOUBLE 489 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsurf) 490 #else 491 ierr = NF_PUT_VAR_REAL (nid,nvarid,tsurf) 492 #endif 493 494 ! Soil temperature 495 496 ierr = NF_REDEF (nid) 497 #ifdef NC_DOUBLE 498 ierr = NF_DEF_VAR (nid,"tsoil",NF_DOUBLE,2,(/idim2,idim3/),nvarid) 499 #else 500 ! ierr = NF_DEF_VAR (nid, "tsoil", NF_FLOAT, 2, idim2,nvarid) 501 ierr = NF_DEF_VAR (nid,"tsoil",NF_FLOAT,2,(/idim2,idim3/),nvarid) 502 #endif 503 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 16, 504 . "Soil temperature") 505 ierr = NF_ENDDEF(nid) 506 #ifdef NC_DOUBLE 507 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsoil) 508 #else 509 ierr = NF_PUT_VAR_REAL (nid,nvarid,tsoil) 510 #endif 511 512 c emissivity 513 514 ierr = NF_REDEF (nid) 515 #ifdef NC_DOUBLE 516 ierr = NF_DEF_VAR (nid, "emis", NF_DOUBLE, 1, idim2,nvarid) 517 #else 518 ierr = NF_DEF_VAR (nid, "emis", NF_FLOAT, 1, idim2,nvarid) 519 #endif 520 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 18, 521 . "Surface emissivity") 522 ierr = NF_ENDDEF(nid) 523 #ifdef NC_DOUBLE 524 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,emis) 525 #else 526 ierr = NF_PUT_VAR_REAL (nid,nvarid,emis) 527 #endif 528 529 c planetary boundary layer 530 531 ierr = NF_REDEF (nid) 532 #ifdef NC_DOUBLE 533 ierr = NF_DEF_VAR (nid,"q2", NF_DOUBLE, 2, (/idim2,idim4/),nvarid) 534 #else 535 ierr = NF_DEF_VAR (nid, "q2", NF_FLOAT, 2,(/idim2,idim4/),nvarid) 536 #endif 537 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 17, 538 . "pbl wind variance") 539 ierr = NF_ENDDEF(nid) 540 #ifdef NC_DOUBLE 541 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q2) 542 #else 543 ierr = NF_PUT_VAR_REAL (nid,nvarid,q2) 544 #endif 545 IF (ierr.NE.NF_NOERR) THEN 546 PRINT*, 'physdem1: Failed to write q2' 547 CALL abort 548 ENDIF 549 550 551 552 553 554 555 556 c cloud fraction (added by BC 2010) 557 558 ierr = NF_REDEF (nid) 559 #ifdef NC_DOUBLE 560 ierr = NF_DEF_VAR (nid, "cloudfrac", NF_DOUBLE, 2, 561 & (/idim2,idim6/),nvarid) 562 #else 563 ierr = NF_DEF_VAR (nid, "cloudfrac", NF_FLOAT, 2, 564 & (/idim2,idim6/),nvarid) 565 #endif 566 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 14, 567 . "Cloud fraction") 568 ierr = NF_ENDDEF(nid) 569 #ifdef NC_DOUBLE 570 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cloudfrac) 571 #else 572 ierr = NF_PUT_VAR_REAL (nid,nvarid,cloudfrac) 573 #endif 574 575 c total cloud fraction (added by BC 2010) 576 577 ierr = NF_REDEF (nid) 578 #ifdef NC_DOUBLE 579 ierr = NF_DEF_VAR (nid,"totcloudfrac", NF_DOUBLE, 1, idim2,nvarid) 580 #else 581 ierr = NF_DEF_VAR (nid, "totcloudfrac", NF_FLOAT, 1, idim2,nvarid) 582 #endif 583 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 14, 584 . "Total fraction") 585 ierr = NF_ENDDEF(nid) 586 #ifdef NC_DOUBLE 587 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,totcloudfrac) 588 #else 589 ierr = NF_PUT_VAR_REAL (nid,nvarid,totcloudfrac) 590 #endif 591 592 c oceanic ice (added by BC 2010) 593 594 ierr = NF_REDEF (nid) 595 #ifdef NC_DOUBLE 596 ierr = NF_DEF_VAR (nid, "hice", NF_DOUBLE, 1, idim2,nvarid) 597 #else 598 ierr = NF_DEF_VAR (nid, "hice", NF_FLOAT, 1, idim2,nvarid) 599 #endif 600 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 21, 601 . "Height of oceanic ice") 602 ierr = NF_ENDDEF(nid) 603 #ifdef NC_DOUBLE 604 ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,hice) 605 #else 606 ierr = NF_PUT_VAR_REAL (nid,nvarid,hice) 607 #endif 608 609 610 611 612 613 614 615 616 617 618 619 c tracers 620 621 if (nq > 0) then 622 623 ! Preliminary stuff: check if tracers follow old naming convention (qsurf01, 624 ! qsurf02, ...) 625 count=0 626 do iq=1,nq 627 txt= " " 628 write(txt,'(a1,i2.2)')'q',iq 629 if (txt.ne.nametrac(iq)) then ! use tracer names stored in dynamics 630 ! did not find old tracer name 631 exit ! might as well stop here 632 else 633 ! found old tracer name 634 count=count+1 635 endif 636 enddo 637 if (count.eq.nq) then 638 write(*,*) "physdem1:tracers seem to follow old naming ", 639 & "convention (qsurf01,qsurf02,...)" 640 641 call abort 642 !write(*,*) " => will work for now ... " 643 !write(*,*) " but you should run newstart to rename them" 644 !oldtracernames=.true. 645 ! Moreover, if computing water cycle with ice, move surface ice 646 ! back to qsurf(nq) 647 !IF (iceparty) THEN 648 ! write(*,*)'physdem1: moving surface water ice to index ',nq 649 ! qsurf(1:ngrid,nq)=qsurf(1:ngrid,nq-1) 650 ! qsurf(1:ngrid,nq-1)=0 651 !ENDIF 652 endif ! of if (count.eq.nq) 653 654 IF(nq.GE.1) THEN 655 ! preliminary stuff: look for water vapour & water ice tracers (if any) 656 if (.not.oldtracernames) then 657 do iq=1,nq 658 if (nametrac(iq).eq."h2o_vap") then 659 i_h2o_vap=iq 660 endif 661 if (nametrac(iq).eq."h2o_ice") then 662 i_h2o_ice=iq 663 endif 664 enddo ! of iq=1,nq 665 ! handle special case of only water vapour tracer (no ice) 666 if ((i_h2o_vap.ne.0).and.(i_h2o_ice.eq.0)) then 667 ! then the index of (surface) ice is i_h2o_vap 668 print*,'water vapour but no water ice, WTF?' 669 call abort 670 i_h2o_ice=i_h2o_vap 671 endif 672 endif ! of if (.not.oldtracernames) 673 674 DO iq=1,nq 675 IF (oldtracernames) THEN 676 txt=" " 677 write(txt,'(a5,i2.2)')'qsurf',iq 678 ELSE 679 txt=nametrac(iq) 680 681 682 ! in new version, h2o_vap acts as liquid surface tracer 683 ! so the section below is now redundant 684 ! ------------------------------------------------------------------ 685 ! ! Exception: there is no water vapour surface tracer 686 ! if (txt.eq."h2o_vap") then 687 ! write(*,*)"physdem1: skipping water vapour tracer" 688 ! if (i_h2o_ice.eq.i_h2o_vap) then 689 ! ! then there is no "water ice" tracer; but still 690 ! ! there is some water ice on the surface 691 ! write(*,*)" writting water ice instead" 692 ! txt="h2o_ice" 693 ! else 694 ! ! there is a "water ice" tracer which has been / will be 695 ! ! delt with in due time 696 ! cycle 697 ! endif ! of if (igcm_h2o_ice.eq.igcm_h2o_vap) 698 ! endif ! of if (txt.eq."h2o_vap") 699 ! ------------------------------------------------------------------ 700 701 702 703 ENDIF ! of IF (oldtracernames) 704 705 ierr=NF_REDEF(nid) 706 IF (ierr.NE.NF_NOERR) THEN 707 PRINT*, 'physdem1: Failed to swich to NetCDF define mode' 708 CALL abort 709 ENDIF 710 #ifdef NC_DOUBLE 711 ierr=NF_DEF_VAR(nid,txt,NF_DOUBLE,1,idim2,nvarid) 712 #else 713 ierr=NF_DEF_VAR(nid,txt,NF_FLOAT,1,idim2,nvarid) 714 #endif 715 IF (ierr.NE.NF_NOERR) THEN 716 PRINT*, 'physdem1: Failed to define ',trim(txt) 717 CALL abort 718 ENDIF 719 ierr=NF_PUT_ATT_TEXT (nid, nvarid, "title", 17, 720 & "tracer on surface") 721 IF (ierr.NE.NF_NOERR) THEN 722 PRINT*, 'physdem1: Failed to define ',trim(txt), 723 & ' title attribute' 724 CALL abort 725 ENDIF 726 ierr=NF_ENDDEF(nid) 727 IF (ierr.NE.NF_NOERR) THEN 728 PRINT*, 'physdem1: Failed to swich out of define mode' 729 CALL abort 730 ENDIF 731 732 #ifdef NC_DOUBLE 733 ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,qsurf(1,iq)) 734 #else 735 ierr=NF_PUT_VAR_REAL (nid,nvarid,qsurf(1,iq)) 736 #endif 737 IF (ierr.NE.NF_NOERR) THEN 738 PRINT*, 'physdem1: Failed to write ',trim(txt) 739 CALL abort 740 ENDIF 741 ENDDO ! of DO iq=1,nq 742 ENDIF ! of IF(nq.GE.1) 743 744 endif ! of if tracer 745 746 c close file 747 ierr = NF_CLOSE(nid) 748 749 RETURN 750 751 END 98 tab_cntrl(35) = volcapa ! soil volumetric heat capacity 99 100 call put_var("controle","Control parameters",tab_cntrl) 101 102 ! Write the mid-layer depths 103 call put_var("soildepth","Soil mid-layer depth",mlayer) 104 105 ! Write longitudes 106 call put_field("longitude","Longitudes of physics grid",lonfi) 107 108 ! Write latitudes 109 call put_field("latitude","Latitudes of physics grid",latfi) 110 111 ! Write mesh areas 112 call put_field("area","Mesh area",area) 113 114 ! Write surface geopotential 115 call put_field("phisfi","Geopotential at the surface",phisfi) 116 117 ! Write surface albedo 118 call put_field("albedodat","Albedo of bare ground",albedodat) 119 120 ! Subgrid topogaphy variables 121 call put_field("ZMEA","Relief: mean relief",zmea) 122 call put_field("ZSTD","Relief: standard deviation",zstd) 123 call put_field("ZSIG","Relief: sigma parameter",zsig) 124 call put_field("ZGAM","Relief: gamma parameter",zgam) 125 call put_field("ZTHE","Relief: theta parameter",zthe) 126 127 ! Soil thermal inertia 128 call put_field("inertiedat","Soil thermal inertia",inertiedat) 129 130 ! Close file 131 call close_restartphy 132 133 end subroutine physdem0 134 135 subroutine physdem1(filename,nsoil,ngrid,nlay,nq, & 136 phystep,time,tsurf,tsoil,emis,q2,qsurf, & 137 cloudfrac,totcloudfrac,hice) 138 ! write time-dependent variable to restart file 139 use iostart, only : open_restartphy, close_restartphy, & 140 put_var, put_field 141 use infotrac, only: tname 142 implicit none 143 !====================================================================== 144 !#include "temps.h" 145 #include "comcstfi.h" 146 #include "planete.h" 147 !====================================================================== 148 character(len=*),intent(in) :: filename 149 integer,intent(in) :: nsoil 150 integer,intent(in) :: ngrid 151 integer,intent(in) :: nlay 152 integer,intent(in) :: nq 153 real,intent(in) :: phystep 154 real,intent(in) :: time 155 real,intent(in) :: tsurf(ngrid) 156 real,intent(in) :: tsoil(ngrid,nsoil) 157 real,intent(in) :: emis(ngrid) 158 real,intent(in) :: q2(ngrid,nlay+1) 159 real,intent(in) :: qsurf(ngrid,nq) 160 real,intent(in) :: cloudfrac(ngrid,nlay) 161 real,intent(in) :: totcloudfrac(ngrid) 162 real,intent(in) :: hice(ngrid) 163 164 integer :: iq 165 166 ! Open file 167 call open_restartphy(filename) 168 169 ! First variable to write must be "Time", in order to correctly 170 ! set time counter in file 171 !call put_var("Time","Temps de simulation",time) 172 173 ! Surface temperature 174 call put_field("tsurf","Surface temperature",tsurf) 175 176 ! Soil temperature 177 call put_field("tsoil","Soil temperature",tsoil) 178 179 ! Emissivity of the surface 180 call put_field("emis","Surface emissivity",emis) 181 182 ! Planetary Boundary Layer 183 call put_field("q2","pbl wind variance",q2) 184 185 ! cloud fraction and sea ice (NB: these should be optional... to be improved) 186 call put_field("cloudfrac","Cloud fraction",cloudfrac) 187 call put_field("totcloudfrac","Total fraction",totcloudfrac) 188 call put_field("hice","Height of oceanic ice",hice) 189 190 ! tracers 191 if (nq>0) then 192 do iq=1,nq 193 call put_field(tname(iq),"tracer on surface",qsurf(:,iq)) 194 enddo 195 endif ! of if (nq>0) 196 197 ! close file 198 CALL close_restartphy 199 !$OMP BARRIER 200 201 end subroutine physdem1 202 203 end module phyredem -
trunk/LMDZ.GENERIC/libf/phystd/physiq.F90
r1194 r1216 10 10 use radinc_h, only : L_NSPECTI,L_NSPECTV,naerkind 11 11 use watercommon_h, only : RLVTT, Psat_water,epsi 12 use gases_h 12 use gases_h, only: gnom, gfrac 13 13 use radcommon_h, only: sigma, eclipse, glat, grav 14 14 use radii_mod, only: h2o_reffrad, co2_reffrad, h2o_cloudrad 15 use aerosol_mod 16 use surfdat_h 17 use comdiurn_h 18 use comsaison_h 19 use comsoil_h 20 USE comgeomfi_h 21 USE tracer_h 15 use aerosol_mod, only: iaero_co2, iaero_h2o 16 use surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe, & 17 dryness, watercaptag 18 use comdiurn_h, only: coslat, sinlat, coslon, sinlon 19 use comsaison_h, only: mu0, fract, dist_star, declin 20 use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat 21 USE comgeomfi_h, only: long, lati, area, totarea 22 USE tracer_h, only: noms, mmol, radius, rho_q, qext, & 23 alpha_lift, alpha_devil, qextrhor, & 24 igcm_h2o_ice, igcm_h2o_vap, igcm_dustbin, & 25 igcm_co2_ice 26 use control_mod, only: ecritphy, iphysiq, nday 27 use phyredem, only: physdem0, physdem1 22 28 23 29 implicit none … … 80 86 ! pt(ngrid,nlayer) Temperature (K) 81 87 ! pq(ngrid,nlayer,nq) Advected fields 82 ! pudyn(ngrid,nlayer) \ 88 ! pudyn(ngrid,nlayer) \ 83 89 ! pvdyn(ngrid,nlayer) \ Dynamical temporal derivative for the 84 90 ! ptdyn(ngrid,nlayer) / corresponding variables … … 123 129 #include "comcstfi.h" 124 130 #include "planete.h" 125 #include "control.h"131 !#include "control.h" 126 132 #include "netcdf.inc" 127 133 … … 621 627 ! need epsi for the wvp definitions in callcorrk.F 622 628 629 if (ngrid.ne.1) then ! no need to create a restart file in 1d 630 call physdem0("restartfi.nc",long,lati,nsoilmx,ngrid,nlayer,nq, & 631 ptimestep,pday+nday,time_phys,area, & 632 albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe) 633 endif 634 623 635 endif ! (end of "if firstcall") 624 636 … … 626 638 ! 1.2 Initializations done at every physical timestep: 627 639 ! --------------------------------------------------- 628 629 640 ! Initialize various variables 630 641 ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 655 666 ! Compute variations of g with latitude (oblate case) 656 667 ! 657 if (oblate .eq . .false.) then668 if (oblate .eqv. .false.) then 658 669 glat(:) = g 659 670 else if (flatten .eq. 0.0 .or. J2 .eq. 0.0 .or. Rmean .eq. 0.0 .or. MassPlanet .eq. 0.0) then … … 734 745 call stelang(ngrid,sinlon,coslon,sinlat,coslat, & 735 746 ztim1,ztim2,ztim3,mu0,fract, flatten) 736 else if(diurnal .eq . .false.) then747 else if(diurnal .eqv. .false.) then 737 748 738 749 call mucorr(ngrid,declin,lati,mu0,fract,10000.,rad,flatten) … … 745 756 if(rings_shadow) then 746 757 write(*,*) 'Rings shadow activated' 747 if(diurnal .eq . .false.) then ! we need to compute the daily average insolation758 if(diurnal .eqv. .false.) then ! we need to compute the daily average insolation 748 759 pas = 1./nb_hours 749 760 ptime_day = 0. … … 784 795 endif 785 796 786 787 797 if (corrk) then 788 798 … … 1531 1541 1532 1542 if(meanOLR)then 1533 if((ngrid.gt.1) .or. (mod(icount-1, nint(ecritphy)).eq.0))then1543 if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then 1534 1544 ! to record global radiative balance 1535 1545 open(92,file="rad_bal.out",form='formatted',position='append') … … 1607 1617 1608 1618 if(meanOLR)then 1609 if((ngrid.gt.1) .or. (mod(icount-1, nint(ecritphy)).eq.0))then1619 if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then 1610 1620 ! to record global water balance 1611 1621 open(98,file="h2o_bal.out",form='formatted',position='append') … … 1681 1691 endif 1682 1692 1683 write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin 1684 #ifdef CPP_PARA 1685 ! for now in parallel we use a different routine to write restartfi.nc 1686 call phyredem(ngrid,"restartfi.nc", & 1687 ptimestep,pday,ztime_fin,tsurf,tsoil,emis,q2,qsurf_hist, & 1688 cloudfrac,totcloudfrac,hice) 1689 #else 1690 call physdem1(ngrid,"restartfi.nc",long,lati,nsoilmx,nq, & 1691 ptimestep,pday,ztime_fin,tsurf,tsoil,emis,q2,qsurf_hist, & 1692 area,albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe, & 1693 cloudfrac,totcloudfrac,hice,noms) 1694 #endif 1695 endif 1693 if (ngrid.ne.1) then 1694 write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin 1695 !#ifdef CPP_PARA 1696 !! for now in parallel we use a different routine to write restartfi.nc 1697 ! call phyredem(ngrid,"restartfi.nc", & 1698 ! ptimestep,pday,ztime_fin,tsurf,tsoil,emis,q2,qsurf_hist, & 1699 ! cloudfrac,totcloudfrac,hice) 1700 !#else 1701 ! call physdem1(ngrid,"restartfi.nc",long,lati,nsoilmx,nq, & 1702 ! ptimestep,pday,ztime_fin,tsurf,tsoil,emis,q2,qsurf_hist, & 1703 ! area,albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe, & 1704 ! cloudfrac,totcloudfrac,hice,noms) 1705 !#endif 1706 call physdem1("restartfi.nc",nsoilmx,ngrid,nlayer,nq, & 1707 ptimestep,ztime_fin, & 1708 tsurf,tsoil,emis,q2,qsurf_hist, & 1709 cloudfrac,totcloudfrac,hice) 1710 endif 1711 1712 endif ! of if (lastcall) 1696 1713 1697 1714 -
trunk/LMDZ.GENERIC/libf/phystd/rcm1d.F
r1150 r1216 2 2 3 3 ! to use 'getin' 4 use ioipsl_getincom 5 use surfdat_h 6 use comdiurn_h 7 use comsaison_h 8 use comsoil_h 9 USE comgeomfi_h 10 4 use ioipsl_getincom, only: getin 5 use infotrac, only: nqtot, tname 6 use surfdat_h, only: albedodat, phisfi, dryness, watercaptag, 7 & zmea, zstd, zsig, zgam, zthe, 8 & emissiv, emisice, albedice, iceradius, 9 & dtemisice 10 use comdiurn_h, only: sinlat, coslat, sinlon, coslon 11 ! use comsaison_h 12 use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat, volcapa 13 USE comgeomfi_h, only: lati, long, area 14 use control_mod, only: day_step, ecritphy 15 use phyredem, only: physdem0,physdem1 16 use comgeomphy, only: initcomgeomphy 11 17 implicit none 12 18 … … 41 47 #include "comcstfi.h" 42 48 #include "planete.h" 43 #include "control.h"49 !#include "control.h" 44 50 #include "comvert.h" 45 51 #include "netcdf.inc" … … 61 67 REAL play(nlayermx) ! Pressure at the middle of the layers (Pa) 62 68 REAL plev(nlayermx+1) ! intermediate pressure levels (pa) 63 REAL psurf,tsurf 69 REAL psurf,tsurf(1) 64 70 REAL u(nlayermx),v(nlayermx) ! zonal, meridional wind 65 71 REAL gru,grv ! prescribed "geostrophic" background wind 66 72 REAL temp(nlayermx) ! temperature at the middle of the layers 67 REAL q(nlayermx,nqmx) ! tracer mixing ratio (e.g. kg/kg)68 REAL qsurf(nqmx) ! tracer surface budget (e.g. kg.m-2)73 REAL,ALLOCATABLE :: q(:,:) ! tracer mixing ratio (e.g. kg/kg) 74 REAL,ALLOCATABLE :: qsurf(:) ! tracer surface budget (e.g. kg.m-2) 69 75 REAL tsoil(nsoilmx) ! subsurface soik temperature (K) 70 76 ! REAL co2ice ! co2ice layer (kg.m-2) !not used anymore … … 72 78 integer :: i_h2o_ice=0 ! tracer index of h2o ice 73 79 integer :: i_h2o_vap=0 ! tracer index of h2o vapor 74 REAL emis ! surface layer80 REAL emis(1) ! surface layer 75 81 REAL q2(nlayermx+1) ! Turbulent Kinetic Energy 76 82 REAL zlay(nlayermx) ! altitude estimee dans les couches (km) … … 80 86 REAL dudyn(nlayermx),dvdyn(nlayermx),dtempdyn(nlayermx) 81 87 REAL dpsurf 82 REAL dq(nlayermx,nqmx)83 REAL dqdyn(nlayermx,nqmx)88 REAL,ALLOCATABLE :: dq(:,:) 89 REAL,ALLOCATABLE :: dqdyn(:,:) 84 90 85 91 c Various intermediate variables … … 88 94 REAL phi(nlayermx),h(nlayermx),s(nlayermx) 89 95 REAL pks, ptif, w(nlayermx) 90 REAL qtotinit, mqtot(nqmx),qtot91 96 INTEGER ierr, aslun 92 97 REAL tmp1(0:nlayermx),tmp2(0:nlayermx) … … 112 117 113 118 ! added by AS to avoid the use of adv trac common 114 character*20 nametrac(nqmx) ! name of the tracer (no need for adv trac common) 115 119 character*20,allocatable :: nametrac(:) ! name of the tracer (no need for adv trac common) 120 121 real :: latitude, longitude 116 122 117 123 c======================================================================= 118 124 c INITIALISATION 119 125 c======================================================================= 126 ! initialize "serial/parallel" related stuff 127 CALL init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/)) 128 call initcomgeomphy 120 129 121 130 !! those are defined in surfdat_h.F90 … … 227 236 ! read number of tracers: 228 237 read(90,*,iostat=ierr) nq 238 nqtot=nq ! set value of nqtot (in infotrac module) as nq 229 239 if (ierr.ne.0) then 230 240 write(*,*) "rcm1d: error reading number of tracers" 231 241 write(*,*) " (first line of traceur.def) " 232 242 stop 243 endif 244 if (nq>0) then 245 allocate(tname(nq)) 246 allocate(q(nlayermx,nq)) 247 allocate(qsurf(nq)) 248 allocate(dq(nlayermx,nq)) 249 allocate(dqdyn(nlayermx,nq)) 233 250 else 234 ! check that the number of tracers is indeed nqmx 235 if (nq.ne.nqmx) then 236 write(*,*) "rcm1d: error, wrong number of tracers:" 237 write(*,*) "nq=",nq," whereas nqmx=",nqmx 238 stop 239 endif 251 allocate(tname(1)) ! tname(1) is used below, even if nq=0 240 252 endif 241 253 242 254 do iq=1,nq 243 255 ! minimal version, just read in the tracer names, 1 per line 244 read(90,*,iostat=ierr) nametrac(iq)256 read(90,*,iostat=ierr) tname(iq) 245 257 if (ierr.ne.0) then 246 258 write(*,*) 'rcm1d: error reading tracer names...' … … 253 265 i_h2o_vap=0 254 266 do iq=1,nq 255 if ( nametrac(iq)=="co2_ice") then267 if (tname(iq)=="co2_ice") then 256 268 i_co2_ice=iq 257 elseif ( nametrac(iq)=="h2o_ice") then269 elseif (tname(iq)=="h2o_ice") then 258 270 i_h2o_ice=iq 259 elseif ( nametrac(iq)=="h2o_vap") then271 elseif (tname(iq)=="h2o_vap") then 260 272 i_h2o_vap=iq 261 273 endif … … 275 287 276 288 else 277 nq=nqmx 289 nq=nqtot 290 if (nq>0) then 291 allocate(tname(nq)) 292 allocate(q(nlayermx,nq)) 293 allocate(qsurf(nq)) 294 allocate(dq(nlayermx,nq)) 295 allocate(dqdyn(nlayermx,nq)) 296 else 297 allocate(tname(1)) ! tname(1) is used below, even if nq=0 298 endif 278 299 ! Check that tracer boolean is compliant with number of tracers 279 300 ! -- otherwise there is an error (and more generally we have to be consistent) … … 290 311 do iq=1,nq 291 312 write(str7,'(a1,i2.2)')'q',iq 292 nametrac(iq)=str7313 tname(iq)=str7 293 314 enddo 294 315 ! actually, we'll need at least one "co2_ice" tracer 295 316 ! (for surface CO2 ice) 296 nametrac(1)="co2_ice"297 317 i_co2_ice=1 318 tname(i_co2_ice)="co2_ice" 298 319 endif ! of if (tracer) 299 320 … … 315 336 phisfi(1)=0.E+0 316 337 !!! LATITUDE. can be set. 317 lati (1)=0 ! default value for lati(1)338 latitude=0 ! default value for latitude 318 339 PRINT *,'latitude (in degrees) ?' 319 call getin("latitude",lati (1))320 write(*,*) " latitude = ",lati (1)321 lati (1)=lati(1)*pi/180.E+0340 call getin("latitude",latitude) 341 write(*,*) " latitude = ",latitude 342 latitude=latitude*pi/180.E+0 322 343 !!! LONGITUDE. useless in 1D. 323 long (1)=0.E+0324 long (1)=long(1)*pi/180.E+0344 longitude=0.E+0 345 longitude=longitude*pi/180.E+0 325 346 326 347 !!! CALL INIFIS … … 332 353 !!! - physical frequency: nevermind, in inifis this is a simple print 333 354 cpp=1.d-7 !JL because we divide by cpp in inifis, there may be a more elegant solution 334 CALL inifis(1,llm, day0,daysec,dtphys,335 . lati ,long,area,rad,g,r,cpp)355 CALL inifis(1,llm,nq,day0,daysec,dtphys, 356 . latitude,longitude,area,rad,g,r,cpp) 336 357 !!! We check everything is OK. 337 358 PRINT *,"CHECK" … … 558 579 c emissivity / surface co2 ice ( + h2o ice??) 559 580 c ------------------------------------------- 560 emis =emissiv ! default value for emissivity581 emis(1)=emissiv ! default value for emissivity 561 582 PRINT *,'Emissivity of bare ground ?' 562 call getin("emis",emis )563 write(*,*) " emis = ",emis 564 emissiv=emis ! we do this so that condense_co2 sets things to the right583 call getin("emis",emis(1)) 584 write(*,*) " emis = ",emis(1) 585 emissiv=emis(1) ! we do this so that condense_co2 sets things to the right 565 586 ! value if there is no snow 566 587 … … 573 594 ! if we have some CO2 ice on the surface, change emissivity 574 595 if (lati(1).ge.0) then ! northern hemisphere 575 emis =emisice(1)596 emis(1)=emisice(1) 576 597 else ! southern hemisphere 577 emis =emisice(2)598 emis(1)=emisice(2) 578 599 endif 579 600 ENDIF … … 673 694 call profile(nlayer+1,tmp1,tmp2) 674 695 675 tsurf =tmp2(0)696 tsurf(1)=tmp2(0) 676 697 DO ilayer=1,nlayer 677 698 temp(ilayer)=tmp2(ilayer) 678 699 ENDDO 679 700 print*,"check" 680 PRINT*,"INPUT SURFACE TEMPERATURE",tsurf 701 PRINT*,"INPUT SURFACE TEMPERATURE",tsurf(1) 681 702 PRINT*,"INPUT TEMPERATURE PROFILE",temp 682 703 … … 698 719 DO isoil=1,nsoil 699 720 inertiedat(1,isoil)=inertiedat(1,1) ! soil thermal inertia 700 tsoil(isoil)=tsurf ! soil temperature721 tsoil(isoil)=tsurf(1) ! soil temperature 701 722 ENDDO 702 723 … … 711 732 712 733 713 c Ecriture de "startfi"734 c Write a "startfi" file 714 735 c -------------------- 715 c (Ce fichier sera aussitot relu au premier 716 c appel de "physiq", mais il est necessaire pour passer 717 c les variables purement physiques a "physiq"... 718 719 call physdem1(1,"startfi.nc",long,lati,nsoilmx,nq, 720 & dtphys,float(day0), 721 & time,tsurf,tsoil,emis,q2,qsurf, 722 & area,albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe, 723 & cloudfrac,totcloudfrac,hice,nametrac) 736 c This file will be read during the first call to "physiq". 737 c It is needed to transfert physics variables to "physiq"... 738 739 call physdem0("startfi.nc",long,lati,nsoilmx,1,llm,nq, 740 & dtphys,real(day0),time,area, 741 & albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe) 742 call physdem1("startfi.nc",nsoilmx,1,llm,nq, 743 & dtphys,time, 744 & tsurf,tsoil,emis,q2,qsurf, 745 & cloudfrac,totcloudfrac,hice) 746 747 ! call physdem1(1,"startfi.nc",long,lati,nsoilmx,nq, 748 ! & dtphys,float(day0), 749 ! & time,tsurf,tsoil,emis,q2,qsurf, 750 ! & area,albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe, 751 ! & cloudfrac,totcloudfrac,hice,nametrac) 724 752 725 753 c======================================================================= … … 775 803 776 804 CALL physiq (1,llm,nq, 777 . nametrac,805 . tname, 778 806 , firstcall,lastcall, 779 807 , day,time,dtphys, … … 858 886 ENDDO ! fin de la boucle temporelle 859 887 888 write(*,*) "rcm1d: Everything is cool." 889 860 890 c ======================================================== 861 891 end !rcm1d … … 874 904 875 905 #include "../dyn3d/disvert.F" 906 #include "../dyn3d/abort_gcm.F" -
trunk/LMDZ.GENERIC/libf/phystd/soil.F
r787 r1216 4 4 & capcal,fluxgrd) 5 5 6 use comsoil_h 6 use comsoil_h, only: layer, mlayer, volcapa 7 7 8 8 implicit none … … 17 17 !----------------------------------------------------------------------- 18 18 19 #include "dimensions.h"20 #include "dimphys.h"19 include "dimensions.h" 20 include "dimphys.h" 21 21 22 22 … … 25 25 ! --------- 26 26 ! inputs: 27 integer ngrid ! number of (horizontal) grid-points28 integer nsoil ! number of soil layers29 logical firstcall ! identifier for initialization call30 logical lastcall31 real therm_i(ngrid,nsoil) ! thermal inertia32 real timestep ! time step33 real tsurf(ngrid) ! surface temperature27 integer,intent(in) :: ngrid ! number of (horizontal) grid-points 28 integer,intent(in) :: nsoil ! number of soil layers 29 logical,intent(in) :: firstcall ! identifier for initialization call 30 logical,intent(in) :: lastcall 31 real,intent(in) :: therm_i(ngrid,nsoil) ! thermal inertia 32 real,intent(in) :: timestep ! time step 33 real,intent(in) :: tsurf(ngrid) ! surface temperature 34 34 ! outputs: 35 real tsoil(ngrid,nsoil) ! soil (mid-layer) temperature36 real capcal(ngrid) ! surface specific heat37 real fluxgrd(ngrid) ! surface diffusive heat flux35 real,intent(out) :: tsoil(ngrid,nsoil) ! soil (mid-layer) temperature 36 real,intent(out) :: capcal(ngrid) ! surface specific heat 37 real,intent(out) :: fluxgrd(ngrid) ! surface diffusive heat flux 38 38 39 39 ! local saved variables: … … 50 50 51 51 52 ! print*,'tsoil=',tsoil53 ! print*,'tsurf=',tsurf54 55 52 ! 0. Initialisations and preprocessing step 56 53 if (firstcall) then … … 58 55 ! and not changed by soil.F 59 56 60 ALLOCATE(mthermdiff(ngrid,0:nsoil mx-1)) ! mid-layer thermal diffusivity61 ALLOCATE(thermdiff(ngrid,nsoil mx-1)) ! inter-layer thermal diffusivity62 ALLOCATE(coefq(0:nsoil mx-1)) ! q_{k+1/2} coefficients63 ALLOCATE(coefd(ngrid,nsoil mx-1)) ! d_k coefficients64 ALLOCATE(alph(ngrid,nsoil mx-1)) ! alpha_k coefficients65 ALLOCATE(beta(ngrid,nsoil mx-1)) ! beta_k coefficients57 ALLOCATE(mthermdiff(ngrid,0:nsoil-1)) ! mid-layer thermal diffusivity 58 ALLOCATE(thermdiff(ngrid,nsoil-1)) ! inter-layer thermal diffusivity 59 ALLOCATE(coefq(0:nsoil-1)) ! q_{k+1/2} coefficients 60 ALLOCATE(coefd(ngrid,nsoil-1)) ! d_k coefficients 61 ALLOCATE(alph(ngrid,nsoil-1)) ! alpha_k coefficients 62 ALLOCATE(beta(ngrid,nsoil-1)) ! beta_k coefficients 66 63 67 64 ! 0.1 Build mthermdiff(:), the mid-layer thermal diffusivities … … 187 184 enddo 188 185 189 if (lastcall) then190 IF ( ALLOCATED(mthermdiff)) DEALLOCATE(mthermdiff)191 IF ( ALLOCATED(thermdiff)) DEALLOCATE(thermdiff)192 IF ( ALLOCATED(coefq)) DEALLOCATE(coefq)193 IF ( ALLOCATED(coefd)) DEALLOCATE(coefd)194 IF ( ALLOCATED(alph)) DEALLOCATE(alph)195 IF ( ALLOCATED(beta)) DEALLOCATE(beta)196 endif197 198 186 end 199 187 -
trunk/LMDZ.GENERIC/libf/phystd/soil_settings.F
r787 r1216 1 subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil) 2 3 use comsoil_h 4 1 subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil,indextime) 2 3 ! use netcdf 4 use comsoil_h, only: layer, mlayer, inertiedat, volcapa 5 use iostart, only: inquire_field_ndims, get_var, get_field, 6 & inquire_field, inquire_dimension_length 5 7 implicit none 6 8 … … 9 11 ! 10 12 ! Purpose: Read and/or initialise soil depths and properties 13 ! 14 ! Modifications: Aug.2010 EM : use NetCDF90 to load variables (enables using 15 ! r4 or r8 restarts independently of having compiled 16 ! the GCM in r4 or r8) 17 ! June 2013 TN : Possibility to read files with a time axis 18 ! 11 19 ! 12 20 ! This subroutine reads from a NetCDF file (opened by the caller) … … 26 34 !====================================================================== 27 35 28 #include "dimensions.h"29 #include "dimphys.h"30 31 #include "netcdf.inc"32 36 !====================================================================== 33 37 ! arguments 34 38 ! --------- 35 39 ! inputs: 36 integer nid ! Input Netcdf file ID37 integer ngrid ! # of horizontal grid points38 integer nsoil ! # of soil layers39 integer sta ! # at which reading starts40 real tsurf(ngrid) ! surface temperature40 integer,intent(in) :: nid ! Input Netcdf file ID 41 integer,intent(in) :: ngrid ! # of horizontal grid points 42 integer,intent(in) :: nsoil ! # of soil layers 43 real,intent(in) :: tsurf(ngrid) ! surface temperature 44 integer,intent(in) :: indextime ! position on time axis 41 45 ! output: 42 real tsoil(ngrid,nsoilmx) ! soil temperature46 real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature 43 47 44 48 !====================================================================== … … 50 54 integer ndims ! # of dimensions of read <inertiedat> data 51 55 integer ig,iloop ! loop counters 56 57 integer edges(3),corner(3) ! to read a specific time 52 58 53 59 logical :: olddepthdef=.false. ! flag … … 70 76 real,parameter :: default_volcapa=1.e6 71 77 72 integer, dimension(2) :: sta2d 73 integer, dimension(2) :: siz2d 74 75 !====================================================================== 76 77 !! this is defined in comsoil_h 78 IF (.not.ALLOCATED(layer)) 79 . ALLOCATE(layer(nsoilmx)) 80 IF (.not.ALLOCATED(mlayer)) 81 . ALLOCATE(mlayer(0:nsoilmx-1)) 82 IF (.not.ALLOCATED(inertiedat)) 83 . ALLOCATE(inertiedat(ngrid,nsoilmx)) 84 85 !! this is defined in dimphys.h 86 sta = cursor 78 logical :: found,ok 79 80 !====================================================================== 87 81 88 82 ! 1. Depth coordinate … … 91 85 ! 1.1 Start by reading how many layers of soil there are 92 86 93 ierr=NF_INQ_DIMID(nid,"subsurface_layers",dimid) 94 if (ierr.ne.NF_NOERR) then 95 write(*,*)'soil_settings: Problem reading <subsurface_layers>' 96 call abort 97 endif 98 99 ierr=NF_INQ_DIMLEN(nid,dimid,dimlen) 100 if (ierr.ne.NF_NOERR) then 101 write(*,*)'soil_settings: Problem getting <subsurface_layers>', 102 & 'length' 103 call abort 104 endif 87 dimlen=inquire_dimension_length("subsurface_layers") 105 88 106 89 if (dimlen.ne.nsoil) then … … 112 95 endif 113 96 114 sta2d = (/sta,1/)115 siz2d = (/ngrid,dimlen/)116 117 118 97 ! 1.2 Find out the # of dimensions <inertiedat> was defined as using 119 ! (in ye old days, thermal inertia was only given at the "surface") 120 ! Look for thermal inertia data 121 ierr=NF_INQ_VARID(nid, "inertiedat", nvarid) 122 if (ierr.NE.NF_NOERR) then 123 write(*,*)'soil_settings: Field <inertiedat> not found!' 124 call abort 125 endif 126 127 ! Read the # of dimensions <inertidat> was defined as using 128 ierr=NF_INQ_VARNDIMS(nid,nvarid,ndims) 129 ! if (ndims.eq.1) then we have the "old 2D-surface" format 98 99 ndims=inquire_field_ndims("inertiedat") 130 100 131 101 ! 1.3 Read depths values or set olddepthdef flag and values … … 147 117 enddo 148 118 else ! Look for depth 149 ierr=NF_INQ_VARID(nid,"soildepth",nvarid)150 if (ierr.ne.NF_NOERR) then151 write(*,*)'soil_settings: Field <soildepth> not found!'152 call abort153 endif154 119 ! read <depth> coordinate 155 120 if (interpol) then !put values in oldmlayer 156 if (.not.allocated(oldmlayer)) then 157 allocate(oldmlayer(dimlen),stat=ierr) 158 endif 159 #ifdef NC_DOUBLE 160 ierr = NF_GET_VAR_DOUBLE(nid,nvarid,oldmlayer) 161 #else 162 ierr = NF_GET_VAR_REAL(nid,nvarid,oldmlayer) 163 #endif 164 if (ierr.ne.NF_NOERR) then 165 write(*,*)'soil_settings: Problem while reading <soildepth>' 166 call abort 121 call get_var("soildepth",oldmlayer,found) 122 if (.not.found) then 123 write(*,*)'soil_settings: Problem while reading <soildepth>' 167 124 endif 168 125 else ! put values in mlayer 169 #ifdef NC_DOUBLE 170 ierr = NF_GET_VAR_DOUBLE(nid,nvarid,mlayer) 171 #else 172 ierr = NF_GET_VAR_REAL(nid,nvarid,mlayer) 173 #endif 174 if (ierr.ne.NF_NOERR) then 175 write(*,*)'soil_settings: Problem while reading <soildepth>' 176 call abort 126 call get_var("soildepth",mlayer,found) 127 if (.not.found) then 128 write(*,*)'soil_settings: Problem while reading <soildepth>' 177 129 endif 178 130 endif !of if (interpol) … … 183 135 ! default mlayer distribution, following a power law: 184 136 ! mlayer(k)=lay1*alpha**(k-1/2) 185 lay1=2.e-4 !mars case (nsoilmx=18) 186 ! lay1=3.e-2 !earth case (nsoilmx=13) 137 lay1=2.e-4 187 138 alpha=2 188 139 do iloop=0,nsoil-1 … … 200 151 enddo 201 152 202 ! 2. Volumetric heat capacity (note: it is declared in comsoil .h)153 ! 2. Volumetric heat capacity (note: it is declared in comsoil_h) 203 154 ! --------------------------- 204 155 ! "volcapa" is (so far) 0D and written in "controle" table of startfi file … … 214 165 volcapa=default_volcapa 215 166 endif 216 ! Look for it 217 ! ierr=NF_INQ_VARID(nid,"volcapa",nvarid) 218 ! if (ierr.NE.NF_NOERR) then 219 ! write(*,*)'soil_settings: Field <volcapa> not found!' 220 ! write(*,*)'Initializing Volumetric heat capacity to ', 221 ! & default_volcapa 222 ! volcapa=default_volcapa 223 ! else 224 !#ifdef NC_DOUBLE 225 ! ierr = NF_GET_VAR_DOUBLE(nid,nvarid,volcapa) 226 !#else 227 ! ierr = NF_GET_VAR_REAL(nid,nvarid,volcapa) 228 !#endif 229 ! if (ierr.ne.NF_NOERR) then 230 ! write(*,*)'soil_settings: Problem while reading <volcapa>' 231 ! call abort 232 ! endif 233 ! endif 234 235 ! 3. Thermal inertia (note: it is declared in comsoil.h) 167 168 ! 3. Thermal inertia (note: it is declared in comsoil_h) 236 169 ! ------------------ 237 170 238 171 ! 3.1 Look (again) for thermal inertia data (to reset nvarid) 239 ierr=NF_INQ_VARID(nid, "inertiedat", nvarid)240 if (ierr.NE.NF_NOERR) then241 write(*,*)'soil_settings: Field <inertiedat> not found!'242 call abort243 endif244 172 245 173 ! 3.2 Knowing the # of dimensions <inertidat> was defined as using, … … 251 179 ! Read Surface thermal inertia 252 180 allocate(surfinertia(ngrid)) 253 #ifdef NC_DOUBLE 254 ierr = NF_GET_VARA_DOUBLE(nid, nvarid, sta, ngrid, surfinertia) 255 #else 256 ierr = NF_GET_VARA_REAL(nid, nvarid, sta, ngrid, surfinertia) 257 #endif 258 if (ierr.NE.NF_NOERR) then 259 write(*,*)'soil_settings: Problem while reading <inertiedat>' 181 call get_field("inertiedat",surfinertia,found) 182 if (.not.found) then 183 write(*,*) "soil_settings: Failed loading <inertiedat>" 260 184 call abort 261 185 endif 262 186 263 187 write(*,*)' => Building soil thermal inertia (using reference sur … … 277 201 stop 278 202 endif 279 endif 280 #ifdef NC_DOUBLE 281 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,oldinertiedat) 282 #else 283 ierr = NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,oldinertiedat) 284 #endif 285 if (ierr.NE.NF_NOERR) then 286 write(*,*)'soil_settings: Problem while reading <inertiedat>' 287 call abort 203 endif ! of if (.not.allocated(oldinertiedat)) 204 call get_field("inertiedat",oldinertiedat,found) 205 if (.not.found) then 206 write(*,*) "soil_settings: Failed loading <inertiedat>" 207 call abort 288 208 endif 289 209 else ! put values in therm_i 290 #ifdef NC_DOUBLE 291 ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,inertiedat) 292 #else 293 ierr = NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,inertiedat) 294 #endif 295 if (ierr.NE.NF_NOERR) then 296 write(*,*)'soil_settings: Problem while reading <inertiedat>' 297 call abort 298 endif 210 call get_field("inertiedat",inertiedat,found) 211 if (.not.found) then 212 write(*,*) "soil_settings: Failed loading <inertiedat>" 213 call abort 214 endif 215 ! endif 299 216 endif ! of if (interpol) 300 217 endif ! of if (ndims.eq.1) … … 303 220 ! ------------------------- 304 221 305 ierr=NF_INQ_VARID(nid,"tsoil",nvarid) 306 if (ierr.ne.NF_NOERR) then 222 ! ierr=nf90_inq_varid(nid,"tsoil",nvarid) 223 ok=inquire_field("tsoil") 224 ! if (ierr.ne.nf90_noerr) then 225 if (.not.ok) then 307 226 write(*,*)'soil_settings: Field <tsoil> not found!' 308 227 write(*,*)' => Building <tsoil> from surface values <tsurf>' … … 320 239 endif 321 240 endif 322 #ifdef NC_DOUBLE 323 ierr=NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,oldtsoil) 324 #else 325 ierr=NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,oldtsoil) 326 #endif 327 if (ierr.ne.NF_NOERR) then 328 write(*,*)'soil_settings: Problem while reading <tsoil>' 329 call abort 330 endif 241 call get_field("tsoil",oldtsoil,found) 242 if (.not.found) then 243 write(*,*) "soil_settings: Failed loading <tsoil>" 244 call abort 245 endif 331 246 else ! put values in tsoil 332 #ifdef NC_DOUBLE 333 ierr=NF_GET_VARA_DOUBLE(nid,nvarid,sta2d,siz2d,tsoil) 334 #else 335 ierr=NF_GET_VARA_REAL(nid,nvarid,sta2d,siz2d,tsoil) 336 #endif 337 if (ierr.ne.NF_NOERR) then 338 write(*,*)'soil_settings: Problem while reading <tsoil>' 339 call abort 340 endif 247 call get_field("tsoil",tsoil,found,timeindex=indextime) 248 if (.not.found) then 249 write(*,*) "soil_settings: Failed loading <tsoil>" 250 call abort 251 endif 341 252 endif ! of if (interpol) 342 endif 253 endif! of if (.not.ok) 343 254 344 255 ! 5. If necessary, interpolate soil temperatures and thermal inertias -
trunk/LMDZ.GENERIC/libf/phystd/start2archive.F
r993 r1216 19 19 c======================================================================= 20 20 21 use infotrac, only: iniadvtrac, nqtot, tname 21 22 USE comsoil_h 22 USE comgeomfi_h 23 23 USE comgeomfi_h, ONLY: lati, long, area 24 ! use control_mod 25 use comgeomphy, only: initcomgeomphy 24 26 implicit none 25 27 … … 32 34 #include "logic.h" 33 35 #include "temps.h" 34 #include "control.h"36 !#include "control.h" 35 37 #include "ener.h" 36 38 37 39 #include "dimphys.h" 38 40 #include "planete.h" 39 #include"advtrac.h"41 !#include"advtrac.h" 40 42 #include "netcdf.inc" 41 43 … … 48 50 REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants 49 51 REAL teta(ip1jmp1,llm) ! temperature potentielle 50 REAL q(ip1jmp1,llm,nqmx)! champs advectes52 REAL,ALLOCATABLE :: q(:,:,:) ! champs advectes 51 53 REAL pks(ip1jmp1) ! exner (f pour filtre) 52 54 REAL pk(ip1jmp1,llm) … … 63 65 REAL tsoil(ngridmx,nsoilmx) ! Soil temperature 64 66 REAL co2ice(ngridmx) ! CO2 ice layer 65 REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqmx) 67 REAL q2(ngridmx,nlayermx+1) 68 REAL,ALLOCATABLE :: qsurf(:,:) 66 69 REAL emis(ngridmx) 67 70 INTEGER start,length … … 83 86 REAL ithS(ip1jmp1,nsoilmx) ! Soil Thermal Inertia 84 87 REAL co2iceS(ip1jmp1) 85 REAL q2S(ip1jmp1,llm+1),qsurfS(ip1jmp1,nqmx) 88 REAL q2S(ip1jmp1,llm+1) 89 REAL,ALLOCATABLE :: qsurfS(:,:) 86 90 REAL emisS(ip1jmp1) 87 91 … … 122 126 c----------------------------------------------------------------------- 123 127 128 CALL defrun_new(99, .TRUE. ) 124 129 grireg = .TRUE. 125 130 cursor = 1 ! added by AS in dimphys. 131 132 ! initialize "serial/parallel" related stuff 133 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 134 call initcomgeomphy 126 135 127 136 ! ALLOCATE ARRAYS IN comgeomfi_h (usually done in inifis) … … 134 143 c Lecture des donnees 135 144 c======================================================================= 136 ! Load tracer names: 137 call iniadvtrac(nq,numvanle) 138 ! Initialize global tracer indexes (stored in tracer.h) 139 ! ... this has to be done before phyetat0 140 call initracer(ngridmx,nqmx,tnom) 145 ! Load tracer number and names: 146 call iniadvtrac(nqtot,numvanle) 147 148 ! allocate arrays: 149 allocate(q(ip1jmp1,llm,nqtot)) 150 allocate(qsurf(ngridmx,nqtot)) 151 allocate(qsurfS(ip1jmp1,nqtot)) 141 152 142 153 fichnom = 'start.nc' 143 CALL dynetat0(fichnom,nq mx,vcov,ucov,teta,q,masse,154 CALL dynetat0(fichnom,nqtot,vcov,ucov,teta,q,masse, 144 155 . ps,phis,timedyn) 145 156 … … 173 184 Lmodif=0 174 185 175 CALL phyetat0 (ngridmx,fichnom,0,Lmodif,nsoilmx,nq mx,day_ini_fi,186 CALL phyetat0 (ngridmx,fichnom,0,Lmodif,nsoilmx,nqtot,day_ini_fi, 176 187 . timefi, 177 188 . tsurf,tsoil,emis,q2,qsurf, … … 286 297 call gr_fi_dyn(1,ngridmx,iip1,jjp1,emis,emisS) 287 298 call gr_fi_dyn(llm+1,ngridmx,iip1,jjp1,q2,q2S) 288 call gr_fi_dyn(nq mx,ngridmx,iip1,jjp1,qsurf,qsurfS)299 call gr_fi_dyn(nqtot,ngridmx,iip1,jjp1,qsurf,qsurfS) 289 300 call gr_fi_dyn(llm,ngridmx,iip1,jjp1,cloudfrac,cloudfracS) 290 301 call gr_fi_dyn(1,ngridmx,iip1,jjp1,hice,hiceS) … … 390 401 391 402 c----------------------------------------------------------------------- 392 c Ecriture du champs q ( q[1,nq mx] )393 c----------------------------------------------------------------------- 394 do iq=1,nq mx395 call write_archive(nid,ntime,tn om(iq),'tracer','kg/kg',403 c Ecriture du champs q ( q[1,nqtot] ) 404 c----------------------------------------------------------------------- 405 do iq=1,nqtot 406 call write_archive(nid,ntime,tname(iq),'tracer','kg/kg', 396 407 & 3,q(1,1,iq)) 397 408 end do 398 409 c----------------------------------------------------------------------- 399 c Ecriture du champs qsurf ( qsurf[1,nq mx] )400 c----------------------------------------------------------------------- 401 do iq=1,nq mx402 txt=trim(tn om(iq))//"_surf"410 c Ecriture du champs qsurf ( qsurf[1,nqtot] ) 411 c----------------------------------------------------------------------- 412 do iq=1,nqtot 413 txt=trim(tname(iq))//"_surf" 403 414 call write_archive(nid,ntime,txt,'Tracer on surface', 404 415 & 'kg.m-2',2,qsurfS(1,iq)) … … 448 459 ierr=NF_CLOSE(nid) 449 460 461 write(*,*) "start2archive: All is well that ends well." 462 450 463 end -
trunk/LMDZ.GENERIC/libf/phystd/stelang.F
r1174 r1216 65 65 C --------- 66 66 C 67 INTEGER kgrid 68 REAL ptim1,ptim2,ptim3, pflat 69 REAL psilon(kgrid),pcolon(kgrid),pmu0(kgrid),pfract(kgrid) 70 REAL psilat(kgrid), pcolat(kgrid) 67 INTEGER,INTENT(IN) :: kgrid 68 REAL,INTENT(IN) :: ptim1,ptim2,ptim3, pflat 69 REAL,INTENT(IN) :: psilon(kgrid),pcolon(kgrid) 70 REAL,INTENT(IN) :: psilat(kgrid), pcolat(kgrid) 71 REAL,INTENT(OUT) :: pmu0(kgrid),pfract(kgrid) 71 72 C 72 73 INTEGER jl … … 100 101 ztim3=pcolat(jl)*ptim3 101 102 pmu0(jl)=ztim1+ztim2*pcolon(jl)+ztim3*psilon(jl) 102 pmu0(jl)=pmu0(jl)/SQRT(pcolat(jl)**2 + (rap**2) *(psilat(jl)**2))103 pmu0(jl)=pmu0(jl)/SQRT(pcolat(jl)**2+(rap**2)*(psilat(jl)**2)) 103 104 104 105 ENDDO -
trunk/LMDZ.GENERIC/libf/phystd/surfini.F
r837 r1216 1 1 SUBROUTINE surfini(ngrid,nq,qsurf,psolaralb) 2 2 3 USE surfdat_h 4 USE tracer_h 3 USE surfdat_h, only: albedodat, albedice 4 USE tracer_h, only: igcm_co2_ice 5 use comgeomfi_h, only: lati 6 use planetwide_mod, only: planetwide_maxval, planetwide_minval 5 7 6 8 IMPLICIT NONE … … 17 19 #include "callkeys.h" 18 20 c 19 INTEGER ngrid,ig,icap20 INTEGER nq21 REAL piceco2(ngrid),psolaralb(ngrid)22 REAL qsurf(ngrid,nq) !tracer on surface (kg/m2)21 INTEGER,INTENT(IN) :: ngrid 22 INTEGER,INTENT(IN) :: nq 23 REAL,INTENT(OUT) :: psolaralb(ngrid) 24 REAL,INTENT(IN) :: qsurf(ngrid,nq) !tracer on surface (kg/m2) 23 25 24 EXTERNAL ISMIN,ISMAX25 INTEGER ISMIN,ISMAX26 INTEGER :: ig,icap 27 REAL :: min_albedo,max_albedo 26 28 c 27 29 c======================================================================= 28 30 29 c30 c calcul de piceco2 (kg/m2) a l'etat initial31 c ------------------------------------------32 31 33 32 DO ig=1,ngrid 34 33 psolaralb(ig)=albedodat(ig) 35 ! psolaralb(ig,2)=albedodat(ig)36 34 ENDDO 37 35 38 PRINT*,'surfini: minimum des donnees albedo', 39 s albedodat(ISMIN(ngrid,albedodat,1)) 40 PRINT*,'surfini: maximum des donnees albedo', 41 s albedodat(ISMAX(ngrid,albedodat,1)) 42 43 c calcul de psolaralb 44 c ------------------- 45 ! DO ig=1,ngrid 46 c IF (water) THEN 47 c if (qsurf(ig,nq).gt.0.005) then 48 c psolaralb(ig,1) = 0.4 49 c psolaralb(ig,2) = 0.4 50 c endif 51 c ENDIF 52 ! ENDDO ! of DO ig=1,ngrid 53 c IF there is more than 5 pr. um of h2o ice but no C02 ice, surface albedo is set to 0.4. 36 call planetwide_minval(albedodat,min_albedo) 37 call planetwide_maxval(albedodat,max_albedo) 38 write(*,*) 'surfini: minimum corrected albedo',min_albedo 39 write(*,*) 'surfini: maximum corrected albedo',max_albedo 54 40 55 41 if (igcm_co2_ice.ne.0) then … … 57 43 DO ig=1,ngrid 58 44 IF (qsurf(ig,igcm_co2_ice) .GT. 0.) THEN 59 !!!! no good in parallel 60 IF(ig.GT.ngrid/2+1) THEN 61 icap=2 45 IF(lati(ig).LT.0.) THEN 46 icap=2 ! Southern hemisphere 62 47 ELSE 63 icap=1 48 icap=1 ! Northern hemisphere 64 49 ENDIF 65 50 psolaralb(ig) = albedice(icap) 66 ! psolaralb(ig,2) = albedice(icap)67 51 END IF 68 52 ENDDO ! of DO ig=1,ngrid … … 72 56 endif 73 57 74 PRINT*,'surfini: minimum des donnees albedo',75 s psolaralb(ISMIN(ngrid,psolaralb,1))76 PRINT*,'surfini: maximum des donnees albedo',77 s psolaralb(ISMAX(ngrid,psolaralb,1))58 call planetwide_minval(psolaralb,min_albedo) 59 call planetwide_maxval(psolaralb,max_albedo) 60 write(*,*) 'surfini: minimum corrected albedo',min_albedo 61 write(*,*) 'surfini: maximum corrected albedo',max_albedo 78 62 79 RETURN80 63 END -
trunk/LMDZ.GENERIC/libf/phystd/tabfi.F
r787 r1216 44 44 c======================================================================= 45 45 ! to use 'getin' 46 use ioipsl_getincom 47 48 USE surfdat_h 49 use comsoil_h 50 USE comgeomfi_h 46 use ioipsl_getincom , only: getin 47 48 use surfdat_h, only: albedice, emisice, iceradius, dtemisice, 49 & emissiv 50 use comsoil_h, only: volcapa 51 use iostart, only: get_var 52 use mod_phys_lmdz_para, only: is_parallel 51 53 52 54 implicit none 53 55 54 #include "dimensions.h"55 #include "dimphys.h"56 56 #include "comcstfi.h" 57 57 #include "planete.h" … … 63 63 c----------------------------------------------------------------------- 64 64 65 INTEGER ngrid66 67 65 c Arguments 68 66 c --------- 69 INTEGER nid,nvarid,tab070 INTEGER*4 day_ini71 INTEGER Lmodif72 INTEGER lmax73 REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time67 INTEGER,INTENT(IN) :: ngrid,nid,tab0 68 INTEGER*4,INTENT(OUT) :: day_ini 69 INTEGER,INTENT(IN) :: Lmodif 70 INTEGER,INTENT(OUT) :: lmax 71 REAL,INTENT(OUT) :: p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time 74 72 75 73 c Variables 76 74 c --------- 77 INTEGER length 78 parameter (length = 100) 75 INTEGER,PARAMETER :: length=100 79 76 REAL tab_cntrl(length) ! array in which are stored the run's parameters 80 INTEGER ierr 77 INTEGER ierr,nvarid 81 78 INTEGER size 82 79 CHARACTER modif*20 83 80 LOGICAL :: found 81 82 write(*,*)"tabfi: nid=",nid," tab0=",tab0," Lmodif=",Lmodif 83 84 IF (nid.eq.0) then 85 c----------------------------------------------------------------------- 86 c Initialization of various physical constants to defaut values (nid = 0 case) 87 c----------------------------------------------------------------------- 88 ELSE 84 89 c----------------------------------------------------------------------- 85 90 c Initialization of physical constants by reading array tab_cntrl(:) … … 88 93 c Read 'controle' array 89 94 c 90 ierr = NF_INQ_VARID (nid, "controle", nvarid) 91 IF (ierr .NE. NF_NOERR) THEN 92 PRINT*, "Tabfi: Could not find <controle> data" 93 CALL abort 94 ENDIF 95 #ifdef NC_DOUBLE 96 ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl) 97 #else 98 ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl) 99 #endif 100 IF (ierr .NE. NF_NOERR) THEN 101 PRINT*, "Tabfi: Failed reading <controle> array" 102 CALL abort 103 ENDIF 104 105 print*,'tabfi: tab_cntrl',tab_cntrl 95 96 call get_var("controle",tab_cntrl,found) 97 if (.not.found) then 98 write(*,*)"tabfi: Failed reading <controle> array" 99 call abort 100 else 101 write(*,*)'tabfi: tab_cntrl',tab_cntrl 102 endif 106 103 c 107 104 c Initialization of some physical constants 108 105 c informations on physics grid 109 if(ngrid.ne.tab_cntrl(tab0+1)) then110 print*,'tabfi: WARNING !!! tab_cntrl(tab0+1).ne.ngrid'111 print*,tab_cntrl(tab0+1),ngrid112 endif106 ! if(ngrid.ne.tab_cntrl(tab0+1)) then 107 ! print*,'tabfi: WARNING !!! tab_cntrl(tab0+1).ne.ngrid' 108 ! print*,tab_cntrl(tab0+1),ngrid 109 ! endif 113 110 lmax = nint(tab_cntrl(tab0+2)) 114 111 day_ini = tab_cntrl(tab0+3) … … 146 143 c soil properties 147 144 volcapa = tab_cntrl(tab0+35) ! volumetric heat capacity 148 149 150 151 152 145 c----------------------------------------------------------------------- 153 146 c Save some constants for later use (as routine arguments) … … 160 153 p_rad=rad 161 154 155 ENDIF ! end of (nid = 0) 162 156 163 157 c----------------------------------------------------------------------- … … 209 203 c----------------------------------------------------------------------- 210 204 c Modifications... 205 ! NB: Modifying controls should only be done by newstart, and in seq mode 206 if ((Lmodif.eq.1).and.is_parallel) then 207 write(*,*) "tabfi: Error modifying tab_control should", 208 & " only happen in serial mode (eg: by newstart)" 209 stop 210 endif 211 211 c----------------------------------------------------------------------- 212 212 -
trunk/LMDZ.GENERIC/libf/phystd/write_archive.F
r993 r1216 32 32 c======================================================================= 33 33 34 use comsoil_h, only: nsoilmx 34 35 implicit none 35 36 36 37 #include "dimensions.h" 37 #include "dimphys.h"38 38 #include "paramet.h" 39 #include "control.h"40 39 #include "comvert.h" 41 40 #include "comgeom.h" -
trunk/LMDZ.GENERIC/libf/phystd/writediagfi.F
r993 r1216 39 39 ! 40 40 !================================================================= 41 42 USE surfdat_h 43 #ifdef CPP_PARA 41 use surfdat_h, only: phisfi 42 use control_mod, only: ecritphy, day_step, iphysiq 44 43 USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root, 45 44 & is_master, gather 46 45 USE mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 47 #endif48 46 implicit none 49 47 50 48 ! Commons 51 #include "dimensions.h" 52 #include "dimphys.h" 53 #include "paramet.h" 54 #include "control.h" 55 #include "comvert.h" 56 #include "comgeom.h" 57 #include "netcdf.inc" 58 #include "temps.h" 49 include "dimensions.h" 50 include "paramet.h" 51 include "comvert.h" 52 include "comgeom.h" 53 include "netcdf.inc" 54 include "temps.h" 59 55 60 56 ! Arguments on input: … … 73 69 real*4,save :: date 74 70 75 REAL phis(ip1jmp1) ! surface geopotential on extended lonxlat grid71 REAL phis(ip1jmp1) 76 72 77 73 integer irythme … … 96 92 integer,save :: n_nom_def 97 93 integer :: n 98 integer,parameter :: n_nom_def_max= 9999 character(len= 20),save :: nom_def(n_nom_def_max)94 integer,parameter :: n_nom_def_max=199 95 character(len=120),save :: nom_def(n_nom_def_max) 100 96 logical,save :: firstcall=.true. 101 102 integer dimvert 97 98 #ifndef MESOSCALE 103 99 104 100 #ifdef CPP_PARA … … 113 109 real phisfi_glo(klon_glo) ! surface geopotential on global physics grid 114 110 #else 115 logical,parameter :: is_parallel=.false.116 logical,parameter :: is_master=.true.117 logical,parameter :: is_mpi_root=.true.118 111 real phisfi_glo(ngrid) ! surface geopotential on global physics grid 119 112 #endif 113 120 114 !*************************************************************** 121 115 !Sortie des variables au rythme voulu 122 116 123 irythme = int(ecritphy)! sortie au rythme de ecritphy117 irythme = ecritphy ! sortie au rythme de ecritphy 124 118 ! irythme = iconser ! sortie au rythme des variables de controle 125 119 ! irythme = iphysiq ! sortie a tous les pas physique … … 129 123 !*************************************************************** 130 124 131 132 125 ! At very first call, check if there is a "diagfi.def" to use and read it 133 126 ! ----------------------------------------------------------------------- … … 135 128 firstcall=.false. 136 129 137 ! Open diagfi.def definition file if there is one:130 ! Open diagfi.def definition file if there is one: 138 131 open(99,file="diagfi.def",status='old',form='formatted', 139 132 s iostat=ierr2) … … 170 163 end if 171 164 172 173 165 ! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file 174 166 ! ------------------------------------------------------------------------ … … 185 177 stop 186 178 endif 187 179 188 180 zitau = -1 ! initialize zitau 189 181 … … 240 232 ! are undefined; so set them to 1 241 233 iphysiq=1 242 !JL11irythme=1234 irythme=1 243 235 ! NB: 244 236 endif … … 546 538 endif 547 539 540 #endif 548 541 end 549 -
trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90
r965 r1216 10 10 ! (yielding the sought time series of the variable) 11 11 12 #ifdef CPP_PARA 12 ! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4 13 14 use comsoil_h, only: nsoilmx 15 use control_mod, only: ecritphy, day_step, iphysiq 13 16 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather 14 17 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 15 #endif16 18 17 19 implicit none 18 20 19 21 #include"dimensions.h" 20 #include"dimphys.h"21 22 #include"paramet.h" 22 #include"control.h"23 23 #include"netcdf.inc" 24 24 … … 31 31 integer,intent(in) :: dimpx ! dimension of the variable (3,2 or 0) 32 32 real,dimension(ngrid,nsoilmx),intent(in) :: px ! variable 33 ! Note: nsoilmx is a common parameter set in 'dimphys.h'33 ! Note: nsoilmx is a parameter set in 'comsoil_h' 34 34 35 35 ! Local variables: 36 real ,dimension(iip1,jjp1,nsoilmx) :: data3 ! to store 3D data on extended lonxlat grid37 ! Note iip1,jjp1 known from paramet.h; nsoilmx known from dimphys.h38 real ,dimension(iip1,jjp1) :: data2 ! to store 2D data on extended lonxlat grid39 real :: data0 ! to store 0D data36 real*4,dimension(iip1,jjp1,nsoilmx) :: data3 ! to store 3D data 37 ! Note iip1,jjp1 known from paramet.h; nsoilmx known from comsoil_h 38 real*4,dimension(iip1,jjp1) :: data2 ! to store 2D data 39 real*4 :: data0 ! to store 0D data 40 40 integer :: i,j,l ! for loops 41 41 integer :: ig0 42 42 43 real ,save :: date ! time counter (in elapsed days)43 real*4,save :: date ! time counter (in elapsed days) 44 44 integer,save :: isample ! sample rate at which data is to be written to output 45 45 integer,save :: ntime=0 ! counter to internally store time steps … … 63 63 real dx2_glo(iim,jjp1) ! to store a global 2D (surface) data set 64 64 real px2(ngrid) 65 #else66 logical,parameter :: is_master=.true.67 logical,parameter :: is_mpi_root=.true.68 65 #endif 69 66 … … 83 80 84 81 ! Set output sample rate 85 isample= int(ecritphy)! same as for diagfi outputs82 isample=ecritphy ! same as for diagfi outputs 86 83 ! Note ecritphy is known from control.h 87 84 … … 128 125 ierr=NF_INQ_VARID(nid,"time",varid) 129 126 ! Add the current value of date to the "time" array 130 #ifdef NC_DOUBLE131 ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)132 #else127 !#ifdef NC_DOUBLE 128 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date) 129 !#else 133 130 ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date) 134 #endif131 !#endif 135 132 if (ierr.ne.NF_NOERR) then 136 133 write(*,*)"writediagsoil: Failed writing date to time variable" … … 203 200 204 201 ! B.3. Write the slab of data 205 #ifdef NC_DOUBLE206 ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data3)207 #else202 !#ifdef NC_DOUBLE 203 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data3) 204 !#else 208 205 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3) 209 #endif206 !#endif 210 207 if (ierr.ne.NF_NOERR) then 211 208 write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//& … … 273 270 274 271 ! B.3. Write the slab of data 275 #ifdef NC_DOUBLE276 ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data2)277 #else272 !#ifdef NC_DOUBLE 273 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data2) 274 !#else 278 275 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2) 279 #endif276 !#endif 280 277 if (ierr.ne.NF_NOERR) then 281 278 write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//& … … 312 309 313 310 ! B.3. Write the data 314 #ifdef NC_DOUBLE315 ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data0)316 #else311 !#ifdef NC_DOUBLE 312 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data0) 313 !#else 317 314 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data0) 318 #endif315 !#endif 319 316 if (ierr.ne.NF_NOERR) then 320 317 write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//& -
trunk/LMDZ.GENERIC/libf/phystd/writediagspecIR.F
r993 r1216 48 48 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 49 49 #endif 50 use control_mod, only: ecritphy, iphysiq, day_step 50 51 51 52 implicit none … … 55 56 #include "dimphys.h" 56 57 #include "paramet.h" 57 #include "control.h"58 !#include "control.h" 58 59 #include "comvert.h" 59 60 #include "comgeom.h" … … 114 115 !Sortie des variables au rythme voulu 115 116 116 irythme = int(ecritphy)*iradia ! sortie au rythme de ecritphy*iradia117 irythme = ecritphy*iradia ! sortie au rythme de ecritphy*iradia 117 118 !EM+JL if the spetra need to be output more frequently, need to define a ecritSpec... 118 119 ! irythme = iphysiq ! sortie a tous les pas physique -
trunk/LMDZ.GENERIC/libf/phystd/writediagspecVI.F
r993 r1216 48 48 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 49 49 #endif 50 use control_mod, only: ecritphy, iphysiq, day_step 50 51 51 52 implicit none … … 55 56 #include "dimphys.h" 56 57 #include "paramet.h" 57 #include "control.h"58 !#include "control.h" 58 59 #include "comvert.h" 59 60 #include "comgeom.h" … … 114 115 !Sortie des variables au rythme voulu 115 116 116 irythme = int(ecritphy)*iradia ! sortie au rythme de ecritphy117 irythme = ecritphy*iradia ! sortie au rythme de ecritphy 117 118 !EM+JL if the spetra need to be output more frequently, need to define a ecritSpec... 118 119 ! irythme = iphysiq ! sortie a tous les pas physique -
trunk/LMDZ.GENERIC/libf/phystd/wstats.F90
r965 r1216 1 1 subroutine wstats(ngrid,nom,titre,unite,dim,px) 2 2 3 #ifdef CPP_PARA4 3 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin 5 4 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 6 #endif7 5 8 6 implicit none … … 47 45 real px2_glop(ngrid) ! to store a 2D data set on global physics grid 48 46 real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid 49 logical,parameter :: is_master=.true.50 logical,parameter :: is_mpi_root=.true.51 integer,parameter :: klon_mpi_begin=152 47 #endif 53 48 … … 290 285 endif ! of if (is_master) 291 286 292 end 287 end subroutine wstats 293 288 294 289 !====================================================== … … 367 362 endif 368 363 369 end 364 end subroutine inivar 365 366 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 367 368 subroutine def_var_stats(nid,name,title,units,nbdim,dimids,nvarid,ierr) 369 370 ! This subroutine defines variable 'name' in a (pre-existing and opened) 371 ! NetCDF file (known from its NetCDF ID 'nid'). 372 ! The number of dimensions 'nbdim' of the variable, as well as the IDs of 373 ! corresponding dimensions must be set (in array 'dimids'). 374 ! Upon successfull definition of the variable, 'nvarid' contains the 375 ! NetCDF ID of the variable. 376 ! The variables' attributes 'title' (Note that 'long_name' would be more 377 ! appropriate) and 'units' are also set. 378 379 implicit none 380 381 #include "netcdf.inc" 382 383 integer,intent(in) :: nid ! NetCDF file ID 384 character(len=*),intent(in) :: name ! the variable's name 385 character(len=*),intent(in) :: title ! 'title' attribute of variable 386 character(len=*),intent(in) :: units ! 'units' attribute of variable 387 integer,intent(in) :: nbdim ! number of dimensions of the variable 388 integer,dimension(nbdim),intent(in) :: dimids ! NetCDF IDs of the dimensions 389 ! the variable is defined along 390 integer,intent(out) :: nvarid ! NetCDF ID of the variable 391 integer,intent(out) :: ierr ! returned NetCDF staus code 392 393 ! 1. Switch to NetCDF define mode 394 ierr=NF_REDEF(nid) 395 396 ! 2. Define the variable 397 #ifdef NC_DOUBLE 398 ierr = NF_DEF_VAR (nid,adjustl(name),NF_DOUBLE,nbdim,dimids,nvarid) 399 #else 400 ierr = NF_DEF_VAR (nid,adjustl(name),NF_FLOAT,nbdim,dimids,nvarid) 401 #endif 402 if(ierr/=NF_NOERR) then 403 write(*,*) "def_var_stats: Failed defining variable "//trim(name) 404 write(*,*) NF_STRERROR(ierr) 405 stop "" 406 endif 407 408 ! 3. Write attributes 409 ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",& 410 len_trim(adjustl(title)),adjustl(title)) 411 if(ierr/=NF_NOERR) then 412 write(*,*) "def_var_stats: Failed writing title attribute for "//trim(name) 413 write(*,*) NF_STRERROR(ierr) 414 stop "" 415 endif 416 417 ierr=NF_PUT_ATT_TEXT(nid,nvarid,"units",& 418 len_trim(adjustl(units)),adjustl(units)) 419 if(ierr/=NF_NOERR) then 420 write(*,*) "def_var_stats: Failed writing units attribute for "//trim(name) 421 write(*,*) NF_STRERROR(ierr) 422 stop "" 423 endif 424 425 ! 4. Switch out of NetCDF define mode 426 ierr = NF_ENDDEF(nid) 427 428 end subroutine def_var_stats 429 -
trunk/LMDZ.GENERIC/makegcm_g95
r988 r1216 15 15 set bands="32x36" 16 16 set scatterers="1" 17 set full="" 17 18 ######################################################################## 18 19 # path a changer contenant les sources et les objets du modele … … 273 274 latitudes and vertical layers respectively. 274 275 275 -t ntrac Selects the number of tracers present in the model276 277 Options -d and -t overwrite file278 $LMDGCM/libf/grid/dimensions.h279 which contains the 3 dimensions of the280 horizontal grid281 im, jm, lm plus the number of tracers passively advected282 by the dynamics ntrac,283 in 4 PARAMETER FORTRAN format284 with a new file:285 $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac286 If the file does not exist already287 it is created by the script288 $LMDGCM/libf/grid/dimension/makdim289 290 276 -s nscat Number of radiatively active scatterers 291 277 … … 331 317 there is no need to specify -Ldirn. 332 318 319 -full Full (re)compilation (from scratch) 320 333 321 eod 334 322 exit … … 367 355 case -olddyn 368 356 set dyntype="olddyn" ; shift; goto top 357 358 case -full 359 set full="full" ; shift ; goto top 369 360 370 361 case -filtre … … 527 518 # Build the appropriate 'dimensions.h' file 528 519 cd dimension 529 ./makdim $ ntrac $dim520 ./makdim $dim 530 521 # echo contents of dimensions.h to standard output 531 522 cat $libf/grid/dimensions.h … … 559 550 echo dimension $dimension dim $dim 560 551 if ( $dimension == 1 ) then 561 echo pas de dynamique 562 set dyn="L_DYN= DYN= L_FILTRE= " 552 echo "No dynamics" 553 ## set dyn="L_DYN= DYN= L_FILTRE= " 554 ## NB: we still need to have L_DYN=libdyn3d to reach routines and module 555 ## objects which are located in dyn3d 556 set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique " 563 557 endif 564 558 endif … … 588 582 589 583 echo "dimc $dimc" 584 585 #cleanup for a full recompilation, if requested 586 if ("$full" == "full") then 587 # remove makefile and $libo 588 cd $model 589 \rm -f makefile 590 \rm -rf $libo/* 591 endif 590 592 591 593 ######################################################################## -
trunk/LMDZ.GENERIC/makegcm_gfortran
r989 r1216 15 15 set bands="32x36" 16 16 set scatterers="1" 17 set full="" 17 18 ######################################################################## 18 19 # path a changer contenant les sources et les objets du modele … … 184 185 set optim90="-O3 -funroll-loops " 185 186 set optimtru90="-O3 -funroll-loops " 186 set opt_link=" -L$NCDFLIB -lnetcdf -lnetcdff"187 set opt_link=" -L$NCDFLIB -lnetcdf " 187 188 188 189 #NB: on gnome -O3 ==> NaNs ... … … 274 275 latitudes and vertical layers respectively. 275 276 276 -t ntrac Selects the number of tracers present in the model277 278 Options -d and -t overwrite file279 $LMDGCM/libf/grid/dimensions.h280 which contains the 3 dimensions of the281 horizontal grid282 im, jm, lm plus the number of tracers passively advected283 by the dynamics ntrac,284 in 4 PARAMETER FORTRAN format285 with a new file:286 $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac287 If the file does not exist already288 it is created by the script289 $LMDGCM/libf/grid/dimension/makdim290 291 277 -s nscat Number of radiatively active scatterers 292 278 … … 332 318 there is no need to specify -Ldirn. 333 319 320 -full Full (re)compilation (from scratch) 321 334 322 eod 335 323 exit … … 368 356 case -olddyn 369 357 set dyntype="olddyn" ; shift; goto top 358 359 case -full 360 set full="full" ; shift ; goto top 370 361 371 362 case -filtre … … 532 523 # Build the appropriate 'dimensions.h' file 533 524 cd dimension 534 ./makdim $ ntrac $dim525 ./makdim $dim 535 526 # echo contents of dimensions.h to standard output 536 527 cat $libf/grid/dimensions.h … … 564 555 echo dimension $dimension dim $dim 565 556 if ( $dimension == 1 ) then 566 echo pas de dynamique 567 set dyn="L_DYN= DYN= L_FILTRE= " 557 echo "No dynamics" 558 ## set dyn="L_DYN= DYN= L_FILTRE= " 559 ## NB: we still need to have L_DYN=libdyn3d to reach routines and module 560 ## objects which are located in dyn3d 561 set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique " 568 562 endif 569 563 endif … … 593 587 594 588 echo "dimc $dimc" 589 590 #cleanup for a full recompilation, if requested 591 if ("$full" == "full") then 592 # remove makefile and $libo 593 cd $model 594 \rm -f makefile 595 \rm -rf $libo/* 596 endif 595 597 596 598 ######################################################################## … … 657 659 set f77="gfortran -ffree-line-length-264" 658 660 set f90="gfortran -ffree-line-length-264" 659 set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdff -lnetcdf " 661 # set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdff -lnetcdf " 662 set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdf " 660 663 else if $SUN then 661 664 set f77=f90 -
trunk/LMDZ.GENERIC/makegcm_ifort
r988 r1216 15 15 set bands="32x36" 16 16 set scatterers="1" 17 set full="" 17 18 ######################################################################## 18 19 # path a changer contenant les sources et les objets du modele … … 279 280 latitudes and vertical layers respectively. 280 281 281 -t ntrac Selects the number of tracers present in the model282 283 Options -d and -t overwrite file284 $LMDGCM/libf/grid/dimensions.h285 which contains the 3 dimensions of the286 horizontal grid287 im, jm, lm plus the number of tracers passively advected288 by the dynamics ntrac,289 in 4 PARAMETER FORTRAN format290 with a new file:291 $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac292 If the file does not exist already293 it is created by the script294 $LMDGCM/libf/grid/dimension/makdim295 296 282 -s nscat Number of radiatively active scatterers 297 283 … … 337 323 there is no need to specify -Ldirn. 338 324 325 -full Full (re)compilation (from scratch) 326 339 327 eod 340 328 exit … … 373 361 case -olddyn 374 362 set dyntype="olddyn" ; shift; goto top 363 364 case -full 365 set full="full" ; shift ; goto top 375 366 376 367 case -filtre … … 534 525 # Build the appropriate 'dimensions.h' file 535 526 cd dimension 536 ./makdim $ ntrac $dim527 ./makdim $dim 537 528 # echo contents of dimensions.h to standard output 538 529 cat $libf/grid/dimensions.h … … 566 557 echo dimension $dimension dim $dim 567 558 if ( $dimension == 1 ) then 568 echo pas de dynamique 569 set dyn="L_DYN= DYN= L_FILTRE= " 559 echo "No dynamics" 560 ## set dyn="L_DYN= DYN= L_FILTRE= " 561 ## NB: we still need to have L_DYN=libdyn3d to reach routines and module 562 ## objects which are located in dyn3d 563 set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique " 570 564 endif 571 565 endif … … 595 589 596 590 echo "dimc $dimc" 591 592 #cleanup for a full recompilation, if requested 593 if ("$full" == "full") then 594 # remove makefile and $libo 595 cd $model 596 \rm -f makefile 597 \rm -rf $libo/* 598 endif 597 599 598 600 ######################################################################## -
trunk/LMDZ.GENERIC/makegcm_pgf90
r988 r1216 15 15 set bands="32x36" 16 16 set scatterers="1" 17 set full="" 17 18 ######################################################################## 18 19 # path a changer contenant les sources et les objets du modele … … 271 272 latitudes and vertical layers respectively. 272 273 273 -t ntrac Selects the number of tracers present in the model274 275 Options -d and -t overwrite file276 $LMDGCM/libf/grid/dimensions.h277 which contains the 3 dimensions of the278 horizontal grid279 im, jm, lm plus the number of tracers passively advected280 by the dynamics ntrac,281 in 4 PARAMETER FORTRAN format282 with a new file:283 $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac284 If the file does not exist already285 it is created by the script286 $LMDGCM/libf/grid/dimension/makdim287 288 274 -s nscat Number of radiatively active scatterers 289 275 … … 329 315 there is no need to specify -Ldirn. 330 316 317 -full Full (re)compilation (from scratch) 318 331 319 eod 332 320 exit … … 365 353 case -olddyn 366 354 set dyntype="olddyn" ; shift; goto top 355 356 case -full 357 set full="full" ; shift ; goto top 367 358 368 359 case -filtre … … 529 520 # Build the appropriate 'dimensions.h' file 530 521 cd dimension 531 ./makdim $ ntrac $dim522 ./makdim $dim 532 523 # echo contents of dimensions.h to standard output 533 524 cat $libf/grid/dimensions.h … … 561 552 echo dimension $dimension dim $dim 562 553 if ( $dimension == 1 ) then 563 echo pas de dynamique 564 set dyn="L_DYN= DYN= L_FILTRE= " 554 echo "No dynamics" 555 ## set dyn="L_DYN= DYN= L_FILTRE= " 556 ## NB: we still need to have L_DYN=libdyn3d to reach routines and module 557 ## objects which are located in dyn3d 558 set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique " 565 559 endif 566 560 endif … … 590 584 591 585 echo "dimc $dimc" 586 587 #cleanup for a full recompilation, if requested 588 if ("$full" == "full") then 589 # remove makefile and $libo 590 cd $model 591 \rm -f makefile 592 \rm -rf $libo/* 593 endif 592 594 593 595 ########################################################################
Note: See TracChangeset
for help on using the changeset viewer.