Changeset 1130 for trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90
- Timestamp:
- Dec 20, 2013, 4:04:56 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90
r1047 r1130 13 13 14 14 use comsoil_h, only: nsoilmx 15 use control_mod, only: ecritphy, day_step, iphysiq 16 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather 17 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 15 18 16 19 implicit none … … 19 22 !#include"dimphys.h" 20 23 #include"paramet.h" 21 #include"control.h"24 !#include"control.h" 22 25 !#include"comsoil.h" 23 26 #include"netcdf.inc" … … 56 59 integer,dimension(4) :: edges,corners 57 60 61 #ifdef CPP_PARA 62 ! Added to work in parallel mode 63 real dx3_glop(klon_glo,nsoilmx) 64 real dx3_glo(iim,jjp1,nsoilmx) ! to store a global 3D data set 65 real dx2_glop(klon_glo) 66 real dx2_glo(iim,jjp1) ! to store a global 2D (surface) data set 67 real px2(ngrid) 68 #endif 69 58 70 ! 1. Initialization step 59 71 if (firstname.eq."1234567890") then … … 75 87 76 88 ! Create output NetCDF file 77 ierr=NF_CREATE(filename,IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid) 78 if (ierr.ne.NF_NOERR) then 89 if (is_master) then 90 ierr=NF_CREATE(filename,NF_CLOBBER,nid) 91 if (ierr.ne.NF_NOERR) then 79 92 write(*,*)'writediagsoil: Error, failed creating file '//trim(filename) 80 93 stop 81 endif 82 94 endif 95 endif ! of if (is_master) 96 83 97 ! Define dimensions and axis attributes 84 98 call iniwritesoil(nid,ngrid) … … 89 103 else 90 104 ! If not an initialization call, simply open the NetCDF file 91 ierr=NF_OPEN(filename,NF_WRITE,nid) 105 if (is_master) then 106 ierr=NF_OPEN(filename,NF_WRITE,nid) 107 endif 92 108 endif ! of if (firstname.eq."1234567890") 93 109 … … 105 121 if (name.eq.firstname) then 106 122 ntime=ntime+1 107 date= real(zitau+1)/real(day_step)123 date=float(zitau+1)/float(day_step) 108 124 ! Note: day_step is known from control.h 109 125 110 ! Get NetCDF ID for "time" 111 ierr=NF_INQ_VARID(nid,"time",varid) 112 ! Add the current value of date to the "time" array 126 if (is_master) then 127 ! Get NetCDF ID for "time" 128 ierr=NF_INQ_VARID(nid,"time",varid) 129 ! Add the current value of date to the "time" array 113 130 !#ifdef NC_DOUBLE 114 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)131 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date) 115 132 !#else 116 ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date)133 ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date) 117 134 !#endif 118 if (ierr.ne.NF_NOERR) then135 if (ierr.ne.NF_NOERR) then 119 136 write(*,*)"writediagsoil: Failed writing date to time variable" 120 137 stop 121 endif 138 endif 139 endif ! of if (is_master) 122 140 endif ! of if (name.eq.firstname) 123 141 … … 125 143 if (dimpx.eq.3) then ! Case of a 3D variable 126 144 ! A. Recast data along 'dynamics' grid 145 #ifdef CPP_PARA 146 ! gather field on a "global" (without redundant longitude) array 147 call Gather(px,dx3_glop) 148 !$OMP MASTER 149 if (is_mpi_root) then 150 call Grid1Dto2D_glo(dx3_glop,dx3_glo) 151 ! copy dx3_glo() to dx3(:) and add redundant longitude 152 data3(1:iim,:,:)=dx3_glo(1:iim,:,:) 153 data3(iip1,:,:)=data3(1,:,:) 154 endif 155 !$OMP END MASTER 156 !$OMP BARRIER 157 #else 127 158 do l=1,nsoilmx 128 159 ! handle the poles … … 140 171 enddo 141 172 enddo 173 #endif 142 174 143 175 ! B. Write (append) the variable to the NetCDF file 176 if (is_master) then 144 177 ! B.1. Get the ID of the variable 145 178 ierr=NF_INQ_VARID(nid,name,varid) … … 179 212 " to file "//trim(filename)//" at time",date 180 213 endif 214 endif ! of if (is_master) 181 215 182 216 elseif (dimpx.eq.2) then ! Case of a 2D variable 217 183 218 ! A. Recast data along 'dynamics' grid 219 #ifdef CPP_PARA 220 ! gather field on a "global" (without redundant longitude) array 221 px2(:)=px(:,1) 222 call Gather(px2,dx2_glop) 223 !$OMP MASTER 224 if (is_mpi_root) then 225 call Grid1Dto2D_glo(dx2_glop,dx2_glo) 226 ! copy dx3_glo() to dx3(:) and add redundant longitude 227 data2(1:iim,:)=dx2_glo(1:iim,:) 228 data2(iip1,:)=data2(1,:) 229 endif 230 !$OMP END MASTER 231 !$OMP BARRIER 232 #else 184 233 ! handle the poles 185 234 do i=1,iip1 … … 195 244 data2(iip1,j)=data2(1,j) ! extra (modulo) longitude 196 245 enddo 246 #endif 197 247 198 248 ! B. Write (append) the variable to the NetCDF file 249 if (is_master) then 199 250 ! B.1. Get the ID of the variable 200 251 ierr=NF_INQ_VARID(nid,name,varid) … … 231 282 " to file "//trim(filename)//" at time",date 232 283 endif 284 endif ! of if (is_master) 233 285 234 286 elseif (dimpx.eq.0) then ! Case of a 0D variable 287 #ifdef CPP_PARA 288 write(*,*) "writediagsoil: dimps==0 case not implemented in // mode!!" 289 stop 290 #endif 235 291 ! A. Copy data value 236 292 data0=px(1,1) … … 270 326 271 327 ! 4. Close the NetCDF file 272 ierr=NF_CLOSE(nid) 328 if (is_master) then 329 ierr=NF_CLOSE(nid) 330 endif 273 331 274 332 end subroutine writediagsoil
Note: See TracChangeset
for help on using the changeset viewer.