-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnwps_coremodel_cg1.pl
executable file
·268 lines (256 loc) · 7.12 KB
/
nwps_coremodel_cg1.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/usr/bin/env perl
# -----------------------------------------------------------
# PERL Script
# PERL Version(s): 5
# Original Author(s): Eve-Marie Devalire for WFO-Eureka
# File Creation Date: 04/20/2004
# Date Last Modified: 11/15/2014
#
# Version control: 2.31
#
# Support Team:
#
# Contributors: Alex Gibbs, Tony Freeman, Pablo Santos, Douglas Gaer
# Roberto Padilla-Hernandez
# -----------------------------------------------------------
# ------------- Program Description and Details -------------
# -----------------------------------------------------------
#
# This program is the one making all the other communicate. It receives one
# from each one of the non common packages and deal with global varaibles.
# Thus, it processes the input, makes the SWAN model run for each domain,
# process the output and ship the files to AWIPS.
#
# The packages used are the following:
#
# WaveInput
# WindInput
# GraphicOutput
# TextOutput
# SwanRun
# -----------------------------------------------------------
######################################################
# Packages and exportation requirements #
######################################################
use lib ("$ENV{'PMnwps'}");
use lib ("$ENV{'USHnwps'}");
use lib ("$ENV{'RUNdir'}");
use lib ("$ENV{'DATA'}");
#use WaveInput qw(waveInputProcessing);
#use WindInput qw(windInputProcessing);
#use GraphicOutput qw(graphicOutputProcessing);
use RunSwan qw(runModel);
use CommonSub qw(removeFiles removeOldFiles mvFiles renameFilesWithSuffix giveDate);
use ArraySub qw(inArray);
use ConfigSwan;
use Cleanup;
use Logs;
use WaveHazards qw(runWaveHazards);
use Archive qw(isRunFromArchive extractArchive archiveFiles completeArchiveAndCleanup);
use TextOutput qw(textOutputProcessing);
######################################################
# Variables declaration #
######################################################
our $dateSuffix;
our ($cg,$date,$inpGrid,$filename,$spectraFrom);
our (@date,$h,$min);
our $path=PATH;
######################################################
# Environment Variables #
######################################################
# Setup our NWPS env
my $NWPSdir = $ENV{'HOMEnwps'};
my $ISPRODUCTION = $ENV{'ISPRODUCTION'};
my $DEBUGGING = $ENV{'DEBUGGING'};
my $DEBUG_LEVEL = $ENV{'DEBUG_LEVEL'};
# Setup our processing DIRs
my $BATHYdb = $ENV{'BATHYdb'};
my $SHAPEFILEdb = $ENV{'SHAPEFILEdb'};
my $ARCHdir = $ENV{'ARCHdir'};
my $DATAdir = $ENV{'DATAdir'};
my $INPUTdir = $ENV{'INPUTdir'};
my $LOGdir = $ENV{'LOGdir'};
my $VARdir = $ENV{'VARdir'};
my $OUTPUTdir = $ENV{'OUTPUTdir'};
my $RUNdir = $ENV{'RUNdir'};
my $TMPdir = $ENV{'TMPdir'};
# Setup our model run environment
my $RUNLEN = $ENV{'RUNLEN'};
my $WNA = $ENV{'WNA'};
my $NESTS = $ENV{'NESTS'};
my $RTOFS = $ENV{'RTOFS'};
my $WATERLEVELS = $ENV{'WATERLEVELS'};
my $WINDS = $ENV{'WINDS'};
my $WEB = $ENV{'WEB'};
my $PLOT = $ENV{'PLOT'};
my $SITEID = $ENV{'SITEID'};
my $MODELCORE = $ENV{'MODELCORE'};
my $NWPSplatform = $ENV{'NWPSplatform'};
######################################################
# Subroutines calls #
######################################################
#for_WCOSS
#codeswanpl03
print " ++++++++++++++++++ nwps_coremodel_CG1.pl++++++++++++++++++++++\n";
print " Rundir: ${RUNdir} \n";
print " NWPSplatform: ${NWPSplatform} \n";
print " ++++++++++++++++++ nwps_coremodel_CG1.pl++++++++++++++++++++++\n";
if((${NWPSplatform} eq 'WCOSS') || (${NWPSplatform} eq 'DEVWCOSS')) {
my $infoFile02 = "${RUNdir}/info_to_nwps_coremodel.txt";
open IN, "<$infoFile02" or die "Cannot open: $!";
our ($NWPSdir, $DEBUGGING, $DEBUG_LEVEL, $BATHYdb, $SHAPEFILEdb, $ARCHdir);
our ($DATAdir, $LOGdir, $VARdir, $OUTPUTdir, $RUNdir, $TMPdir, $RUNLEN);
our ($NESTS, $RTOFS, $WATERLEVELS, $WEB, $PLOT, $MODELCORE, $LOGdir, $SITEID);
our ($WNA, $WINDS, $INPUTdir, $ISPRODUCTIO, $DATAdir, $siteid, $GEN_NETCDF);
our ($USERDELTAC);
my $ndata=0;
while (<IN>) {
$ndata+=1;
chomp($_);
if ($ndata ==1) {
$NWPSdir=$_;
}
if ($ndata ==2) {
$ISPRODUCTIO=$_;
}
if ($ndata ==3) {
$DEBUGGING=$_;
}
if ($ndata ==4) {
$DEBUG_LEVEL=$_;
}
if ($ndata ==5) {
$BATHYdb=$_;
}
if ($ndata ==6) {
$SHAPEFILEdb =$_;
}
if ($ndata ==7) {
$ARCHdir=$_;
}
if ($ndata ==8) {
$DATAdir=$_;
}
if ($ndata ==9) {
$INPUTdir=$_;
}
if ($ndata ==10) {
$LOGdir=$_;
}
if ($ndata ==11) {
$VARdir=$_;
}
if ($ndata ==12) {
$OUTPUTdir=$_;
}
if ($ndata ==13) {
$RUNdir=$_;
}
if ($ndata ==14) {
$TMPdir=$_;
}
if ($ndata ==15) {
$RUNLEN=$_;
}
if ($ndata ==16) {
$WNA=$_;
}
if ($ndata ==17) {
$NESTS=$_;
}
if ($ndata ==18) {
$RTOFS=$_;
}
if ($ndata ==19) {
$WATERLEVELS=$_;
}
if ($ndata ==20) {
$WINDS=$_;
}
if ($ndata ==21) {
$WEB=$_;
}
if ($ndata ==22) {
$PLOT=$_;
}
if ($ndata ==23) {
$SITEID=$_;
$siteid= lc $SITEID;
}
if ($ndata ==24) {
$MODELCORE=$_;
}
if ($ndata ==25) {
$GEN_NETCDF=$_;
}
if ($ndata ==26) {
$USERDELTAC=$_;
}
}
close IN;
#print "$NWPSdir, $ISPRODUCTIO, $DEBUGGING, $DEBUG_LEVEL, $BATHYdb, $SHAPEFILEdb, $ARCHdir\n";
#print "$DATAdir, $INPUTdir, $LOGdir, $VARdir, $OUTPUTdir, $RUNdir, $TMPdir, $RUNLEN, $WNA\n";
#print "$NEST, $RTOFS, $WATERLEVELS, $WINDS, $WEB, $PLOT, $MODELCORE, $LOGdir, $SITEID, $DATAdir\n";
#print "$GEN_NETCDF\n";
#
}
Logs::initialize();
Logs::run("BEGIN RUN");
if ($DEBUGGING eq "TRUE") {
Logs::run("NWPSdir: $NWPSdir");
Logs::run("DEBUGGING: $DEBUGGING");
Logs::run("DEBUG_LEVEL: $DEBUG_LEVEL");
Logs::run("ISPRODUCTION: $ISPRODUCTION");
Logs::run("RUNLEN: $RUNLEN");
Logs::run("WNA: $WNA");
Logs::run("NESTS: $NESTS");
Logs::run("RTOFS: $RTOFS");
Logs::run("WATERLEVELS: $WATERLEVELS");
Logs::run("WINDS: $WINDS");
Logs::run("WEB: $WEB");
}
#Break here for WCOSS_main_01
#Break here for WCOSS_main_02
#
#for_WCOSS
#codeswanpl02
if((${NWPSplatform} eq 'WCOSS') || (${NWPSplatform} eq 'DEVWCOSS')) {
my $infoFile01 = "${RUNdir}/info_to_makeSwanRun.txt";
open IN, "<$infoFile01" or die "Cannot open: $!";
my $ndata=0;
while (<IN>) {
$ndata+=1;
$count++;
print "ndata= $ndata\n";
if ($ndata ==1) {
$date=$_;
print "$data\n";
}
if ($ndata ==2) {
$inpGrid=$_;
print "$inpGrid\n";
}
if ($ndata ==3) {
$filename=$_;
print "$filename\n";
}
}
close IN;
}
#Get the CGS hash
my %CGSS = %ConfigSwan::CGS;
#Get the number of hashes (Number of computational grids) in the hash CGS
my $numcgrids += scalar keys %CGSS;
print "Number of Computational grids: " . keys( %CGSS). "\n";
#foreach my $CG (sort(values(%ConfigSwan::CGS))) {
#foreach my $CG ( reverse sort values %ConfigSwan::CGS) {
#Give the names of the hashes that contains the CG information
my @columns = qw(CG1 CG2 CG3 CG4 CG5);
#Loop over the actual umber of Comp. Grids, in spite of nymber of elemnts in @columns
for $i (0..0){
# Get a slice of the Config hash
my $CG = @CGSS{$columns[$i]}; # 6,1,3
%CG = %{$CG};
$dateSuffix = &runModel($date,$inpGrid,$filename,%CG);
}
#Break here for WCOSS_main_03