Changeset 1529 for trunk/LMDZ.GENERIC/libf/phystd/iniwritesoil.F90
- Timestamp:
- Apr 5, 2016, 10:51:51 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.GENERIC/libf/phystd/iniwritesoil.F90
r1384 r1529 1 subroutine iniwritesoil(nid,ngrid )1 subroutine iniwritesoil(nid,ngrid,inertia,area) 2 2 3 3 ! initialization routine for 'writediagoil'. Here we create/define … … 5 5 ! (time-independent) parameters. 6 6 7 use comsoil_h, only: mlayer, inertiedat, nsoilmx 8 use comcstfi_mod, only: pi 7 use comsoil_h, only: mlayer, nsoilmx 8 USE comcstfi_mod, only: pi 9 USE regular_lonlat_mod, ONLY: lon_reg, lat_reg 10 use mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat 9 11 10 12 implicit none 11 13 12 #include"dimensions.h" 13 #include"paramet.h" 14 #include"comgeom.h" 15 #include"netcdf.inc" 14 include"netcdf.inc" 16 15 17 16 ! Arguments: 18 17 integer,intent(in) :: ngrid 19 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) 20 21 21 22 ! Local variables: … … 30 31 integer,dimension(3) :: dimids ! to store IDs of dimensions of a variable 31 32 character(len=60) :: text ! to store some text 32 real,dimension( iip1,jjp1,nsoilmx) :: data3 ! to store 3D data33 real,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data 33 34 integer :: i,j,l,ig0 35 real :: lon_reg_ext(nbp_lon+1) ! extended longitudes 34 36 35 37 ! 1. Define the dimensions … … 38 40 39 41 ! Define the dimensions 40 ierr=NF_DEF_DIM(nid,"longitude",iip1,idim_rlonv) 41 ! iip1 known from paramet.h 42 ierr=NF_DEF_DIM(nid,"longitude",nbp_lon+1,idim_rlonv) 42 43 if (ierr.ne.NF_NOERR) then 43 44 write(*,*)"iniwritesoil: Error, could not define longitude dimension" 44 45 endif 45 ierr=NF_DEF_DIM(nid,"latitude",jjp1,idim_rlatu) 46 ! jjp1 known from paramet.h 46 ierr=NF_DEF_DIM(nid,"latitude",nbp_lat,idim_rlatu) 47 47 if (ierr.ne.NF_NOERR) then 48 48 write(*,*)"iniwritesoil: Error, could not define latitude dimension" 49 49 endif 50 50 ierr=NF_DEF_DIM(nid,"depth",nsoilmx,idim_depth) 51 ! nsoilmx known from dimphys.h51 ! nsoilmx known from comsoil_h 52 52 if (ierr.ne.NF_NOERR) then 53 53 write(*,*)"iniwritesoil: Error, could not define depth dimension" … … 81 81 ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text) 82 82 83 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) 86 83 87 ! Write longitude to file 84 88 ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode 85 89 ! Write 86 90 #ifdef NC_DOUBLE 87 ierr=NF_PUT_VAR_DOUBLE(nid,varid, rlonv*(180./pi))88 #else 89 ierr=NF_PUT_VAR_REAL(nid,varid, rlonv*(180./pi))90 #endif 91 ! Note: rlonv is known from comgeom.h 91 ierr=NF_PUT_VAR_DOUBLE(nid,varid,lon_reg_ext*(180./pi)) 92 #else 93 ierr=NF_PUT_VAR_REAL(nid,varid,lon_reg_ext*(180./pi)) 94 #endif 95 ! Note: rlonv is known from comgeom.h and pi from comcstfi.h 92 96 if (ierr.ne.NF_NOERR) then 93 97 write(*,*)"iniwritesoil: Error, could not write longitude variable" … … 117 121 ! Write 118 122 #ifdef NC_DOUBLE 119 ierr=NF_PUT_VAR_DOUBLE(nid,varid,rlatu*(180./pi)) 120 #else 121 ierr=NF_PUT_VAR_REAL(nid,varid,rlatu*(180./pi)) 122 #endif 123 ! Note: rlatu is known from comgeom.h 123 ierr=NF_PUT_VAR_DOUBLE(nid,varid,lat_reg*(180./pi)) 124 #else 125 ierr=NF_PUT_VAR_REAL(nid,varid,lat_reg*(180./pi)) 126 #endif 124 127 if (ierr.ne.NF_NOERR) then 125 128 write(*,*)"iniwritesoil: Error, could not write longitude variable" … … 209 212 ! Write 210 213 #ifdef NC_DOUBLE 211 ierr=NF_PUT_VAR_DOUBLE(nid,varid,aire) 212 #else 213 ierr=NF_PUT_VAR_REAL(nid,varid,aire) 214 #endif 215 ! Note: aire is known from comgeom.h 214 ierr=NF_PUT_VAR_DOUBLE(nid,varid,area) 215 #else 216 ierr=NF_PUT_VAR_REAL(nid,varid,area) 217 #endif 216 218 if (ierr.ne.NF_NOERR) then 217 219 write(*,*)"iniwritesoil: Error, could not write area variable" … … 240 242 ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text) 241 243 242 ! Recast data along 'dynamics' grid243 ! Note: inertiedat is known from comsoil_h244 245 do l=1,nsoilmx246 ! handle the poles247 do i=1,iip1248 data3(i,1,l)=inertiedat(1,l)249 data3(i,jjp1,l)=inertiedat(ngrid,l)250 enddo251 ! rest of the grid252 do j=2,jjm253 ig0=1+(j-2)*iim254 do i=1,iim255 data3(i,j,l)=inertiedat(ig0+i,l)256 enddo257 data3(iip1,j,l)=data3(1,j,l) ! extra (modulo) longitude258 enddo259 enddo ! of do l=1,nsoilmx260 261 244 ! Write data2 to file 262 245 ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode 263 246 ! Write 264 247 #ifdef NC_DOUBLE 265 ierr=NF_PUT_VAR_DOUBLE(nid,varid, data3)266 #else 267 ierr=NF_PUT_VAR_REAL(nid,varid, data3)248 ierr=NF_PUT_VAR_DOUBLE(nid,varid,inertia) 249 #else 250 ierr=NF_PUT_VAR_REAL(nid,varid,inertia) 268 251 #endif 269 252 if (ierr.ne.NF_NOERR) then
Note: See TracChangeset
for help on using the changeset viewer.