Changeset 5033 for BOL/Replay
- Timestamp:
- Jul 9, 2024, 1:42:07 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BOL/Replay/replay_equip.sh
r4681 r5033 1 1 #!/bin/bash 2 2 3 #set -vx3 #set -vx 4 4 5 5 #============================================================================= … … 79 79 nconly=false 80 80 where=-before_return 81 lonlat= 81 82 82 83 if [ $# = 0 ] ; then $0 -h ; exit ; fi … … 85 86 case $1 in 86 87 -h|--help) cat <<........fin 87 $0 [-nconly] [-ncvars var1,var2,...] [-pre prefix] [location_in_the_code] routine_name88 $0 [-nconly] [-ncvars var1,var2,...] [-pre prefix] [location_in_the_code] [-lonlat lon,lat] routine_name 88 89 The prefix will be put on each variable stored in the nc file to avoid duplicate 89 90 variables names … … 91 92 The prefix is used to prevent having twice the same name if the same variable is 92 93 output at two locations in the code. 94 The -nconly option can be used to equip other routines with nc output only 93 95 location_in_the_code can be : -before_return (the default valuer) 94 96 -after_declarations … … 97 99 -before_call "param_name" (TO BE DONE) 98 100 -after_call "param_name" (TO BE DONE) 101 -lonlat longitude,latitude 99 102 ........fin 100 103 exit ;; … … 104 107 -pre) prefix=$2 ; shift ; shift ;; 105 108 -ncvars) ncvars="`echo $2 | sed -e 's/,/ /g'`" ; shift ; shift ;; 109 -lonlat) lonlat=$2 ; shift ; shift ;; 106 110 *) if (( $# > 1 )) ; then $0 -h ; exit ; fi ; param=`basename $1 .F90` ; shift 107 111 esac … … 113 117 thermcell_main|thermcell_plume_6A|thermcell_env|thermcell_height|thermcell_dry|\ 114 118 thermcell_closure|thermcell_height|thermcell_dq|thermcell_flux2|thermcell_down| \ 115 thermcell_updown_dq ) \119 thermcell_updown_dq|thermcell_dtke) \ 116 120 param_ini=thermcell_ini ; inimod=lmdz_thermcell_ini ; klon=ngrid ; klev=nlay ;; 117 wake| wake_popdyn_1|wake_popdyn_2|vdif_kcay|ustarhb) param_ini=wake_ini ; inimod=lmdz_wake_ini ; klon=klon ; klev=klev ;;121 wake|pkupper|wake_popdyn_1|wake_popdyn_2|vdif_kcay|ustarhb) param_ini=wake_ini ; inimod=lmdz_wake_ini ; klon=klon ; klev=klev ;; 118 122 ratqs_main|ratqs_inter|ratqs_oro|ratqs_hetero|ratqs_tke) param_ini=ratqs_ini ; inimod=lmdz_ratqs_ini ; klon=klon ; klev=klev ;; 119 123 lscp|fisrtilp) param_ini=lscp_ini ; inimod=lmdz_lscp_ini ; klon=klon ; klev=klev ;; … … 141 145 line2=`tail -n +$line1 ${tmp} | sed -n -e '/)/=' | head -1` 142 146 tail -n +$line1 ${tmp} | sed -n -e 1,${line2}p 147 } 148 149 #----------------------------------------------------------------------------- 150 function var_get_dims(){ 151 #----------------------------------------------------------------------------- 152 local var=$1 153 local line=$( grep dimension input | grep '::.*'$var | grep -w $var | sed -e 's/ //g' ) 154 local pattern='dimension\s*\(([a-z0-9,+]*)\)' 155 if [[ $line =~ $pattern ]] ; then 156 echo ${BASH_REMATCH[1]} | sed -e 's/,/ /g' 157 fi 158 } 159 #----------------------------------------------------------------------------- 160 function var_dims(){ 161 #----------------------------------------------------------------------------- 162 local var=$1 163 local dims=$(var_get_dims $var) 164 if [[ "$dims" != "" ]] ; then 165 local dims_= 166 for d in $dims ; do 167 if [[ $d = $klon ]] ; then 168 dims_="${dims_} 1:$klon" 169 else 170 dims_="$dims_ :" 171 fi 172 done 173 echo \(${dims_}\) | sed -e 's/( /(/' -e 's/ /,/g' 174 fi 175 176 } 177 #----------------------------------------------------------------------------- 178 function var_recl(){ 179 #----------------------------------------------------------------------------- 180 local var=$1 181 local dims=$( var_get_dims $var ) 182 if [[ "$dims" != "" ]] ; then 183 local dims_= ; for i in $dims ; do dims_="$dims_ ($i)" ; done 184 echo $dims_ | sed -e 's/ /*/' 185 else 186 echo 1 187 fi 143 188 } 144 189 … … 156 201 esac 157 202 echo '! <<< dump_param_open' 158 for var in $* ; do echo 'rec_length_replay=rec_length_replay+kind('$var')*size(['$var'])' ; done 203 echo 'print*,"NOUVEAU REPLAY"' 204 for var in $* ; do 205 #echo 'rec_length_replay=rec_length_replay+kind('$var')*size(['$var'])' 206 echo 'rec_length_replay=rec_length_replay+kind('$var')*'$( var_recl $var ) 207 done 159 208 cat <<....eod 160 209 open(${fort},file='dump_param_${inout}.bin',form='unformatted',access='direct',recl=rec_length_replay) ! $replay_comment … … 266 315 vars=$* 267 316 for var in $vars ; do 268 echo "call iotd_ecrit_seq('"$pre$var"',$klev_,'"$pre$var in $param"',' ',"$var")" 317 local vardim=$( var_dims $var ) 318 echo "call iotd_ecrit_seq('"$pre$var"',$klev_,'"$pre$var in $param"',' ',"$var$vardim")" 269 319 done 270 320 fi … … 296 346 #line=`sed -n -e "/CALL "$param_ini"/=" physiq_mod.F90 | head -1` 297 347 line=`sed -n -e "/CALL wake_ini/=" physiq_mod.F90 | head -1` 298 sed -i"" -e "${line}s/^/ CALL iophys_ini(pdtphys) ! $replay_comment ! $replay_comment\n/" physiq_mod.F90 348 if [[ "$lonlat" = "" ]] ; then 349 pattern="CALL iophys_ini(pdtphys)" 350 else 351 pattern='call iotd_ini("phys.nc",1,1,klev,'$lonlat',presnivs,1,1,1,0.,pdtphys,calend)' 352 fi 353 sed -i"" -e "${line}s/^/ $pattern ! $replay_comment ! $replay_comment\n/" physiq_mod.F90 299 354 fi 300 355 … … 304 359 305 360 extract_subroutine $param $paramfile # -> input file 361 #var_get_dims ztv 362 #var_dims ztv 363 #exit 364 # var_recl ztv 365 # var_dims pplev 366 # var_recl pplev 367 # var_dims ngrid 368 # var_recl ngrid 369 # exit 370 306 371 varin0=`grep inten.*.in input | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'` 307 372 varinout0=`grep inten.*.inout input | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'` 308 varin=`echo $varin0 | sed -e 's/ /,/g' -e "s/,,,/,/g" -e "s/,,/,/g"` 373 echo varin0 $varin0 374 varin_rec= ; for v in $varin0 ; do varin_rec="$varin_rec $v$( var_dims $v)" ; done 375 varin=`echo $varin_rec | sed -e 's/ /,/g' -e "s/,,,/,/g" -e "s/,,/,/g"` 376 #echo $varin $varin 309 377 output=full # Attention, l'option full ne marche pas a cause de tableaux locaux undef 310 378 nvar0D=0 ; nvar1D=0 ; nvar2D=0 … … 390 458 cat> $paraminc1 <<eod 391 459 logical, save :: first_replay=.true. 392 integer, save :: rec_length_replay=0,irec=0 393 if (first_replay) then 460 integer, save :: rec_length_replay=0,irec=0,gr_index_=-1 461 !\$OMP THREADPRIVATE(first_replay,rec_length_replay,irec,gr_index_) 462 integer, external :: grid_index 394 463 eod 464 if [ "$lonlat" != "" ] ; then echo "if (first_replay) gr_index_=grid_index($lonlat)" >> $paraminc1 ; fi 465 echo "if ($klon==1) gr_index_=1" >> $paraminc1 466 echo "if (abs(gr_index_)>0) then" >> $paraminc1 467 echo "if (first_replay) then" >> $paraminc1 395 468 dump_param_open out $varin0 >> $paraminc1 396 469 cat>> $paraminc1 <<eod 397 first_replay=.false.398 470 endif 399 471 irec=irec+1 400 write(81,rec=irec) $varin 472 write(81,rec=irec) $( echo $varin | sed -e "s/,$klon/,1/" ) 473 endif 474 first_replay=.false. 401 475 eod 476 477 iotd_calls 1 in_${prefix} $var_1D_inout 402 478 iotd_calls 1 in_${prefix} $var_1D_inout >> $paraminc1 403 479 iotd_calls $klev in_${prefix} $var_2D_inout >> $paraminc1 404 480 fi # nconly = false 405 406 481 if [ "`grep $paraminc1 $paramfile`" = "" ] ; then 407 482 # Not changing $paraminc1 if it is already included in the file … … 419 494 iotd_calls $klev "${prefix}" $var_2D >> $paraminc2 420 495 include_line "include \"$paraminc2\"" $param $paramfile "$where" 496 497 if [[ "$lonlat" != "" ]] ; then 498 for file in $paraminc1 $paraminc2 ; do sed -i -e "s/1:$klon/gr_index_/g" -e '/rec_l/s/\*('$klon')//g' $file ; done 499 fi 421 500 422 #---------------------------------------------------------------------------- -501 #---------------------------------------------------------------------------- 423 502 # dump_ini_module gere l'ecriture des variables d'interface de l'intialisation 424 503 # du module en mode replay
Note: See TracChangeset
for help on using the changeset viewer.