Changeset 4235 for dynamico_lmdz
- Timestamp:
- Jan 21, 2020, 12:54:37 AM (5 years ago)
- Location:
- dynamico_lmdz/simple_physics
- Files:
-
- 1 added
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
dynamico_lmdz/simple_physics/bash/beautify.sh
r4233 r4235 1 1 #!/bin/bash 2 3 # NOTE : sed -i seems to work differently on GNU and OSX systems 4 # a temporary file is used instead 5 6 TMP=$(mktemp) 7 2 8 for x in $* ; do 3 9 # indent source file using emacs in batch mode … … 5 11 emacs -batch $x --eval '(f90-mode)' --eval '(indent-region (point-min) (point-max) nil)' --eval '(delete-trailing-whitespace)' -f save-buffer 2>/dev/null 6 12 # remove blank lines at end of file 7 sed -i '' -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $x 13 sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $x > $TMP 14 cp -f $TMP $x 8 15 done 16 17 rm -f $TMP -
dynamico_lmdz/simple_physics/bash/concatenate_all_code.sh
r4234 r4235 4 4 5 5 for src in $* ; do 6 awk "{ print \"$src \" \$0; }" physics/${src}.F906 awk "{ print \"$src \" NR \" \" \$0; }" physics/${src}.F90 7 7 done -
dynamico_lmdz/simple_physics/bash/makedeps.sh
r4234 r4235 3 3 # input file $1 is output of bash/concatenate_all_code.sh, see phyparam/Makefile 4 4 5 function find_use()5 function print_deps() 6 6 { 7 grep '\bUSE\b' | grep -i -v '\bEND\b' | tr ',' ' ' | awk '{print "obj/" $1 ".o : " "obj/" $3".o" }'7 tr ',' ' ' | awk '{print "obj/" $1 ".o : " "obj/" $4 ".o" }' 8 8 } 9 9 10 cat $1 | find_use 10 grep '\bUSE\b' $1 | grep -i -v 'INTRINSIC' | grep -i -v '\bEND\b' | print_deps -
dynamico_lmdz/simple_physics/phyparam/DYNAMICO/icosa_phyparam_mod.F90
r4231 r4235 1 1 MODULE icosa_phyparam_mod 2 #include "use_logging.h" 3 4 ! FCM gets confused when external modules are USEd at module level 5 ! => USE statements to DYNAMICO modules go into subroutines 6 2 7 IMPLICIT NONE 8 PRIVATE 3 9 SAVE 10 11 LOGICAL :: firstcall = .TRUE. 12 LOGICAL, PARAMETER :: lastcall = .FALSE. 13 14 REAL, PARAMETER :: oneday = 86400. ! hard-coded 15 INTEGER, PARAMETER :: log_unit = 15 16 17 PUBLIC :: init_physics, physics 4 18 5 19 CONTAINS … … 7 21 SUBROUTINE init_physics 8 22 ! DYNAMICO 9 USE mpipara, ONLY : is_mpi_master 10 USE icosa, ONLY : llm, g, radius, cpp, kappa 11 USE time_mod, ONLY : dt, itau_physics 23 USE mpipara, ONLY : is_mpi_master 24 USE icosa, ONLY : llm 25 26 USE icosa, ONLY : g, radius, cpp, kappa 12 27 USE getin_mod, ONLY : getin 13 USE physics_interface_mod 28 USE physics_interface_mod, ONLY : inout => physics_inout 14 29 ! phyparam 30 USE logging, ONLY : flush_plugin, dbtag, max_log_level 31 USE read_param_mod 15 32 USE comgeomfi 16 33 USE iniphyparam_mod 17 34 INTEGER, PARAMETER :: dayref=0 18 INTEGER :: ngrid 35 CHARACTER(10) :: physics_log_level 36 INTEGER :: ngrid, lev 37 REAL :: timestep 19 38 REAL :: unjours ! solar day in seconds 20 39 21 IF(is_mpi_master) WRITE(*,*) 'phyparam/init_physics called' 22 23 ngrid = physics_inout%ngrid 40 flush_plugin => flush_log_ 41 42 physics_log_level='INF' 43 CALL getin('physics_log_level', physics_log_level) 44 DO lev=1, SIZE(dbtag) 45 IF(dbtag(lev)==TRIM(physics_log_level)) THEN 46 max_log_level = lev 47 EXIT 48 END IF 49 END DO 50 51 read_paramr_plugin => read_paramr 52 read_parami_plugin => read_parami 53 read_paramb_plugin => read_paramb 54 55 WRITELOG(*,*) 'init_physics called' 56 WRITELOG(*,*) 'physics log level set to ', dbtag(max_log_level) 57 LOG_INFO('phyparam') 58 59 ngrid = inout%ngrid 60 timestep = inout%dt_phys 61 24 62 unjours = 86400. 25 63 CALL getin('unjours', unjours) 26 64 27 CALL init_comgeomfi(ngrid, llm, & 28 & physics_inout%lon, physics_inout%lat) 65 CALL init_comgeomfi(ngrid, llm, inout%lon, inout%lat) 29 66 CALL iniphyparam(ngrid, llm, & 30 & unjours, dayref, dt*itau_physics, &67 & unjours, dayref, timestep, & 31 68 & radius, g, cpp*kappa, cpp) 32 69 … … 34 71 35 72 SUBROUTINE physics 36 USE mpipara, ONLY : is_mpi_master 37 IF(is_mpi_master) PRINT *, 'phyparam/physics called' 73 USE mpipara, ONLY : is_mpi_master 74 USE icosa, ONLY : llm 75 USE physics_interface_mod, ONLY : inout => physics_inout 76 USE phyparam_mod 77 USE error_mod 78 REAL :: dps(inout%ngrid), play(inout%ngrid, llm), pphi(inout%ngrid, llm) 79 REAL :: timestep, time, jourvrai, gmtime 80 INTEGER :: l 81 IF(is_mpi_master) WRITE(log_unit,*) 'phyparam/physics called', SHAPE(inout%p), SHAPE(inout%pk) 82 83 timestep = inout%dt_phys 84 time = timestep * inout%it 85 gmtime = time/oneday 86 jourvrai = FLOOR(gmtime) 87 gmtime = gmtime - jourvrai 88 89 ! compute pressure and geopotential at full levels 90 CALL compute_play(inout%ngrid, llm, inout%p, play) 91 CALL compute_play(inout%ngrid, llm, inout%geopot, pphi) 92 93 ! substract surface geopotential 94 DO l=1,llm 95 pphi(:,l) = pphi(:,l) - inout%geopot(:,1) 96 END DO 97 98 IF(is_mpi_master) PRINT *, 'phyparam phi :', pphi(inout%ngrid/2+1, :) 99 100 CALL check_NaN('physics', 'ulon', inout%ulon) 101 CALL check_NaN('physics', 'ulat', inout%ulat) 102 CALL check_NaN('physics', 'temp', inout%temp) 103 104 ! go 105 CALL phyparam(inout%ngrid,llm, & 106 & firstcall,lastcall, & 107 & jourvrai, gmtime, timestep, & 108 & inout%p, play, pphi, & 109 & inout%ulon, inout%ulat, inout%temp, & 110 & inout%dulon, inout%dulat, inout%dtemp, dps) 111 112 IF(is_mpi_master) PRINT *, 'phyparam dT :', inout%dtemp(inout%ngrid/2+1, :) 113 114 CALL check_NaN('physics', 'dulon', inout%dulon) 115 CALL check_NaN('physics', 'dulat', inout%dulat) 116 CALL check_NaN('physics', 'dtemp', inout%dtemp) 117 118 firstcall = .FALSE. 38 119 END SUBROUTINE physics 39 120 121 SUBROUTINE compute_play(ngrid, llm, plev, play) 122 INTEGER, INTENT(IN) :: ngrid, llm 123 REAL, INTENT(IN) :: plev(ngrid, llm+1) ! pressure at interfaces (half-levels) 124 REAL, INTENT(OUT) :: play(ngrid, llm) ! pressure in layers (full levels) 125 INTEGER :: ij, l 126 DO l = 1,llm 127 DO ij = 1,ngrid 128 play(ij,l) = .5*(plev(ij,l)+plev(ij,l+1)) 129 END DO 130 END DO 131 END SUBROUTINE compute_play 132 133 !------------------------------------------------------------------------------------ 134 !------------------------------- Infrastructure plugins ----------------------------- 135 136 !--------------------------------------- Logging ------------------------------------ 137 138 SUBROUTINE flush_log_(lev, tag, buf) 139 USE mpipara, ONLY : is_mpi_master 140 USE logging, ONLY : dbtag 141 INTEGER, INTENT(IN) :: lev 142 CHARACTER(*), INTENT(IN) :: tag, buf(:) 143 CHARACTER(100) :: prefix 144 INTEGER :: i 145 146 IF(is_mpi_master) THEN 147 WRITE(prefix,*) '[', dbtag(lev), ' ', tag, ']' 148 DO i=1, SIZE(buf) 149 WRITE(log_unit,*) TRIM(prefix), TRIM(buf(i)) 150 END DO 151 WRITE(log_unit, *) '' 152 END IF 153 END SUBROUTINE flush_log_ 154 155 !--------------------------------------- read_param ------------------------------------ 156 157 SUBROUTINE read_paramr(name, defval, val, comment) 158 USE getin_mod, ONLY : getin 159 CHARACTER(*), INTENT(IN) :: name, comment 160 REAL, INTENT(IN) :: defval 161 REAL, INTENT(OUT) :: val 162 val = defval 163 CALL getin(name, val) 164 END SUBROUTINE read_paramr 165 166 SUBROUTINE read_parami(name, defval, val, comment) 167 USE getin_mod, ONLY : getin 168 CHARACTER(*), INTENT(IN) :: name, comment 169 INTEGER, INTENT(IN) :: defval 170 INTEGER, INTENT(OUT) :: val 171 val = defval 172 CALL getin(name, val) 173 END SUBROUTINE read_parami 174 175 SUBROUTINE read_paramb(name, defval, val, comment) 176 USE getin_mod, ONLY : getin 177 CHARACTER(*), INTENT(IN) :: name, comment 178 LOGICAL, INTENT(IN) :: defval 179 LOGICAL, INTENT(OUT) :: val 180 val = defval 181 CALL getin(name, val) 182 END SUBROUTINE read_paramb 183 40 184 END MODULE icosa_phyparam_mod -
dynamico_lmdz/simple_physics/phyparam/Makefile
r4234 r4235 11 11 F90FLAGS ?= -ffree-line-length-none 12 12 13 VPATH = obj14 13 NAMES = $(basename $(notdir $(wildcard physics/*.F90))) 15 14 OBJECTS = $(addprefix obj/, $(addsuffix .o, $(NAMES))) … … 18 17 19 18 obj : 19 @rm -rf obj include lib xml tmp *~ */*~ 20 20 @mkdir obj include lib xml tmp 21 21 22 deps : 22 clean : 23 @rm -rf obj include lib xml tmp *~ */*~ 24 @mkdir obj include lib xml tmp 23 25 @../bash/concatenate_all_code.sh $(NAMES) > tmp/all_code 24 26 @../bash/makedeps.sh tmp/all_code > Makefile.inc 25 26 clean : deps27 rm -rf obj include lib xml tmp *~ */*~28 27 29 28 nice: … … 41 40 @$(FFRONT) -M tmp tmp/$(SRC).f90 > xml/$(SRC).xml 42 41 42 # dependencies between modules 43 44 $(OBJECTS) : obj/logging.o 43 45 -include Makefile.inc -
dynamico_lmdz/simple_physics/phyparam/physics/callkeys.F90
r4229 r4235 3 3 SAVE 4 4 5 LOGICAL callrad,calldifv,calladj,callcond,callsoil,season,diurnal,lverbose6 INTEGER iradia7 REAL period_sort5 LOGICAL :: callrad, calldifv, calladj, callsoil, season, diurnal, lverbose 6 INTEGER :: iradia 7 REAL :: period_sort 8 8 9 9 END MODULE callkeys -
dynamico_lmdz/simple_physics/phyparam/physics/iniphyparam_mod.F90
r4230 r4235 54 54 CALL read_param('coefir',.08 ,coefir,'coefir') 55 55 56 CALL read_param('callrad',.true.,callrad,'appel rayonnemen ')56 CALL read_param('callrad',.true.,callrad,'appel rayonnement') 57 57 CALL read_param('calldifv',.true.,calldifv,'appel difv') 58 58 CALL read_param('calladj',.true.,calladj,'appel adj') 59 CALL read_param('callcond',.true.,callcond,'appel cond')60 59 CALL read_param('callsoil',.true.,callsoil,'appel soil') 61 CALL read_param('season',.true.,season,' appel soil')62 CALL read_param('diurnal',.false.,diurnal,' appel soil')63 CALL read_param('lverbose',.true.,lverbose,' 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') 64 63 CALL read_param('period_sort',1.,period_sort,'period sorties en jour') 65 64 -
dynamico_lmdz/simple_physics/phyparam/physics/logging.F90
r4233 r4235 42 42 INTEGER, PARAMETER, PUBLIC :: log_level_fatal=1, log_level_error=2, log_level_warn=3, log_level_info=4, log_level_dbg=5 43 43 INTEGER, PUBLIC :: max_log_level = log_level_info 44 CHARACTER(3), DIMENSION(log_level_dbg), PUBLIC :: dbtag = (/ 'FAT', 'ERR', 'WRN', 'INF', 'DBG' /) 44 45 45 46 PUBLIC :: logging_buf, logging_bufsize, logging_lineno, flush_log, log_gridpoint, & … … 73 74 INTEGER, INTENT(IN) :: lev 74 75 CHARACTER(*), INTENT(IN) :: tag, buf(:) 75 CHARACTER(3), DIMENSION(log_level_dbg) :: dbtag = (/ 'FAT', 'ERR', 'WRN', 'INF', 'DBG' /)76 76 CHARACTER(100) :: prefix 77 77 INTEGER :: i -
dynamico_lmdz/simple_physics/phyparam/physics/read_param_mod.F90
r4233 r4235 43 43 INTERFACE read_param 44 44 PROCEDURE read_paramr, read_parami, read_paramb 45 END INTERFACE 45 END INTERFACE read_param 46 46 47 47 PUBLIC :: read_param … … 86 86 LOGICAL, INTENT(OUT) :: val 87 87 #ifndef XCODEML 88 IF(.NOT.ASSOCIATED(read_param r_plugin)) THEN88 IF(.NOT.ASSOCIATED(read_paramb_plugin)) THEN 89 89 CALL missing_plugin('read_paramb','read_param_mod') 90 90 val = defval -
dynamico_lmdz/simple_physics/phyparam/physics/writefield_mod.F90
r4229 r4235 24 24 INTERFACE writefield 25 25 PROCEDURE writefield1, writefield2 26 END INTERFACE 26 END INTERFACE writefield 27 27 28 28 PUBLIC :: writefield
Note: See TracChangeset
for help on using the changeset viewer.