source: dynamico_lmdz/simple_physics/phyparam/physics/iniphyparam_mod.F90 @ 4240

Last change on this file since 4240 was 4236, checked in by dubos, 5 years ago

simple_physics : some Python bindings

File size: 4.0 KB
Line 
1MODULE iniphyparam_mod
2#include "use_logging.h"
3  IMPLICIT NONE
4  PRIVATE
5
6  REAL, PARAMETER :: perfect_gas_const = 8314.46261815324 ! NB using g instead of kg for mass
7
8  PUBLIC :: iniphyparam
9
10CONTAINS
11
12  SUBROUTINE read_params(ptimestep) BIND(C, name='phyparam_setup')
13    !$cython header void phyparam_setup(double);
14    !$cython wrapper def setup(timestep) : phy.phyparam_setup(timestep)
15    USE read_param_mod
16    USE phys_const, ONLY : planet_rad,g,r,cpp,rcp,dtphys,unjours,mugaz
17    USE astronomy
18    USE planet, ONLY : coefir, coefvis
19    USE turbulence, ONLY : lmixmin, emin_turb
20    USE surface
21    USE callkeys
22    REAL, INTENT(IN), VALUE :: ptimestep
23
24    CALL read_param('planet_rad',6.4e6 ,planet_rad,'planet_rad')
25    CALL read_param('g',9.8            ,g,'g')
26    CALL read_param('cpp',1004.        ,cpp,'cpp')
27    CALL read_param('mugaz',28.        ,mugaz,'mugaz')
28    r=perfect_gas_const/mugaz
29    rcp=r/cpp
30
31    CALL read_param('unjours', 86400.,  unjours,'unjours')
32    CALL read_param('year_day',360.    ,year_day,'year_day')
33    CALL read_param('periheli',150.    ,periheli,'periheli')
34    CALL read_param('aphelie',150.     ,aphelie,'aphelie')
35    CALL read_param('peri_day',0.      ,peri_day,'peri_day')
36    CALL read_param('obliquit',23.     ,obliquit,'obliquit')
37
38    CALL read_param('Cd_mer',.01       ,Cd_mer,'Cd_mer')
39    CALL read_param('Cd_ter',.01       ,Cd_ter,'Cd_ter')
40    CALL read_param('I_mer',3000.      ,I_mer,'I_mer')
41    CALL read_param('I_ter',3000.      ,I_ter,'I_ter')
42    CALL read_param('alb_ter',.112     ,alb_ter,'alb_ter')
43    CALL read_param('alb_mer',.112     ,alb_mer,'alb_mer')
44    CALL read_param('emi_mer',1.       ,emi_mer,'emi_mer')
45    CALL read_param('emi_mer',1.       ,emi_mer,'emi_mer')
46    CALL read_param('emin_turb',1.e-16 ,emin_turb,'emin_turb')
47    CALL read_param('lmixmin',100.     ,lmixmin,'lmixmin')
48
49    CALL read_param('coefvis',.99      ,coefvis,'coefvis')
50    CALL read_param('coefir',.08       ,coefir,'coefir')
51
52    CALL read_param('callrad',  .true.,  callrad,   'appel rayonnement')
53    CALL read_param('calldifv', .true.,  calldifv,  'appel difv')
54    CALL read_param('calladj',  .true.,  calladj,   'appel adj')
55    CALL read_param('callsoil', .true.,  callsoil,  'appel soil')
56    CALL read_param('season',   .true.,  season,    'with seasonal cycle')
57    CALL read_param('diurnal',  .false., diurnal,   'with diurnal cycle')
58    CALL read_param('lverbose', .true.,  lverbose,  'lverbose')
59    CALL read_param('period_sort', 1., period_sort, 'period sorties en jour')
60
61    !   choice of the frequency of the computation of radiations
62    IF(diurnal) THEN
63       iradia=NINT(unjours/(20.*ptimestep))
64    ELSE
65       iradia=NINT(unjours/(4.*ptimestep))
66    ENDIF
67    iradia=1
68
69    dtphys=ptimestep
70  END SUBROUTINE read_params
71
72  SUBROUTINE iniphyparam(ptimestep, punjours, prad, pg, pr, pcpp)
73    USE phys_const, ONLY : planet_rad,g,r,cpp,rcp,dtphys,unjours
74    USE callkeys
75    REAL, INTENT(IN)  :: ptimestep, punjours, prad, pg, pr, pcpp
76
77    CALL read_params(ptimestep)
78
79    CALL check_mismatch('unjours', punjours, unjours)
80    CALL check_mismatch('rad', prad, planet_rad)
81    CALL check_mismatch('g', pg, g)
82    CALL check_mismatch('R', pr, r)
83    CALL check_mismatch('cpp', pcpp, cpp)
84    LOG_WARN('iniphyparam')
85
86    WRITELOG(*,*) 'Activation de la physique:'
87    WRITELOG(*,*) ' R=',r
88    WRITELOG(*,*) ' Rayonnement ',callrad
89    WRITELOG(*,*) ' Diffusion verticale turbulente ', calldifv
90    WRITELOG(*,*) ' Ajustement convectif ',calladj
91    WRITELOG(*,*) ' Sol ',callsoil
92    WRITELOG(*,*) ' Cycle diurne ',diurnal
93
94    WRITELOG(*,*) 'unjours',unjours
95    WRITELOG(*,*) 'The radiative transfer is computed each ', &
96         &   iradia,' physical time-step or each ', &
97         &   iradia*ptimestep,' seconds'
98
99    LOG_INFO('iniphyparam')
100  END SUBROUTINE iniphyparam
101
102  SUBROUTINE check_mismatch(name, a,b)
103    CHARACTER(*), INTENT(IN) :: name
104    REAL, INTENT(IN) :: a,b
105    IF(a /= b) THEN
106       WRITELOG(*,*) 'Phys/dyn mismatch for ', name, ' : ',a,b
107    END IF
108  END SUBROUTINE check_mismatch
109
110END MODULE iniphyparam_mod
Note: See TracBrowser for help on using the repository browser.