Changeset 4346


Ignore:
Timestamp:
Nov 10, 2022, 4:18:58 PM (23 months ago)
Author:
fhourdin
Message:

New version with -nconly option

Allows to output all the variables of a routine in the phys.nc
file, even with not replaying this particular routine.

Location:
BOL/Replay
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BOL/Replay/replay_1D.sh

    r4344 r4346  
    2020replay_clean.sh
    2121replay_equip.sh $routine
     22# If wanting to equip other routines with nc outputs only
     23# replay_equip.sh -nconly -pre TOTO other_routine
    2224cd -
    2325
  • BOL/Replay/replay_clean.sh

    r4337 r4346  
    22
    33replay_comment="replay automatic include"
    4 \rm -f dump_param*.h dump_ini.h call_param_replay.F90 dump_ini_module.F90 get_ini_module.F90 input tmp tmp2
     4\rm -f dump_replay*.h mcall_param_replay.F90 dump_ini_module.F90 get_ini_module.F90 input tmp tmp2
    55for file in `grep "$replay_comment" *F90 | cut -d: -f1` ; do
    66   sed -i"" -e "/$replay_comment/d" $file
  • BOL/Replay/replay_equip.sh

    r4337 r4346  
    7474#=============================================================================
    7575
    76 param=`basename $1 .F90`
     76#-----------------------------------------------------------------------------
     77# Reading rguments
     78#-----------------------------------------------------------------------------
     79nconly=false
     80if [ $# = 0 ] ; then $0 -h ; exit ; fi
     81while (($# > 0))
     82   do
     83   case $1 in
     84     -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........fin
     88        exit ;;
     89     -nconly) nconly=true ; shift ;;
     90     -pre) prefix=$2 ; shift ; shift ;;
     91     *) if (( $# > 1 )) ; then $0 -h ; exit ; fi ; param=`basename $1 .F90` ; shift
     92    esac
     93done
     94if [ "$param" = "" ] ; then $0 -h ; exit ; fi
     95
    7796case $param in
    7897   thermcell_main|thermcell_plume_6A|thermcell_env|thermcell_height|thermcell_dry|\
     
    84103
    85104replay_comment="replay automatic include"
    86 paraminc1=dump_param1.h
    87 paraminc2=dump_param2.h
    88 iniinc=dump_ini.h
     105paraminc1=dump_replay_${param}_head.h
     106paraminc2=dump_replay_${param}_nc_${prefix}.h
     107iniinc=dump_replay_ini.h
     108paramfile=`grep -i "subro.* ${param}[\ (]" *.F90 | sed -e 's/ //g' | grep "${param}(" | cut -d: -f1`
     109echo La parametrisation $param est contenue dans le fichier $paramfile
     110if [ `echo ${paramfile} | wc -w` != 1 ] ; then echo file $paramfile multiple  ; $0 -h ; exit ; fi
     111
    89112
    90113#-----------------------------------------------------------------------------
     
    118141echo '! dump_param_open >>> '
    119142}
     143
    120144
    121145#-----------------------------------------------------------------------------
     
    133157   \rm -f tmp tmp2
    134158}
     159
    135160
    136161#-----------------------------------------------------------------------------
     
    159184}
    160185
    161 #-----------------------------------------------------------------------------
    162 function get_param_file(){
    163 #-----------------------------------------------------------------------------
    164   p=$1
    165   grep -i "subro.* $p[\ (]" *.F90 | sed -e 's/ //g' | grep "$p(" | cut -d: -f1
    166 }
     186
     187
    167188
    168189#-----------------------------------------------------------------------------
     
    181202
    182203#-----------------------------------------------------------------------------
     204function iotd_calls(){
     205#-----------------------------------------------------------------------------
     206    klev=$1 ; shift
     207    pre=$1 ; shift
     208    if (( $# >> 0 )) ; then
     209       vars=$*
     210       for var in $vars ; do
     211          echo "call iotd_ecrit_seq('"$pre$var"',1,'"$pre$var in $param"',' ',"$var")"
     212       done
     213    fi
     214}
     215         
     216
     217#-----------------------------------------------------------------------------
    183218# On nettoye les inclusions précédente dans les fichiers .F90
    184219#-----------------------------------------------------------------------------
    185220
    186 for file in `grep "$replay_comment" *.F90 2> /dev/null | cut -d: -f1` ; do
    187    sed -i"" -e "/$replay_comment/d" $file
    188 done
    189 line=`sed -n -e "/CALL wake_ini/=" physiq_mod.F90 | head -1`
    190 sed -i"" -e "${line}s/$/\n   CALL iophys_ini(pdtphys) ! $replay_comment  ! $replay_comment/" physiq_mod.F90
    191 
    192 #-----------------------------------------------------------------------------
    193 # Modifying the parameterization routine
    194 #-----------------------------------------------------------------------------
    195 
    196 paramfile=`get_param_file $param`
    197 echo La parametrisation $param est contenue dans le fichier $paramfile
    198 if [ `echo ${paramfile} | wc -w` != 1 ] ; then echo file $paramfile multiple  exit ; fi
    199 extract_subroutine $param $paramfile
     221if [ $nconly = false ] ; then
     222   for file in `grep "$replay_comment" *.F90 2> /dev/null | cut -d: -f1` ; do
     223      sed -i"" -e "/$replay_comment/d" $file
     224   done
     225   line=`sed -n -e "/CALL wake_ini/=" physiq_mod.F90 | head -1`
     226   sed -i"" -e "${line}s/$/\n   CALL iophys_ini(pdtphys) ! $replay_comment  ! $replay_comment/" physiq_mod.F90
     227fi
    200228
    201229#-----------------------------------------------------------------------------
     
    203231#-----------------------------------------------------------------------------
    204232
     233extract_subroutine $param $paramfile # -> input file
    205234varin0=`grep inten.*.in input | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'`
    206235varinout0=`grep inten.*.inout input | sed -e '/\!.*$/d' | cut -d: -f3 | sed -e 's/,/ /g'`
     
    213242   full) search_str='real'
    214243esac
     244var_1D_inout=`grep -i "$search_str" input | grep intent.*inout | grep $klon | sed -e 's/!.*$//' -e /$klev/d | cut -d: -f3 | sed -e 's/,/ /g'`
     245var_2D_inout=`grep -i "$search_str" input | grep intent.*inout | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
    215246var_1D_noarg=`grep -i "$search_str" input | sed -e /intent/d | grep $klon | sed -e 's/!.*$//' -e /$klev/d | cut -d: -f3 | sed -e 's/,/ /g'`
    216247var_2D_noarg=`grep -i "$search_str" input | sed -e /intent/d | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
     
    218249var_2D=`grep -i "$search_str" input | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
    219250echo varin  : $varin
    220 echo var_1D_noarg : $var_1D_noarg
    221 echo var_2D_noarg : $var_2D_noarg
    222 echo var_1D : $var_1D
    223 echo var_2D : $var_2D
     251echo var_1D_inout : $var_1D_inout ; echo
     252echo var_2D_inout : $var_2D_inout ; echo
     253echo var_1D_noarg : $var_1D_noarg ; echo
     254echo var_2D_noarg : $var_2D_noarg ; echo
     255echo var_1D : $var_1D ; echo
     256echo var_2D : $var_2D ; echo
    224257
    225258#-----------------------------------------------------------------------------
    226259# Ecriture de la routine d'appel a la parametrisation en mode replay
    227260#-----------------------------------------------------------------------------
     261
     262if [ $nconly = false ] ; then
    228263
    229264cat > call_param_replay.F90 <<eod
     
    268303eod
    269304
    270 
    271 #-----------------------------------------------------------------------------
    272 # Creation d'un .h d'ecriture de toutes les variables intent in & out
     305fi # nconly = false
     306
     307#-----------------------------------------------------------------------------
     308# Creating file dump_${param}_head.h
    273309#-----------------------------------------------------------------------------
    274310
    275311\rm $paraminc1
     312if [ $nconly = false ] ; then
    276313cat> $paraminc1 <<eod
    277314logical, save :: first=.true.
     
    286323write(81,rec=irec) $varin
    287324eod
     325iotd_calls 1     in_${prefix} $var_1D_inout >> $paraminc1
     326iotd_calls $klev in_${prefix} $var_2D_inout >> $paraminc1
     327fi # nconly = false
     328
    288329for var in $var_1D_noarg $var_2D_noarg ; do echo $var=0. >> $paraminc1 ; done
    289330include_line "include \"$paraminc1\"" $param $paramfile after_declarations
    290331
     332#-----------------------------------------------------------------------------
     333# Creating file dump_${param}_nc_${prefix}.h
     334#-----------------------------------------------------------------------------
     335
    291336\rm $paraminc2
    292 for var in $var_1D ; do
    293 echo "call iotd_ecrit_seq('"$var"',1,'"$var"',' ',"$var")" >> $paraminc2
    294 done
    295 for var in $var_2D ; do
    296 echo "call iotd_ecrit_seq('"$var"',"$klev",'"$var"',' ',"$var")" >> $paraminc2
    297 done
     337iotd_calls 1     "${prefix}" $var_1D >> $paraminc2
     338iotd_calls $klev "${prefix}" $var_2D >> $paraminc2
    298339include_line "include \"$paraminc2\"" $param $paramfile before_return
    299340 
     
    303344#-----------------------------------------------------------------------------
    304345
     346if [ $nconly = false ] ; then
    305347varinmod=`grep -i 'intent.in' $inimod.F90 | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'`
    306348varinmodv=`echo $varinmod | sed -e 's/ /,/g'`
     
    311353eod
    312354include_line "include \"$iniinc\"" $paramini $inimod.F90  before_return
     355fi # nconly = false
    313356
    314357
     
    316359# get_ini_module gere l'initialisation du module en mode replay
    317360#-----------------------------------------------------------------------------
    318 
     361if [ $nconly = false ] ; then
    319362cat > get_ini_module.F90 <<eod
    320363subroutine get_ini_module
     
    334377end
    335378eod
     379fi # nconly = false
    336380
    337381#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.