Changeset 4591


Ignore:
Timestamp:
Jun 29, 2023, 8:20:49 AM (17 months ago)
Author:
fhourdin
Message:

Compatible avec les modules et reorganisation

Retour en arrière : call_param_replay.F90 est à nouveau un fichier séparé.

La même chose pour call_ini_replay.F90 (qui remplace get_ini_module).
replay_clean.sh crée une version quasi vide de ces deux fichiers.
Ceux-ci seront bientôt par défaut dans l'archive svn.
Le fait de ne pas créer et faire disparaitre ces fichiers permet entre autre de ne pas avoir à refaire le makefile pour rien.

Location:
BOL/Replay
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • BOL/Replay/replay_clean.sh

    r4378 r4591  
    44replay_comment="replay automatic include"
    55if [ $# = 0 ] ; then
    6    \rm -f dump_replay*.h dump_param.h dump_ini.h call_param_repla* get_ini_modul* input tmp tmp2 tmp3 tmp2_cpp
     6   \rm -f dump_replay*.h dump_param.h dump_ini.h input tmp tmp2 tmp3 tmp2_cpp
    77   for file in `grep "$replay_comment" *F90 | cut -d: -f1` ; do
    88      sed -i"" -e "/$replay_comment/d" $file
    99   done
     10   cat > call_param_replay.F90 <<...eod
     11   subroutine call_param_replay(ngrid,nlay)
     12   integer,intent(in) :: ngrid,nlay
     13   stop 'In call_param_replay : You should run replay_equip.sh before runing replay[13]d'
     14   return
     15   end
     16...eod
     17   cat > call_ini_replay.F90 <<...eod
     18   subroutine call_ini_replay
     19   stop 'In call_ini_replay : You should run replay_equip.sh before runing replay[13]d'
     20   return
     21   end
     22...eod
     23
    1024else
    1125   for file in $* ; do
  • BOL/Replay/replay_equip.sh

    r4378 r4591  
    5454#  * call_param_replay : sous programme d'appelle en boucle à la param
    5555#  * dump_ini_module.F90   : écriture de l'interface "in" de param_ini
    56 #  * get_ini_module    : lecture de l'interface "in" de param_ini
     56#  * call_ini_replay.F90    : lecture de l'interface "in" de param_ini
    5757#                dans ${param_ini}_mod.bin.
    5858#  Par ailleurs, un programme replay1d a été ajouté dans phylmd/dyn1d
     
    114114      thermcell_closure|thermcell_height|thermcell_dq|thermcell_flux2|thermcell_down| \
    115115      thermcell_updown_dq) \
    116       paramini=thermcell_ini ; inimod=thermcell_ini_mod ; klon=ngrid ; klev=nlay ;;
    117    wake|wake_popdyn_2) paramini=wake_ini ; inimod=wake_ini_mod ; klon=klon ; klev=klev ;;
     116      paramini=thermcell_ini ; inimod=lmdz_thermcell_ini ; klon=ngrid ; klev=nlay ;;
     117   wake|wake_popdyn_1|wake_popdyn_2) paramini=wake_ini ; inimod=lmdz_wake_ini ; klon=klon ; klev=klev ;;
    118118   *) echo Cas non prevu ; exit
    119119esac
     
    142142#-----------------------------------------------------------------------------
    143143function dump_param_open(){
    144 #-----------------------------------------------------------------------------
    145 # Opening an direct access file with one record per time-step
    146 # Each record has the size and contains the arguments in and inout of the
    147 # routine
    148 #-----------------------------------------------------------------------------
    149 inout=$1 ; shift
    150 case $inout in
    151    out) fort=81 ;;
    152    in) fort=82
    153 esac
    154 echo '! <<< dump_param_open'
    155 for var in $* ; do echo 'rec_length_replay=rec_length_replay+kind('$var')*size(['$var'])' ; done
    156 cat <<eod
    157 open(${fort},file='dump_param_${inout}.bin',form='unformatted',access='direct',recl=rec_length_replay)  ! $replay_comment
    158 eod
    159 echo '! dump_param_open >>> '
     144    #-----------------------------------------------------------------------------
     145    # Opening an direct access file with one record per time-step
     146    # Each record has the size and contains the arguments in and inout of the
     147    # routine
     148    #-----------------------------------------------------------------------------
     149    inout=$1 ; shift
     150    case $inout in
     151       out) fort=81 ;;
     152       in) fort=82
     153    esac
     154    echo '! <<< dump_param_open'
     155    for var in $* ; do echo 'rec_length_replay=rec_length_replay+kind('$var')*size(['$var'])' ; done
     156    cat <<....eod
     157    open(${fort},file='dump_param_${inout}.bin',form='unformatted',access='direct',recl=rec_length_replay)  ! $replay_comment
     158....eod
     159    echo '! dump_param_open >>> '
    160160}
    161161
     
    176176}
    177177
     178
     179#-----------------------------------------------------------------------------
     180function echo_use_module(){
     181#-----------------------------------------------------------------------------
     182# Regle tacite : l'instruction MODULE commence à la premiere colonne.
     183#                Existe-t-i une facon de la faire tomber ?
     184#                En enlevant tous les blanc dans le input sans doute ...
     185   param_=$1 ; shift
     186   paramfile_=$1
     187   if [ ! -f $paramfile_ ] ; then echo plantage which_module ; exit 1 ; fi
     188   module=`grep '^[mM][oO][dD][uU][lL][eE] .*[a-Z]' $paramfile_ | head -1 | awk ' { print $2 } '`
     189   if [ "$module" != "" ] ; then
     190       echo USE $module, ONLY : $param_
     191   fi
     192}
    178193
    179194#-----------------------------------------------------------------------------
     
    195210   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'`"
    196211   line_last_declaration=`cat tmp2 | tr '[A-Z]' '[a-z]' | sed -n -e "/$last_line_declaration2/="`
     212   echo OK0
     213   if [ "`grep -i 'end.*module' $paramfile_`" = "" ] ; then echo aka ;  line_end_module=`wc -l $paramfile_ | awk ' { print $1 } '` ; else echo akb ; line_end_module=`sed -n -e '/[eE][nN][dD] .*[mM][oO][dD][uU][lL][eE]/=' $paramfile_` ; fi
     214   echo OK1
     215   echo $line_end_module
    197216   if [ "$line_last_declaration" = "" ] ; then echo line_last_declaration $line_last_declaration line $last_line_declaration2  ; exit ; fi
    198217   if (( $# > 0 )) ; then
     
    201220         -after_declarations)      targeted_line=$line_last_declaration ;;
    202221         -before_return)           targeted_line=$line_return ;;
     222         -before_end_module)       targeted_line=$line_end_module ;;
    203223         -before_line|-after_line) linestr=`echo $1 | sed -e "s/$wtype //"` ; targeted_line=`sed -n -e "/$linestr/=" tmp2` ;;
    204          *)                  echo Cas non prevu 0 where=$where in inclide_file
     224         *)                  echo Cas non prevu 0 where=$where in include_file
    205225      esac
    206226      case $wtype in
    207227         -after_declarations|-after_line)  line0=$(( $line_subroutine - 1 )) ;;
    208228         -before_return|-before_line)      line0=$(( $line_subroutine - 2 )) ;;
    209          *)                  echo Cas non prevu 1 where=$where in inclide_file
     229         -before_end_module)               line0=-1 ;;
     230         *)                  echo Cas non prevu 1 where=$where in include_file
    210231      esac
    211       echo Including line $line0 in $paramfile_ the line : $line_to_be_included
     232      echo Including line $line0 + $targeted_line in $paramfile_ the line : $line_to_be_included
    212233      linebefore_include=$(( $line0 + $targeted_line ))
    213234     sed -i'' -e $linebefore_include"s/$/\n $line_to_be_included \!  $replay_comment/" $paramfile_
     
    310331if [ $nconly = false ] ; then
    311332
    312 cat > call_param_replay <<eod
     333cat > call_param_replay.F90 <<eod
    313334subroutine call_param_replay($klon,$klev)
    314335USE IOIPSL, ONLY : getin
     336`echo_use_module $param  $paramfile`
    315337IMPLICIT NONE
    316338integer :: ifin,irec,it,rec_length_replay=0,replay_irec0=1,replay_nt=1000
    317339eod
    318 grep 'intent.*::' input | sed -e 's/ //g' -e 's/,intent(.*[nt])//'>> call_param_replay
     340grep 'intent.*::' input | sed -e 's/ //g' -e 's/,intent(.*[nt])//'>> call_param_replay.F90
    319341# duplicating declaration for inout variables
    320342
    321343for var in $varinout0 ; do
    322     sed -e 's/::/ :: /' -e 's/,/ , /g' -e 's/$/ /' input | grep 'intent.*inout.*::.* '$var' ' | sed -e 's/ //g' -e 's/,intent(.*[nt])//' | sed -e 's/::.*$/, allocatable, save :: '$var'_Replay0/' | sed -e 's/'$klon'/:/' -e 's/'$klev'/:/' >> call_param_replay
     344    sed -e 's/::/ :: /' -e 's/,/ , /g' -e 's/$/ /' input | grep 'intent.*inout.*::.* '$var' ' | sed -e 's/ //g' -e 's/,intent(.*[nt])//' | sed -e 's/::.*$/, allocatable, save :: '$var'_Replay0/' | sed -e 's/'$klon'/:/' -e 's/'$klev'/:/' >> call_param_replay.F90
    323345done
    324346# Initalisation, shared with dump_param1.sh
    325 dump_param_open "in" $varin0 >> call_param_replay
     347dump_param_open "in" $varin0 >> call_param_replay.F90
    326348for var in $varinout0 ; do
    327     sed -e 's/::/ :: /' -e 's/,/ , /g' -e 's/$/ /' input | grep 'intent.*inout.*::.* '$var' ' | sed -e 's/intent(.*t)//' -e 's/^.*(/allocate('$var'_Replay0(/' -e 's/).*$/))/' >> call_param_replay
     349    sed -e 's/::/ :: /' -e 's/,/ , /g' -e 's/$/ /' input | grep 'intent.*inout.*::.* '$var' ' | sed -e 's/intent(.*t)//' -e 's/^.*(/allocate('$var'_Replay0(/' -e 's/).*$/))/' >> call_param_replay.F90
    328350done
    329351
    330 cat >> call_param_replay <<eod
     352cat >> call_param_replay.F90 <<eod
    331353call getin('replay_nt',replay_nt)
    332354call getin('replay_irec0',replay_irec0)
     
    342364eod
    343365
    344 block_Replay0 "it == 1"          _Replay0   ""       $varinout0 >> call_param_replay
    345 block_Replay0 "replay_irec0 < 0" ""         _Replay0 $varinout0 >> call_param_replay
    346 get_subroutine_arg $param $paramfile | sed -e 's/subroutine/   call/' >> call_param_replay
    347 block_Replay0 "replay_irec0 < 0" _Replay0   ""       $varinout0 >> call_param_replay
    348 cat >> call_param_replay <<eod
     366block_Replay0 "it == 1"          _Replay0   ""       $varinout0 >> call_param_replay.F90
     367block_Replay0 "replay_irec0 < 0" ""         _Replay0 $varinout0 >> call_param_replay.F90
     368get_subroutine_arg $param $paramfile | sed -e 's/subroutine/   call/' >> call_param_replay.F90
     369block_Replay0 "replay_irec0 < 0" _Replay0   ""       $varinout0 >> call_param_replay.F90
     370cat >> call_param_replay.F90 <<eod
    349371enddo
    350372return
     
    410432
    411433#-----------------------------------------------------------------------------
    412 # get_ini_module gere l'initialisation du module en mode replay
     434# call_ini_replay.F90 gere l'initialisation du module en mode replay
    413435#-----------------------------------------------------------------------------
    414436if [ $nconly = false -a $paramini != None ] ; then
    415     cat > get_ini_module <<....eod............................................
    416     subroutine get_ini_module
     437    cat > call_ini_replay.F90 <<....eod............................................
     438    subroutine call_ini_replay
    417439    use $inimod
    418440    IMPLICIT NONE
    419441....eod............................................
    420     grep -i intent.in $inimod.F90  |  tr '[A-Z]' '[a-z]' | sed -e 's/,.*intent.i.*)//' >> get_ini_module
    421     cat >> get_ini_module <<....eod...........................................
     442    grep -i intent.in $inimod.F90  |  tr '[A-Z]' '[a-z]' | sed -e 's/,.*intent.i.*)//' >> call_ini_replay.F90
     443    cat >> call_ini_replay.F90 <<....eod...........................................
    422444    open(90,file='$inimod.bin',form='unformatted')
    423445    read(90) $varinmodv
     
    425447....eod...........................................
    426448    #get_subroutine_arg $paramini $inimod.F90 ; exit
    427     get_subroutine_arg $paramini $inimod.F90 | sed -e 's/subroutine/call/' >> get_ini_module
    428     cat >> get_ini_module <<....eod...........................................
     449    get_subroutine_arg $paramini $inimod.F90 | sed -e 's/subroutine/call/' >> call_ini_replay.F90
     450    cat >> call_ini_replay.F90 <<....eod...........................................
    429451    return
    430452    end
    431453....eod...........................................
    432454fi # nconly = false
    433 
    434 #-----------------------------------------------------------------------------
    435 # Inclusion de l'ecriture de l'interface de l'initialisation
    436 #-----------------------------------------------------------------------------
    437 
    438 if [ $nconly = false ] ; then
    439      for file in get_ini_module call_param_replay ; do sed -i'' -e "s/$/                                        \!$replay_comment/"  $file ; done
    440      cat get_ini_module >> $inimod.F90
    441      cat call_param_replay >> $paramfile
    442 fi
    443 
    444 #\rm -f tmp input
Note: See TracChangeset for help on using the changeset viewer.