source: BOL/Replay/replay_equip.sh @ 5033

Last change on this file since 5033 was 5033, checked in by fhourdin, 7 weeks ago

Extraction 1D depuis le 3D

File size: 23.0 KB
Line 
1#!/bin/bash
2
3   #set -vx
4
5#=============================================================================
6#  F. Hourdin : 2022/05/03
7#
8#  Objet :
9#  -----
10#  Script préparant les programes pour rejouer (replay) une paramétrisation
11#  ou un morceau de paramétriation.
12#
13#
14#  Applicabilité :
15#  ---------------
16#  Est fait pour rejouer des paramétisation de LMDZ organisées comme
17#    des calcul sur des successions de colonnes indépendantes (boucle
18#    interne en $klon) de $klev niveaux verticaux.
19#  Demande que la paramétrisation répondent aux règles de codage suivantes :
20#  1) Les routines de calcul et les routines ou fonctions qu'elles appellent
21#     n'ont que deux interfaces : A) les arguments d'entrée
22#                                 B) le use d'un unique module
23#     Entre autre, les dimensions de la paramétrisation sont passés
24#     en argument, ce qui permet une allocation dynamique implicite
25#     de toutes les variables.
26#  2) le module d'initialisation doit lui même être initialisé par
27#     une unique routine pilotée entièrement par ses arguments.
28#  3) Toutes les variables d'interface doivent être déclarées intent in
29#     out, ou inout
30#  On appelera la paramétriation "param" et l'intialisation "param_ini"
31#     mais les noms de fichiers sont en argument dans le script.
32#
33#
34#  Principe :
35#  ----------
36#  Dans une première simulation, on écrit dans un fichier binaire toutes
37#  les variables "intent in/inout" de la routine d'initialisation et de la routine
38#  de calcul.
39#
40#
41#  En pratique :
42#  -------------
43#
44#  Le script a comme argument le nom de la routine à traiter, nommée $param
45#   Des correpspondances en déduisent :
46#   param_ini=wake_ini  # nom de la subroutine d'intialisation
47#   inimod= # nom du module contenant $param_ini
48#   klon=klon ; klev=klev  # nom des dimensions horiz; vert utilisée
49#
50#  Le fichier ${paramfile} contenant $param est detecté automatiquement
51#  Le script crée 5 fichiers
52#  * dump_param1.h          : écriture de l'interface "in" de param (dump_param.bin fort.82)
53#  * dump_param2.h          : écriture des sorties de la routines dans phys.nc
54#  * call_param_replay : sous programme d'appelle en boucle à la param
55#  * dump_ini_module.F90   : écriture de l'interface "in" de param_ini
56#  * call_ini_replay.F90    : lecture de l'interface "in" de param_ini
57#                dans ${param_ini}_mod.bin.
58#  Par ailleurs, un programme replay1d a été ajouté dans phylmd/dyn1d
59#        qui appelle call_param_replay
60#  Le script ajoute par ailleurs quelques lignes dans ${paramfile} et
61#        ${param_ini}.F90
62#  replay_clean.sh élimine toutes les lignes ajoutées
63#
64#
65#  A travailler :
66#  --------------
67#  * détecter automatiquement le fichier contenant l'intialisation
68#  * détecter automatiquement les dimensions
69#  * avoir un moyen de vérifier si les variables intent in et out sont
70#    bien les bonnes.
71#  * Initialisation plus simple de la routine getin_p
72#  * Des choix sur la facon de controler l'initialisation et le pb des getin
73#
74#=============================================================================
75
76#-----------------------------------------------------------------------------
77# Reading rguments
78#-----------------------------------------------------------------------------
79nconly=false
80where=-before_return
81lonlat=
82
83if [ $# = 0 ] ; then $0 -h ; exit ; fi
84while (($# > 0))
85   do
86   case $1 in
87     -h|--help) cat <<........fin
88           $0 [-nconly] [-ncvars var1,var2,...] [-pre prefix] [location_in_the_code] [-lonlat lon,lat] routine_name
89           The prefix will be put on each variable stored in the nc file to avoid duplicate
90                variables names
91           If -ncvars is not specified, all the variables are output
92           The prefix is used to prevent having twice the same name if the same variable is
93              output at two locations in the code.
94           The -nconly option can be used to equip other routines with nc output only
95           location_in_the_code can be : -before_return               (the default valuer)
96                                         -after_declarations
97                                         -before_line  "line in code"
98                                         -after_line   "line in code"
99                                         -before_call  "param_name"   (TO BE DONE)
100                                         -after_call   "param_name"   (TO BE DONE)
101           -lonlat longitude,latitude
102........fin
103        exit ;;
104     -nconly) nconly=true ; shift ;;
105     -before_line|-after_line|-before_call|-after_call) where="$1 $2" ; shift ; shift ;;
106     -before_return|-after_declarations) where=$1 ; shift ;;
107     -pre) prefix=$2 ; shift ; shift ;;
108     -ncvars) ncvars="`echo $2 | sed -e 's/,/ /g'`" ; shift ; shift ;;
109     -lonlat) lonlat=$2 ; shift ; shift ;;
110     *) if (( $# > 1 )) ; then $0 -h ; exit ; fi ; param=`basename $1 .F90` ; shift
111    esac
112done
113if [ "$param" = "" ] ; then $0 -h ; exit ; fi
114
115case $param in
116   vdif_k|vdif_cd|vdif|my_25|vdif_dq) param_ini=vdif_ini ; inimod=simple_vdif_ini ; klon=ngrid ; klev=nlay ;;
117   thermcell_main|thermcell_plume_6A|thermcell_env|thermcell_height|thermcell_dry|\
118      thermcell_closure|thermcell_height|thermcell_dq|thermcell_flux2|thermcell_down| \
119      thermcell_updown_dq|thermcell_dtke) \
120      param_ini=thermcell_ini ; inimod=lmdz_thermcell_ini ; klon=ngrid ; klev=nlay ;;
121   wake|pkupper|wake_popdyn_1|wake_popdyn_2|vdif_kcay|ustarhb) param_ini=wake_ini ; inimod=lmdz_wake_ini ; klon=klon ; klev=klev ;;
122   ratqs_main|ratqs_inter|ratqs_oro|ratqs_hetero|ratqs_tke) param_ini=ratqs_ini ; inimod=lmdz_ratqs_ini ; klon=klon ; klev=klev ;;
123   lscp|fisrtilp) param_ini=lscp_ini ; inimod=lmdz_lscp_ini ; klon=klon ; klev=klev ;;
124   *) echo Cas non prevu ; exit
125esac
126
127replay_comment="replay automatic include"
128paraminc1=dump_replay_${param}_head.h
129paraminc2=dump_replay_${param}_nc_${prefix}.h
130iniinc=dump_replay_ini.h
131paramfile=`grep -i "subro.* ${param}[\ (]" *.F90 | sed -e 's/ //g' | grep "${param}(" | cut -d: -f1`
132echo ===================================================================================
133echo Equiping $param contained in file $paramfile
134if [ `echo ${paramfile} | wc -w` != 1 ] ; then echo file $paramfile multiple  ; $0 -h ; exit ; fi
135
136
137#-----------------------------------------------------------------------------
138# Transformer l'entete d'une subroutine en un call
139#-----------------------------------------------------------------------------
140
141function get_subroutine_arg(){
142   tmp=tmp_get_subroutine_arg
143   cat $2 | tr '[A-Z]' '[a-z]' > ${tmp}
144   line1=`sed -n -e '/subrou.*'\`echo $1 | tr '[A-Z]' '[a-z]'\`'.*(/=' ${tmp} | head -1 `
145   line2=`tail -n +$line1 ${tmp} | sed -n -e '/)/=' | head -1`
146   tail -n +$line1 ${tmp} | sed -n -e 1,${line2}p
147}
148
149#-----------------------------------------------------------------------------
150function 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#-----------------------------------------------------------------------------
160function 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#-----------------------------------------------------------------------------
178function 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
188}
189
190#-----------------------------------------------------------------------------
191function dump_param_open(){
192    #-----------------------------------------------------------------------------
193    # Opening an direct access file with one record per time-step
194    # Each record has the size and contains the arguments in and inout of the
195    # routine
196    #-----------------------------------------------------------------------------
197    inout=$1 ; shift
198    case $inout in
199       out) fort=81 ;;
200       in) fort=82
201    esac
202    echo '! <<< dump_param_open'
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
208    cat <<....eod
209    open(${fort},file='dump_param_${inout}.bin',form='unformatted',access='direct',recl=rec_length_replay)  ! $replay_comment
210....eod
211    echo '! dump_param_open >>> '
212}
213
214
215#-----------------------------------------------------------------------------
216function extract_subroutine(){
217#-----------------------------------------------------------------------------
218   # $1 nom de la subroutine
219   # $2 nom du fichier
220   # input <- routine under treatment with small caps only
221   tmp=tmp_extract_subroutine
222   ( cpp $2 2>/dev/null ) | tr '[A-Z]' '[a-z]' > ${tmp}
223   name_min=`echo $1 | tr '[A-Z]' '[a-z]'`
224   line1=`sed -n -e "/subrou.*${name_min}.*(/=" ${tmp} | head -1 `
225   tail -n +$line1 ${tmp} > ${tmp}2
226   line2=`sed -n -e "/[Rr][Ee][Tt][Uu][Rr][Nn]/=" ${tmp}2 | head -1`
227   head -$line2 ${tmp}2  > input
228   \rm -f ${tmp} ${tmp}2
229}
230
231
232#-----------------------------------------------------------------------------
233function echo_use_module(){
234#-----------------------------------------------------------------------------
235# Regle tacite : l'instruction MODULE commence à la premiere colonne.
236#                Existe-t-i une facon de la faire tomber ?
237#                En enlevant tous les blanc dans le input sans doute ...
238   param_=$1 ; shift
239   paramfile_=$1
240   if [ ! -f $paramfile_ ] ; then echo plantage which_module ; exit 1 ; fi
241   module=`grep '^[mM][oO][dD][uU][lL][eE] .*[a-Z]' $paramfile_ | head -1 | awk ' { print $2 } '`
242   if [ "$module" != "" ] ; then
243       echo USE $module, ONLY : $param_
244   fi
245}
246
247#-----------------------------------------------------------------------------
248function include_line(){
249#-----------------------------------------------------------------------------
250   # Including param_dump*.h in the parameterization
251   #set -vx
252   tmp=tmp_include_line
253   line_to_be_included=$1  ; shift
254   param_=$1 ; shift
255   paramfile_=$1 ; shift
256   name_min=`echo $param_ | tr [A-Z] [a-z]`
257   line_subroutine=`cat $paramfile_ | tr '[A-Z]' '[a-z]' | sed -n -e "/subrou.*${name_min}.*(/=" | head -1 `
258   tail -n +$line_subroutine $paramfile_ > ${tmp} # file starting at the subroutine instruction
259   line_return=`sed -n -e "/[Rr][Ee][Tt][Uu][Rr][Nn]/=" ${tmp} | head -1`
260   head -$line_return ${tmp} > ${tmp}2               # file containing the routine
261   sed -e 's/\!.*$//' ${tmp}2 > ${tmp}3
262   cpp ${tmp}2 > ${tmp}3 2>/dev/null
263   cat ${tmp}3 | tr '[A-Z]' '[a-z]' > ${tmp}2_cpp   # same after cpp filtering
264   last_line_declaration2="`sed -n -e 's/\!.*$//' -e 's/^/ /' -e '/[\ ,]real[\ ,]/p' -e '/[\ ,]integer[\ ,]/p' -e '/[\ ,]logical[\ ,]/p' -e '/[\ ,]character[\ ,]/p' ${tmp}2_cpp | tail -1 | sed -e 's/  / /g' -e 's/ /.*/g'`"
265   line_last_declaration=`cat ${tmp}2 | tr '[A-Z]' '[a-z]' | sed -n -e "/$last_line_declaration2/="`
266   echo OK0
267   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
268   echo OK1
269   echo $line_end_module
270   if [ "$line_last_declaration" = "" ] ; then echo line_last_declaration $line_last_declaration line $last_line_declaration2  ; exit ; fi
271   if (( $# > 0 )) ; then
272      wtype=`echo $1 | awk ' { print $1 } '`
273      case $wtype in
274         -after_declarations)      targeted_line=$line_last_declaration ;;
275         -before_return)           targeted_line=$line_return ;;
276         -before_end_module)       targeted_line=$line_end_module ;;
277         -before_line|-after_line) linestr=`echo $1 | sed -e "s/$wtype //"` ; targeted_line=`sed -n -e "/$linestr/=" ${tmp}2` ;;
278         *)                  echo Cas non prevu 0 where=$where in include_file
279      esac
280      case $wtype in
281         -after_declarations|-after_line)  line0=$(( $line_subroutine - 1 )) ;;
282         -before_return|-before_line)      line0=$(( $line_subroutine - 2 )) ;;
283         -before_end_module)               line0=-1 ;;
284         *)                  echo Cas non prevu 1 where=$where in include_file
285      esac
286      echo Including line $line0 + $targeted_line in $paramfile_ the line : $line_to_be_included
287      linebefore_include=$(( $line0 + $targeted_line ))
288     sed -i'' -e $linebefore_include"s/$/\n $line_to_be_included \!  $replay_comment/" $paramfile_ 
289   fi
290}
291
292
293
294
295#-----------------------------------------------------------------------------
296function block_Replay0() {
297#-----------------------------------------------------------------------------
298condition=$1 ; shift
299suf1=$1 ; shift
300suf2=$1 ; shift
301if [ $# -gt 0 ] ; then
302   vars=$*
303   echo '   if ('$condition') then'
304   for var in $vars ; do echo '      '$var$suf1=$var$suf2 ; done
305   echo '   endif'
306fi
307}
308
309#-----------------------------------------------------------------------------
310function iotd_calls(){
311#-----------------------------------------------------------------------------
312    klev_=$1 ; shift
313    pre=$1 ; shift
314    if (( $# >> 0 )) ; then
315       vars=$*
316       for var in $vars ; do
317          local vardim=$( var_dims $var )
318          echo "call iotd_ecrit_seq('"$pre$var"',$klev_,'"$pre$var in $param"',' ',"$var$vardim")"
319       done
320    fi
321}
322         
323#-----------------------------------------------------------------------------
324function b_among_a() {
325#-----------------------------------------------------------------------------
326   a="$1"
327   b="$2"
328   o=""
329   for v in $a ; do
330       for vv in $b ; do
331           if [ "$v" = "$vv" ] ; then o="$o $v" ;  fi
332       done
333   done
334   echo $o
335}
336
337
338#-----------------------------------------------------------------------------
339# On nettoye les inclusions précédente dans les fichiers .F90
340#-----------------------------------------------------------------------------
341
342if [ $nconly = false ] ; then
343   for file in `grep "$replay_comment" *.F90 2> /dev/null | cut -d: -f1` ; do
344      sed -i"" -e "/$replay_comment/d" $file
345   done
346   #line=`sed -n -e "/CALL "$param_ini"/=" physiq_mod.F90 | head -1`
347   line=`sed -n -e "/CALL wake_ini/=" physiq_mod.F90 | head -1`
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
354fi
355
356#-----------------------------------------------------------------------------
357# Analysis of the variables to be stored and there nature
358#-----------------------------------------------------------------------------
359
360extract_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
371varin0=`grep inten.*.in input | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'`
372varinout0=`grep inten.*.inout input | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'`
373echo varin0 $varin0
374varin_rec= ; for v in $varin0 ; do varin_rec="$varin_rec $v$( var_dims $v)" ; done
375varin=`echo $varin_rec | sed -e 's/ /,/g' -e "s/,,,/,/g" -e "s/,,/,/g"`
376#echo $varin $varin
377output=full # Attention, l'option full ne marche pas a cause de tableaux locaux undef
378nvar0D=0 ; nvar1D=0 ; nvar2D=0
379case $output in
380   light) search_str='real.*intent' ;;
381   full) search_str='real'
382esac
383var_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'`
384var_2D_inout=`grep -i "$search_str" input | grep intent.*inout | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
385var_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'`
386var_2D_noarg=`grep -i "$search_str" input | sed -e /intent/d | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
387var_1D=`grep -i "$search_str" input | grep $klon | sed -e 's/!.*$//' -e /$klev/d | cut -d: -f3 | sed -e 's/,/ /g'`
388var_2D=`grep -i "$search_str" input | grep $klon | grep $klev | cut -d: -f3 | sed -e 's/!.*$//' -e 's/,/ /g'`
389if [ "$ncvars" != "" ] ; then
390   var_1D=`b_among_a "$var_1D" "$ncvars"`
391   var_2D=`b_among_a "$var_2D" "$ncvars"`
392fi
393echo Variables in and inout : $varin0
394echo 1D variables "(all)" : $var_1D
395echo 2D variables "(all)" : $var_2D
396echo 1D variables "intent(inout)" : $var_1D_inout
397echo 2D variables "intent(inout)" : $var_2D_inout
398echo local 1D variables : $var_1D_noarg
399echo local 2D variables : $var_2D_noarg
400
401#-----------------------------------------------------------------------------
402# Ecriture de la routine d'appel a la parametrisation en mode replay
403#-----------------------------------------------------------------------------
404
405if [ $nconly = false ] ; then
406
407cat > call_param_replay.F90 <<eod
408subroutine call_param_replay($klon,$klev)
409USE IOIPSL, ONLY : getin
410`echo_use_module $param  $paramfile`
411IMPLICIT NONE
412integer :: ifin,irec,it,rec_length_replay=0,replay_irec0=1,replay_nt=1000
413eod
414grep 'intent.*::' input | sed -e 's/ //g' -e 's/,intent(.*[nt])//'>> call_param_replay.F90
415# duplicating declaration for inout variables
416
417for var in $varinout0 ; do
418    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}'+1/:/' -e 's/'${klev}'/:/' >> call_param_replay.F90
419done
420# Initalisation, shared with dump_param1.sh
421dump_param_open "in" $varin0 >> call_param_replay.F90
422for var in $varinout0 ; do
423    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
424done
425
426cat >> call_param_replay.F90 <<eod
427call getin('replay_nt',replay_nt)
428call getin('replay_irec0',replay_irec0)
429do it=1,replay_nt
430   if (replay_irec0>=0) then
431       irec=replay_irec0+it-1
432   else
433       irec=-replay_irec0
434   endif
435   print*,'Time step',it,', reading record',irec,'in dump_param.bin'
436   read(82,rec=irec,iostat=ifin) $varin
437   if (.NOT. ifin == 0 ) stop "Fin du fichier fort.82"
438eod
439
440block_Replay0 "it == 1"          _Replay0   ""       $varinout0 >> call_param_replay.F90
441block_Replay0 "replay_irec0 < 0" ""         _Replay0 $varinout0 >> call_param_replay.F90
442get_subroutine_arg $param $paramfile | sed -e 's/subroutine/   call/' >> call_param_replay.F90
443block_Replay0 "replay_irec0 < 0" _Replay0   ""       $varinout0 >> call_param_replay.F90
444cat >> call_param_replay.F90 <<eod
445enddo
446return
447end
448eod
449
450fi # nconly = false
451
452#-----------------------------------------------------------------------------
453# Creating file dump_${param}_head.h
454#-----------------------------------------------------------------------------
455
456if [ $nconly = false ] ; then
457\rm $paraminc1
458cat> $paraminc1 <<eod
459logical, save :: first_replay=.true.
460integer, save :: rec_length_replay=0,irec=0,gr_index_=-1
461!\$OMP THREADPRIVATE(first_replay,rec_length_replay,irec,gr_index_)
462integer, external :: grid_index
463eod
464if [ "$lonlat" != "" ] ; then echo "if (first_replay) gr_index_=grid_index($lonlat)" >> $paraminc1 ; fi
465echo "if ($klon==1) gr_index_=1" >> $paraminc1
466echo "if (abs(gr_index_)>0) then" >> $paraminc1
467echo "if (first_replay) then" >> $paraminc1
468dump_param_open out $varin0 >> $paraminc1
469cat>> $paraminc1 <<eod
470endif
471irec=irec+1
472write(81,rec=irec) $( echo $varin | sed -e "s/,$klon/,1/" )
473endif
474first_replay=.false.
475eod
476
477iotd_calls 1     in_${prefix} $var_1D_inout
478iotd_calls 1     in_${prefix} $var_1D_inout >> $paraminc1
479iotd_calls $klev in_${prefix} $var_2D_inout >> $paraminc1
480fi # nconly = false
481if [ "`grep $paraminc1 $paramfile`" = "" ] ; then
482   # Not changing $paraminc1 if it is already included in the file
483   # To allow adding new nc outputs in a routine equiped for replay
484   for var in $var_1D_noarg $var_2D_noarg ; do echo $var=0. >> $paraminc1 ; done
485   include_line "include \"$paraminc1\"" $param $paramfile -after_declarations
486fi
487
488#-----------------------------------------------------------------------------
489# Creating file dump_${param}_nc_${prefix}.h
490#-----------------------------------------------------------------------------
491
492\rm $paraminc2
493iotd_calls 1     "${prefix}" $var_1D >> $paraminc2
494iotd_calls $klev "${prefix}" $var_2D >> $paraminc2
495include_line "include \"$paraminc2\"" $param $paramfile "$where"
496
497if [[ "$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
499fi
500 
501#----------------------------------------------------------------------------
502# dump_ini_module gere l'ecriture des variables d'interface de l'intialisation
503# du module en mode replay
504#-----------------------------------------------------------------------------
505
506if [ $nconly = false -a $param_ini != None ] ; then
507   varinmod=`grep -i 'intent.in' $inimod.F90 | sed -e 's/\!.*$//' | cut -d: -f3 | sed -e 's/,/ /g'`
508   varinmodv=`echo $varinmod | sed -e 's/ /,/g'`
509   cat > $iniinc <<...eod...............................................
510   open(90,file='$inimod.bin',form='unformatted')
511   write(90) $varinmodv
512   close(90)
513...eod...............................................
514   for var_ in $varinmod ; do echo "print*,'Interface $param_ini $var_',$var_" >> $iniinc ; done
515   include_line "include \"$iniinc\"" $param_ini $inimod.F90  -before_return
516fi # nconly = false
517
518#-----------------------------------------------------------------------------
519# call_ini_replay.F90 gere l'initialisation du module en mode replay
520#-----------------------------------------------------------------------------
521if [ $nconly = false -a $param_ini != None ] ; then
522    cat > call_ini_replay.F90 <<....eod............................................
523    subroutine call_ini_replay
524    use $inimod
525    IMPLICIT NONE
526....eod............................................
527    grep -i intent.in $inimod.F90  |  tr '[A-Z]' '[a-z]' | sed -e 's/,.*intent.i.*)//' >> call_ini_replay.F90
528    cat >> call_ini_replay.F90 <<....eod...........................................
529    open(90,file='$inimod.bin',form='unformatted')
530    read(90) $varinmodv
531    close(90)
532....eod...........................................
533    #get_subroutine_arg $param_ini $inimod.F90 ; exit
534    get_subroutine_arg $param_ini $inimod.F90 | sed -e 's/subroutine/call/' >> call_ini_replay.F90
535    cat >> call_ini_replay.F90 <<....eod...........................................
536    return
537    end
538....eod...........................................
539fi # nconly = false
Note: See TracBrowser for help on using the repository browser.