1 !----------------------------------------------------------------------
2 ! Subroutine: model_geos_coord
3 !> Get GEOS coordinates
4 !----------------------------------------------------------------------
5 subroutine model_geos_coord(model,mpl,nam)
10 class(model_type),intent(inout) :: model !< Model
11 type(mpl_type),intent(inout) :: mpl !< MPI data
12 type(nam_type),intent(in) :: nam !< Namelist
15 integer :: img,il0,ilon,ilat
16 integer :: ncid,nlon_id,nlat_id,nlev_id,lon_id,lat_id,delp_id
18 real(kind=8),allocatable :: lon(:,:),lat(:,:),delp(:,:,:)
19 character(len=1024),parameter :: subr =
'model_geos_coord'
21 ! Open file and get dimensions
23 call mpl%ncerr(subr,nf90_open(trim(nam%datadir)
24 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'Xdim',nlon_id))
25 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'Ydim',nlat_id))
26 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nlon_id,len=model%nlon))
27 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nlat_id,len=model%nlat))
28 model%nmg = model%nlon*model%nlat
29 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'lev',nlev_id))
30 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nlev_id,len=model%nlev))
34 allocate(lon(model%nlon,model%nlat))
35 allocate(lat(model%nlon,model%nlat))
36 allocate(delp(model%nlon,model%nlat,model%nlev))
38 ! Read data and close file
39 call mpl%ncerr(subr,nf90_inq_varid(ncid,
'lons',lon_id))
40 call mpl%ncerr(subr,nf90_inq_varid(ncid,
'lats',lat_id))
41 call mpl%ncerr(subr,nf90_inq_varid(ncid,
'delp',delp_id))
42 call mpl%ncerr(subr,nf90_get_var(ncid,lon_id,lon))
43 call mpl%ncerr(subr,nf90_get_var(ncid,lat_id,lat))
44 call mpl%ncerr(subr,nf90_get_var(ncid,delp_id,delp))
45 call mpl%ncerr(subr,nf90_close(ncid))
52 model%mg_to_tile(img) = 1
53 model%mg_to_lon(img) = ilon
54 model%mg_to_lat(img) = ilat
65 ilon = model%mg_to_lon(img)
66 ilat = model%mg_to_lat(img)
67 P0 = sum(delp(ilon,ilat,:))
69 if (nam%levs(il0)==model%nlev) then
70 model%vunit(img,il0) = log(P0-0.5*delp(ilon,ilat,model%nlev))
72 model%vunit(img,il0) = log(P0-sum(delp(ilon,ilat,nam%levs(il0)+1:model%nlev))-0.5*delp(ilon,ilat,nam%levs(il0)))
75 if (model%nl0>nam%nl) model%vunit(img,model%nl0) = log(P0)
77 model%vunit(img,:) = real(nam%levs(1:model%nl0),
kind_real)
86 end subroutine model_geos_coord
88 !----------------------------------------------------------------------
89 ! Subroutine: model_geos_read
91 !----------------------------------------------------------------------
92 subroutine model_geos_read(model,mpl,nam,filename,fld)
97 class(model_type),intent(inout) :: model !< Model
98 type(mpl_type),intent(inout) :: mpl !< MPI data
99 type(nam_type),intent(in) :: nam !< Namelist
100 character(len=*),intent(in) :: filename !< File name
101 real(
kind_real),intent(out) :: fld(model%nmga,model%nl0,nam%nv) !< Field
104 integer :: iv,il0,img,ilon,ilat,ndims
105 integer :: ncid,fld_id
106 real(
kind_real) :: fld_mg(model%nmg,model%nl0)
107 real(
kind_real),allocatable :: fld_tmp(:,:,:)
108 character(len=1024),parameter :: subr =
'model_geos_read'
112 allocate(fld_tmp(model%nlon,model%nlat,model%nl0))
115 call mpl%ncerr(subr,nf90_open(trim(nam%datadir)
121 call mpl%ncerr(subr,nf90_inq_varid(ncid,nam%variables(iv),fld_id))
124 call mpl%ncerr(subr,nf90_inquire_variable(ncid,fld_id,ndims=ndims))
130 fld_tmp = mpl%msv%valr
131 if (trim(nam%lev2d)==
'first') then
132 call mpl%ncerr(subr,nf90_get_var(ncid,fld_id,fld_tmp(:,:,1),(/1,1,1/), &
133 & (/model%nlon,model%nlat,1/)))
134 elseif (trim(nam%lev2d)==
'last') then
135 call mpl%ncerr(subr,nf90_get_var(ncid,fld_id,fld_tmp(:,:,model%nl0),(/1,1,1/), &
136 & (/model%nlon,model%nlat,1/)))
141 call mpl%ncerr(subr,nf90_get_var(ncid,fld_id,fld_tmp(:,:,il0),(/1,1,nam%levs(il0),1/), &
142 & (/model%nlon,model%nlat,1,1/)))
145 call mpl%abort(subr,
'wrong number of dimensions for variable '
151 ilon = model%mg_to_lon(img)
152 ilat = model%mg_to_lat(img)
153 fld_mg(img,il0) = fld_tmp(ilon,ilat,il0)
157 call mpl%glb_to_loc(model%nl0,model%nmga,model%nmg,model%mga_to_mg,fld_mg,fld(:,:,iv))
162 call mpl%ncerr(subr,nf90_close(ncid))
168 end subroutine model_geos_read