source: trunk/mesoscale/LMD_LES_MARS/modif_mars/res/Registry.bash @ 17

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

spiga:mineur

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#! /bin/bash
2#
3# This is a script to generate FORTRAN code from registry
4#
5# A. Spiga - 17/03/08
6#
7
8
9#
10#
11#
12echo AUTOMATIC FILE GENERATION
13grep '#SAVEMARS2' Registry.EM | grep 'rhd' > fromregistry2
14grep '#SAVEMARS3' Registry.EM | grep 'rhd' > fromregistry3
15yeah2=$(awk 'END {print NR}' fromregistry2)
16yeah3=$(awk 'END {print NR}' fromregistry3)
17echo save ${yeah2} 2D arrays
18echo save ${yeah3} 3D arrays
19
20
21#
22#
23#
24\rm wrf_output_2d.h 2> /dev/null
25touch wrf_output_2d.h
26
27echo '!-------------------' >> test_include
28echo '! INCLUDE 'wrf_output_2d.h'' >> test_include
29echo '!-------------------' >> test_include
30if [ ${yeah2} -ne 0 ]
31then
32awk '{print "      INTEGER, PARAMETER :: ind_"$3" = " NR}' fromregistry2 >> test_include
33awk 'END {print "      INTEGER, PARAMETER :: n2d = " NR}' fromregistry2 >> test_include
34mv test_include wrf_output_2d.h
35else
36echo '           INTEGER, PARAMETER :: n2d = 1' >> test_include
37mv test_include wrf_output_2d.h
38fi
39
40\rm wrf_output_3d.h 2> /dev/null
41touch wrf_output_3d.h
42
43echo '!-------------------' >> test_include
44echo '! INCLUDE 'wrf_output_3d.h'' >> test_include
45echo '!-------------------' >> test_include
46if [ ${yeah3} -ne 0 ]
47then
48awk '{print "      INTEGER, PARAMETER :: ind_"$3" = " NR}' fromregistry3 >> test_include
49awk 'END {print "      INTEGER, PARAMETER :: n3d = " NR}' fromregistry3 >> test_include
50mv test_include wrf_output_3d.h
51else
52echo '           INTEGER, PARAMETER :: n3d = 1' >> test_include
53mv test_include wrf_output_3d.h
54fi
55
56
57#
58#
59#
60\rm fill_save_2d.F90 2> /dev/null
61if [ ${yeah2} -ne 0 ]
62then
63echo 'SUBROUTINE fill_save_2d( &' >> test_subroutine
64awk '{print $NF ",&"}' fromregistry2 >> test_subroutine
65echo 'ngrid,&' >> test_subroutine
66echo 'output_tab2d)' >> test_subroutine
67echo '   ' >> test_subroutine
68echo 'IMPLICIT NONE' >> test_subroutine
69echo '   ' >> test_subroutine
70echo 'include "wrf_output_2d.h"' >> test_subroutine
71#echo 'include "dimension.h"' >> test_subroutine
72echo '   ' >> test_subroutine
73echo 'INTEGER :: ngrid' >> test_subroutine
74awk '{print "REAL, DIMENSION(ngrid) :: " $NF}' fromregistry2 >> test_subroutine
75echo 'REAL, DIMENSION(ngrid,n2d) :: output_tab2d' >> test_subroutine
76echo '   ' >> test_subroutine
77awk '{print "output_tab2d(:,ind_"$3")="$NF"(:)"}' fromregistry2 >> test_subroutine
78echo '   ' >> test_subroutine
79echo 'END SUBROUTINE fill_save_2d' >> test_subroutine
80mv test_subroutine fill_save_2d.F90
81fi
82
83\rm fill_save_3d.F90 2> /dev/null
84if [ ${yeah3} -ne 0 ]
85then
86echo 'SUBROUTINE fill_save_3d( &' >> test_subroutine
87awk '{print $NF ",&"}' fromregistry3 >> test_subroutine
88echo 'ngrid,&' >> test_subroutine
89echo 'nlayer,&' >> test_subroutine
90echo 'output_tab3d)' >> test_subroutine
91echo '   ' >> test_subroutine
92echo 'IMPLICIT NONE' >> test_subroutine
93echo '   ' >> test_subroutine
94echo 'include "wrf_output_3d.h"' >> test_subroutine
95#echo 'include "dimension.h"' >> test_subroutine
96echo '   ' >> test_subroutine
97echo 'INTEGER :: ngrid' >> test_subroutine
98echo 'INTEGER :: nlayer' >> test_subroutine
99awk '{print "REAL, DIMENSION(ngrid,nlayer) :: " $NF}' fromregistry3 >> test_subroutine
100echo 'REAL, DIMENSION(ngrid,nlayer,n3d) :: output_tab3d' >> test_subroutine
101echo '   ' >> test_subroutine
102awk '{print "output_tab3d(:,:,ind_"$3")="$NF"(:,:)"}' fromregistry3 >> test_subroutine
103echo '   ' >> test_subroutine
104echo 'END SUBROUTINE fill_save_3d' >> test_subroutine
105mv test_subroutine fill_save_3d.F90
106fi
107
108
109#
110#
111#
112\rm fill_save.inc 2> /dev/null
113
114if [ ${yeah2} -ne 0 ]
115then
116echo '      CALL fill_save_2d(' >> fill_save.inc
117awk '{print "     . "$NF ","}' fromregistry2 >> fill_save.inc
118echo '     . ngrid,' >> fill_save.inc
119echo '     . output_tab2d)' >> fill_save.inc
120fi
121
122if [ ${yeah3} -ne 0 ]
123then
124echo '      CALL fill_save_3d(' >> fill_save.inc
125awk '{print "     . "$NF ","}' fromregistry3 >> fill_save.inc
126echo '     . ngrid,' >> fill_save.inc
127echo '     . nlayer,' >> fill_save.inc
128echo '     . output_tab3d)' >> fill_save.inc
129fi
130
131
132
133#
134#
135#
136\rm module_lmd_driver_output1.inc 2> /dev/null
137touch module_lmd_driver_output1.inc
138\rm module_lmd_driver_output2.inc 2> /dev/null
139touch module_lmd_driver_output2.inc
140\rm module_lmd_driver_output3.inc 2> /dev/null
141touch module_lmd_driver_output3.inc
142
143echo 'REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT)  :: &' >> module_lmd_driver_output2.inc
144
145if [ ${yeah2} -ne 0 ]
146then
147awk '{print "       " $3 ",&"}' fromregistry2 >> module_lmd_driver_output1.inc
148more module_lmd_driver_output1.inc >> module_lmd_driver_output2.inc
149awk '{print $3"(i,j) = output_tab2d(subs,ind_"$3")"}' fromregistry2 >> module_lmd_driver_output3.inc
150fi
151
152echo '   PSFC,TSK' >> module_lmd_driver_output2.inc
153echo 'REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(OUT)  :: &' >> module_lmd_driver_output2.inc
154
155if [ ${yeah3} -ne 0 ]
156then
157awk '{print "        " $3 ",&"}' fromregistry3 >> module_lmd_driver_output1.inc
158awk '{print "        " $3 ",&"}' fromregistry3 >> module_lmd_driver_output2.inc
159echo 'DO k = kps,kpe' >> module_lmd_driver_output3.inc
160awk '{print $3"(i,k,j) = output_tab3d(subs,k,ind_"$3")"}' fromregistry3 >> module_lmd_driver_output3.inc
161echo 'ENDDO' >> module_lmd_driver_output3.inc
162fi
163
164echo '   RTHBLTEN,RUBLTEN,RVBLTEN' >> module_lmd_driver_output2.inc
165
166
167
168#
169#
170#
171\rm module_lmd_driver_output4.inc 2> /dev/null
172touch module_lmd_driver_output4.inc
173awk '{print "  &    ,"$3"=grid%"$3"   &"}' fromregistry2 >> module_lmd_driver_output4.inc
174awk '{print "  &    ,"$3"=grid%"$3"   &"}' fromregistry3 >> module_lmd_driver_output4.inc
175
176
177
178#
179#
180#
181\rm fromregistry2
182\rm fromregistry3
183mv module_lmd_driver_output?.inc ../inc/
184\rm ../mars_lmd/libf/phymars/fill_save_?d.F90 2> /dev/null
185\rm ../mars_lmd/libf/phymars/wrf_output_?d.h 2> /dev/null
186mv fill_save.inc fill_save_?d.F90 wrf_output_?d.h ../mars_lmd/libf/phymars/
187
188#
189#
190#
191echo END of AUTOMATIC FILE GENERATION
192echo I guess you modified 'Registry.EM' ...
193echo ... so remove the file 'Registry' and recompile the model
Note: See TracBrowser for help on using the repository browser.