Changeset 4236 for dynamico_lmdz/simple_physics/phyparam
- Timestamp:
- Jan 22, 2020, 9:46:46 PM (5 years ago)
- Location:
- dynamico_lmdz/simple_physics/phyparam
- Files:
-
- 8 added
- 8 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
dynamico_lmdz/simple_physics/phyparam/Makefile
r4235 r4236 16 16 all : obj $(OBJECTS) lib/libphyparam.so 17 17 18 py : clean all 19 bash/extract_cython.sh 20 cd python ; rm -rf build *.c ; python setup.py build_ext --inplace 21 cd python ; python -c 'import phyparam as phys ; phys.setup(100.); phys.alloc(30,100) ; phys.coldstart(30, 100.)' 18 22 obj : 19 23 @rm -rf obj include lib xml tmp *~ */*~ 20 24 @mkdir obj include lib xml tmp 21 25 22 clean : 26 clean : nice 23 27 @rm -rf obj include lib xml tmp *~ */*~ 24 28 @mkdir obj include lib xml tmp 25 @ ../bash/concatenate_all_code.sh $(NAMES) > tmp/all_code26 @ ../bash/makedeps.sh tmp/all_code > Makefile.inc29 @bash/concatenate_all_code.sh $(NAMES) > tmp/all_code 30 @bash/makedeps.sh tmp/all_code > Makefile.inc 27 31 28 32 nice: 29 ../bash/beautify.sh physics/*.F9033 bash/beautify.sh physics/*.F90 30 34 31 35 %.so : $(OBJECTS) -
dynamico_lmdz/simple_physics/phyparam/dynphy_lonlat/iniphysiq_mod.F90
r4223 r4236 87 87 CALL setup_phyparam 88 88 89 CALL iniphyparam(klon_omp,nlayer, & 90 punjours, & 91 pdayref,ptimestep, & 92 prad,pg,pr,pcpp) 89 CALL iniphyparam(ptimestep, punjours, prad, pg, pr, pcpp) 93 90 94 91 !$OMP END PARALLEL -
dynamico_lmdz/simple_physics/phyparam/physics/error_mod.F90
r4235 r4236 11 11 INTERFACE check_NaN 12 12 MODULE PROCEDURE check_NaN1, check_NaN2 13 END INTERFACE check_NaN13 END INTERFACE 14 14 15 15 PUBLIC :: check_NaN -
dynamico_lmdz/simple_physics/phyparam/physics/iniphyparam_mod.F90
r4235 r4236 10 10 CONTAINS 11 11 12 SUBROUTINE iniphyparam(ngrid,nlayer, & 13 & punjours, & 14 & pdayref,ptimestep, & 15 & prad,pg,pr,pcpp) 16 USE callkeys 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 17 16 USE phys_const, ONLY : planet_rad,g,r,cpp,rcp,dtphys,unjours,mugaz 17 USE astronomy 18 18 USE planet, ONLY : coefir, coefvis 19 USE astronomy20 19 USE turbulence, ONLY : lmixmin, emin_turb 21 20 USE surface 22 USE read_param_mod 21 USE callkeys 22 REAL, INTENT(IN), VALUE :: ptimestep 23 23 24 INTEGER, INTENT(IN) :: & 25 ngrid, & ! Size of the horizontal grid 26 nlayer, & ! Number of vertical layers. 27 pdayref ! Day of reference for the simulation 28 REAL, INTENT(IN) :: ptimestep, prad, pg, pr, pcpp, punjours 29 30 CALL read_param('unjours', 86400., unjours,'unjours') 31 CALL read_param('planet_rad',prad,planet_rad,'planet_rad') 32 CALL read_param('g',9.8 ,g,'g') 33 CALL read_param('cpp',1004. ,cpp,'cpp') 34 CALL read_param('mugaz',28. ,mugaz,'mugaz') 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') 35 28 r=perfect_gas_const/mugaz 36 29 rcp=r/cpp 37 30 38 CALL read_param('year_day',360. ,year_day,'year_day') 39 CALL read_param('periheli',150. ,periheli,'periheli') 40 CALL read_param('aphelie',150. ,aphelie,'aphelie') 41 CALL read_param('peri_day',0. ,peri_day,'peri_day') 42 CALL read_param('obliquit',23. ,obliquit,'obliquit') 43 CALL read_param('Cd_mer',.01 ,Cd_mer,'Cd_mer') 44 CALL read_param('Cd_ter',.01 ,Cd_ter,'Cd_ter') 45 CALL read_param('I_mer',3000. ,I_mer,'I_mer') 46 CALL read_param('I_ter',3000. ,I_ter,'I_ter') 47 CALL read_param('alb_ter',.112 ,alb_ter,'alb_ter') 48 CALL read_param('alb_mer',.112 ,alb_mer,'alb_mer') 49 CALL read_param('emi_mer',1. ,emi_mer,'emi_mer') 50 CALL read_param('emi_mer',1. ,emi_mer,'emi_mer') 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') 51 46 CALL read_param('emin_turb',1.e-16 ,emin_turb,'emin_turb') 52 CALL read_param('lmixmin',100. ,lmixmin,'lmixmin') 53 CALL read_param('coefvis',.99 ,coefvis,'coefvis') 54 CALL read_param('coefir',.08 ,coefir,'coefir') 47 CALL read_param('lmixmin',100. ,lmixmin,'lmixmin') 55 48 56 CALL read_param('callrad',.true.,callrad,'appel rayonnement') 57 CALL read_param('calldifv',.true.,calldifv,'appel difv') 58 CALL read_param('calladj',.true.,calladj,'appel adj') 59 CALL read_param('callsoil',.true.,callsoil,'appel soil') 60 CALL read_param('season',.true.,season,'with seasonal cycle') 61 CALL read_param('diurnal',.false.,diurnal,'with diurnal cycle') 62 CALL read_param('lverbose',.true.,lverbose,'lverbose') 63 CALL read_param('period_sort',1.,period_sort,'period sorties en jour') 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) 64 78 65 79 CALL check_mismatch('unjours', punjours, unjours) … … 78 92 WRITELOG(*,*) ' Cycle diurne ',diurnal 79 93 80 ! choice of the frequency of the computation of radiations 81 IF(diurnal) THEN 82 iradia=NINT(punjours/(20.*ptimestep)) 83 ELSE 84 iradia=NINT(punjours/(4.*ptimestep)) 85 ENDIF 86 iradia=1 87 WRITELOG(*,*) 'unjours',punjours 94 WRITELOG(*,*) 'unjours',unjours 88 95 WRITELOG(*,*) 'The radiative transfer is computed each ', & 89 96 & iradia,' physical time-step or each ', & 90 97 & iradia*ptimestep,' seconds' 91 92 dtphys=ptimestep93 98 94 99 LOG_INFO('iniphyparam') -
dynamico_lmdz/simple_physics/phyparam/physics/logging.F90
r4235 r4236 3 3 ! see also use_logging.h 4 4 ! macro LOGBUF accumulates log output into logging_buffer 5 6 5 IMPLICIT NONE 7 6 SAVE … … 9 8 10 9 INTERFACE ! Explicit interfaces for plugins 11 12 10 ! Plugin that typically prints all lines in the loggin buffer 'buf' and prepends tags (log level, timestamp, ...) 13 SUBROUTINE plugin(lev, tag, buf) 14 INTEGER, INTENT(IN) :: lev 15 CHARACTER(*), INTENT(IN) :: tag, buf(:) 11 SUBROUTINE plugin(lev, taglen, tag, buflen, bufsize, buf) BIND(C) 12 USE, INTRINSIC :: iso_c_binding, ONLY : c_char, c_null_char, c_int 13 INTEGER(c_int), INTENT(IN), VALUE :: lev, taglen, buflen, bufsize 14 CHARACTER(KIND=c_char), INTENT(IN) :: tag(taglen), buf(buflen, bufsize) 16 15 END SUBROUTINE plugin 17 16 18 17 ! Plugin that writes into string 'line' information about the gridpoint of index 'index' 19 SUBROUTINE plugin_log_gridpoint(index, line) 20 INTEGER, INTENT(IN) :: index ! index of gridpoint 21 CHARACTER(*), INTENT(OUT) :: line 18 SUBROUTINE plugin_log_gridpoint(index, line_len, line) BIND(C) 19 USE, INTRINSIC :: iso_c_binding, ONLY : c_char, c_null_char, c_int 20 INTEGER(c_int), INTENT(IN), VALUE :: index, line_len ! index of gridpoint, LEN(line) 21 CHARACTER(KIND=c_char), INTENT(OUT) :: line(line_len) 22 22 END SUBROUTINE plugin_log_gridpoint 23 23 … … 30 30 #ifndef XCODEML 31 31 ! Note F2003/F2008: XCodeML cannot parse procedure pointers 32 PROCEDURE(plugin), POINTER, PUBLIC :: flush_plugin => NULL() 33 PROCEDURE(plugin_log_gridpoint), POINTER, PUBLIC :: log_gridpoint_plugin => NULL() 32 PUBLIC :: flush_plugin, log_gridpoint_plugin 33 PROCEDURE(plugin), POINTER :: flush_plugin => NULL() 34 PROCEDURE(plugin_log_gridpoint), POINTER :: log_gridpoint_plugin => NULL() 34 35 #endif 35 36 … … 49 50 CONTAINS 50 51 52 SUBROUTINE set_plugins(flush_plugin_c) BIND(C, name='phyparam_set_plugins_logging') 53 !$cython header void phyparam_set_plugins_logging(void *); 54 USE, INTRINSIC :: ISO_C_BINDING 55 TYPE(C_FUNPTR), INTENT(IN), VALUE :: flush_plugin_c 56 CALL C_F_PROCPOINTER(flush_plugin_c, flush_plugin) 57 END SUBROUTINE set_plugins 58 51 59 SUBROUTINE missing_plugin(name, mod) 52 60 CHARACTER(*), INTENT(IN) :: name, mod … … 56 64 CALL flush_log(log_level_warn, 'missing_plugin') 57 65 END SUBROUTINE missing_plugin 66 67 !------------------------------------------------------------------------------------------------- 58 68 59 69 SUBROUTINE flush_log(lev,tag) … … 66 76 WRITE(*,*) ' see logging.F90' 67 77 END IF 68 IF(logging_lineno>0 .AND. lev<=max_log_level) CALL flush_plugin(lev, TRIM(tag), logging_buf(1:logging_lineno)) 78 IF(logging_lineno>0 .AND. lev<=max_log_level) & 79 CALL flush_plugin(lev, LEN(tag), TRIM(tag), linesize, logging_lineno, logging_buf) 69 80 logging_lineno=0 70 81 #endif 71 82 END SUBROUTINE flush_log 72 83 73 SUBROUTINE default_flush_plugin(lev, tag, buf) 74 INTEGER, INTENT(IN) :: lev 75 CHARACTER(*), INTENT(IN) :: tag, buf(:) 84 SUBROUTINE default_flush_plugin(lev, taglen, tag, buflen, bufsize, buf) 85 USE, INTRINSIC :: iso_c_binding, ONLY : c_char, c_null_char, c_int 86 INTEGER(c_int), INTENT(IN), VALUE :: lev, taglen, buflen, bufsize 87 CHARACTER(KIND=c_char), INTENT(IN) :: tag(taglen), buf(buflen, bufsize) 76 88 CHARACTER(100) :: prefix 89 CHARACTER(buflen+1) :: line 77 90 INTEGER :: i 78 91 WRITE(prefix,*) '[', dbtag(lev), ' ', tag, ']' 79 DO i=1, SIZE(buf) 80 WRITE(*,*) TRIM(prefix), TRIM(buf(i)) 92 DO i=1, bufsize 93 WRITE(line,*) buf(:,i) 94 WRITE(*,*) TRIM(prefix), TRIM(line) 81 95 END DO 82 96 END SUBROUTINE default_flush_plugin 97 98 !------------------------------------------------------------------------------------------------- 83 99 84 100 SUBROUTINE log_gridpoint(index) … … 91 107 WRITE(*,*) ' see logging.F90' 92 108 END IF 93 CALL log_gridpoint_plugin(index, l ogging_buf(logging_lineno))109 CALL log_gridpoint_plugin(index, linesize, logging_buf(logging_lineno)) 94 110 #endif 95 111 END SUBROUTINE log_gridpoint 96 112 97 SUBROUTINE default_log_gridpoint(index, line) 98 INTEGER, INTENT(IN) :: index ! index of gridpoint 99 CHARACTER(*), INTENT(OUT) :: line 113 SUBROUTINE default_log_gridpoint(index, line_len, line) 114 USE, INTRINSIC :: iso_c_binding, ONLY : c_char, c_null_char, c_int 115 INTEGER(c_int), INTENT(IN), VALUE :: index, line_len ! index of gridpoint, LEN(line) 116 CHARACTER(KIND=c_char), INTENT(OUT) :: line(line_len) 100 117 line=' ' 101 118 END SUBROUTINE default_log_gridpoint -
dynamico_lmdz/simple_physics/phyparam/physics/phyparam_mod.F90
r4229 r4236 34 34 & pplev,pplay,pphi, & 35 35 & pu,pv,pt, & 36 & pdu,pdv,pdt,pdpsrf) 36 & pdu,pdv,pdt,pdpsrf) BIND(C, name='phyparam_phyparam') 37 37 USE phys_const, ONLY : g, rcp, r, unjours 38 38 USE surface, ONLY : soil … … 45 45 ! 20 parameters GCM for planetary atmospheres. 46 46 ! It includes: 47 ! radi tive transfer (long and shortwave) for CO2 and dust.47 ! radiative transfer (long and shortwave) for CO2 and dust. 48 48 ! vertical turbulent mixing 49 49 ! convective adjsutment 50 ! heat diffusion in the soil 50 51 ! 51 52 ! author: Frederic Hourdin 15 / 10 /93 52 53 !======================================================================= 53 54 54 INTEGER, INTENT(IN) ::&55 INTEGER, INTENT(IN), VALUE :: & 55 56 ngrid, & ! Size of the horizontal grid. 56 57 nlayer ! Number of vertical layers. 57 LOGICAL, INTENT(IN) ::&58 LOGICAL, INTENT(IN), VALUE :: & 58 59 firstcall, & ! True at the first call 59 60 lastcall ! True at the last call 60 REAL, INTENT(IN) :: &61 REAL, INTENT(IN), VALUE :: & 61 62 rjourvrai, & ! Number of days counted from the North. Spring equinox 62 63 gmtime, & ! time of the day in seconds 63 ptimestep, & ! timestep (s) 64 ptimestep ! timestep (s) 65 REAL, INTENT(IN) :: & 64 66 pplev(ngrid,nlayer+1), & ! Pressure at interfaces between layers (pa) 65 67 pplay(ngrid,nlayer), & ! Pressure at the middle of the layers (Pa) … … 431 433 END SUBROUTINE radiative_tendencies 432 434 433 SUBROUTINE alloc(ngrid, nlayer) 435 SUBROUTINE alloc(ngrid, nlayer) BIND(C, name='phyparam_alloc') 436 !$cython header void phyparam_alloc(int, int); 437 !$cython wrapper def alloc(ngrid, nlayer) : phy.phyparam_alloc(ngrid, nlayer) 434 438 USE astronomy, ONLY : iniorbit 435 439 USE surface, ONLY : zc,zd 436 INTEGER, INTENT(IN) :: ngrid, nlayer440 INTEGER, INTENT(IN), VALUE :: ngrid, nlayer 437 441 LOGICAL, PARAMETER :: firstcall=.TRUE. 438 442 ! allocate arrays for internal state … … 448 452 END SUBROUTINE alloc 449 453 450 SUBROUTINE precompute 454 SUBROUTINE precompute() BIND(C, name='phyparam_precompute') 455 !$cython header void phyparam_precompute(); 456 !$cython wrapper def precompute() : phy.phyparam_precompute() 451 457 USE surface 452 458 ! precompute time-independent arrays … … 458 464 END SUBROUTINE precompute 459 465 460 SUBROUTINE coldstart(ngrid, ptimestep) 466 SUBROUTINE coldstart(ngrid, ptimestep) BIND(C, name='phyparam_coldstart') 467 !$cython header void phyparam_coldstart(int, double); 468 !$cython wrapper def coldstart (ngrid, timestep): phy.phyparam_coldstart(ngrid, timestep) 461 469 ! create internal state to start a run without a restart file 462 470 USE surface, ONLY : soil 463 INTEGER, INTENT(IN) :: ngrid464 REAL, INTENT( iN):: ptimestep471 INTEGER, INTENT(IN), VALUE :: ngrid 472 REAL, INTENT(IN), VALUE :: ptimestep 465 473 tsurf(:) = tsoil_init 466 474 tsoil(:,:) = tsoil_init -
dynamico_lmdz/simple_physics/phyparam/physics/read_param_mod.F90
r4235 r4236 43 43 INTERFACE read_param 44 44 PROCEDURE read_paramr, read_parami, read_paramb 45 END INTERFACE read_param45 END INTERFACE 46 46 47 47 PUBLIC :: read_param -
dynamico_lmdz/simple_physics/phyparam/physics/writefield_mod.F90
r4235 r4236 24 24 INTERFACE writefield 25 25 PROCEDURE writefield1, writefield2 26 END INTERFACE writefield26 END INTERFACE 27 27 28 28 PUBLIC :: writefield
Note: See TracChangeset
for help on using the changeset viewer.