Changeset 4347 for BOL/Replay
- Timestamp:
- Nov 11, 2022, 5:04:57 AM (2 years ago)
- Location:
- BOL/Replay
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
BOL/Replay/Readme
r4344 r4347 32 32 It equips the fortran routine before compilation. 33 33 The main documentation of the replay tools is in this script 34 By default, it equips the code for binary output for replay and nc output 35 for diangostics. 36 The -nconly option can be used to equip other routines with nc output only 37 replay_equip.sh -h 38 to see the options 34 39 35 40 * replay_param.sh -
BOL/Replay/replay_clean.sh
r4346 r4347 1 1 #!/bin/bash 2 2 3 3 4 replay_comment="replay automatic include" 4 \rm -f dump_replay*.h mcall_param_replay.F90 dump_ini_module.F90 get_ini_module.F90 input tmp tmp2 5 for file in `grep "$replay_comment" *F90 | cut -d: -f1` ; do 6 sed -i"" -e "/$replay_comment/d" $file 7 done 5 if [ $# = 0 ] ; then 6 \rm -f dump_replay*.h mcall_param_replay.F90 dump_ini_module.F90 get_ini_module.F90 input tmp tmp2 7 for file in `grep "$replay_comment" *F90 | cut -d: -f1` ; do 8 sed -i"" -e "/$replay_comment/d" $file 9 done 10 else 11 for file in $* ; do 12 list_include=`grep $replay_comment $file | grep include | cut -d\" -f2` 13 echo removing $list_include 14 \rm -f $list_include 15 \rm -f dump_replay_`basename $file .F90`_*h 16 sed -i'' -e "/$replay_comment/d" $file 17 done 18 fi -
BOL/Replay/replay_equip.sh
r4346 r4347 78 78 #----------------------------------------------------------------------------- 79 79 nconly=false 80 where=-before_return 81 80 82 if [ $# = 0 ] ; then $0 -h ; exit ; fi 81 83 while (($# > 0)) … … 83 85 case $1 in 84 86 -h|--help) cat <<........fin 85 $0 [-nconly] [-pre prefix] routine_name 86 The prefix will be put on each variable stored in the nc file 87 $0 [-nconly] [-ncvars var1,var2,...] [-pre prefix] [location_in_the_code] routine_name 88 The prefix will be put on each variable stored in the nc file to avoid duplicate 89 variables names 90 If -ncvars is not specified, all the variables are output 91 The prefix is used to prevent having twice the same name if the same variable is 92 output at two locations in the code. 93 location_in_the_code can be : -before_return (the default valuer) 94 -after_declarations 95 -before_line "line in code" 96 -after_line "line in code" 97 -before_call "param_name" (TO BE DONE) 98 -after_call "param_name" (TO BE DONE) 87 99 ........fin 88 100 exit ;; 89 101 -nconly) nconly=true ; shift ;; 102 -before_line|-after_line|-before_call|-after_call) where="$1 $2" ; shift ; shift ;; 103 -before_return|-after_declarations) where=$1 ; shift ;; 90 104 -pre) prefix=$2 ; shift ; shift ;; 105 -ncvars) ncvars="`echo $2 | sed -e 's/,/ /g'`" ; shift ; shift ;; 91 106 *) if (( $# > 1 )) ; then $0 -h ; exit ; fi ; param=`basename $1 .F90` ; shift 92 107 esac … … 107 122 iniinc=dump_replay_ini.h 108 123 paramfile=`grep -i "subro.* ${param}[\ (]" *.F90 | sed -e 's/ //g' | grep "${param}(" | cut -d: -f1` 109 echo La parametrisation $param est contenue dans le fichier $paramfile 124 echo =================================================================================== 125 echo Equiping $param contained in file $paramfile 110 126 if [ `echo ${paramfile} | wc -w` != 1 ] ; then echo file $paramfile multiple ; $0 -h ; exit ; fi 111 127 … … 149 165 # $2 nom du fichier 150 166 # input <- routine under treatment with small caps only 151 cpp $2| tr '[A-Z]' '[a-z]' > tmp167 ( cpp $2 2>/dev/null ) | tr '[A-Z]' '[a-z]' > tmp 152 168 name_min=`echo $1 | tr '[A-Z]' '[a-z]'` 153 169 line1=`sed -n -e "/subrou.*${name_min}.*(/=" tmp | head -1 ` … … 163 179 #----------------------------------------------------------------------------- 164 180 # Including param_dump*.h in the parameterization 165 line_to_be_included=$1166 param_=$2167 param file_=$3168 where=$4181 #set -vx 182 line_to_be_included=$1 ; shift 183 param_=$1 ; shift 184 paramfile_=$1 ; shift 169 185 name_min=`echo $param_ | tr [A-Z] [a-z]` 170 echo $name_min ...171 186 line_subroutine=`cat $paramfile_ | tr '[A-Z]' '[a-z]' | sed -n -e "/subrou.*${name_min}.*(/=" | head -1 ` 172 echo LINE $line_subroutine 173 tail -n +$line_subroutine $paramfile_ > tmp 187 tail -n +$line_subroutine $paramfile_ > tmp # file starting at the subroutine instruction 174 188 line_return=`sed -n -e "/[Rr][Ee][Tt][Uu][Rr][Nn]/=" tmp | head -1` 175 line_declarations=`head -$line_return tmp | tr '[A-Z]' '[a-z]' | sed -n -e 's/\!.*$//' -e "/[\ ,]real[\ ,]/=" -e "/[\ ,]integer[\ ,]/=" -e "/[\ ,]logical[\ ,]/=" -e "/[\ ,]character[\ ,]/=" | tail -1` 176 echo lignes $line_subroutine $line_return $line_declarations 177 case $where in 178 after_declarations) linebefore_include=$(( $(( $line_subroutine + $line_declarations )) -1 )) ;; 179 before_return) linebefore_include=$(( $(( $line_subroutine + $line_return )) -2 )) ;; 180 *) echo Cas non prevu where=$where in inclide_file 181 esac 182 # including lines in revers order 183 sed -i'' -e $linebefore_include"s/$/\n $line_to_be_included \! $replay_comment/" $paramfile_ 189 head -$line_return tmp > tmp2 # file containing the routine 190 sed -e 's/\!.*$//' tmp2 > tmp3 191 cpp tmp2 > tmp3 2>/dev/null 192 cat tmp3 | tr '[A-Z]' '[a-z]' > tmp2_cpp # same after cpp filtering 193 last_line_declaration2="`sed -n -e 's/\!.*$//' -e 's/^/ /' -e '/[\ ,]real[\ ,]/p' -e '/[\ ,]integer[\ ,]/p' -e '/[\ ,]logical[\ ,]/p' -e '/[\ ,]character[\ ,]/p' tmp2_cpp | tail -1 | sed -e 's/ / /g' -e 's/ /.*/g'`" 194 line_last_declaration=`cat tmp2 | tr '[A-Z]' '[a-z]' | sed -n -e "/$last_line_declaration2/="` 195 if [ "$line_last_declaration" = "" ] ; then echo line_last_declaration $line_last_declaration line $last_line_declaration2 ; exit ; fi 196 if (( $# > 0 )) ; then 197 wtype=`echo $1 | awk ' { print $1 } '` 198 case $wtype in 199 -after_declarations) targeted_line=$line_last_declaration ;; 200 -before_return) targeted_line=$line_return ;; 201 -before_line|-after_line) linestr=`echo $1 | sed -e "s/$wtype //"` ; targeted_line=`sed -n -e "/$linestr/=" tmp2` ;; 202 *) echo Cas non prevu 0 where=$where in inclide_file 203 esac 204 case $wtype in 205 -after_declarations|-after_line) line0=$(( $line_subroutine - 1 )) ;; 206 -before_return|-before_line) line0=$(( $line_subroutine - 2 )) ;; 207 *) echo Cas non prevu 1 where=$where in inclide_file 208 esac 209 echo Including line $line0 in $paramfile_ the line : $line_to_be_included 210 linebefore_include=$(( $line0 + $targeted_line )) 211 sed -i'' -e $linebefore_include"s/$/\n $line_to_be_included \! $replay_comment/" $paramfile_ 212 fi 184 213 } 185 214 … … 204 233 function iotd_calls(){ 205 234 #----------------------------------------------------------------------------- 206 klev =$1 ; shift235 klev_=$1 ; shift 207 236 pre=$1 ; shift 208 237 if (( $# >> 0 )) ; then 209 238 vars=$* 210 239 for var in $vars ; do 211 echo "call iotd_ecrit_seq('"$pre$var"', 1,'"$pre$var in $param"',' ',"$var")"240 echo "call iotd_ecrit_seq('"$pre$var"',$klev_,'"$pre$var in $param"',' ',"$var")" 212 241 done 213 242 fi 214 243 } 215 244 245 #----------------------------------------------------------------------------- 246 function b_among_a() { 247 #----------------------------------------------------------------------------- 248 a="$1" 249 b="$2" 250 o="" 251 for v in $a ; do 252 for vv in $b ; do 253 if [ "$v" = "$vv" ] ; then o="$o $v" ; fi 254 done 255 done 256 echo $o 257 } 258 216 259 217 260 #----------------------------------------------------------------------------- … … 228 271 229 272 #----------------------------------------------------------------------------- 230 # Liste des variables d'intent in pour stokage273 # Analysis of the variables to be stored and there nature 231 274 #----------------------------------------------------------------------------- 232 275 … … 235 278 varinout0=`grep inten.*.inout input | sed -e '/\!.*$/d' | cut -d: -f3 | sed -e 's/,/ /g'` 236 279 varin=`echo $varin0 | sed -e 's/ /,/g' -e "s/,,,/,/g" -e "s/,,/,/g"` 237 echo varin $varin0238 280 output=full # Attention, l'option full ne marche pas a cause de tableaux locaux undef 239 281 nvar0D=0 ; nvar1D=0 ; nvar2D=0 … … 248 290 var_1D=`grep -i "$search_str" input | grep $klon | sed -e 's/!.*$//' -e /$klev/d | cut -d: -f3 | sed -e 's/,/ /g'` 249 291 var_2D=`grep -i "$search_str" input | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'` 250 echo varin : $varin 251 echo var_1D_inout : $var_1D_inout ; echo 252 echo var_2D_inout : $var_2D_inout ; echo 253 echo var_1D_noarg : $var_1D_noarg ; echo 254 echo var_2D_noarg : $var_2D_noarg ; echo 255 echo var_1D : $var_1D ; echo 256 echo var_2D : $var_2D ; echo 292 if [ "$ncvars" != "" ] ; then 293 var_1D=`b_among_a "$var_1D" "$ncvars"` 294 var_2D=`b_among_a "$var_2D" "$ncvars"` 295 fi 296 echo Variables in and inout : $varin0 297 echo 1D variables "(all)" : $var_1D 298 echo 2D variables "(all)" : $var_2D 299 echo 1D variables "intent(inout)" : $var_1D_inout 300 echo 2D variables "intent(inout)" : $var_2D_inout 301 echo local 1D variables : $var_1D_noarg 302 echo local 2D variables : $var_2D_noarg 257 303 258 304 #----------------------------------------------------------------------------- … … 309 355 #----------------------------------------------------------------------------- 310 356 357 if [ $nconly = false ] ; then 311 358 \rm $paraminc1 312 if [ $nconly = false ] ; then313 359 cat> $paraminc1 <<eod 314 360 logical, save :: first=.true. … … 327 373 fi # nconly = false 328 374 329 for var in $var_1D_noarg $var_2D_noarg ; do echo $var=0. >> $paraminc1 ; done 330 include_line "include \"$paraminc1\"" $param $paramfile after_declarations 375 if [ "`grep $paraminc1 $paramfile`" = "" ] ; then 376 # Not changing $paraminc1 if it is already included in the file 377 # To allow adding new nc outputs in a routine equiped for replay 378 for var in $var_1D_noarg $var_2D_noarg ; do echo $var=0. >> $paraminc1 ; done 379 include_line "include \"$paraminc1\"" $param $paramfile -after_declarations 380 fi 331 381 332 382 #----------------------------------------------------------------------------- … … 337 387 iotd_calls 1 "${prefix}" $var_1D >> $paraminc2 338 388 iotd_calls $klev "${prefix}" $var_2D >> $paraminc2 339 include_line "include \"$paraminc2\"" $param $paramfile before_return389 include_line "include \"$paraminc2\"" $param $paramfile "$where" 340 390 341 391 #----------------------------------------------------------------------------- … … 352 402 close(90) 353 403 eod 354 include_line "include \"$iniinc\"" $paramini $inimod.F90 before_return404 include_line "include \"$iniinc\"" $paramini $inimod.F90 -before_return 355 405 fi # nconly = false 356 406
Note: See TracChangeset
for help on using the changeset viewer.