source: trunk/LMDZ.MARS/libf/phymars/dyn1d/init_testphys1d_mod.F90 @ 3253

Last change on this file since 3253 was 3253, checked in by llange, 12 months ago

Mars PCM
Following -r 3098; cleaning of vdfic for the management of subsurface water ice.
Fixing some errors (wrong interpolation to compute the water ice temperature, wrong boundary conditions to compute qvap(1))
LL

File size: 31.9 KB
Line 
1MODULE init_testphys1d_mod
2
3implicit none
4
5contains
6
7SUBROUTINE init_testphys1d(start1Dname,startfiname,therestart1D,therestartfi,ngrid,nlayer,odpref, &
8                           nq,q,time,psurf,u,v,temp,ndt,ptif,pks,dttestphys,zqsat,dq,dqdyn,day0,day,gru,grv,w,  &
9                           play,plev,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau)
10
11use ioipsl_getincom,          only: getin ! To use 'getin'
12use comcstfi_h,               only: pi, rad, omeg, g, mugaz, rcp, r, cpp
13use time_phylmdz_mod,         only: daysec, day_step, ecritphy, iphysiq
14use planete_h,                only: year_day, periheli, aphelie, peri_day, obliquit, emin_turb, lmixmin
15use surfdat_h,                only: albedodat, z0_default, z0, emissiv, emisice, albedice, iceradius, dtemisice,      &
16                                    zmea, zstd, zsig, zgam, zthe, hmons, summit, base, phisfi, watercaptag, watercap, &
17                                    tsurf, emis, qsurf, perennial_co2ice, ini_surfdat_h_slope_var, end_surfdat_h_slope_var
18use infotrac,                 only: nqtot, tname, nqperes, nqfils
19use read_profile_mod,         only: read_profile
20use iostart,                  only: open_startphy, get_var, close_startphy
21use physics_distribution_mod, only: init_physics_distribution
22use comsoil_h,                only: volcapa, nsoilmx, inertiesoil, inertiedat, layer, mlayer, flux_geo, tsoil, &
23                                    adsorption_soil, qsoil, igcm_h2o_ice_soil, porosity_reg, &
24                                    ini_comsoil_h_slope_var, end_comsoil_h_slope_var
25use comvert_mod,              only: ap, bp, aps, bps, pa, preff, presnivs, pseudoalt, scaleheight
26use dimradmars_mod,           only: tauvis, totcloudfrac, albedo, ini_dimradmars_mod_slope_var, end_dimradmars_mod_slope_var
27use regular_lonlat_mod,       only: init_regular_lonlat
28use mod_interface_dyn_phys,   only: init_interface_dyn_phys
29use geometry_mod,             only: init_geometry, init_geometry_cell_area_for_outputs
30use dimphy,                   only: init_dimphy
31use comgeomfi_h,              only: sinlat, ini_fillgeom
32use slope_mod,                only: theta_sl, psi_sl
33use comslope_mod,             only: def_slope, subslope_dist
34use dust_param_mod,           only: tauscaling
35use tracer_mod,               only: igcm_co2
36use logic_mod,                only: hybrid
37use vertical_layers_mod,      only: init_vertical_layers
38use inichim_newstart_mod,     only: inichim_newstart
39use mod_grid_phy_lmdz,        only: regular_lonlat
40use phys_state_var_init_mod,  only: phys_state_var_init
41use turb_mod,                 only: q2
42use nonoro_gwd_ran_mod,       only: du_nonoro_gwd, dv_nonoro_gwd
43use conf_phys_mod,            only: conf_phys
44use paleoclimate_mod,         only: paleoclimate, ini_paleoclimate_h, end_paleoclimate_h, h2o_ice_depth
45use comslope_mod,             only: nslope, subslope_dist, ini_comslope_h, end_comslope_h
46use co2condens_mod,           only: CO2cond_ps
47! Mostly for XIOS outputs:
48use mod_const_mpi,            only: COMM_LMDZ
49
50implicit none
51
52include "dimensions.h"
53include "callkeys.h"
54
55!=======================================================================
56! Arguments
57!=======================================================================
58integer,      intent(in) :: ngrid, nlayer
59real,         intent(in) :: odpref                     ! DOD reference pressure (Pa)
60character(*), intent(in) :: start1Dname, startfiname   ! Name of starting files for 1D
61logical,      intent(in) :: therestart1D, therestartfi ! Use of starting files for 1D
62
63integer, intent(inout) :: nq
64
65real, dimension(:,:,:), allocatable, intent(out) :: q     ! tracer mixing ratio (e.g. kg/kg)
66real,                                intent(out) :: time  ! time (0<time<1; time=0.5 at noon)
67real,                                intent(out) :: psurf ! Surface pressure
68real, dimension(nlayer),             intent(out) :: u, v  ! zonal, meridional wind
69real, dimension(nlayer),             intent(out) :: temp  ! temperature at the middle of the layers
70integer,                             intent(out) :: ndt
71real,                                intent(out) :: ptif, pks
72real,                                intent(out) :: dttestphys                   ! testphys1d timestep
73real, dimension(:),     allocatable, intent(out) :: zqsat                        ! useful for (atm_wat_profile=2)
74real, dimension(:,:,:), allocatable, intent(out) :: dq, dqdyn                    ! Physical and dynamical tandencies
75integer,                             intent(out) :: day0                         ! initial (sol ; =0 at Ls=0) and final date
76real,                                intent(out) :: day                          ! date during the run
77real,                                intent(out) :: gru, grv                     ! prescribed "geostrophic" background wind
78real, dimension(nlayer),             intent(out) :: w                            ! "Dummy wind" in 1D
79real, dimension(nlayer),             intent(out) :: play                         ! Pressure at the middle of the layers (Pa)
80real, dimension(nlayer + 1),         intent(out) :: plev                         ! intermediate pressure levels (pa)
81real, dimension(1),                  intent(out) :: latitude, longitude, cell_area
82real,                                intent(out) :: atm_wat_profile, atm_wat_tau ! Force atmospheric water profiles
83
84!=======================================================================
85! Local variables
86!=======================================================================
87integer                   :: ierr, iq, j, ilayer, isoil, nlevel, nsoil, flagthermo, flagh2o, nslope_tmp
88integer                   :: dayn ! Final date
89real, dimension(nlayer)   :: zlay ! altitude estimee dans les couches (km)
90real, dimension(0:nlayer) :: tmp1, tmp2
91
92! Dummy variables along "dynamics scalar grid"
93real, dimension(:,:,:,:), allocatable :: qdyn
94real, dimension(:,:),     allocatable :: psdyn
95
96! RV & JBC: Use of starting files for 1D
97logical                :: found
98character(30)          :: header
99real, dimension(100)   :: tab_cntrl
100
101! New flag to compute paleo orbital configurations + few variables JN
102logical :: paleomars
103real    :: halfaxe, eccentric, Lsperi
104
105! MVals: isotopes as in the dynamics (CRisi)
106integer                                  :: ipere, ierr0
107character(30), dimension(:), allocatable :: tnom_transp ! transporting fluid short name
108character(80)                            :: line        ! to store a line of text
109logical                                  :: continu
110
111! LL: Possibility to add subsurface ice
112real    :: ice_depth          ! depth of the ice table, ice_depth < 0. means no ice
113real    :: inertieice         ! ice thermal inertia
114integer :: iref
115
116! LL: Subsurface water ice
117real :: rho_H2O_ice           ! Density (kg/m^3) of water ice
118
119!=======================================================================
120! Code
121!=======================================================================
122!------------------------------------------------------
123! Prescribed constants to be set here
124!------------------------------------------------------
125! Mars planetary constants
126! ------------------------
127rad = 3397200.            ! mars radius (m) ~3397200 m
128daysec = 88775.           ! length of a sol (s) ~88775 s
129omeg = 4.*asin(1.)/daysec ! rotation rate (rad.s-1)
130g = 3.72                  ! gravity (m.s-2) ~3.72
131mugaz = 43.49             ! atmosphere mola mass (g.mol-1) ~43.49
132rcp = .256793             ! = r/cp ~0.256793
133r = 8.314511*1000./mugaz
134cpp = r/rcp
135year_day = 669            ! length of year (sols) ~668.6
136periheli = 206.66         ! minimum sun-mars distance (Mkm) ~206.66
137aphelie = 249.22          ! maximum sun-mars distance (Mkm) ~249.22
138halfaxe = 227.94          ! demi-grand axe de l'ellipse
139peri_day = 485.           ! perihelion date (sols since N. Spring)
140obliquit = 25.2           ! Obliquity (deg) ~25.2
141eccentric = 0.0934        ! Eccentricity (0.0934)
142
143! Planetary Boundary Layer and Turbulence parameters
144! --------------------------------------------------
145z0_default = 1.e-2 ! surface roughness (m) ~0.01
146emin_turb = 1.e-6  ! minimal turbulent energy ~1.e-8
147lmixmin = 30       ! mixing length ~100
148
149! Cap properties and surface emissivities
150! ---------------------------------------
151emissiv = 0.95         ! Bare ground emissivity ~.95
152emisice(1) = 0.95      ! Northern cap emissivity
153emisice(2) = 0.95      ! Southern cap emisssivity
154albedice(1) = 0.5      ! Northern cap albedo
155albedice(2) = 0.5      ! Southern cap albedo
156iceradius(1) = 100.e-6 ! mean scat radius of CO2 snow (north)
157iceradius(2) = 100.e-6 ! mean scat radius of CO2 snow (south)
158dtemisice(1) = 2.      ! time scale for snow metamorphism (north)
159dtemisice(2) = 2.      ! time scale for snow metamorphism (south)
160
161! Water ice properties
162! ---------------------------------------
163inertieice = 2100.
164rho_H2O_ice = 920.
165
166! Mesh surface (not a very usefull quantity in 1D)
167! ------------------------------------------------
168cell_area(1) = 1.
169
170! Check if there is a 'traceur.def' file and process it
171! Load tracer names from file 'traceur.def'
172! -----------------------------------------------------
173open(90,file = 'traceur.def',status = 'old',form = 'formatted',iostat = ierr)
174if (ierr /= 0) then
175    write(*,*) 'Cannot find required file "traceur.def"'
176    write(*,*) ' If you want to run with tracers, I need it'
177    write(*,*) ' ... might as well stop here ...'
178    error stop
179else
180    write(*,*) "init_testphys1d: Reading file traceur.def"
181    ! read number of tracers:
182    read(90,*,iostat = ierr) nq
183    nqtot = nq ! set value of nqtot (in infotrac module) as nq
184    if (ierr /= 0) then
185        write(*,*) "init_testphys1d: error reading number of tracers"
186        write(*,*) "   (first line of traceur.def) "
187        error stop
188    endif
189    if (nq < 1) then
190        write(*,*) "init_testphys1d: error number of tracers"
191        write(*,*) "is nq=",nq," but must be >=1!"
192        error stop
193    endif
194endif
195
196! Allocate arrays
197allocate(tname(nq),q(1,nlayer,nq),zqsat(nlayer))
198allocate(dq(1,nlayer,nq),dqdyn(1,nlayer,nq),tnom_transp(nq))
199
200! Read tracer names from file traceur.def
201do iq = 1,nq
202    read(90,'(80a)',iostat = ierr) line ! store the line from traceur.def
203    if (ierr /= 0) then
204        error stop 'init_testphys1d: error reading tracer names...'
205    endif
206    ! if format is tnom_0, tnom_transp (isotopes)
207    read(line,*,iostat = ierr0) tname(iq),tnom_transp(iq)
208    if (ierr0 /= 0) then
209        read(line,*) tname(iq)
210        tnom_transp(iq) = 'air'
211    endif
212enddo
213close(90)
214
215! Isotopes: as in the 3D case we have to determine father/son relations for isotopes and carrying fluid
216allocate(nqfils(nqtot))
217nqperes = 0
218nqfils = 0
219do iq = 1,nqtot
220    if (tnom_transp(iq) == 'air') then
221        ! ceci est un traceur père
222        write(*,*) 'Le traceur',iq,', appele ',trim(tname(iq)),', est un pere'
223        nqperes = nqperes + 1
224    else !if (tnom_transp(iq) == 'air') then
225        ! ceci est un fils. Qui est son père?
226        write(*,*) 'Le traceur',iq,', appele ',trim(tname(iq)),', est un fils'
227        continu = .true.
228        ipere = 1
229        do while (continu)
230            if (tnom_transp(iq) == tname(ipere)) then
231                ! Son père est ipere
232                write(*,*) 'Le traceur',iq,'appele ',trim(tname(iq)),' est le fils de ',ipere,'appele ',trim(tname(ipere))
233                nqfils(ipere) = nqfils(ipere) + 1
234                continu = .false.
235            else !if (tnom_transp(iq) == tnom_0(ipere)) then
236                ipere = ipere + 1
237                if (ipere > nqtot) then
238                    write(*,*) 'Le traceur',iq,'appele ',trim(tname(iq)),', est orpelin.'
239                    call abort_gcm('infotrac_init','Un traceur est orphelin',1)
240                endif !if (ipere > nqtot) then
241            endif !if (tnom_transp(iq) == tnom_0(ipere)) then
242        enddo !do while (continu)
243    endif !if (tnom_transp(iq) == 'air') then
244enddo !do iq=1,nqtot
245write(*,*) 'nqperes=',nqperes
246write(*,*) 'nqfils=',nqfils
247
248#ifdef CPP_XIOS
249    call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,COMM_LMDZ)
250#else
251    call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,1)
252#endif
253
254! Date and local time at beginning of run
255! ---------------------------------------
256if (.not. therestartfi) then
257    ! Date (in sols since spring solstice) at beginning of run
258    day0 = 0 ! default value for day0
259    write(*,*) 'Initial date (in martian sols; =0 at Ls=0)?'
260    call getin("day0",day0)
261    day = float(day0)
262    write(*,*) " day0 = ",day0
263    ! Local time at beginning of run
264    time = 0 ! default value for time
265    write(*,*)'Initial local time (in hours, between 0 and 24)?'
266    call getin("time",time)
267    write(*,*)" time = ",time
268    time = time/24. ! convert time (hours) to fraction of sol
269else
270    call open_startphy(trim(startfiname))
271    call get_var("controle",tab_cntrl,found)
272    if (.not. found) then
273        call abort_physic("open_startphy","tabfi: Failed reading <controle> array",1)
274    else
275        write(*,*)'tabfi: tab_cntrl',tab_cntrl
276    endif
277    day0 = tab_cntrl(3)
278    day = float(day0)
279
280    call get_var("Time",time,found)
281    call close_startphy
282endif !(.not. therestartfi)
283
284! Discretization (Definition of grid and time steps)
285! --------------------------------------------------
286nlevel = nlayer + 1
287nsoil = nsoilmx
288
289day_step = 48 ! Default value for day_step
290write(*,*)'Number of time steps per sol?'
291call getin("day_step",day_step)
292write(*,*) " day_step = ",day_step
293
294ecritphy = day_step ! Default value for ecritphy, output every time step
295
296ndt = 10 ! Default value for ndt
297write(*,*)'Number of sols to run?'
298call getin("ndt",ndt)
299write(*,*) " ndt = ",ndt
300
301dayn = day0 + ndt
302ndt = ndt*day_step
303dttestphys = daysec/day_step
304
305! Imposed surface pressure
306! ------------------------
307psurf = 610. ! Default value for psurf
308write(*,*) 'Surface pressure (Pa)?'
309if (.not. therestart1D) then
310    call getin("psurf",psurf)
311else
312    open(3,file = trim(start1Dname),status = "old",action = "read")
313    read(3,*) header, psurf
314endif
315write(*,*) " psurf = ",psurf
316
317! Coefficient to control the surface pressure change
318! To be defined in "callphys.def" so that the PEM can read it asa well
319! If CO2cond_ps = 0, surface pressure is kept constant; If CO2cond_ps = 1, surface pressure varies normally
320! CO2cond_ps = 300*400/144.37e6 = 8.31e-4 (ratio of polar cap surface over planetary surface) is a typical value for tests
321! --------------------------------------------------------------------
322CO2cond_ps = 1. ! Default value
323write(*,*) 'Coefficient to control the surface pressure change?'
324call getin("CO2cond_ps",CO2cond_ps)
325if (CO2cond_ps < 0. .or. CO2cond_ps > 1.) then
326    write(*,*) 'Value for ''CO2cond_ps'' is not between 0 and 1.'
327    error stop 'Please, specify a correct value!'
328endif
329
330! Reference pressures
331pa = 20.     ! Transition pressure (for hybrid coord.)
332preff = 610. ! Reference surface pressure
333
334! Aerosol properties
335! ------------------
336tauvis = 0.2 ! Default value for tauvis (dust opacity)
337write(*,'("Reference dust opacity at ",f4.0," Pa?")')odpref
338call getin("tauvis",tauvis)
339write(*,*) " tauvis = ",tauvis
340
341! Orbital parameters
342! ------------------
343if (.not. therestartfi) then
344    paleomars = .false. ! Default: no water ice reservoir
345    call getin("paleomars",paleomars)
346    if (paleomars) then
347        write(*,*) "paleomars=", paleomars
348        write(*,*) "Orbital parameters from callphys.def"
349        write(*,*) "Enter eccentricity & Lsperi"
350        write(*,*) 'Martian eccentricity (0<e<1)?'
351        call getin('eccentric ',eccentric)
352        write(*,*)"eccentric =",eccentric
353        write(*,*) 'Solar longitude of perihelion (0<Ls<360)?'
354        call getin('Lsperi',Lsperi )
355        write(*,*)"Lsperi=",Lsperi
356        Lsperi = Lsperi*pi/180.0 ! Put it in rad for peri_day
357        periheli = halfaxe*(1 - eccentric)
358        aphelie = halfaxe*(1 + eccentric)
359        call call_dayperi(Lsperi,eccentric,peri_day,year_day)
360        write(*,*) "Corresponding orbital params for GCM"
361        write(*,*) " periheli = ",periheli
362        write(*,*) " aphelie = ",aphelie
363        write(*,*) "date of perihelion (sol)",peri_day
364    else
365        write(*,*) "paleomars=", paleomars
366        write(*,*) "Default present-day orbital parameters"
367        write(*,*) "Unless specified otherwise"
368        write(*,*)'Min. distance Sun-Mars (Mkm)?'
369        call getin("periheli",periheli)
370        write(*,*) " periheli = ",periheli
371
372        write(*,*)'Max. distance Sun-Mars (Mkm)?'
373        call getin("aphelie",aphelie)
374        write(*,*) " aphelie = ",aphelie
375
376        write(*,*)'Day of perihelion?'
377        call getin("periday",peri_day)
378        write(*,*) " periday = ",peri_day
379
380        write(*,*)'Obliquity?'
381        call getin("obliquit",obliquit)
382        write(*,*) " obliquit = ",obliquit
383     endif
384endif !(.not. therestartfi)
385
386! Latitude/longitude
387! ------------------
388latitude = 0. ! default value for latitude
389write(*,*)'latitude (in degrees)?'
390call getin("latitude",latitude(1))
391write(*,*) " latitude = ",latitude
392latitude = latitude*pi/180.
393longitude = 0.
394longitude = longitude*pi/180.
395
396! Some initializations (some of which have already been done above!)
397! and loads parameters set in callphys.def and allocates some arrays
398! Mars possible matter with dttestphys in input and include!!!
399! Initializations below should mimick what is done in iniphysiq for 3D GCM
400call init_interface_dyn_phys
401call init_regular_lonlat(1,1,longitude,latitude,(/0.,0./),(/0.,0./))
402call init_geometry(1,longitude,latitude,(/0.,0.,0.,0./),(/0.,0.,0.,0./),cell_area)
403call init_geometry_cell_area_for_outputs(1,cell_area)
404! Ehouarn: init_vertial_layers called later (because disvert not called yet)
405! call init_vertical_layers(nlayer,preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
406call init_dimphy(1,nlayer) ! Initialize dimphy module
407call phys_state_var_init(1,llm,nq,tname,day0,dayn,time,daysec,dttestphys,rad,g,r,cpp,nqperes,nqfils) ! MVals: variables isotopes
408call ini_fillgeom(1,latitude,longitude,(/1.0/))
409call conf_phys(1,llm,nq)
410call initracer(ngrid,nq,qsurf)
411
412! In 1D model physics are called every time step
413! ovverride iphysiq value that has been set by conf_phys
414if (iphysiq /= 1) then
415    write(*,*) "init_testphys1d: setting iphysiq=1"
416    iphysiq = 1
417endif
418
419! Initialize local slope parameters
420! ---------------------------------
421nslope_tmp = nslope
422write(*,*)'Number of slopes?' ! Number of subgrid scale slopes
423call getin("nslope",nslope_tmp)
424write(*,*) " nslope = ", nslope_tmp
425if (.not. therestartfi) then
426    nslope = nslope_tmp
427    call end_comslope_h
428    call ini_comslope_h(1,nslope)
429    select case (nslope)
430        case(1)
431            ! Sub-slopes parameters (minimum/maximun angles)
432            def_slope(1) = -90.
433            def_slope(2) = 90.
434            ! Fraction of subslopes in mesh
435            subslope_dist(1,1) = 1.
436        case(3)
437            ! Sub-slopes parameters (minimum/maximun angles)
438            def_slope(1) = -50.
439            def_slope(2) = -3.
440            def_slope(3) = 3.
441            def_slope(4) = 50.
442            ! Fraction of subslopes in mesh
443            subslope_dist(1,1) = 0.1
444            subslope_dist(1,2) = 0.8
445            subslope_dist(1,3) = 0.1
446        case(5)
447            ! Sub-slopes parameters (minimum/maximun angles)
448            def_slope(1) = -43.
449            def_slope(2) = -9.
450            def_slope(3) = -3.
451            def_slope(4) = 3.
452            def_slope(5) = 9.
453            def_slope(6) = 43.
454            ! Fraction of subslopes in mesh
455            subslope_dist(1,1) = 0.025
456            subslope_dist(1,2) = 0.075
457            subslope_dist(1,3) = 0.8
458            subslope_dist(1,4) = 0.075
459            subslope_dist(1,5) = 0.025
460        case(7)
461            ! Sub-slopes parameters (minimum/maximun angles)
462            def_slope(1) = -43.
463            def_slope(2) = -19.
464            def_slope(3) = -9.
465            def_slope(4) = -3.
466            def_slope(5) = 3.
467            def_slope(6) = 9.
468            def_slope(7) = 19.
469            def_slope(8) = 43.
470            ! Fraction of subslopes in mesh
471            subslope_dist(1,1) = 0.01
472            subslope_dist(1,2) = 0.02
473            subslope_dist(1,3) = 0.06
474            subslope_dist(1,4) = 0.8
475            subslope_dist(1,5) = 0.06
476            subslope_dist(1,6) = 0.02
477            subslope_dist(1,7) = 0.01
478        case default
479            error stop 'Number of slopes not possible: nslope should be 1, 3, 5 or 7!'
480    end select
481
482    call end_surfdat_h_slope_var
483    call ini_surfdat_h_slope_var(1,nq,nslope)
484    call end_comsoil_h_slope_var
485    call ini_comsoil_h_slope_var(1,nslope)
486    call end_dimradmars_mod_slope_var
487    call ini_dimradmars_mod_slope_var(1,nslope)
488    call end_paleoclimate_h
489    call ini_paleoclimate_h(1,nslope)
490else
491    if (nslope /= nslope_tmp) then
492        error stop 'Number of slopes not compatible between "startfi.nc" and "run.def".'
493    else
494        write(*,*) 'Be careful: subslopes distribution and definition are taken from "startfi.nc" and not initialized by default!'
495    endif
496endif
497
498! Slope inclination angle (deg) 0: horizontal, 90: vertical
499theta_sl = 0. ! default: no inclination
500call getin("slope_inclination",theta_sl)
501
502! Slope orientation (deg)
503! 0 == Northward, 90 == Eastward, 180 == Southward, 270 == Westward
504psi_sl = 0. ! default value
505call getin("slope_orientation",psi_sl)
506
507! Initialize tracers (surface and atmosphere)
508!--------------------------------------------
509write(*,*) "init_testphys1d: initializing tracers"
510if (.not. therestart1D) then
511    call read_profile(nq,nlayer,qsurf(1,:,1),q)
512    do iq = 1,nq
513        qsurf(1,iq,:) = qsurf(1,iq,1)
514    enddo
515else
516    do iq = 1,nq
517        read(3,*) header, (qsurf(1,iq,j), j = 1,size(qsurf,3)), (q(1,ilayer,iq), ilayer = 1,nlayer)
518        if (trim(tname(iq)) /= trim(header)) then
519            write(*,*) 'Tracer names between "traceur.def" and "'//trim(start1Dname)//'" do not match!'
520            write(*,*) 'Please, write the tracer names in the same order for both files.'
521            error stop
522        endif
523    enddo
524endif
525
526! Initialize albedo / soil thermal inertia
527! ----------------------------------------
528if (.not. therestartfi) then
529    albedodat(1) = 0.2 ! default value for albedodat
530    write(*,*)'Albedo of bare ground?'
531    call getin("albedo",albedodat(1))
532    write(*,*) " albedo = ",albedodat(1)
533    albedo(1,:,:) = albedodat(1)
534
535    inertiedat(1,1) = 400 ! default value for inertiedat
536    write(*,*)'Soil thermal inertia (SI)?'
537    call getin("inertia",inertiedat(1,1))
538    write(*,*) " inertia = ",inertiedat(1,1)
539
540    ice_depth = -1 ! default value: no ice
541    call getin("subsurface_ice_depth",ice_depth)
542    write(*,*) " subsurface_ice_depth = ",ice_depth
543    h2o_ice_depth(:,:) = ice_depth
544    z0(1) = z0_default ! default value for roughness
545    write(*,*) 'Surface roughness length z0 (m)?'
546    call getin("z0",z0(1))
547    write(*,*) " z0 = ",z0(1)
548endif !(.not. therestartfi)
549
550! For the gravity wave scheme
551! ---------------------------
552zmea(1) = 0.
553zstd(1) = 0.
554zsig(1) = 0.
555zgam(1) = 0.
556zthe(1) = 0.
557
558! For the non-orographic gravity waves scheme
559du_nonoro_gwd(1,:) = 0
560dv_nonoro_gwd(1,:) = 0
561
562! For the slope wind scheme
563! -------------------------
564hmons(1) = 0.
565write(*,*)'hmons is initialized to ',hmons(1)
566summit(1) = 0.
567write(*,*)'summit is initialized to ',summit(1)
568base(1) = 0.
569
570! Default values initializing the coefficients calculated later
571! -------------------------------------------------------------
572tauscaling(1) = 1.   ! calculated in aeropacity_mod.F
573totcloudfrac(1) = 1. ! calculated in watercloud_mod.F
574
575! Specific initializations for "physiq"
576! -------------------------------------
577! surface geopotential is not used (or useful) since in 1D
578! everything is controled by surface pressure
579phisfi(1) = 0.
580
581! Initialization to take into account prescribed winds
582! ----------------------------------------------------
583ptif = 2.*omeg*sinlat(1)
584
585! Geostrophic wind
586gru = 10. ! default value for gru
587write(*,*)'zonal eastward component of the geostrophic wind (m/s)?'
588call getin("u",gru)
589write(*,*) " u = ",gru
590grv = 0. !default value for grv
591write(*,*)'meridional northward component of the geostrophic wind (m/s)?'
592call getin("v",grv)
593write(*,*) " v = ",grv
594
595! Initialize winds for first time step
596!-------------------------------------
597if (.not. therestart1D) then
598    u = gru
599    v = grv
600else
601    read(3,*) header, (u(ilayer), ilayer = 1,nlayer)
602    read(3,*) header, (v(ilayer), ilayer = 1,nlayer)
603endif
604w = 0. ! default: no vertical wind
605
606! Initialize turbulent kinetic energy
607!------------------------------------
608q2 = 0.
609
610! CO2 ice on the surface
611! ----------------------
612if (.not. therestartfi) then
613    qsurf(1,igcm_co2,:) = 0. ! default value for co2ice
614    write(*,*)'Initial CO2 ice on the surface (kg.m-2)'
615    call getin("co2ice",qsurf(1,igcm_co2,1))
616    qsurf(1,igcm_co2,:) = qsurf(1,igcm_co2,1)
617    write(*,*) " co2ice = ",qsurf(1,igcm_co2,1)
618endif !(.not. therestartfi)
619
620! Emissivity
621! ----------
622if (.not. therestartfi) then
623    emis = emissiv
624    if (qsurf(1,igcm_co2,1) == 1.) then
625        emis = emisice(1) ! northern hemisphere
626        if (latitude(1) < 0) emis = emisice(2) ! southern hemisphere
627    endif
628endif !(.not. therestartfi)
629
630! Compute pressures and altitudes of atmospheric levels
631! -----------------------------------------------------
632! Vertical Coordinates
633! """"""""""""""""""""
634hybrid = .true.
635write(*,*)'Hybrid coordinates?'
636call getin("hybrid",hybrid)
637write(*,*) " hybrid = ", hybrid
638
639call disvert_noterre
640! Now that disvert has been called, initialize module vertical_layers_mod
641call init_vertical_layers(nlayer,preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
642
643plev = ap + psurf*bp
644play = aps + psurf*bps
645zlay = -200.*r*log(play/plev(1))/g
646
647! Initialize temperature profile
648! ------------------------------
649pks = psurf**rcp
650
651! Altitude in km in profile: divide zlay by 1000
652tmp1(0) = 0.
653tmp1(1:) = zlay/1000.
654
655call profile(nlayer + 1,tmp1,tmp2)
656
657if (.not. therestart1D) then
658    tsurf = tmp2(0)
659    temp = tmp2(1:)
660else
661    read(3,*) header, (tsurf(1,:), j = 1,size(tsurf,2)), (temp(ilayer), ilayer = 1,nlayer)
662    close(3)
663endif
664
665! Initialize soil properties, temperature and content
666! ------------------------------------------
667volcapa = 1.e6 ! volumetric heat capacity
668
669if (.not. therestartfi) qsoil = 0.
670
671if (.not. therestartfi) then
672    ! Initialize depths
673    ! -----------------
674    do isoil = 0,nsoil - 1
675       mlayer(isoil) = 2.e-4*(1 + isoil**2.9*(1 - exp(-real(isoil)/20.))) ! mid layer depth
676    enddo
677    do isoil = 1,nsoil - 1
678       layer(isoil) = (mlayer(isoil) + mlayer(isoil - 1))/2
679    enddo
680    layer(nsoil) = 2*mlayer(nsoil - 1) - mlayer(nsoil - 2)
681
682    ! Creating the new soil inertia table if there is subsurface ice:
683    if (ice_depth > 0) then
684        iref = 1 ! ice/regolith boundary index
685        if (ice_depth < layer(1)) then
686            inertiedat(1,1) = sqrt(layer(1)/((ice_depth/inertiedat(1,1)**2) + ((layer(1) - ice_depth)/inertieice**2)))
687            inertiedat(1,2:) = inertieice
688            if(adsorption_soil) then
689            ! add subsurface ice in qsoil if one runs with adsorption
690                qsoil(1,1,igcm_h2o_ice_soil,:) = (ice_depth-layer(2))/(layer(1) - layer(2))*porosity_reg*rho_H2O_ice
691                qsoil(1,2:,igcm_h2o_ice_soil,:) = porosity_reg*rho_H2O_ice
692            endif
693        else ! searching for the ice/regolith boundary:
694            do isoil = 1,nsoil
695                if ((ice_depth >= layer(isoil)) .and. (ice_depth < layer(isoil + 1))) then
696                    iref = isoil
697                    exit
698                endif
699            enddo
700            ! We then change the soil inertia table:
701            inertiedat(1,:iref - 1) = inertiedat(1,1)
702            ! We compute the transition in layer(iref)
703            inertiedat(1,iref) = sqrt((layer(iref+1) - layer(iref))/(((ice_depth - layer(iref))/inertiedat(1,1)**2) + ((layer(iref+1) - ice_depth)/inertieice**2)))
704            ! Finally, we compute the underlying ice:
705            inertiedat(1,iref + 1:) = inertieice
706           
707            if(adsorption_soil) then
708            ! add subsurface ice in qsoil if one runs with adsorption
709                qsoil(1,:iref - 1,igcm_h2o_ice_soil,:) = 0.
710                qsoil(1,iref+1:,igcm_h2o_ice_soil,:) = porosity_reg*rho_H2O_ice
711                qsoil(1,iref,igcm_h2o_ice_soil,:) = (ice_depth-layer(iref+1))/(layer(iref) - layer(iref+1))*porosity_reg*rho_H2O_ice
712            endif
713        endif ! (ice_depth < layer(1))
714    else ! ice_depth < 0 all is set to surface thermal inertia
715        inertiedat(1,:) = inertiedat(1,1) ! soil thermal inertia
716    endif ! ice_depth > 0
717   
718    do isoil = 1,nsoil
719        inertiesoil(1,isoil,:) = inertiedat(1,isoil)
720        tsoil(1,isoil,:) = tsurf(1,:) ! soil temperature
721    enddo
722endif !(.not. therestartfi)
723
724! Initialize subsurface geothermal flux
725! -------------------------------------
726flux_geo = 0.
727call getin("flux_geo",flux_geo(1,1))
728write(*,*) " flux_geo = ",flux_geo(1,1)
729flux_geo = flux_geo(1,1)
730
731
732! Initialize traceurs
733! -------------------
734if (photochem .or. callthermos) then
735    write(*,*) 'Initializing chemical species'
736    ! flagthermo=0: initialize over all atmospheric layers
737    flagthermo = 0
738    ! check if "h2o_vap" has already been initialized
739    ! (it has been if there is a "profile_h2o_vap" file around)
740    inquire(file = "profile_h2o_vap",exist = found)
741    if (found) then
742        flagh2o = 0 ! 0: do not initialize h2o_vap
743    else
744        flagh2o = 1 ! 1: initialize h2o_vap in inichim_newstart
745    endif
746
747    ! hack to accomodate that inichim_newstart assumes that
748    ! q & psurf arrays are on the dynamics scalar grid
749    allocate(qdyn(2,1,llm,nq),psdyn(2,1))
750    qdyn(1,1,1:llm,1:nq) = q(1,1:llm,1:nq)
751    psdyn(1:2,1) = psurf
752    call inichim_newstart(ngrid,nq,qdyn,qsurf(1,:,1),psdyn,flagh2o,flagthermo)
753    q(1,1:llm,1:nq) = qdyn(1,1,1:llm,1:nq)
754endif
755
756! Check if the surface is a water ice reservoir
757! ---------------------------------------------
758if (.not. therestartfi) watercap(1,:) = 0 ! Initialize watercap
759watercaptag(1) = .false. ! Default: no water ice reservoir
760write(*,*)'Water ice cap on ground?'
761call getin("watercaptag",watercaptag)
762write(*,*) " watercaptag = ",watercaptag
763
764! Initialize perennial_co2ice
765! ---------------------------
766if (.not. therestartfi .and. paleoclimate) perennial_co2ice = 0.
767
768! Check if the atmospheric water profile is specified
769! ---------------------------------------------------
770! Adding an option to force atmospheric water values JN
771atm_wat_profile = -1. ! Default: free atm wat profile
772if (water) then
773    write(*,*)'Force atmospheric water vapor profile?'
774    call getin('atm_wat_profile',atm_wat_profile)
775    write(*,*) 'atm_wat_profile = ', atm_wat_profile
776    if (abs(atm_wat_profile + 1.) < 1.e-15) then ! if == -1.
777        write(*,*) 'Free atmospheric water vapor profile'
778        write(*,*) 'Total water is conserved in the column'
779    else if (abs(atm_wat_profile) < 1.e-15) then ! if == 0.
780        write(*,*) 'Dry atmospheric water vapor profile'
781    else if (0. < atm_wat_profile .and. atm_wat_profile <= 1.) then
782        write(*,*) 'Prescribed atmospheric water vapor profile'
783        write(*,*) 'Unless it reaches saturation (maximal value)'
784    else if (atm_wat_profile .eq. 2) then
785        write(*,*) 'Prescribed atmospheric water vapor profile'
786        write(*,*) 'like present day northern midlatitude'
787        write(*,*) 'Unless it reaches saturation (maximal value)'
788    else
789        error stop 'Water vapor profile value not correct!'
790    endif
791endif
792
793! Check if the atmospheric water profile relaxation is specified
794! --------------------------------------------------------------
795! Adding an option to relax atmospheric water values JBC
796atm_wat_tau = -1. ! Default: no time relaxation
797if (water) then
798    write(*,*) 'Relax atmospheric water vapor profile?'
799    call getin('atm_wat_tau',atm_wat_tau)
800    write(*,*) 'atm_wat_tau = ', atm_wat_tau
801    if (atm_wat_tau < 0.) then
802        write(*,*) 'Atmospheric water vapor profile is not relaxed.'
803    else
804        if (0. <= atm_wat_profile .and. atm_wat_profile <= 1.) then
805            write(*,*) 'Relaxed atmospheric water vapor profile towards ', atm_wat_profile
806            write(*,*) 'Unless it reaches saturation (maximal value)'
807        else
808            write(*,*) 'Reference atmospheric water vapor profile not known!'
809            error stop 'Please, specify atm_wat_profile'
810        endif
811    endif
812endif
813
814END SUBROUTINE init_testphys1d
815
816END MODULE init_testphys1d_mod
Note: See TracBrowser for help on using the repository browser.