source: trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.bash @ 11

Last change on this file since 11 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: 5.8 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 'rh' > fromregistry2
14grep '#SAVEMARS3' Registry.EM | grep 'rh' > 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
61#if [ ${yeah2} -ne 0 ]
62#then
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
81#fi
82
83\rm fill_save_3d.F90 2> /dev/null
84#if [ ${yeah3} -ne 0 ]
85#then
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
106#fi
107
108
109#
110#
111#
112\rm fill_save.inc 2> /dev/null
113
114#if [ ${yeah2} -ne 0 ]
115#then
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
120#fi
121
122#if [ ${yeah3} -ne 0 ]
123#then
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
129#fi
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
148#more module_lmd_driver_output1.inc >> module_lmd_driver_output2.inc
149cat module_lmd_driver_output1.inc >> module_lmd_driver_output2.inc
150awk '{print $3"(i,j) = output_tab2d(subs,ind_"$3")"}' fromregistry2 >> module_lmd_driver_output3.inc
151fi
152
153echo '   PSFC,TSK' >> module_lmd_driver_output2.inc
154echo 'REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(OUT)  :: &' >> module_lmd_driver_output2.inc
155
156if [ ${yeah3} -ne 0 ]
157then
158awk '{print "        " $3 ",&"}' fromregistry3 >> module_lmd_driver_output1.inc
159awk '{print "        " $3 ",&"}' fromregistry3 >> module_lmd_driver_output2.inc
160echo 'DO k = kps,kpe' >> module_lmd_driver_output3.inc
161awk '{print $3"(i,k,j) = output_tab3d(subs,k,ind_"$3")"}' fromregistry3 >> module_lmd_driver_output3.inc
162echo 'ENDDO' >> module_lmd_driver_output3.inc
163fi
164
165echo '   RTHBLTEN,RUBLTEN,RVBLTEN' >> module_lmd_driver_output2.inc
166
167
168
169#
170#
171#
172\rm module_lmd_driver_output4.inc 2> /dev/null
173touch module_lmd_driver_output4.inc
174awk '{print "  &    ,"$3"=grid%"$3"   &"}' fromregistry2 >> module_lmd_driver_output4.inc
175awk '{print "  &    ,"$3"=grid%"$3"   &"}' fromregistry3 >> module_lmd_driver_output4.inc
176
177
178
179#
180#
181#
182\rm fromregistry2
183\rm fromregistry3
184mv module_lmd_driver_output?.inc ../inc/
185\rm ../mars_lmd/libf/phymars/fill_save_?d.F90 2> /dev/null
186\rm ../mars_lmd/libf/phymars/wrf_output_?d.h 2> /dev/null
187mv fill_save.inc fill_save_?d.F90 wrf_output_?d.h ../mars_lmd/libf/phymars/
188
189#
190#
191#
192echo END of AUTOMATIC FILE GENERATION
193echo I guess you modified 'Registry.EM' ...
194echo ... so remove the file 'Registry' and recompile the model
Note: See TracBrowser for help on using the repository browser.