source: trunk/MESOSCALE/LMD_MM_MARS/SRC/WPS/util/regtest_wps.csh @ 524

Last change on this file since 524 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

  • Property svn:executable set to *
File size: 12.1 KB
Line 
1#!/bin/csh
2
3unalias cp rm ls
4
5if ( ( ! -d WPS ) || ( ! -d WRFV2 ) ) then
6        clear
7        echo " "
8        echo " "
9        echo "This test is run from a directory where"
10        echo "both WPS and WRFV2 exist"
11        echo " "
12        echo " "
13        exit ( 1 ) 
14endif
15
16set NUM_FRAMES = 12
17set TOP_DIR = `pwd`
18set PLOTS_ONLY = TRUE
19set PLOTS_ONLY = FALSE
20
21#       WRFV2 build
22
23clear
24if ( `uname` == Linux ) then
25        echo 1. starting WRFV2 build - takes about 7 minutes
26else if ( `uname` == AIX ) then
27        echo "1. starting WRFV2 build - takes 20 (bs) to 35 (bv) minutes"
28else
29        echo 1. starting WRFV2 build
30endif
31echo "     start: " `date`
32pushd WRFV2 >& /dev/null
33
34#       We at least want to be able to do nesting.
35
36if ( `uname` == Linux ) then
37        echo 2 | ./configure >& /dev/null
38else if ( `uname` == AIX ) then
39        echo 9 | ./configure >& /dev/null
40else
41        echo need info on this `uname` arch
42        exit
43endif
44
45./compile em_real >&! build.log
46if ( ( -e main/wrf.exe ) && \
47     ( -e main/real.exe ) ) then
48        echo "        WRFV2 build OK"
49else
50        echo " "
51        echo " "
52        echo "WRFV2 build failed"
53        echo "Look at $TOP_DIR/WRFV2/build.log"
54        echo " "
55        echo " "
56        exit ( 2 ) 
57endif
58echo "     end:   " `date`
59popd >& /dev/null
60
61#       WPS build
62
63echo " "
64echo 2. starting WPS build - takes about 1 minute
65echo "     start: " `date`
66pushd WPS >& /dev/null
67echo 2 | ./configure >& /dev/null
68./compile wps >&! build.log
69if ( ( -e geogrid.exe ) && \
70     ( -e metgrid.exe ) && \
71     ( -e ungrib.exe ) ) then
72        echo "        WPS build OK"
73else
74        echo " "
75        echo " "
76        echo "WPS build failed"
77        echo "Look at $TOP_DIR/WPS/build.log"
78        echo " "
79        echo " "
80        exit ( 3 ) 
81endif
82echo "     end:   " `date`
83popd >& /dev/null
84
85#       WPS TESTS
86
87echo " "
88echo 3. starting WPS tests
89echo "     start: " `date`
90pushd WPS >& /dev/null
91set count = 0
92
93#       Loop over all of the tests
94
95if ( ${#argv} == 0 ) then
96        set all_tests = ( `ls -1 test_suite` )
97else   
98        set all_tests = ( $* )
99endif
100foreach test_num ( $all_tests ) 
101
102        #       Set the env from the helpful env file
103
104        source test_suite/${test_num}/the_env
105       
106        #       Copy in the WPS namelist.
107
108        cp test_suite/${test_num}/namelist.wps .
109
110        #       Tell folks what we are doing.
111
112        @ count ++
113        echo "        Test #${count}"
114        echo "        share:   " $share
115        echo "        geogrid: " $geogrid
116        echo "        ungrib:  " $ungrib
117        echo "        metgrid: " $metgrid
118
119        #       Set the path to the static geog data in the namelist.
120
121        if      ( -d /bouleau/users/duda/GEOG ) then
122        #       Michael is a no-op
123        else if ( -d /standalone/users/gill/DATA/GEOG ) then
124                echo ' geog_data_path = "/standalone/users/gill/DATA/GEOG"' >! foodir
125        else if ( -d /data3a/mp/gill/DATA/GEOG ) then
126                echo ' geog_data_path = "/data3a/mp/gill/DATA/GEOG"' >! foodir
127        else if ( -d /mmm/users/wrfhelp/WPS_GEOG ) then
128                echo ' geog_data_path = "/mmm/users/wrfhelp/WPS_GEOG"' >! foodir
129        else
130                echo " "
131                echo " "
132                echo "Could not find the static data for geogrid"
133                echo " "
134                echo " "
135                exit ( 4 ) 
136        endif
137        sed -e '/geog_data_path/d' namelist.wps >! .foo
138        sed -e '/stand_lon/r foodir' .foo >! namelist.wps
139
140        #       Clean up the ol temp file we made.
141
142        rm .foo
143
144        if ( $PLOTS_ONLY == FALSE ) then
145                #       Echo what is happening for each program, also there is
146                #       start/ending couplet so that approx timings are possible.
147       
148                echo "        geogrid.exe share=${share} geogrid=$geogrid"
149                echo "           start: " `date`
150                geogrid.exe >&! geogrid.print.share=${share}.geogrid=$geogrid
151                grep -i success geogrid.print.share=${share}.geogrid=$geogrid >& /dev/null
152                set ok = $status
153                if ( $ok != 0 ) then
154                        echo " "
155                        echo " "
156                        echo "Failed to run geogrid.exe"
157                        echo " "
158                        echo " "
159                        exit ( 5 ) 
160                endif
161                echo "           end:   " `date`
162        endif
163
164        #       Now we slide over to the ungrib and metgrid programs.  We need to get the
165        #       location of the met data.  This is not a nml var, but an argument
166        #       to a script.
167
168        if      ( -d /standalone/users/gill/DATA/WPS_regression_data ) then
169                set datadir = /standalone/users/gill/DATA/WPS_regression_data
170        else if ( -d /data3a/mp/gill/DATA/WPS_regression_data ) then
171                set datadir = /data3a/mp/gill/DATA/WPS_regression_data
172        else if ( -d /mmm/users/gill/DATA/WPS_regression_data ) then
173                set datadir = /mmm/users/gill/DATA/WPS_regression_data
174        else
175                echo " "
176                echo " "
177                echo "Could not find the met data for ungrib.exe"
178                echo " "
179                echo " "
180                exit ( 6 ) 
181        endif
182
183        #       List of all of the input data (met) files.  The g1/g2 means Grib Edition
184        #       1 vs Edition 2.  Each has the associated Vtable, where the difference
185        #       between dir and the Vtable name is the extra "_g1" or "_g2".
186
187        set source = ( `ls -1 $datadir/$test_num` )
188
189        #       Loop of the data sources, one run each of ungrib and one of metgrid.
190
191        foreach data_source ( $source )
192
193                #       The sources are just directories in the TEST_001, etc dirs.  Also
194                #       in there is a namelist file.  That is not a valid source of data,
195                #       so we skip it an move on.
196
197                if ( ( $data_source == namelist.input ) || ( $data_source == rip_test.in ) ) then
198                        goto skipped_namelist_as_a_directory
199                endif
200
201                #       The incremented counter, to keep track of which data source
202                #       we are running, and so that we are using the right Vtable.
203
204                set Vtable = `echo $data_source | cut -d "_" -f1`
205                cp ungrib/Variable_Tables/Vtable.$Vtable Vtable
206                ./link_grib.csh $datadir/$test_num/$data_source/*
207
208                if ( $PLOTS_ONLY == FALSE ) then
209
210                        #       Run ungrib, the grib decoder.
211                       
212                        echo "           ungrib.exe share=${share} ungrib=$ungrib source=$data_source"
213                        echo "              start: " `date`
214                        ungrib.exe >&! ungrib.print.share=${share}.ungrib=${ungrib}.source=$data_source
215                        grep -i success ungrib.print.share=${share}.ungrib=$ungrib.source=$data_source >& /dev/null
216        #               grep -i Bandimere ungrib.print.share=${share}.ungrib=$ungrib.source=$data_source >& /dev/null
217                        set ok = $status
218                        if ( $ok != 0 ) then
219                                echo " "
220                                echo " "
221                                echo "Failed to run ungrib.exe"
222                                echo " "
223                                echo " "
224                                exit ( 6 ) 
225                        endif
226                        echo "              end:   " `date`
227       
228                        #       Now with the geogrid and ungrib progs done, we can move to metgrid.
229       
230                        echo "           metgrid.exe share=${share} metgrid=${metgrid} source=$data_source"
231                        echo "              start: " `date`
232                        metgrid.exe >&! metgrid.print.share=${share}.metgrid=${metgrid}.source=$data_source
233                        grep -i success metgrid.print.share=${share}.metgrid=${metgrid}.source=$data_source >& /dev/null
234                        set ok = $status
235                        if ( $ok != 0 ) then
236                                echo " "
237                                echo " "
238                                echo "Failed to run metgrid.exe"
239                                echo " "
240                                echo " "
241                                exit ( 7 ) 
242                        endif
243                        echo "              end:   " `date`
244       
245                        #       Save the data.
246       
247                        if ( ! -d TEMPORARY_STORAGE ) then
248                                mkdir TEMPORARY_STORAGE
249                        endif
250                        if ( -d TEMPORARY_STORAGE/${test_num}.source=${data_source} ) then
251                                rm -rf TEMPORARY_STORAGE/${test_num}.source=${data_source}
252                        endif
253                        mkdir TEMPORARY_STORAGE/${test_num}.source=${data_source}
254                        mv FILE* TEMPORARY_STORAGE/${test_num}.source=${data_source}
255                        mv met_* TEMPORARY_STORAGE/${test_num}.source=${data_source}
256       
257                        #       ## Run the real/wrf combo on this data generated. ##
258       
259                        #       Get to the WRF dir, just up and over a bit.
260       
261                        pushd ../WRFV2/test/em_real >& /dev/null
262       
263                                #       We need the data we just made from metgrid to be the input for real.
264               
265                                ln -sf ../../../WPS/TEMPORARY_STORAGE/${test_num}.source=${data_source}/met_* .
266               
267                                #       Manufacture the namelist.  A template is in the data dir, just edit the
268                                #       number of metgrid levels.
269               
270                                cp $datadir/$test_num/namelist.input namelist.input.template
271                                set NUM_METGRID_LEVELS = `ncdump -h met_em.d02.* | grep -i num_metgrid_levels | grep = | awk '{print $3}'`
272                                m4 -DNUM_METGRID_LEVELS=${NUM_METGRID_LEVELS} namelist.input.template >! namelist.input
273               
274                                #       The real portion.
275               
276                                echo "           real.exe share=${share} metgrid=${metgrid} source=$data_source"
277                                echo "              start: " `date`
278                                real.exe >&! real.print.share=${share}.metgrid=${metgrid}.source=$data_source
279                                grep -i success real.print.share=${share}.metgrid=${metgrid}.source=$data_source >& /dev/null
280                                set ok = $status
281                                if ( $ok != 0 ) then
282                                        echo " "
283                                        echo " "
284                                        echo "Failed to run real.exe"
285                                        echo " "
286                                        echo " "
287                                        exit ( 8 ) 
288                                endif
289                                echo "              end:   " `date`
290               
291                                #       The wrf portion.
292               
293                                echo "           wrf.exe share=${share} metgrid=${metgrid} source=$data_source"
294                                echo "              start: " `date`
295                                wrf.exe >&! wrf.print.share=${share}.metgrid=${metgrid}.source=$data_source
296                                grep -i success wrf.print.share=${share}.metgrid=${metgrid}.source=$data_source >& /dev/null
297                                set ok = $status
298                                if ( $ok != 0 ) then
299                                        echo " "
300                                        echo " "
301                                        echo "Failed to run wrf.exe"
302                                        echo " "
303                                        echo " "
304                                        exit ( 9 ) 
305                                endif
306                                echo "              end:   " `date`
307       
308                                #       Save the model IC, BC and forecast data.
309       
310                                if ( ! -d TEMPORARY_STORAGE ) then
311                                        mkdir TEMPORARY_STORAGE
312                                endif
313                                if ( -d TEMPORARY_STORAGE/${test_num}.source=${data_source} ) then
314                                        rm -rf TEMPORARY_STORAGE/${test_num}.source=${data_source}
315                                endif
316                                mkdir TEMPORARY_STORAGE/${test_num}.source=${data_source}
317                                mv wrfi* wrfb* wrfo* namelist.input TEMPORARY_STORAGE/${test_num}.source=${data_source}
318                                rm met_*
319       
320                        #       Get back out to the WPS dir.
321       
322                        popd >& /dev/null
323
324                endif
325
326#######
327
328                pushd ../WRFV2/test/em_real >& /dev/null
329               
330                #       Handle the plots with RIP.
331               
332                echo "           ripdp_wrf and rip share=${share} metgrid=${metgrid} source=$data_source"
333                echo "              start: " `date`
334                if ( ! -d RIP ) then
335                        mkdir RIP
336                endif
337                rm -rf RIP/${test_num}_${data_source}* >& /dev/null
338                ripdp_wrf RIP/${test_num}_${data_source} \
339                          all \
340                          TEMPORARY_STORAGE/${test_num}.source=${data_source}/wrfo* >&! \
341                          ripdp_wrf.print.share=${share}.metgrid=${metgrid}.source=$data_source
342                grep -i vladimir ripdp_wrf.print.share=${share}.metgrid=${metgrid}.source=$data_source >& /dev/null
343                set ok = $status
344                if ( $ok != 0 ) then
345                        echo " "
346                        echo " "
347                        echo "Failed to run ripdp_wrf"
348                        echo " "
349                        echo " "
350                        exit ( 10 ) 
351                endif
352
353                #       ... and RIP.
354
355                cp ${datadir}/${test_num}/rip_test.in test.in
356                rip RIP/${test_num}_${data_source} test.in >&! \
357                          rip.print.share=${share}.metgrid=${metgrid}.source=$data_source
358                grep -i vladimir rip.print.share=${share}.metgrid=${metgrid}.source=$data_source >& /dev/null
359                set ok = $status
360                if ( $ok != 0 ) then
361                        echo " "
362                        echo " "
363                        echo "Failed to run rip"
364                        echo " "
365                        echo " "
366                        exit ( 11 ) 
367                endif
368
369                #       Split plots into CGM pieces.
370
371                if ( -e med.info ) then
372                        rm med.info
373                endif
374                touch med.info
375
376                set count = 0
377
378                echo "read test.cgm" >> med.info
379                while ( $count < $NUM_FRAMES ) 
380                        @ count ++
381                        if ( $count < 10 ) then
382                                set index = 0$count
383                        else
384                                set index =  $count
385                        endif
386                        echo "${index} , ${index} w plot${index}.cgm" >> med.info
387                end
388                echo "quit" >> med.info
389
390                #       Run med to split frames.
391
392                med -f med.info >& /dev/null
393
394                #       Convert to a more traditional form, we like gif right now.
395
396                set count = 0
397                while ( $count < $NUM_FRAMES ) 
398                        @ count ++
399                        if ( $count < 10 ) then
400                                set index = 0$count
401                        else
402                                set index =  $count
403                        endif
404                        ctrans -d sun plot${index}.cgm > plot${index}.ras
405                        convert plot${index}.ras ${test_num}_${data_source}_${index}.gif
406                end
407
408                mv test.cgm plot*.cgm plot*.ras *.gif \
409                TEMPORARY_STORAGE/${test_num}.source=${data_source}
410                rm med.info
411
412                #       Build singleton web pages for each image
413
414                set count = 0
415                while ( $count < $NUM_FRAMES ) 
416                        @ count ++
417                        if ( $count < 10 ) then
418                                set index = 0$count
419                        else
420                                set index =  $count
421                        endif
422                        cat >&! TEMPORARY_STORAGE/${test_num}.source=${data_source}/plot_${index}.html << EOF
423<HTML>
424<BODY>
425<img src="${test_num}_${data_source}_${index}.gif">
426</BODY>
427</HTML>
428EOF
429                end
430
431                popd >& /dev/null
432
433                #       Put the pre-built web page on top of the WRF fcst plots.
434
435                if ( ! -e ../WRFV2/test/em_real/TEMPORARY_STORAGE/wps_reg.html ) then
436                        cp util/wps_reg.html ../WRFV2/test/em_real/TEMPORARY_STORAGE
437                endif
438                echo "              end:   " `date`
439
440#########
441                skipped_namelist_as_a_directory:
442
443        end
444
445        #       Save the static data for this location.
446
447        if ( $PLOTS_ONLY == FALSE ) then
448                if ( -d TEMPORARY_STORAGE/${test_num}.location ) then
449                        rm -rf TEMPORARY_STORAGE/${test_num}.location
450                endif
451                mkdir TEMPORARY_STORAGE/${test_num}.location
452                mv geo_* TEMPORARY_STORAGE/${test_num}.location
453        endif
454end
455echo "     end:   " `date`
456popd >& /dev/null
Note: See TracBrowser for help on using the repository browser.