-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcm_run_CPLFCST360S2S.j
executable file
·647 lines (539 loc) · 23.1 KB
/
gcm_run_CPLFCST360S2S.j
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
#!/bin/csh -fx
#######################################################################
# Batch Parameters for Run Job
#######################################################################
#SBATCH --time=@RUN_T
#@RUN_P
#SBATCH --job-name=@RUN_N
#@RUN_SP
#@RUN_SN
#SBATCH -A g0609
#######################################################################
# System Settings
#######################################################################
umask 022
limit stacksize unlimited
#######################################################################
# Architecture Specific Environment Variables
#######################################################################
setenv ARCH `uname`
setenv SITE @SITE
setenv GEOSDIR @GEOSDIR
setenv GEOSBIN @GEOSBIN
setenv RUN_CMD "@RUN_CMD"
setenv GCMVER @GCMVER
source $GEOSBIN/g5_modules
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${BASEDIR}/${ARCH}/lib
#######################################################################
# Experiment Specific Environment Variables
#######################################################################
setenv EXPID @EXPID
setenv EXPDIR @EXPDIR
setenv HOMDIR @HOMDIR
setenv SCRDIR $EXPDIR/scratch
>>>FORCAST<<<set SUBSEASONAL = @FCSTMODE
#######################################################################
# Create Experiment Sub-Directories
#######################################################################
if (! -e $EXPDIR/restarts ) mkdir -p $EXPDIR/restarts
if (! -e $EXPDIR/holding ) mkdir -p $EXPDIR/holding
if (! -e $EXPDIR/archive ) mkdir -p $EXPDIR/archive
if (! -e $EXPDIR/post ) mkdir -p $EXPDIR/post
if (! -e $EXPDIR/plot ) mkdir -p $EXPDIR/plot
if (! -e $SCRDIR ) mkdir -p $SCRDIR
#######################################################################
# Set Experiment Run Parameters
#######################################################################
set NX = `grep NX: $HOMDIR/AGCM.rc | cut -d':' -f2`
set NY = `grep NY: $HOMDIR/AGCM.rc | cut -d':' -f2`
set AGCM_IM = `grep AGCM_IM: $HOMDIR/AGCM.rc | cut -d':' -f2`
set AGCM_JM = `grep AGCM_JM: $HOMDIR/AGCM.rc | cut -d':' -f2`
set AGCM_LM = `grep AGCM_LM: $HOMDIR/AGCM.rc | cut -d':' -f2`
set OGCM_IM = `grep OGCM_IM: $HOMDIR/AGCM.rc | cut -d':' -f2`
set OGCM_JM = `grep OGCM_JM: $HOMDIR/AGCM.rc | cut -d':' -f2`
set END_DATE = `grep END_DATE: $HOMDIR/CAP.rc | cut -d':' -f2`
set NUM_SGMT = `grep NUM_SGMT: $HOMDIR/CAP.rc | cut -d':' -f2`
set FSEGMENT = `grep FCST_SEGMENT: $HOMDIR/CAP.rc | cut -d':' -f2`
set USE_SHMEM = `grep USE_SHMEM: $HOMDIR/CAP.rc | cut -d':' -f2`
@COUPLED set OGCM_LM = `grep OGCM_LM: $HOMDIR/AGCM.rc | cut -d':' -f2`
@COUPLED set NX = `grep OGCM_NX: $HOMDIR/AGCM.rc | cut -d':' -f2`
@COUPLED set NY = `grep OGCM_NY: $HOMDIR/AGCM.rc | cut -d':' -f2`
@COUPLED set HIST_IM = @HIST_IM
@COUPLED set HIST_JM = @HIST_JM
# Check for Over-Specification of CPU Resources
# ---------------------------------------------
if ($?PBS_NODEFILE) then
set NCPUS = `cat $PBS_NODEFILE | wc -l`
@ NPES = $NX * $NY
if( $NPES > $NCPUS ) then
echo "CPU Resources are Over-Specified"
echo "--------------------------------"
echo "Allotted NCPUs: $NCPUS"
echo "Specified NX : $NX"
echo "Specified NY : $NY"
exit
endif
endif
endif
# Set ATMOS and OCEAN Horizontal Resolution Tags
# ----------------------------------------------
set AGCM_IM_Tag = `echo $AGCM_IM | awk '{printf "%4.4i", $1}'`
set AGCM_JM_Tag = `echo $AGCM_JM | awk '{printf "%4.4i", $1}'`
set OGCM_IM_Tag = `echo $OGCM_IM | awk '{printf "%4.4i", $1}'`
set OGCM_JM_Tag = `echo $OGCM_JM | awk '{printf "%4.4i", $1}'`
@COUPLED set HIST_IM_Tag = `echo $HIST_IM | awk '{printf "%4.4i", $1}'`
@COUPLED set HIST_JM_Tag = `echo $HIST_JM | awk '{printf "%4.4i", $1}'`
>>>FVLATLON<<<set ATMOStag = DC${AGCM_IM_Tag}xPC${AGCM_JM_Tag}
>>>FVCUBED<<<set ATMOStag = CF${AGCM_IM_Tag}x6C
@DATAOCEAN set OCEANtag = DE${OGCM_IM_Tag}xPE${OGCM_JM_Tag}
@COUPLED set OCEANtag = TM${OGCM_IM_Tag}xTM${OGCM_JM_Tag}
@COUPLED set HISTtag = DC${HIST_IM_Tag}xPC${HIST_JM_Tag}
#######################################################################
# Move to Scratch Directory and Copy RC Files from Home Directory
#######################################################################
cd $SCRDIR
/bin/rm -rf *
/bin/ln -sf $EXPDIR/RC/* .
/bin/cp $EXPDIR/cap_restart .
/bin/cp -f $HOMDIR/*.rc .
/bin/cp -f $HOMDIR/*.nml .
#######################################################################
# Create Strip Utility to Remove Multiple Blank Spaces
#######################################################################
set FILE = strip
/bin/rm $FILE
cat << EOF > $FILE
#!/bin/ksh
/bin/mv \$1 \$1.tmp
touch \$1
while read line
do
echo \$line >> \$1
done < \$1.tmp
exit
EOF
chmod +x $FILE
#######################################################################
# Create HISTORY Collection Directories
#######################################################################
set collections = ''
foreach line ("`cat HISTORY.rc`")
set firstword = `echo $line | awk '{print $1}'`
set firstchar = `echo $firstword | cut -c1`
set secondword = `echo $line | awk '{print $2}'`
if ( $firstword == "::" ) goto done
if ( $firstchar != "#" ) then
set collection = `echo $firstword | sed -e "s/'//g"`
set collections = `echo $collections $collection`
if ( $secondword == :: ) goto done
endif
if ( $firstword == COLLECTIONS: ) then
set collections = `echo $secondword | sed -e "s/'//g"`
endif
end
done:
foreach collection ( $collections )
if (! -e $EXPDIR/$collection ) mkdir $EXPDIR/$collection
if (! -e $EXPDIR/holding/$collection ) mkdir $EXPDIR/holding/$collection
end
#######################################################################
# Link Boundary Datasets
#######################################################################
setenv BCSDIR @BCSDIR
@DATAOCEAN setenv SSTDIR @SSTDIR
setenv CHMDIR @CHMDIR
@DATAOCEAN setenv BCRSLV ${ATMOStag}_${OCEANtag}
@COUPLED setenv BCRSLV ${ATMOStag}_DE0360xPE0180
setenv DATELINE DC
setenv EMISSIONS @EMISSIONS
@COUPLED setenv GRIDDIR @COUPLEDIR/a${AGCM_IM}x${AGCM_JM}_o${OGCM_IM}x${OGCM_JM}
@COUPLED setenv BCTAG `basename $GRIDDIR`
@DATAOCEAN setenv BCTAG `basename $BCSDIR`
set FILE = linkbcs
/bin/rm -f $FILE
cat << _EOF_ > $FILE
#!/bin/csh -f
@COUPLED /bin/mkdir -p RESTART
/bin/mkdir -p ExtData
/bin/ln -sf $CHMDIR/* ExtData
@COUPLED /bin/ln -sf $GRIDDIR/SEAWIFS_KPAR_mon_clim.${OGCM_IM}x${OGCM_JM} SEAWIFS_KPAR_mon_clim.data
@COUPLED /bin/ln -sf $GRIDDIR/${ATMOStag}_${OCEANtag}-Pfafstetter.til tile.data
@COUPLED /bin/ln -sf $GRIDDIR/${ATMOStag}_${OCEANtag}-Pfafstetter.TRN runoff.bin
@COUPLED /bin/ln -sf $GRIDDIR/tripolar_${OGCM_IM}x${OGCM_JM}.ascii .
@COUPLED /bin/ln -sf $GRIDDIR/vgrid${OGCM_LM}.ascii ./vgrid.ascii
@COUPLED /bin/ln -s /discover/nobackup/yvikhlia/coupled/Forcings/a${HIST_IM}x${HIST_JM}_o${OGCM_IM}x${OGCM_JM}/${HISTtag}_${OCEANtag}-Pfafstetter.til tile_hist.data
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/${BCRSLV}-Pfafstetter.til tile.data
@DATAOCEAN if( -e $BCSDIR/$BCRSLV/${BCRSLV}-Pfafstetter.TIL) then
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/${BCRSLV}-Pfafstetter.TIL tile.bin
@DATAOCEAN endif
/bin/ln -sf $BCSDIR/Shared/pchem.species.CMIP-5.1870-2097.z_91x72.nc4 species.data
/bin/ln -sf $BCSDIR/Shared/*bin .
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/visdf_@RES_DATELINE.dat visdf.dat
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/nirdf_@RES_DATELINE.dat nirdf.dat
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/vegdyn_@RES_DATELINE.dat vegdyn.data
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/lai_clim_@RES_DATELINE.data lai.data
@DATAOCEAN /bin/ln -sf $BCSDIR/$BCRSLV/green_clim_@RES_DATELINE.data green.data
@COUPLED /bin/ln -sf $GRIDDIR/visdf.dat visdf.dat
@COUPLED /bin/ln -sf $GRIDDIR/nirdf.dat nirdf.dat
@COUPLED /bin/ln -sf /discover/nobackup/projects/gmao/t2ssp/h54/c180_o05/restart/MERRA2/OutData/vegdyn_internal_rst vegdyn.data
@COUPLED /bin/ln -sf $GRIDDIR/lai.dat lai.data
@COUPLED /bin/ln -sf $GRIDDIR/green.dat green.data
/bin/ln -sf $BCSDIR/$BCRSLV/topo_DYN_ave_@RES_DATELINE.data topo_dynave.data
/bin/ln -sf $BCSDIR/$BCRSLV/topo_GWD_var_@RES_DATELINE.data topo_gwdvar.data
/bin/ln -sf $BCSDIR/$BCRSLV/topo_TRB_var_@RES_DATELINE.data topo_trbvar.data
>>>FVCUBED<<<if( -e $BCSDIR/$BCRSLV/Gnomonic_$BCRSLV.dat ) then
>>>FVCUBED<<</bin/ln -sf $BCSDIR/$BCRSLV/Gnomonic_$BCRSLV.dat .
>>>FVCUBED<<<endif
@COUPLED /bin/cp $HOMDIR/input.nml .
@COUPLED /bin/cp $HOMDIR/*_table .
@COUPLED /bin/ln -sf $GRIDDIR/cice/kmt_cice.bin .
@COUPLED /bin/ln -sf $GRIDDIR/cice/grid_cice.bin .
_EOF_
@DATAOCEAN echo "/bin/ln -sf $SSTDIR"'/@SSTFILE sst.data' >> $FILE
@DATAOCEAN echo "/bin/ln -sf $SSTDIR"'/@ICEFILE fraci.data' >> $FILE
@DATAOCEAN echo "/bin/ln -sf $SSTDIR"'/@KPARFILE SEAWIFS_KPAR_mon_clim.data' >> $FILE
chmod +x linkbcs
/bin/cp linkbcs $EXPDIR
#######################################################################
# Get C2L History weights/index file for Cubed-Sphere
#######################################################################
set C_NPX = `echo $AGCM_IM | awk '{printf "%5.5i", $1}'`
set C_NPY = `echo $AGCM_JM | awk '{printf "%5.5i", $1}'`
set H_NPX = `echo @HIST_IM | awk '{printf "%5.5i", $1}'`
set H_NPY = `echo @HIST_JM | awk '{printf "%5.5i", $1}'`
set c2l_file = "${C_NPX}x${C_NPY}_c2l_${H_NPX}x${H_NPY}.bin"
if (-e $BCSDIR/$BCRSLV/${c2l_file}) /bin/ln -s $BCSDIR/$BCRSLV/${c2l_file} .
#######################################################################
# Get Executable and RESTARTS
#######################################################################
/bin/cp $EXPDIR/GEOSgcm.x .
set rst_files = `cat AGCM.rc | grep "RESTART_FILE" | cut -d ":" -f1 | cut -d "_" -f1-2`
set chk_files = `cat AGCM.rc | grep "CHECKPOINT_FILE" | cut -d ":" -f1 | cut -d "_" -f1-2`
set rst_file_names = `cat AGCM.rc | grep "RESTART_FILE" | cut -d ":" -f2`
set chk_file_names = `cat AGCM.rc | grep "CHECKPOINT_FILE" | cut -d ":" -f2`
# Remove possible bootstrap parameters (+/-)
# ------------------------------------------
set dummy = `echo $rst_file_names`
set rst_file_names = ''
foreach rst ( $dummy )
set length = `echo $rst | awk '{print length($0)}'`
set bit = `echo $rst | cut -c1`
if( "$bit" == "+" | \
"$bit" == "-" ) set rst = `echo $rst | cut -c2-$length`
set rst_file_names = `echo $rst_file_names $rst`
end
# Copy Restarts to Scratch Directory
# ----------------------------------
foreach rst ( $rst_file_names )
if(-e $EXPDIR/$rst ) /bin/cp $EXPDIR/$rst . &
end
wait
@COUPLED /bin/cp -R $GRIDDIR/INPUT .
@COUPLED /bin/cp $EXPDIR/RESTART/* INPUT
# Copy and Tar Initial Restarts to Restarts Directory
# ---------------------------------------------------
set edate = e`cat cap_restart | cut -c1-8`_`cat cap_restart | cut -c10-11`z
>>>FORCAST<<<set capdateIC = `cat $HOMDIR/cap_restartIC | cut -c1-8`
>>>FORCAST<<<set capdateCR = `cat cap_restart | cut -c1-8`
set numrs = `/bin/ls -1 ${EXPDIR}/restarts/*${edate}* | wc -l`
if($numrs == 0) then
foreach rst ( $rst_file_names )
if( -e $rst & ! -e ${EXPDIR}/restarts/$EXPID.${rst}.${edate}.${GCMVER}.${BCTAG}_${BCRSLV} ) then
/bin/cp $rst ${EXPDIR}/restarts/$EXPID.${rst}.${edate}.${GCMVER}.${BCTAG}_${BCRSLV} &
endif
end
wait
@COUPLED /bin/cp -r $EXPDIR/RESTART ${EXPDIR}/restarts/RESTART.${edate}
cd $EXPDIR/restarts
@DATAOCEAN tar cf restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}
@COUPLED tar cvf restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV} RESTART.${edate}
/bin/rm -rf `/bin/ls -d -1 $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}`
@COUPLED /bin/rm -rf RESTART.${edate}
cd $SCRDIR
endif
##################################################################
######
###### Perform multiple iterations of Model Run
######
##################################################################
@ counter = 1
while ( $counter <= ${NUM_SGMT} )
/bin/rm -f EGRESS
/bin/cp -f $HOMDIR/CAP.rc .
./strip CAP.rc
# Set Time Variables for Current_(c), Ending_(e), and Segment_(s) dates
# ---------------------------------------------------------------------
set nymdc = `cat cap_restart | cut -c1-8`
set nhmsc = `cat cap_restart | cut -c10-15`
set nymde = `cat CAP.rc | grep END_DATE: | cut -d: -f2 | cut -c2-9`
set nhmse = `cat CAP.rc | grep END_DATE: | cut -d: -f2 | cut -c11-16`
set nymds = `cat CAP.rc | grep JOB_SGMT: | cut -d: -f2 | cut -c2-9`
set nhmss = `cat CAP.rc | grep JOB_SGMT: | cut -d: -f2 | cut -c11-16`
# Compute Time Variables at the Finish_(f) of current segment
# -----------------------------------------------------------
set nyear = `echo $nymds | cut -c1-4`
set nmonth = `echo $nymds | cut -c5-6`
set nday = `echo $nymds | cut -c7-8`
set nhour = `echo $nhmss | cut -c1-2`
set nminute = `echo $nhmss | cut -c3-4`
set nsec = `echo $nhmss | cut -c5-6`
@ dt = $nsec + 60 * $nminute + 3600 * $nhour + 86400 * $nday
set nymdf = $nymdc
set nhmsf = $nhmsc
set date = `$GEOSBIN/tick $nymdf $nhmsf $dt`
set nymdf = $date[1]
set nhmsf = $date[2]
set year = `echo $nymdf | cut -c1-4`
set month = `echo $nymdf | cut -c5-6`
set day = `echo $nymdf | cut -c7-8`
@ month = $month + $nmonth
while( $month > 12 )
@ month = $month - 12
@ year = $year + 1
end
@ year = $year + $nyear
@ nymdf = $year * 10000 + $month * 100 + $day
if( $nymdf > $nymde ) set nymdf = $nymde
if( $nymdf == $nymde ) then
if( $nhmsf > $nhmse ) set nhmsf = $nhmse
endif
set yearc = `echo $nymdc | cut -c1-4`
set yearf = `echo $nymdf | cut -c1-4`
# For MERRA-2 and OSTIA, Modify local CAP.rc Ending date if Finish time exceeds Current year boundary
# ---------------------------------------------------------------------------------------------------
if( ${OCEANtag} == DE1440xPE0720 | \
${OCEANtag} == DE2880xPE1440 ) then
if( $yearf > $yearc ) then
@ yearf = $yearc + 1
@ nymdf = $yearf * 10000 + 0101
set oldstring = `cat CAP.rc | grep END_DATE:`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
endif
# Select proper MERRA-2 GOCART Emission RC Files
# (NOTE: MERRA2-DD has same transition date)
# ----------------------------------------------
if( ${EMISSIONS} == MERRA2 | \
${EMISSIONS} == MERRA2-DD ) then
set MERRA2_Transition_Date = 20000401
if( $nymdc < ${MERRA2_Transition_Date} ) then
set MERRA2_EMISSIONS_DIRECTORY = $GEOSDIR/$ARCH/etc/$EMISSIONS/19600101-20000331
if( $nymdf > ${MERRA2_Transition_Date} ) then
set nymdf = ${MERRA2_Transition_Date}
set oldstring = `cat CAP.rc | grep END_DATE:`
set newstring = "END_DATE: $nymdf $nhmsf"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
endif
else
set MERRA2_EMISSIONS_DIRECTORY = $GEOSDIR/$ARCH/etc/$EMISSIONS/20000401-present
endif
if( $AGCM_LM == 72 ) then
/bin/cp --remove-destination ${MERRA2_EMISSIONS_DIRECTORY}/*.rc .
else
set files = `/bin/ls -1 ${MERRA2_EMISSIONS_DIRECTORY}/*.rc`
foreach file ($files)
/bin/rm -f `basename $file`
/bin/rm -f dummy
/bin/cp $file dummy
cat dummy | sed -e "s|/L72/|/L${AGCM_LM}/|g" | sed -e "s|z72|z${AGCM_LM}|g" > `basename $file`
end
endif
endif
if(-e ExtData.rc ) /bin/rm -f ExtData.rc
set extdata_files = `/bin/ls -1 *_ExtData.rc`
cat $extdata_files > ExtData.rc
# Link Boundary Conditions for Appropriate Date
# ---------------------------------------------
setenv YEAR $yearc
./linkbcs
if (! -e tile.bin) then
$GEOSBIN/binarytile.x tile.data tile.bin
@COUPLED $GEOSBIN/binarytile.x tile_hist.data tile_hist.bin
endif
# Test Saltwater Restart for Number of tiles correctness
# ------------------------------------------------------
if ( -x $GEOSBIN/rs_numtiles.x ) then
set N_SALT_TILES_EXPECTED = `grep '^ *0' tile.data | wc -l`
set N_SALT_TILES_FOUND = `$RUN_CMD 1 $GEOSBIN/rs_numtiles.x saltwater_internal_rst | grep Total | awk '{print $3}'`
if ( $N_SALT_TILES_EXPECTED != $N_SALT_TILES_FOUND ) then
echo "Error! Found $N_SALT_TILES_FOUND tiles in saltwater. Expect to find $N_SALT_TILES_EXPECTED tiles."
echo "Your restarts are probably for a different ocean."
exit 7
endif
endif
# Environment variables for MPI, etc
# ----------------------------------
@SETENVS
@GPUSTART
# Run GEOSgcm.x
# -------------
if( $USE_SHMEM == 1 ) $GEOSBIN/RmShmKeys_sshmpi.csh
@ NPES = $NX * $NY
$RUN_CMD $NPES ./GEOSgcm.x
if( $USE_SHMEM == 1 ) $GEOSBIN/RmShmKeys_sshmpi.csh
@GPUEND
if( -e EGRESS ) then
set rc = 0
else
set rc = -1
endif
echo GEOSgcm Run Status: $rc
>>>FORCAST<<<if ($rc != 0) then
>>>FORCAST<<< touch $HOMDIR/PANICSTOP
>>>FORCAST<<< exit
>>>FORCAST<<<endif
#######################################################################
# Rename Final Checkpoints => Restarts for Next Segment and Archive
# Note: cap_restart contains the current NYMD and NHMS
#######################################################################
set edate = e`cat cap_restart | cut -c1-8`_`cat cap_restart | cut -c10-11`z
set numrst = `echo $rst_files | wc -w`
set numchk = `echo $chk_files | wc -w`
@ n = 1
@ z = $numrst + 1
while ( $n <= $numchk )
if ( -e $chk_file_names[$n] ) then
@ m = 1
while ( $m <= $numrst )
if( $chk_files[$n] == $rst_files[$m] || \
\#$chk_files[$n] == $rst_files[$m] ) then
set chk_type = `/usr/bin/file -Lb --mime-type $chk_file_names[$n]`
if ( $chk_type =~ "application/octet-stream" ) then
set ext = bin
else
set ext = nc4
endif
/bin/mv $chk_file_names[$n] $rst_file_names[$m]
/bin/cp $rst_file_names[$m] ${EXPDIR}/restarts/$EXPID.${rst_file_names[$m]}.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}.$ext &
@ m = $numrst + 999
else
@ m = $m + 1
endif
end
wait
if( $m == $z ) then
echo "Warning!! Could not find CHECKPOINT/RESTART match for: " $chk_files[$n]
exit
endif
endif
@ n = $n + 1
end
@COUPLED /bin/cp -r RESTART ${EXPDIR}/restarts/RESTART.${edate}
@COUPLED /bin/cp RESTART/* INPUT
# Rename and Move Intermediate Checkpoints
# ----------------------------------------
/bin/mv -f *_checkpoint* ${EXPDIR}/restarts
cd $EXPDIR/restarts
$GEOSBIN/stripname _checkpoint. _rst.e
if( $FSEGMENT == 00000000 ) then
@DATAOCEAN tar cf restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}.*
@COUPLED tar cvf restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}.* RESTART.${edate}
/bin/rm -rf `/bin/ls -d -1 $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}.*`
@COUPLED /bin/rm -rf RESTART.${edate}
endif
cd $SCRDIR
#######################################################################
# Move HISTORY Files to Holding Directory
#######################################################################
# Check for files waiting in /holding
# -----------------------------------
set waiting_files = `/bin/ls -1 $EXPDIR/holding/*/*nc4`
set num_waiting_files = $#waiting_files
# Move current files to /holding
# ------------------------------
foreach collection ( $collections )
/bin/mv `/bin/ls -1 *.${collection}.*` $EXPDIR/holding/$collection
end
@COUPLED # MOM-Specific Output Files
@COUPLED # -------------------------
@COUPLED set dsets="ocean_month"
@COUPLED foreach dset ( $dsets )
@COUPLED set num = `/bin/ls -1 $dset.nc | wc -l`
@COUPLED if($num != 0) then
@COUPLED if(! -e $EXPDIR/MOM_Output) mkdir -p $EXPDIR/MOM_Output
@COUPLED /bin/mv $SCRDIR/$dset.nc $EXPDIR/MOM_Output/$dset.${edate}.nc
@COUPLED endif
@COUPLED end
@COUPLED
#######################################################################
# Submit Post-Processing and Forecasts
#######################################################################
cd $EXPDIR/post
>>>FORCAST<<</bin/cp gcm_post_full.j gcm_post.j
foreach collection ( $collections ) # Note: Change $collections to "ALL" to run Single Post Job
>>>FORCAST<<<if ($SUBSEASONAL == TRUE ) then
/bin/rm -f sedfile
cat > sedfile << EOF
s/@POST_O/gcm_post.${collection}.${edate}/g
s/@COLLECTION/$collection/g
EOF
>>>FORCAST<<<sed -f sedfile gcm_post.j > gcm_post.jtmp
>>>FORCAST<<<chmod 755 gcm_post.jtmp
>>>FORCAST<<</bin/rm -f gcm_post.jtmp
>>>FORCAST<<</bin/rm -f sedfile
>>>FORCAST<<<sleep 5
>>>FORCAST<<<else
>>>FORCAST<<<if ( ${capdateIC} == ${capdateCR} ) /bin/cp gcm_post_part.j gcm_post.j
>>>FORCAST<<</bin/rm -f sedfile
>>>FORCAST<<<cat > sedfile << EOF
>>>FORCAST<<<s/@POST_O/gcm_post.${edate}/g
>>>FORCAST<<<EOF
sed -f sedfile gcm_post.j > gcm_post.jtmp
chmod 755 gcm_post.jtmp
qsub gcm_post.jtmp
/bin/rm -f gcm_post.jtmp
/bin/rm -f sedfile
sleep 5
>>>FORCAST<<<endif
end
cd $SCRDIR
if( $FSEGMENT != 00000000 ) then
set REPLAY_BEG_DATE = `grep BEG_REPDATE: $HOMDIR/CAP.rc | cut -d':' -f2`
set REPLAY_END_DATE = `grep END_REPDATE: $HOMDIR/CAP.rc | cut -d':' -f2`
set nday = `echo $FSEGMENT | cut -c7-8`
@ dt = 10800 - 86400 * $nday
set date = `$GEOSBIN/tick $nymdc $nhmsc $dt`
set nymdz = $date[1]
set nhmsz = $date[2]
if( $nymdz >= ${REPLAY_BEG_DATE} & \
$nymdz <= ${REPLAY_END_DATE} ) then
$EXPDIR/forecasts/gcm_forecast.setup $nymdz $nymdz $FSEGMENT TRUE
endif
endif
#######################################################################
# Update Iteration Counter
#######################################################################
>>>FORCAST<<<set END_DATE = `grep END_DATE: $HOMDIR/CAP.rc | cut -d':' -f2`
set enddate = `echo $END_DATE | cut -c1-8`
set capdate = `cat cap_restart | cut -c1-8`
if ( $capdate < $enddate ) then
@ counter = $counter + 1
else
@ counter = ${NUM_SGMT} + 1
endif
end
#######################################################################
# Re-Submit Job
#######################################################################
foreach rst ( $rst_file_names )
/bin/rm -f $EXPDIR/$rst
end
/bin/rm -f $EXPDIR/cap_restart
foreach rst ( $rst_file_names )
/bin/cp $rst $EXPDIR/$rst &
end
wait
/bin/cp cap_restart $EXPDIR/cap_restart
@COUPLED /bin/cp -rf RESTART $EXPDIR
if ( $rc == 0 ) then
cd $HOMDIR
echo "DATES (current last): ${capdate} ${enddate}"
>>>FORCAST<<<if ( $SUBSEASONAL == TRUE ) then
>>>FORCAST<<< if ( $capdateIC < $capdate ) qsub $EXPDIR/archive/gcm_archive.j
>>>FORCAST<<<else
if ( $capdate < $enddate ) qsub $HOMDIR/gcm_run.j
>>>FORCAST<<<endif
endif