source: trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90 @ 3556

Last change on this file since 3556 was 3552, checked in by emillour, 4 weeks ago

Generic PCM

Modify iostart routines to take netcdf index as an argument in order to
be used to read/write in other files than startfi.nc (preparing 1D
restart)

MM

File size: 11.1 KB
RevLine 
[1216]1module phyredem
[135]2
[1216]3implicit none
[135]4
[3552]5INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
6
[1216]7contains
[135]8
[1216]9subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, &
10                         phystep,day_ini,time,airefi, &
11                         alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe)
12! create physics restart file and write time-independent variables
[1222]13  use comsoil_h, only: volcapa, mlayer
[1543]14  use geometry_mod, only: cell_area
[1222]15  use surfdat_h, only: zmea, zstd, zsig, zgam, zthe, &
[1482]16                       emisice, emissiv,             &
[1216]17                       iceradius, dtemisice, phisfi
[3311]18  use iostart, only : create_restartphy, close_restartphy, &
[3515]19                      put_var, put_field, length, ldscrpt, ndscrpt
[1216]20  use mod_grid_phy_lmdz, only : klon_glo
[1308]21  use planete_mod, only: year_day, periastr, apoastr, peri_day, &
[3515]22                         obliquit, z0
[1524]23  use comcstfi_mod, only: rad, omeg, g, mugaz, rcp
24  use time_phylmdz_mod, only: daysec
[135]25
[1216]26  implicit none
[1384]27
[1216]28  character(len=*), intent(in) :: filename
29  real,intent(in) :: lonfi(ngrid)
30  real,intent(in) :: latfi(ngrid)
31  integer,intent(in) :: nsoil
32  integer,intent(in) :: ngrid
33  integer,intent(in) :: nlay
34  integer,intent(in) :: nq
35  real,intent(in) :: phystep
36  real,intent(in) :: day_ini
37  real,intent(in) :: time
38  real,intent(in) :: airefi(ngrid)
39  real,intent(in) :: alb(ngrid)
40  real,intent(in) :: ith(ngrid,nsoil)
41  real,intent(in) :: pzmea(ngrid)
42  real,intent(in) :: pzstd(ngrid)
43  real,intent(in) :: pzsig(ngrid)
44  real,intent(in) :: pzgam(ngrid)
45  real,intent(in) :: pzthe(ngrid)
46 
[3515]47  character(ndscrpt), dimension(ldscrpt), parameter :: dscrpt_tab_cntrl = (/ &
48      "(1)  Number of atmospheric columns in physics     ", &
49      "(2)  Number of atmospheric layers                 ", &
50      "(3)  Final day                                    ", &
51      "(4)  Final time of day                            ", &
52      "(5)  Planet radius (m)                            ", &
53      "(6)  Rotation rate (rad.s-1)                      ", &
54      "(7)  Gravity (m.s-2)                              ", &
55      "(8)  Molar mass of the atmosphere (g.mol-1)       ", &
56      "(9)  = r/Cp           (=kappa in the dynamics)    ", &
57      "(10) Length of a solar day (s)                    ", &
58      "(11) Physics time step (s)                        ", &
59      "(12) -                                            ", &
60      "(13) -                                            ", &
61      "(14) Length of year (in solar days)               ", &
62      "(15) Minimum star-planet distance (AU)            ", &
63      "(16) Maximum star-planet distance (AU)            ", &
64      "(17) Date of periastro (sols since N. spring)     ", &
65      "(18) Obliquity of the planet (deg)                ", &
66      "(19) Default surface roughness (m)                ", &
67      "(20) -                                            ", &
68      "(21) -                                            ", &
69      "(22) -                                            ", &
70      "(23) -                                            ", &
71      "(24) Emissivity of northern cap ~0.95             ", &
72      "(25) Emissivity of southern cap ~0.95             ", &
73      "(26) Emissivity of martian soil ~.95              ", &
74      "(27) -                                            ", &
75      "(28) -                                            ", &
76      "(29) -                                            ", &
77      "(30) -                                            ", &
78      "(31) Mean scat radius of CO2 snow (north)         ", &
79      "(32) Mean scat radius of CO2 snow (south)         ", &
80      "(33) Time scale for snow metamorphism (north)     ", &
81      "(34) Time scale for snow metamorphism (south)     ", &
82      "(35) Soil volumetric heat capacity                "/)
[1216]83  real :: tab_cntrl(length) ! nb "length=100" defined in iostart module
84 
85  ! Create physics start file
[3552]86  call create_restartphy(filename,nid_restart)
[135]87
[1216]88! tab_cntrl() contains run parameters
89  tab_cntrl(:)=0 ! initialization
90!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
91! Fill control array tab_cntrl(:) with paramleters for this run
92!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
93! Informations on the physics grid
[3515]94  tab_cntrl(1) = float(klon_glo)  ! number of atmospheric columns in physics
[1216]95  tab_cntrl(2) = float(nlay) ! number of atmospheric layers
96  tab_cntrl(3) = day_ini + int(time)         ! final day
97  tab_cntrl(4) = time -int(time)            ! final time of day
[135]98
[3515]99! Informations about the planet, used by dynamics and physics
100  tab_cntrl(5) = rad      ! planet radius (m)
[1216]101  tab_cntrl(6) = omeg     ! rotation rate (rad.s-1)
[3515]102  tab_cntrl(7) = g        ! gravity (m.s-2)
103  tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1)
104  tab_cntrl(9) = rcp      !  = r/cp  (=kappa in the dynamics)
105  tab_cntrl(10) = daysec  ! length of a solar day (s)
[135]106
[3515]107  tab_cntrl(11) = phystep  ! physics time step (s)
[1216]108  tab_cntrl(12) = 0.
109  tab_cntrl(13) = 0.
[135]110
[3515]111! Informations about the planet, only for physics
112  tab_cntrl(14) = year_day  ! length of year (in solar days)
113  tab_cntrl(15) = periastr  ! minimum star-planet distance (AU)
114  tab_cntrl(16) = apoastr   ! maximum star-planet distance (AU)
[1216]115  tab_cntrl(17) = peri_day  ! date of periastron (sols since N. spring)
[3515]116  tab_cntrl(18) = obliquit  ! Obliquity of the planet (deg)
[135]117
[1216]118! Boundary layer and turbulence
[3515]119  tab_cntrl(19) = z0        ! surface roughness (m)
120!  tab_cntrl(20) = lmixmin   ! mixing length (m)
121!  tab_cntrl(21) = emin_turb ! minimal energy
[135]122
[1216]123! Optical properties of polar caps and ground emissivity
124  tab_cntrl(24) = emisice(1)   ! Emissivity of northern cap ~0.95
125  tab_cntrl(25) = emisice(2)   ! Emissivity of southern cap ~0.95
126  tab_cntrl(26) = emissiv      ! Emissivity of martian soil ~.95
127  tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north)
128  tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south)
129  tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north)
130  tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south)
[135]131
[1216]132  tab_cntrl(28) = 0.
133  tab_cntrl(29) = 0.
134  tab_cntrl(30) = 0.
[135]135! Soil properties:
[1216]136  tab_cntrl(35) = volcapa ! soil volumetric heat capacity
[135]137
[3515]138  ! Write the controle array
[3552]139  call put_var(nid_restart,"controle","Control parameters",tab_cntrl)
[1216]140 
[3515]141  ! Write the controle array descriptor
[3552]142  call put_var(nid_restart,"controle_descriptor",&
[3515]143               "Description of control parameters",dscrpt_tab_cntrl)
144 
[1216]145  ! Write the mid-layer depths
[3552]146  call put_var(nid_restart,"soildepth","Soil mid-layer depth",mlayer)
[1216]147 
148  ! Write longitudes
[3552]149  call put_field(nid_restart,"longitude","Longitudes of physics grid",lonfi)
[1216]150 
151  ! Write latitudes
[3552]152  call put_field(nid_restart,"latitude","Latitudes of physics grid",latfi)
[1216]153 
154  ! Write mesh areas
[3552]155  call put_field(nid_restart,"area","Mesh area",cell_area)
[1216]156 
157  ! Write surface geopotential
[3552]158  call put_field(nid_restart,"phisfi","Geopotential at the surface",phisfi)
[1216]159 
160  ! Write surface albedo
[3552]161  call put_field(nid_restart,"albedodat","Albedo of bare ground",alb)
[1216]162 
163  ! Subgrid topogaphy variables
[3552]164  call put_field(nid_restart,"ZMEA","Relief: mean relief",zmea)
165  call put_field(nid_restart,"ZSTD","Relief: standard deviation",zstd)
166  call put_field(nid_restart,"ZSIG","Relief: sigma parameter",zsig)
167  call put_field(nid_restart,"ZGAM","Relief: gamma parameter",zgam)
168  call put_field(nid_restart,"ZTHE","Relief: theta parameter",zthe)
[1216]169 
170  ! Soil thermal inertia
[3552]171  call put_field(nid_restart,"inertiedat","Soil thermal inertia",ith)
[1216]172 
173  ! Close file
[3552]174  call close_restartphy(nid_restart)
[1216]175 
176end subroutine physdem0
[135]177
[1216]178subroutine physdem1(filename,nsoil,ngrid,nlay,nq, &
[3335]179                    phystep,time,tsurf,tsoil,emis,albedo,q2,qsurf, &
[1297]180                    cloudfrac,totcloudfrac,hice, &
[3397]181                    rnat,pctsrf_sic,tslab,tsea_ice,tice,sea_ice)
[1216]182  ! write time-dependent variable to restart file
183  use iostart, only : open_restartphy, close_restartphy, &
184                      put_var, put_field
[1621]185  use tracer_h, only: noms
[3335]186  USE radinc_h, ONLY: L_NSPECTV
[3100]187!  use slab_ice_h, only: noceanmx
188  USE ocean_slab_mod, ONLY: nslay
[2299]189  use callkeys_mod, only: ok_slab_ocean, calllott_nonoro
190  use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd, &
191                                east_gwstress, west_gwstress
[1297]192
[1216]193  implicit none
[1397]194
[1216]195  character(len=*),intent(in) :: filename
196  integer,intent(in) :: nsoil
197  integer,intent(in) :: ngrid
198  integer,intent(in) :: nlay
199  integer,intent(in) :: nq
200  real,intent(in) :: phystep
201  real,intent(in) :: time
202  real,intent(in) :: tsurf(ngrid)
203  real,intent(in) :: tsoil(ngrid,nsoil)
204  real,intent(in) :: emis(ngrid)
[3335]205  real,intent(in) :: albedo(ngrid,L_NSPECTV)
[1216]206  real,intent(in) :: q2(ngrid,nlay+1)
207  real,intent(in) :: qsurf(ngrid,nq)
208  real,intent(in) :: cloudfrac(ngrid,nlay)
209  real,intent(in) :: totcloudfrac(ngrid)
210  real,intent(in) :: hice(ngrid)
[1297]211  real,intent(in) :: rnat(ngrid)
212  real,intent(in) :: pctsrf_sic(ngrid)
[3100]213  real,intent(in) :: tslab(ngrid,nslay)
[1297]214  real,intent(in) :: tsea_ice(ngrid)
215  real,intent(in) :: sea_ice(ngrid)
[3397]216  real,intent(in) :: tice(ngrid)
[135]217
[1216]218  integer :: iq
219 
220  ! Open file
[3552]221  call open_restartphy(filename,nid_restart)
[135]222
[1216]223  ! First variable to write must be "Time", in order to correctly
224  ! set time counter in file
225  !call put_var("Time","Temps de simulation",time)
226 
227  ! Surface temperature
[3552]228  call put_field(nid_restart,"tsurf","Surface temperature",tsurf)
[1216]229 
230  ! Soil temperature
[3552]231  call put_field(nid_restart,"tsoil","Soil temperature",tsoil)
[1216]232 
233  ! Emissivity of the surface
[3552]234  call put_field(nid_restart,"emis","Surface emissivity",emis)
[1216]235 
[3335]236  ! Surface albedo (assume homegeneous spectral albedo for now)
[3552]237  call put_field(nid_restart,"albedo","Surface albedo",albedo(:,1))
[3335]238 
[1216]239  ! Planetary Boundary Layer
[3552]240  call put_field(nid_restart,"q2","pbl wind variance",q2)
[1216]241 
242! cloud fraction and sea ice (NB: these should be optional... to be improved)
[3552]243  call put_field(nid_restart,"cloudfrac","Cloud fraction",cloudfrac)
244  call put_field(nid_restart,"totcloudfrac","Total fraction",totcloudfrac)
245  call put_field(nid_restart,"hice","Height of oceanic ice",hice)
[135]246
[1297]247 !Slab ocean
248 if(ok_slab_ocean) then
[3552]249   call put_field(nid_restart,"rnat","Nature of surface",rnat)
250   call put_field(nid_restart,"pctsrf_sic","Pourcentage sea ice",pctsrf_sic)
251   call put_field(nid_restart,"tslab","Temperature slab ocean",tslab)
252   call put_field(nid_restart,"tsea_ice","Temperature of top layer (seaice or snow)",tsea_ice)
253   call put_field(nid_restart,"tice","Temperature of seaice",tice)
254   call put_field(nid_restart,"sea_ice","Sea ice mass",sea_ice)
[1297]255 endif!(ok_slab_ocean)
256
[1216]257! tracers
258  if (nq>0) then
259    do iq=1,nq
[3552]260      call put_field(nid_restart,noms(iq),"tracer on surface",qsurf(:,iq))
[1216]261    enddo
262  endif ! of if (nq>0)
[2299]263
264! Non-orographic gavity waves
265if (calllott_nonoro) then
[3552]266   call put_field(nid_restart,"du_nonoro_gwd","Zonal wind tendency due to GW",du_nonoro_gwd)
267   call put_field(nid_restart,"dv_nonoro_gwd","Meridional wind tendency due to GW",dv_nonoro_gwd)
268   call put_field(nid_restart,"east_gwstress","Eastward stress profile due to GW",east_gwstress)
269   call put_field(nid_restart,"west_gwstress","Westward stress profile due to GW",west_gwstress)
[2299]270endif
271
[1216]272! close file
[3552]273      CALL close_restartphy(nid_restart)
[1216]274!$OMP BARRIER
[135]275
[1216]276end subroutine physdem1
[135]277
[1216]278end module phyredem
Note: See TracBrowser for help on using the repository browser.