Changeset 1532
- Timestamp:
- Apr 7, 2016, 3:53:15 PM (9 years ago)
- Location:
- trunk/LMDZ.MARS
- Files:
-
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/README
r1528 r1532 2243 2243 - Added "ioipsl_getin_p_mod.F90" (getin_p routine) in phy_common to 2244 2244 correctly read in parameters from *.def files in a parallel environment. 2245 2246 == 07/04/2016 == EM 2247 - Some fixes for buggy outputs in 1D introduced by previous code modifications. 2248 - made statto.h a module. 2249 - ecritphy in dyn3d/control_mod.F90 should be an integer, not a real. -
trunk/LMDZ.MARS/libf/dyn3d/control_mod.F90
r1416 r1532 12 12 integer,save :: anneeref ! reference year # ! not used 13 13 real,save :: periodav 14 real,save :: ecritphy ! output data in "diagfi.nc" every ecritphy dynamical steps14 integer,save :: ecritphy ! output data in "diagfi.nc" every ecritphy dynamical steps 15 15 integer,save :: ecritstart ! output data in "start.nc" every ecritstart dynamical steps 16 16 real,save :: timestart ! time start for run in "start.nc" -
trunk/LMDZ.MARS/libf/phymars/inistats.F
r1528 r1532 1 1 subroutine inistats(ierr) 2 2 3 use statto_mod, only: istats,istime 3 4 use mod_phys_lmdz_para, only : is_master 4 5 USE comvert_mod, ONLY: ap,bp,aps,bps,preff,pseudoalt,presnivs … … 9 10 implicit none 10 11 11 include "statto.h"12 12 include "netcdf.inc" 13 13 … … 16 16 integer :: l,nsteppd 17 17 real, dimension(nbp_lev) :: sig_s 18 real :: lon_reg_ext(nbp_lon+1) ! extended longitudes18 real,allocatable :: lon_reg_ext(:) ! extended longitudes 19 19 integer :: idim_lat,idim_lon,idim_llm,idim_llmp1,idim_time 20 20 real, dimension(istime) :: lt 21 21 integer :: nvarid 22 22 23 24 IF (nbp_lon*nbp_lat==1) THEN 25 ! 1D model 26 ALLOCATE(lon_reg_ext(1)) 27 ELSE 28 ! 3D model 29 ALLOCATE(lon_reg_ext(nbp_lon+1)) 30 ENDIF 31 23 32 write (*,*) 24 33 write (*,*) ' || STATS ||' … … 46 55 47 56 lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon) 48 !add extra redundant point (180 degrees, since lon_reg starts at -180 49 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 57 IF (nbp_lon*nbp_lat/=1) THEN 58 ! In 3D, add extra redundant point (180 degrees, 59 ! since lon_reg starts at -180) 60 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 61 ENDIF 50 62 51 63 if (is_master) then … … 59 71 60 72 ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_lat) 61 ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_lon) 73 IF (nbp_lon*nbp_lat==1) THEN 74 ierr = NF_DEF_DIM (nid, "longitude", 1, idim_lon) 75 ELSE 76 ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_lon) 77 ENDIF 62 78 ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm) 63 79 ierr = NF_DEF_DIM (nid, "llmp1", nbp_lev+1, idim_llmp1) -
trunk/LMDZ.MARS/libf/phymars/iniwrite.F
r1528 r1532 1 SUBROUTINE iniwrite(nid,idayref,phis,area )1 SUBROUTINE iniwrite(nid,idayref,phis,area,nbplon,nbplat) 2 2 3 3 use comsoil_h, only: mlayer, nsoilmx … … 35 35 integer,intent(in) :: nid ! NetCDF file ID 36 36 INTEGER*4,intent(in) :: idayref ! date (initial date for this run) 37 real,intent(in) :: phis(nbp_lon+1,nbp_lat) ! surface geopotential 38 real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2) 37 real,intent(in) :: phis(nbplon,nbp_lat) ! surface geopotential 38 real,intent(in) :: area(nbplon,nbp_lat) ! mesh area (m2) 39 integer,intent(in) :: nbplon,nbplat ! sizes of area and phis arrays 39 40 40 41 c Local: … … 44 45 REAL tab_cntrl(length) ! run parameters are stored in this array 45 46 INTEGER ierr 46 REAl :: lon_reg_ext(nbp_lon+1) ! extended longitudes47 REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes 47 48 48 49 integer :: nvarid,idim_index,idim_rlonv … … 51 52 integer, dimension(2) :: id 52 53 c----------------------------------------------------------------------- 54 55 IF (nbp_lon*nbp_lat==1) THEN 56 ! 1D model 57 ALLOCATE(lon_reg_ext(1)) 58 ELSE 59 ! 3D model 60 ALLOCATE(lon_reg_ext(nbp_lon+1)) 61 ENDIF 53 62 54 63 DO l=1,length … … 104 113 ! ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) 105 114 ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu) 106 ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv) 115 IF (nbp_lon*nbp_lat==1) THEN 116 ierr = NF_DEF_DIM (nid, "longitude", 1, idim_rlonv) 117 ELSE 118 ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv) 119 ENDIF 107 120 ! ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) 108 121 ierr = NF_DEF_DIM (nid, "interlayer", (nbp_lev+1), idim_llmp1) … … 166 179 c 167 180 c -------------------------- 181 168 182 lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon) 169 !add extra redundant point (180 degrees, since lon_reg starts at -180 170 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 183 IF (nbp_lon*nbp_lat/=1) THEN 184 ! In 3D, add extra redundant point (180 degrees, 185 ! since lon_reg starts at -180) 186 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 187 ENDIF 171 188 172 189 ierr = NF_REDEF (nid) -
trunk/LMDZ.MARS/libf/phymars/iniwritesoil.F90
r1528 r1532 1 subroutine iniwritesoil(nid,ngrid,inertia,area )1 subroutine iniwritesoil(nid,ngrid,inertia,area,nbplon,nbplat) 2 2 3 3 ! initialization routine for 'writediagoil'. Here we create/define … … 17 17 integer,intent(in) :: ngrid 18 18 integer,intent(in) :: nid ! NetCDF output file ID 19 real,intent(in) :: inertia(nbp_lon+1,nbp_lat,nsoilmx) 20 real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2) 19 real,intent(in) :: inertia(nbplon,nbplat,nsoilmx) 20 real,intent(in) :: area(nbplon,nbp_lat) ! mesh area (m2) 21 integer,intent(in) :: nbplon,nbplat ! sizes of area 21 22 22 23 ! Local variables: … … 33 34 real,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data 34 35 integer :: i,j,l,ig0 35 real :: lon_reg_ext(nbp_lon+1) ! extended longitudes 36 real,allocatable :: lon_reg_ext(:) ! extended longitudes 37 38 39 if (nbp_lon*nbp_lat==1) then 40 ! 1D model 41 allocate(lon_reg_ext(1)) 42 else 43 ! 3D model 44 allocate(lon_reg_ext(nbp_lon+1)) 45 endif 36 46 37 47 ! 1. Define the dimensions … … 40 50 41 51 ! Define the dimensions 42 ierr=NF_DEF_DIM(nid,"longitude",nbp_lon+1,idim_rlonv) 52 if (nbp_lon*nbp_lat==1) then 53 ierr=NF_DEF_DIM(nid,"longitude",1,idim_rlonv) 54 else 55 ierr=NF_DEF_DIM(nid,"longitude",nbp_lon+1,idim_rlonv) 56 endif 43 57 if (ierr.ne.NF_NOERR) then 44 58 write(*,*)"iniwritesoil: Error, could not define longitude dimension" … … 82 96 83 97 lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon) 84 !add extra redundant point (180 degrees, since lon_reg starts at -180 85 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 98 if (nbp_lon*nbp_lat/=1) then ! in 3D only: 99 ! add extra redundant point (180 degrees, since lon_reg starts at -180 100 lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) 101 endif 86 102 87 103 ! Write longitude to file -
trunk/LMDZ.MARS/libf/phymars/mkstat.F90
r1528 r1532 10 10 ! Yann W. july 2003 11 11 12 use statto_mod, only: istime,count 12 13 use mod_phys_lmdz_para, only : is_master 13 use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev 14 use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev, klon_glo 14 15 15 16 implicit none 16 17 17 include "statto.h"18 18 include "netcdf.inc" 19 19 … … 22 22 integer, dimension(5) :: dimids 23 23 character (len=50) :: name,nameout,units,title 24 real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: sum3d,square3d,mean3d,sd3d25 real, dimension(nbp_lon+1,nbp_lat) :: sum2d,square2d,mean2d,sd2d24 real,allocatable :: sum3d(:,:,:),square3d(:,:,:),mean3d(:,:,:),sd3d(:,:,:) 25 real,allocatable :: sum2d(:,:),square2d(:,:),mean2d(:,:),sd2d(:,:) 26 26 real, dimension(istime) :: time 27 27 real, dimension(nbp_lat) :: lat 28 real, dimension(nbp_lon+1) :: lon28 real,allocatable :: lon(:) 29 29 real, dimension(nbp_lev) :: alt 30 30 logical :: lcopy=.true. … … 38 38 if (is_master) then 39 39 ! only the master needs do this 40 if (klon_glo>1) then 41 allocate(lon(nbp_lon+1)) 42 allocate(sum3d(nbp_lon+1,nbp_lat,nbp_lev)) 43 allocate(square3d(nbp_lon+1,nbp_lat,nbp_lev)) 44 allocate(mean3d(nbp_lon+1,nbp_lat,nbp_lev)) 45 allocate(sd3d(nbp_lon+1,nbp_lat,nbp_lev)) 46 allocate(sum2d(nbp_lon+1,nbp_lat)) 47 allocate(square2d(nbp_lon+1,nbp_lat)) 48 allocate(mean2d(nbp_lon+1,nbp_lat)) 49 allocate(sd2d(nbp_lon+1,nbp_lat)) 50 else ! 1D model case 51 allocate(lon(1)) 52 allocate(sum3d(1,1,nbp_lev)) 53 allocate(square3d(1,1,nbp_lev)) 54 allocate(mean3d(1,1,nbp_lev)) 55 allocate(sd3d(1,1,nbp_lev)) 56 allocate(sum2d(1,1)) 57 allocate(square2d(1,1)) 58 allocate(mean2d(1,1)) 59 allocate(sd2d(1,1)) 60 endif 40 61 41 62 ierr = NF_OPEN("stats.nc",NF_WRITE,nid) … … 105 126 ! dimout(4)=timeid 106 127 107 size=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 128 if (klon_glo>1) then ! general case 129 size=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 130 else ! 1D model 131 size=(/1,1,nbp_lev,1/) 132 endif 108 133 do lt=1,istime 109 134 start=(/1,1,1,lt/) … … 135 160 ! dimout(3)=timeid 136 161 137 size=(/nbp_lon+1,nbp_lat,1,0/) 162 if (klon_glo>1) then ! general case 163 size=(/nbp_lon+1,nbp_lat,1,0/) 164 else 165 size=(/1,1,1,0/) 166 endif 138 167 do lt=1,istime 139 168 start=(/1,1,lt,0/) -
trunk/LMDZ.MARS/libf/phymars/statto_mod.F90
r1531 r1532 1 MODULE statto_mod 2 IMPLICIT NONE 1 3 2 ! statto :4 ! statto_mod: 3 5 ! This include file controls the production of statistics. 4 6 ! Some variables could be set in a namelist, but it is easier to … … 31 33 integer, parameter :: cntrlsize=15 32 34 33 ! common /sttcom/ dummy,nstore,istats,usdata 34 common /sttcom/ nstore,istats,usdata,count 35 END MODULE statto_mod -
trunk/LMDZ.MARS/libf/phymars/writediagfi.F
r1528 r1532 63 63 real*4 dx1(nbp_lev) ! to store a 1D (column) data set 64 64 real*4 dx0 65 real*4 dx3_1d(1,nbp_lev) ! to store a profile with 1D model 66 real*4 dx2_1d ! to store a surface value with 1D model 65 67 66 68 real*4,save :: date 69 !$OMP THREADPRIVATE(date) 67 70 68 71 REAL phis((nbp_lon+1),nbp_lat) … … 75 78 integer,save :: zitau=0 76 79 character(len=20),save :: firstnom='1234567890' 80 !$OMP THREADPRIVATE(zitau,firstnom) 77 81 78 82 ! Ajouts 79 83 integer, save :: ntime=0 84 !$OMP THREADPRIVATE(ntime) 80 85 integer :: idim,varid 81 86 integer :: nid … … 92 97 character(len=120),save :: nom_def(n_nom_def_max) 93 98 logical,save :: firstcall=.true. 99 !$OMP THREADPRIVATE(firstcall) !diagfi_def,n_nom_def,nom_def read in diagfi.def 94 100 95 #ifndef MESOSCALE96 97 101 #ifdef CPP_PARA 98 102 ! Added to work in parallel mode … … 127 131 firstcall=.false. 128 132 133 !$OMP MASTER 129 134 ! Open diagfi.def definition file if there is one: 130 135 open(99,file="diagfi.def",status='old',form='formatted', … … 150 155 diagfi_def=.false. 151 156 endif 157 !$OMP END MASTER 158 !$OMP BARRIER 152 159 END IF ! of IF (firstcall) 153 160 … … 214 221 215 222 ! Build phis() and area() 216 do i=1,nbp_lon+1 ! poles 223 IF (klon_glo>1) THEN 224 do i=1,nbp_lon+1 ! poles 217 225 phis(i,1)=phisfi_glo(1) 218 226 phis(i,nbp_lat)=phisfi_glo(klon_glo) … … 220 228 area(i,1)=areafi_glo(1)/nbp_lon 221 229 area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon 222 enddo223 do j=2,nbp_lat-1230 enddo 231 do j=2,nbp_lat-1 224 232 ig0= 1+(j-2)*nbp_lon 225 233 do i=1,nbp_lon … … 230 238 phis(nbp_lon+1,j)=phis(1,j) 231 239 area(nbp_lon+1,j)=area(1,j) 232 enddo 240 enddo 241 ENDIF 233 242 234 243 ! write "header" of file (longitudes, latitudes, geopotential, ...) 235 call iniwrite(nid,day_ini,phis,area) 244 IF (klon_glo>1) THEN ! general 3D case 245 call iniwrite(nid,day_ini,phis,area,nbp_lon+1,nbp_lat) 246 ELSE ! 1D model 247 call iniwrite(nid,day_ini,phisfi_glo(1),areafi_glo(1),1,1) 248 ENDIF 236 249 237 250 endif ! of if (is_master) … … 248 261 endif ! if (firstnom.eq.'1234567890') 249 262 250 if ( ngrid.eq.1) then263 if (klon_glo.eq.1) then 251 264 ! in testphys1d, for the 1d version of the GCM, iphysiq and irythme 252 265 ! are undefined; so set them to 1 253 266 iphysiq=1 254 267 irythme=1 255 ! NB:256 268 endif 257 269 … … 320 332 ! Passage variable physique --> variable dynamique 321 333 ! recast (copy) variable from physics grid to dynamics grid 334 IF (klon_glo>1) THEN ! General case 322 335 DO l=1,nbp_lev 323 336 DO i=1,nbp_lon+1 … … 333 346 ENDDO 334 347 ENDDO 348 ELSE ! 1D model case 349 dx3_1d(1,1:nbp_lev)=px(1,1:nbp_lev) 350 ENDIF 335 351 #endif 336 352 ! Ecriture du champs … … 360 376 corner(4)=ntime 361 377 362 edges(1)=nbp_lon+1 378 IF (klon_glo==1) THEN 379 edges(1)=1 380 ELSE 381 edges(1)=nbp_lon+1 382 ENDIF 363 383 edges(2)=nbp_lat 364 384 edges(3)=nbp_lev … … 371 391 ! write(*,*)" edges()=",edges 372 392 ! write(*,*)" dx3()=",dx3 373 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3) 393 IF (klon_glo>1) THEN ! General case 394 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3) 395 ELSE 396 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3_1d) 397 ENDIF 374 398 !#endif 375 399 376 400 if (ierr.ne.NF_NOERR) then 377 401 write(*,*) "***** PUT_VAR problem in writediagfi" 378 write(*,*) "***** with ",nom402 write(*,*) "***** with dx3: ",nom 379 403 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 380 c call abort 404 stop 381 405 endif 382 406 … … 405 429 ! Passage variable physique --> physique dynamique 406 430 ! recast (copy) variable from physics grid to dynamics grid 407 431 IF (klon_glo>1) THEN ! General case 408 432 DO i=1,nbp_lon+1 409 433 dx2(i,1)=px(1,1) … … 417 441 dx2(nbp_lon+1,j)=dx2(1,j) 418 442 ENDDO 443 ELSE ! 1D model case 444 dx2_1d=px(1,1) 445 ENDIF 419 446 #endif 420 447 … … 442 469 corner(2)=1 443 470 corner(3)=ntime 444 edges(1)=nbp_lon+1 471 IF (klon_glo==1) THEN 472 edges(1)=1 473 ELSE 474 edges(1)=nbp_lon+1 475 ENDIF 445 476 edges(2)=nbp_lat 446 477 edges(3)=1 … … 450 481 ! ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx2) 451 482 !#else 452 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2) 483 IF (klon_glo>1) THEN ! General case 484 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2) 485 ELSE 486 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2_1d) 487 ENDIF 453 488 !#endif 454 489 455 490 if (ierr.ne.NF_NOERR) then 456 491 write(*,*) "***** PUT_VAR matter in writediagfi" 457 write(*,*) "***** with ",nom492 write(*,*) "***** with dx2: ",nom 458 493 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 459 c call abort 494 stop 460 495 endif 461 496 … … 505 540 if (ierr.ne.NF_NOERR) then 506 541 write(*,*) "***** PUT_VAR problem in writediagfi" 507 write(*,*) "***** with ",nom542 write(*,*) "***** with dx1: ",nom 508 543 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 509 c call abort 544 stop 510 545 endif 511 546 … … 543 578 if (ierr.ne.NF_NOERR) then 544 579 write(*,*) "***** PUT_VAR matter in writediagfi" 545 write(*,*) "***** with ",nom580 write(*,*) "***** with dx0: ",nom 546 581 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 547 c call abort 582 stop 548 583 endif 549 584 … … 558 593 endif 559 594 560 #endif561 595 end -
trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90
r1528 r1532 36 36 real*4,dimension(nbp_lon+1,nbp_lat) :: data2 ! to store 2D data 37 37 real*4 :: data0 ! to store 0D data 38 real*4 :: data3_1d(1,nsoilmx) ! to store a profile in 1D model 39 real*4 :: data2_1d ! to store surface value with 1D model 38 40 integer :: i,j,l ! for loops 39 41 integer :: ig0 … … 51 53 character(len=20),save :: firstname="1234567890" 52 54 integer,save :: zitau=0 55 !$OMP THREADPRIVATE(date,isample,ntime,firstname,zitau) 53 56 54 57 character(len=30) :: filename="diagsoil.nc" … … 107 110 108 111 ! build inertia() and area() 109 do i=1,nbp_lon+1 ! poles 112 if (klon_glo>1) then 113 do i=1,nbp_lon+1 ! poles 110 114 inertia(i,1,1:nsoilmx)=inertiafi_glo(1,1:nsoilmx) 111 115 inertia(i,nbp_lat,1:nsoilmx)=inertiafi_glo(klon_glo,1:nsoilmx) … … 113 117 area(i,1)=areafi_glo(1)/nbp_lon 114 118 area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon 115 enddo116 do j=2,nbp_lat-1119 enddo 120 do j=2,nbp_lat-1 117 121 ig0= 1+(j-2)*nbp_lon 118 122 do i=1,nbp_lon … … 123 127 inertia(nbp_lon+1,j,1:nsoilmx)=inertia(1,j,1:nsoilmx) 124 128 area(nbp_lon+1,j)=area(1,j) 125 enddo 129 enddo 130 endif 126 131 127 132 ! write "header" of file (longitudes, latitudes, geopotential, ...) 128 call iniwritesoil(nid,ngrid,inertia,area) 133 if (klon_glo>1) then ! general 3D case 134 call iniwritesoil(nid,ngrid,inertia,area,nbp_lon+1,nbp_lat) 135 else ! 1D model 136 call iniwritesoil(nid,ngrid,inertiafi_glo(1,:),areafi_glo(1),1,1) 137 endif 129 138 130 139 endif ! of if (is_master) … … 188 197 !$OMP BARRIER 189 198 #else 190 do l=1,nsoilmx 199 if (klon_glo>1) then ! General case 200 do l=1,nsoilmx 191 201 ! handle the poles 192 202 do i=1,nbp_lon+1 … … 202 212 data3(nbp_lon+1,j,l)=data3(1,j,l) ! extra (modulo) longitude 203 213 enddo 204 enddo 214 enddo 215 else ! 1D model case 216 data3_1d(1,1:nsoilmx)=px(1,1:nsoilmx) 217 endif 205 218 #endif 206 219 … … 229 242 corners(4)=ntime 230 243 231 edges(1)=nbp_lon+1 244 if (klon_glo==1) then 245 edges(1)=1 246 else 247 edges(1)=nbp_lon+1 248 endif 232 249 edges(2)=nbp_lat 233 250 edges(3)=nsoilmx … … 238 255 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data3) 239 256 !#else 240 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3) 257 if (klon_glo>1) then 258 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3) 259 else 260 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3_1d) 261 endif 241 262 !#endif 242 263 if (ierr.ne.NF_NOERR) then … … 263 284 !$OMP BARRIER 264 285 #else 265 ! handle the poles 266 do i=1,nbp_lon+1 267 data2(i,1)=px(1,1) 268 data2(i,nbp_lat)=px(ngrid,1) 269 enddo 270 ! rest of the grid 271 do j=2,nbp_lat-1 272 ig0=1+(j-2)*nbp_lon 273 do i=1,nbp_lon 274 data2(i,j)=px(ig0+i,1) 275 enddo 276 data2(nbp_lon+1,j)=data2(1,j) ! extra (modulo) longitude 277 enddo 286 if (klon_glo>1) then ! general case 287 ! handle the poles 288 do i=1,nbp_lon+1 289 data2(i,1)=px(1,1) 290 data2(i,nbp_lat)=px(ngrid,1) 291 enddo 292 ! rest of the grid 293 do j=2,nbp_lat-1 294 ig0=1+(j-2)*nbp_lon 295 do i=1,nbp_lon 296 data2(i,j)=px(ig0+i,1) 297 enddo 298 data2(nbp_lon+1,j)=data2(1,j) ! extra (modulo) longitude 299 enddo 300 else ! 1D model case 301 data2_1d=px(1,1) 302 endif 278 303 #endif 279 304 … … 300 325 corners(3)=ntime 301 326 302 edges(1)=nbp_lon+1 327 if (klon_glo==1) then 328 edges(1)=1 329 else 330 edges(1)=nbp_lon+1 331 endif 303 332 edges(2)=nbp_lat 304 333 edges(3)=1 … … 308 337 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data2) 309 338 !#else 310 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2) 339 if (klon_glo>1) then ! General case 340 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2) 341 else 342 ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2_1d) 343 endif 311 344 !#endif 312 345 if (ierr.ne.NF_NOERR) then -
trunk/LMDZ.MARS/libf/phymars/wstats.F90
r1528 r1532 1 1 subroutine wstats(ngrid,nom,titre,unite,dim,px) 2 2 3 use statto_mod, only: istats,istime,count 3 4 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin 4 5 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, & … … 6 7 implicit none 7 8 8 include "statto.h"9 9 include "netcdf.inc" 10 10 … … 13 13 integer,intent(in) :: dim 14 14 real,intent(in) :: px(ngrid,nbp_lev) 15 real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: mean3d,sd3d,dx316 real, dimension(nbp_lon+1,nbp_lat) :: mean2d,sd2d,dx215 real,allocatable,save :: mean3d(:,:,:),sd3d(:,:,:),dx3(:,:,:) 16 real,allocatable,save :: mean2d(:,:),sd2d(:,:),dx2(:,:) 17 17 character (len=50) :: namebis 18 18 character (len=50), save :: firstvar 19 !$OMP THREADPRIVATE(firstvar) 19 20 integer :: ierr,varid,nbdim,nid 20 21 integer :: meanid,sdid … … 25 26 26 27 integer, save :: step=0 28 !$OMP THREADPRIVATE(firstcall,indx,step) 27 29 28 30 ! Added to work in parallel mode … … 47 49 firstvar=trim((nom)) 48 50 call inistats(ierr) 51 if (klon_glo>1) then ! general case, 3D GCM 52 allocate(mean3d(nbp_lon+1,nbp_lat,nbp_lev)) 53 allocate(sd3d(nbp_lon+1,nbp_lat,nbp_lev)) 54 allocate(dx3(nbp_lon+1,nbp_lat,nbp_lev)) 55 allocate(mean2d(nbp_lon+1,nbp_lat)) 56 allocate(sd2d(nbp_lon+1,nbp_lat)) 57 allocate(dx2(nbp_lon+1,nbp_lat)) 58 else ! 1D model 59 allocate(mean3d(1,1,nbp_lev)) 60 allocate(sd3d(1,1,nbp_lev)) 61 allocate(dx3(1,1,nbp_lev)) 62 allocate(mean2d(1,1)) 63 allocate(sd2d(1,1)) 64 allocate(dx2(1,1)) 65 endif 49 66 endif 50 67 … … 192 209 if (dim.eq.3) then 193 210 start=(/1,1,1,indx/) 194 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 211 if (klon_glo>1) then !general case 212 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 213 else 214 sizes=(/1,1,nbp_lev,1/) 215 endif 195 216 mean3d(:,:,:)=0 196 217 sd3d(:,:,:)=0 197 218 else if (dim.eq.2) then 198 219 start=(/1,1,indx,0/) 199 sizes=(/nbp_lon+1,nbp_lev,1,0/) 220 if (klon_glo>1) then !general case 221 sizes=(/nbp_lon+1,nbp_lev,1,0/) 222 else 223 sizes=(/1,1,1,0/) 224 endif 200 225 mean2d(:,:)=0 201 226 sd2d(:,:)=0 … … 205 230 if (dim.eq.3) then 206 231 start=(/1,1,1,indx/) 207 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 232 if (klon_glo>1) then !general case 233 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 234 else ! 1D model case 235 sizes=(/1,1,nbp_lev,1/) 236 endif 208 237 #ifdef NC_DOUBLE 209 238 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean3d) … … 214 243 #endif 215 244 if (ierr.ne.NF_NOERR) then 245 write (*,*) "wstats error reading :",trim(nom) 216 246 write (*,*) NF_STRERROR(ierr) 217 247 stop "" … … 220 250 else if (dim.eq.2) then 221 251 start=(/1,1,indx,0/) 222 sizes=(/nbp_lon+1,nbp_lat,1,0/) 252 if (klon_glo>1) then ! general case 253 sizes=(/nbp_lon+1,nbp_lat,1,0/) 254 else 255 sizes=(/1,1,1,0/) 256 endif 223 257 #ifdef NC_DOUBLE 224 258 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean2d) … … 229 263 #endif 230 264 if (ierr.ne.NF_NOERR) then 265 write (*,*) "wstats error reading :",trim(nom) 231 266 write (*,*) NF_STRERROR(ierr) 232 267 stop "" … … 240 275 if (dim.eq.3) then 241 276 dx3(1:nbp_lon,:,:)=px3_glo(:,:,:) 242 dx3(nbp_lon+1,:,:)=dx3(1,:,:) 277 IF (klon_glo>1) THEN ! in 3D, add redundant longitude point 278 dx3(nbp_lon+1,:,:)=dx3(1,:,:) 279 ENDIF 243 280 else ! dim.eq.2 244 281 dx2(1:nbp_lon,:)=px2_glo(:,:) 245 dx2(nbp_lon+1,:)=dx2(1,:) 282 IF (klon_glo>1) THEN ! in 3D, add redundant longitude point 283 dx2(nbp_lon+1,:)=dx2(1,:) 284 ENDIF 246 285 endif 247 286 … … 261 300 ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd3d) 262 301 #endif 302 if (ierr.ne.NF_NOERR) then 303 write (*,*) "wstats error writing :",trim(nom) 304 write (*,*) NF_STRERROR(ierr) 305 stop "" 306 endif 263 307 264 308 else if (dim.eq.2) then … … 274 318 ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd2d) 275 319 #endif 320 if (ierr.ne.NF_NOERR) then 321 write (*,*) "wstats error writing :",trim(nom) 322 write(*,*) "start:",start 323 write(*,*) "sizes:",sizes 324 write(*,*) "mean2d:",mean2d 325 write(*,*) "sd2d:",sd2d 326 write (*,*) NF_STRERROR(ierr) 327 stop "" 328 endif 276 329 277 330 endif ! of if (dim.eq.3) elseif (dim.eq.2) … … 284 337 !====================================================== 285 338 subroutine inivar(nid,varid,ngrid,dim,indx,px,ierr) 286 use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev 339 use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev, klon_glo 287 340 288 341 implicit none … … 298 351 real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: dx3 299 352 real, dimension(nbp_lon+1,nbp_lat) :: dx2 353 real :: dx3_1d(nbp_lev) ! for 1D outputs 354 real :: dx2_1d ! for 1D outputs 300 355 301 356 if (dim.eq.3) then 302 357 303 358 start=(/1,1,1,indx/) 304 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 359 if (klon_glo>1) then ! general 3D case 360 sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/) 361 else 362 sizes=(/1,1,nbp_lev,1/) 363 endif 305 364 306 365 ! Passage variable physique --> variable dynamique 307 366 308 DO l=1,nbp_lev 367 if (klon_glo>1) then ! general case 368 DO l=1,nbp_lev 309 369 DO i=1,nbp_lon+1 310 370 dx3(i,1,l)=px(1,l) … … 318 378 dx3(nbp_lon+1,j,l)=dx3(1,j,l) 319 379 ENDDO 320 ENDDO 321 322 #ifdef NC_DOUBLE 323 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3) 324 #else 325 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3) 326 #endif 380 ENDDO 381 else ! 1D model case 382 dx3_1d(1:nbp_lev)=px(1,1:nbp_lev) 383 endif 384 385 #ifdef NC_DOUBLE 386 if (klon_glo>1) then 387 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3) 388 else 389 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3_1d) 390 endif 391 #else 392 if (klon_glo>1) then 393 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3) 394 else 395 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3_1d) 396 endif 397 #endif 398 if (ierr.ne.NF_NOERR) then 399 write (*,*) "inivar error writing variable" 400 write (*,*) NF_STRERROR(ierr) 401 stop "" 402 endif 327 403 328 404 else if (dim.eq.2) then 329 405 330 406 start=(/1,1,indx,0/) 331 sizes=(/nbp_lon+1,nbp_lat,1,0/) 407 if (klon_glo>1) then ! general 3D case 408 sizes=(/nbp_lon+1,nbp_lat,1,0/) 409 else 410 sizes=(/1,1,1,0/) 411 endif 332 412 333 413 ! Passage variable physique --> physique dynamique 334 414 415 if (klon_glo>1) then ! general case 335 416 DO i=1,nbp_lon+1 336 417 dx2(i,1)=px(1,1) … … 344 425 dx2(nbp_lon+1,j)=dx2(1,j) 345 426 ENDDO 346 347 #ifdef NC_DOUBLE 348 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2) 349 #else 350 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2) 351 #endif 427 else ! 1D model case 428 dx2_1d=px(1,1) 429 endif 430 431 #ifdef NC_DOUBLE 432 if (klon_glo>1) then 433 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2) 434 else 435 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2_1d) 436 endif 437 #else 438 if (klon_glo>1) then 439 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2) 440 else 441 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2_1d) 442 endif 443 #endif 444 if (ierr.ne.NF_NOERR) then 445 write (*,*) "inivar error writing variable" 446 write (*,*) NF_STRERROR(ierr) 447 stop "" 448 endif 352 449 353 450 endif
Note: See TracChangeset
for help on using the changeset viewer.