-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcm_forecast.tmpl
executable file
·844 lines (676 loc) · 31.2 KB
/
gcm_forecast.tmpl
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
#!/bin/csh -f
#######################################################################
# Batch Parameters for Run Job
#######################################################################
#@BATCH_TIME@RUN_FT
#@RUN_FP
#@BATCH_JOBNAME@RUN_FN_&DATE
#@RUN_Q
#@BATCH_GROUP
#@BATCH_OUTPUTNAMEFCSTOUT
#######################################################################
# System Settings
#######################################################################
umask 022
limit stacksize unlimited
#######################################################################
# Architecture Specific Environment Variables
#######################################################################
setenv ARCH `uname`
setenv SITE @SITE
setenv GEOSDIR @GEOSDIR
setenv GEOSBIN @GEOSBIN
setenv GEOSETC @GEOSETC
setenv GEOSUTIL @GEOSSRC
source $GEOSBIN/g5_modules
setenv @LD_LIBRARY_PATH_CMD ${LD_LIBRARY_PATH}:${GEOSDIR}/lib
if ( $?BASEDIR ) then
setenv @LD_LIBRARY_PATH_CMD ${@LD_LIBRARY_PATH_CMD}:${BASEDIR}/${ARCH}/lib
endif
setenv RUN_CMD "@RUN_CMD"
setenv GCMVER `cat $GEOSETC/.AGCM_VERSION`
echo VERSION: $GCMVER
#######################################################################
# Experiment Specific Environment Variables
#######################################################################
setenv EXPID @EXPID
setenv EXPDIR @EXPDIR
setenv HOMDIR @HOMDIR
#######################################################################
# Set Forecast Run Parameters
#######################################################################
set date = `echo &DATE 000000`
set NFMAX = &NFMAX
set FSEGMENT = &FSEGMENT
set FCST_TYPE = &FCST_TYPE
set FCST_LABL = &FCST_LABL
set FCST_ID = ${EXPID}_FCST
set CYCLED = &cycled
set STATS_ONLY = FALSE
#######################################################################
# Create Forecast Sub-Directory
#######################################################################
@ NFCST = 1
while( $NFCST <= $NFMAX )
set date0 = $date[1]
set time0 = $date[2]
set hour = `echo $time0 | cut -c1-2`
set fdate = ${date0}_${hour}z
setenv FCSTDIR $EXPDIR/forecasts/${FCST_LABL}_$fdate
setenv SCRDIR $FCSTDIR/scratch
if (! -e $SCRDIR ) mkdir -p $SCRDIR
cd $SCRDIR
/bin/rm -rf *
set date = `$GEOSUTIL/post/tick $date0 $time0 -10800`
set nymd0 = $date[1]
set nhms0 = $date[2]
set hour = `echo $nhms0 | cut -c1-2`
if( $STATS_ONLY != TRUE ) then
#######################################################################
# Set Experiment Run Parameters
#######################################################################
set NX = `grep '^\s*NX:' $HOMDIR/AGCM.rc | cut -d: -f2`
set NY = `grep '^\s*NY:' $HOMDIR/AGCM.rc | cut -d: -f2`
set AGCM_IM = `grep '^\s*AGCM_IM:' $HOMDIR/AGCM.rc | cut -d: -f2`
set AGCM_JM = `grep '^\s*AGCM_JM:' $HOMDIR/AGCM.rc | cut -d: -f2`
set AGCM_LM = `grep '^\s*AGCM_LM:' $HOMDIR/AGCM.rc | cut -d: -f2`
set OGCM_IM = `grep '^\s*OGCM\.IM_WORLD:' $HOMDIR/AGCM.rc | cut -d: -f2`
set OGCM_JM = `grep '^\s*OGCM\.JM_WORLD:' $HOMDIR/AGCM.rc | cut -d: -f2`
@COUPLED set OGCM_LM = `grep '^\s*OGCM\.LM:' $HOMDIR/AGCM.rc | cut -d: -f2`
@COUPLED set NX = `grep '^\s*OGCM\.NX:' $HOMDIR/AGCM.rc | cut -d: -f2`
@COUPLED set NY = `grep '^\s*OGCM\.NY:' $HOMDIR/AGCM.rc | cut -d: -f2`
# Calculate number of cores/nodes for IOSERVER
# --------------------------------------------
set USE_IOSERVER = @USE_IOSERVER
set NUM_OSERVER_NODES = `grep '^\s*IOSERVER_NODES:' $HOMDIR/AGCM.rc | cut -d: -f2`
set NUM_BACKEND_PES = `grep '^\s*NUM_BACKEND_PES:' $HOMDIR/AGCM.rc | cut -d: -f2`
# Check for Over-Specification of CPU Resources
# ---------------------------------------------
if ($?SLURM_NTASKS) then
set NCPUS = $SLURM_NTASKS
else if ($?PBS_NODEFILE) then
set NCPUS = `cat $PBS_NODEFILE | wc -l`
else
set NCPUS = NULL
endif
@ MODEL_NPES = $NX * $NY
set NCPUS_PER_NODE = @NCPUS_PER_NODE
set NUM_MODEL_NODES=`echo "scale=6;($MODEL_NPES / $NCPUS_PER_NODE)" | bc | awk 'function ceil(x, y){y=int(x); return(x>y?y+1:y)} {print ceil($1)}'`
if ( $NCPUS != NULL ) then
if ( $USE_IOSERVER == 1 ) then
@ TOTAL_NODES = $NUM_MODEL_NODES + $NUM_OSERVER_NODES
@ TOTAL_PES = $TOTAL_NODES * $NCPUS_PER_NODE
if( $TOTAL_PES > $NCPUS ) then
echo "CPU Resources are Over-Specified"
echo "--------------------------------"
echo "Allotted NCPUs: $NCPUS"
echo "Requested NCPUs: $TOTAL_PES"
echo ""
echo "Specified NX: $NX"
echo "Specified NY: $NY"
echo ""
echo "Specified model nodes: $NUM_MODEL_NODES"
echo "Specified oserver nodes: $NUM_OSERVER_NODES"
echo "Specified cores per node: $NCPUS_PER_NODE"
exit
endif
else
@ TOTAL_PES = $MODEL_NPES
if( $TOTAL_PES > $NCPUS ) then
echo "CPU Resources are Over-Specified"
echo "--------------------------------"
echo "Allotted NCPUs: $NCPUS"
echo "Requested NCPUs: $TOTAL_PES"
echo ""
echo "Specified NX: $NX"
echo "Specified NY: $NY"
echo ""
echo "Specified model nodes: $NUM_MODEL_NODES"
echo "Specified cores per node: $NCPUS_PER_NODE"
exit
endif
endif
else
# This is for the desktop path
@ TOTAL_PES = $MODEL_NPES
endif
#######################################################################
# Copy and Modify RC Files from Home Directory
#######################################################################
cp -f $EXPDIR/RC/* .
cp $EXPDIR/linkbcs .
cp -f $HOMDIR/*.rc .
cp -f $HOMDIR/*.nml .
cp -f $HOMDIR/*.yaml .
cp $GEOSBIN/bundleParser.py .
cat fvcore_layout.rc >> input.nml
echo $nymd0 $nhms0 > cap_restart
# Collapse whitespace like the strip utility
# --------------------------------------
cp AGCM.rc AGCM.rc.orig
awk '{$1=$1};1' < AGCM.rc.orig > AGCM.rc
# Turn Off Intermediate Restarts
# ------------------------------
sed -ir 's|^.*RECORD_FREQUENCY:|#&|g' AGCM.rc
sed -ir 's|^.*RECORD_REF_DATE:|#&|g' AGCM.rc
sed -ir 's|^.*RECORD_REF_TIME:|#&|g' AGCM.rc
sed -ir 's|^.*MKIAU_CHECKPOINT_FILE:|#&|g' AGCM.rc
sed -ir 's|^.*MKIAU_CHECKPOINT_TYPE:|#&|g' AGCM.rc
# Shut-Off REPLAY after 6-hours
# -----------------------------
set oldstring = `cat AGCM.rc | grep REPLAY_SHUTOFF: `
set newstring = "REPLAY_SHUTOFF: 21600"
/bin/mv -f AGCM.rc AGCM.tmp
if( $#oldstring == 0 ) then
cat AGCM.tmp > AGCM.rc
echo $newstring >> AGCM.rc
else
if( `echo $oldstring | wc -l` == 1 ) then
cat AGCM.tmp | sed -e "s?$oldstring?$newstring?g" > AGCM.rc
else
echo ERROR: Multiple occurrences of REPLAY_SHUTOFF:
foreach string ($oldstring)
echo $string
end
exit
endif
endif
#######################################################################
# Create Forecast History RC Files
#######################################################################
set HIST_IM = `expr $AGCM_IM \* 4`
set HIST_JM = `expr $AGCM_IM \* 2 + 1`
set FILE = HISTORY.rc
/bin/rm -f $FILE
cat << _EOF_ > $FILE
VERSION: 1
EXPID: ${EXPID}_FCST
EXPDSC: Forecasts_spawned_from_${EXPID}
COLLECTIONS: 'geosgcm_fcst'
::
'prog.eta'
GRID_LABELS: PC${HIST_IM}x${HIST_JM}-DC
::
PC${HIST_IM}x${HIST_JM}-DC.GRID_TYPE: LatLon
PC${HIST_IM}x${HIST_JM}-DC.IM_WORLD: ${HIST_IM}
PC${HIST_IM}x${HIST_JM}-DC.JM_WORLD: ${HIST_JM}
PC${HIST_IM}x${HIST_JM}-DC.POLE: PC
PC${HIST_IM}x${HIST_JM}-DC.DATELINE: DC
PC${HIST_IM}x${HIST_JM}-DC.LM: ${AGCM_LM}
geosgcm_fcst.template: '%y4%m2%d2_%h2%n2z.nc4' ,
geosgcm_fcst.archive: '%c/Y%y4' ,
geosgcm_fcst.format: 'CFIO' ,
geosgcm_fcst.deflate: 1 ,
geosgcm_fcst.grid_label: PC${HIST_IM}x${HIST_JM}-DC ,
geosgcm_fcst.regrid_method: 'BILINEAR' ,
geosgcm_fcst.frequency: 060000 ,
geosgcm_fcst.duration: 000000 ,
geosgcm_fcst.vscale: 100.0 ,
geosgcm_fcst.vunit: 'hPa' ,
geosgcm_fcst.vvars: 'log(PLE)' , 'DYN' ,
geosgcm_fcst.levels: 1000 975 950 925 900 850 800 750 700 600 500 400 300 250 200 150 100 70 50 30 10 7 5 3 1,
geosgcm_fcst.fields: 'PHIS' , 'AGCM' ,
'SLP' , 'DYN' ,
'U;V' , 'DYN' ,
'T' , 'DYN' ,
'PS' , 'DYN' ,
'ZLE' , 'DYN' , 'H' ,
'OMEGA' , 'DYN' ,
'Q' , 'MOIST' , 'QV' ,
'QITOT' , 'AGCM' , 'QI' ,
'QLTOT' , 'AGCM' , 'QL' ,
'RH2' , 'MOIST' , 'RH' ,
'O3' , 'CHEMISTRY' ,
::
prog.eta.template: '%y4%m2%d2_%h2%n2z.nc4' ,
prog.eta.archive: '%c/Y%y4' ,
prog.eta.format: 'CFIO' ,
prog.eta.deflate: 1 ,
prog.eta.grid_label: PC${HIST_IM}x${HIST_JM}-DC ,
prog.eta.regrid_method: 'BILINEAR' ,
prog.eta.mode: 'instantaneous' ,
prog.eta.frequency: 060000 ,
prog.eta.duration: 060000 ,
prog.eta.ref_time: 000000 ,
prog.eta.fields: 'PHIS' , 'AGCM' , 'phis' ,
'SGH' , 'AGCM' , 'hs_stdv' ,
'TS' , 'SURFACE' , 'ts' ,
'FRLAND' , 'SURFACE' , 'frland' ,
'FRLANDICE' , 'SURFACE' , 'frlandice' ,
'FRLAKE' , 'SURFACE' , 'frlake' ,
'FROCEAN' , 'SURFACE' , 'frocean' ,
'FRACI' , 'SURFACE' , 'frseaice' ,
'PS' , 'DYN' , 'ps' ,
'DELP' , 'DYN' , 'delp' ,
'U;V' , 'DYN' , 'u;v' ,
'TV' , 'DYN' , 'tv' ,
'Q' , 'MOIST' , 'sphu' ,
'O3PPMV' , 'CHEMISTRY' , 'ozone' ,
'QITOT' , 'AGCM' , 'qitot' ,
'QLTOT' , 'AGCM' , 'qltot' ,
'QRTOT' , 'MOIST' , 'qrtot' ,
'QSTOT' , 'MOIST' , 'qstot' ,
::
_EOF_
#######################################################################
# 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:
#######################################################################
# Link Boundary Datasets
#######################################################################
setenv BCSDIR @BCSDIR
@DATAOCEANsetenv SSTDIR @SSTDIR
setenv BCRSLV @ATMOStag_@OCEANtag
@MOM5setenv SSTDIR @COUPLEDIR/SST/MERRA2/${OGCM_IM}x${OGCM_JM}/v1
@MOM6setenv SSTDIR @COUPLEDIR/SST/MERRA2/${OGCM_IM}x${OGCM_JM}/v1
#this is hard-wired for NAS for now - should make it more general
@DATAOCEANsetenv BCTAG `basename $BCSDIR`
@COUPLEDsetenv BCTAG `basename @COUPLEDIR/@OCNMODEL/${OGCM_IM}x${OGCM_JM}`
setenv EMISSIONS @EMISSIONS
chmod +x linkbcs
@GCMRUN_CATCHCNset LSM_CHOICE = `grep LSM_CHOICE: AGCM.rc | cut -d':' -f2`
@GCMRUN_CATCHCNif ($LSM_CHOICE == 2) then
@GCMRUN_CATCHCN grep -v "'CNFROOTC'" HISTORY.rc > Hist_tmp.rc && mv Hist_tmp.rc HISTORY.rc
@GCMRUN_CATCHCNendif
#######################################################################
# Get Executable and RESTARTS
#######################################################################
echo "Copying $EXPDIR/GEOSgcm.x to $SCRDIR"
echo ""
/bin/cp $EXPDIR/GEOSgcm.x $SCRDIR/GEOSgcm.x
setenv GEOSEXE $SCRDIR/GEOSgcm.x
set rst_files = `grep "RESTART_FILE" AGCM.rc | grep -v VEGDYN | grep -v "#" | cut -d ":" -f1 | cut -d "_" -f1-2`
set rst_file_names = `grep "RESTART_FILE" AGCM.rc | grep -v VEGDYN | grep -v "#" | cut -d ":" -f2`
set chk_files = `grep "CHECKPOINT_FILE" AGCM.rc | grep -v "#" | cut -d ":" -f1 | cut -d "_" -f1-2`
set chk_file_names = `grep "CHECKPOINT_FILE" AGCM.rc | grep -v "#" | 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
# Set REPLAYed Analysis
# ---------------------
set ANA_EXPID = `grep '^\s*REPLAY_ANA_EXPID:' AGCM.rc | cut -d: -f2`
set ANA_LOCATION = `grep '^\s*REPLAY_ANA_LOCATION:' AGCM.rc | cut -d: -f2`
# Copy Restarts to Scratch Directory
# ----------------------------------
set year = `echo $nymd0 | cut -c1-4`
set month = `echo $nymd0 | cut -c5-6`
if( $CYCLED == .TRUE. ) then
/bin/ln -s $EXPDIR/restarts/*${nymd0}_${hour}*z.* .
$GEOSBIN/stripname ${EXPID}.
$GEOSBIN/stripname _checkpoint.${nymd0}_${hour}\* _rst # Format if written from RECORD_FREQUENCY
$GEOSBIN/stripname .e${nymd0}_${hour}\* # Format if decorated by gcm_run.j
else if( $FCST_TYPE == 'Exact' | $FCST_TYPE == 'Regular' ) then
/bin/ln -s ${ANA_LOCATION}/rs/Y$year/M$month/${ANA_EXPID}.rst.${nymd0}_${hour}z.tar .
tar xf ${ANA_EXPID}.rst.${nymd0}_${hour}z.tar
if( $FCST_TYPE == 'Exact' ) /bin/ln -s ${ANA_LOCATION}/rs/Y$year/M*/${ANA_EXPID}.agcm_import_rst.* .
$GEOSBIN/stripname ${ANA_EXPID}.
$GEOSBIN/stripname .${nymd0}_${hour}z.bin
$GEOSBIN/stripname .${nymd0}_${hour}z.nc4
# Note: If Radiation Schemes differ, Radiation Restarts may need to be bootstrapped
# ---------------------------------------------------------------------------------
# /bin/rm solar_internal_rst
# /bin/rm irrad_internal_rst
endif
# Get proper ridge scheme GWD internal restart
# --------------------------------------------
/bin/rm gwd_internal_rst
/bin/cp @GWDRSDIR/gwd_internal_c${AGCM_IM} gwd_internal_rst
# Re-Create Proper CAP.rc
# -----------------------
cp CAP.rc CAP.rc.orig
awk '{$1=$1};1' < CAP.rc.orig > CAP.rc
# Re-Create Proper CAP.rc
# -----------------------
set oldstring = `grep JOB_SGMT: CAP.rc`
set newstring = "JOB_SGMT: $FSEGMENT 030000"
/bin/mv CAP.rc CAP.tmp
cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc
set USE_SHMEM = `grep '^\s*USE_SHMEM:' CAP.rc | cut -d':' -f2`
# Set Time Variables for Current_(c), Ending_(e), and Segment_(s) dates
# ---------------------------------------------------------------------
set nymdc = `awk '{print $1}' cap_restart`
set nhmsc = `awk '{print $2}' cap_restart`
set nymde = `grep '^\s*END_DATE:' CAP.rc | cut -d: -f2 | awk '{print $1}'`
set nhmse = `grep '^\s*END_DATE:' CAP.rc | cut -d: -f2 | awk '{print $2}'`
set nymds = `grep '^\s*JOB_SGMT:' CAP.rc | cut -d: -f2 | awk '{print $1}'`
set nhmss = `grep '^\s*JOB_SGMT:' CAP.rc | cut -d: -f2 | awk '{print $2}'`
# 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`
# Which ExtData are we using
set EXTDATA2G_TRUE = `grep -i '^\s*USE_EXTDATA2G:\s*\.TRUE\.' CAP.rc | wc -l`
# Select proper AMIP GOCART Emission RC Files
# -------------------------------------------
if( ${EMISSIONS} == AMIP_EMISSIONS) then
if( $EXTDATA2G_TRUE == 0 ) then
set AMIP_Transition_Date = 20000301
# Before 2000-03-01, we need to use AMIP.20C which has different
# emissions (HFED instead of QFED) valid before 2000-03-01. Note
# that if you make a change to anything in $EXPDIR/RC/AMIP or
# $EXPDIR/RC/AMIP.20C, you might need to make a change in the other
# directory to be consistent. Some files in AMIP.20C are symlinks to
# that in AMIP but others are not.
if( $nymdc < ${AMIP_Transition_Date} ) then
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP.20C
if( $nymdf > ${AMIP_Transition_Date} ) then
set nymdf = ${AMIP_Transition_Date}
set oldstring = `grep '^\s*END_DATE:' CAP.rc`
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 AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif
else
set AMIP_EMISSIONS_DIRECTORY = $EXPDIR/RC/AMIP
endif
if( $AGCM_LM == 72 ) then
cp ${AMIP_EMISSIONS_DIRECTORY}/*.rc .
cp ${AMIP_EMISSIONS_DIRECTORY}/*.yaml .
else
set files = `/bin/ls -1 ${AMIP_EMISSIONS_DIRECTORY}/*.rc ${AMIP_EMISSIONS_DIRECTORY}/*.yaml`
foreach file ($files)
/bin/rm -f `basename $file`
/bin/rm -f dummy
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( $AGCM_LM != 72 ) then
set files = `/bin/ls *.yaml`
foreach file ($files)
cp $file dummy
cat dummy | sed -e "s|/L72/|/L${AGCM_LM}/|g" | sed -e "s|z72|z${AGCM_LM}|g" > $file
end
endif
# Rename big ExtData files that are not needed
# --------------------------------------------
set SC_TRUE = `grep -i '^\s*ENABLE_STRATCHEM:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $SC_TRUE == 0 && -e StratChem_ExtData.rc ) /bin/mv StratChem_ExtData.rc StratChem_ExtData.rc.NOT_USED
set GMI_TRUE = `grep -i '^\s*ENABLE_GMICHEM:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $GMI_TRUE == 0 && -e GMI_ExtData.rc ) /bin/mv GMI_ExtData.rc GMI_ExtData.rc.NOT_USED
set GCC_TRUE = `grep -i '^\s*ENABLE_GEOSCHEM:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $GCC_TRUE == 0 && -e GEOSCHEMchem_ExtData.rc ) /bin/mv GEOSCHEMchem_ExtData.rc GEOSCHEMchem_ExtData.rc.NOT_USED
set CARMA_TRUE = `grep -i '^\s*ENABLE_CARMA:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $CARMA_TRUE == 0 && -e CARMAchem_GridComp_ExtData.rc ) /bin/mv CARMAchem_GridComp_ExtData.rc CARMAchem_GridComp_ExtData.rc.NOT_USED
set DNA_TRUE = `grep -i '^\s*ENABLE_DNA:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $DNA_TRUE == 0 && -e DNA_ExtData.rc ) /bin/mv DNA_ExtData.rc DNA_ExtData.rc.NOT_USED
set ACHEM_TRUE = `grep -i '^\s*ENABLE_ACHEM:\s*\.TRUE\.' GEOS_ChemGridComp.rc | wc -l`
if ( $ACHEM_TRUE == 0 && -e GEOSachem_ExtData.rc ) /bin/mv GEOSachem_ExtData.rc GEOSachem_ExtData.rc.NOT_USED
@MP_TURN_OFF_WSUB_EXTDATA# 1MOM and GFDL microphysics do not use WSUB_CLIM
@MP_TURN_OFF_WSUB_EXTDATA# -------------------------------------------------
if ($EXTDATA2G_TRUE == 0 ) then
@MP_TURN_OFF_WSUB_EXTDATA/bin/mv WSUB_ExtData.rc WSUB_ExtData.tmp
@MP_TURN_OFF_WSUB_EXTDATAcat WSUB_ExtData.tmp | sed -e '/^WSUB_CLIM/ s#ExtData.*#/dev/null#' > WSUB_ExtData.rc
else
@MP_TURN_OFF_WSUB_EXTDATA/bin/mv WSUB_ExtData.yaml WSUB_ExtData.tmp
@MP_TURN_OFF_WSUB_EXTDATAcat WSUB_ExtData.tmp | sed -e '/collection:/ s#WSUB_SWclim.*#/dev/null#' > WSUB_ExtData.yaml
endif
@MP_TURN_OFF_WSUB_EXTDATA/bin/rm WSUB_ExtData.tmp
# Generate the complete ExtData.rc
# --------------------------------
if(-e ExtData.rc ) /bin/rm -f ExtData.rc
set extdata_files = `/bin/ls -1 *_ExtData.rc`
# Switch to MODIS v6.1 data after Nov 2021
if( $EXTDATA2G_TRUE == 0 ) then
set MODIS_Transition_Date = 20211101
if ( ${EMISSIONS} == OPS_EMISSIONS && ${MODIS_Transition_Date} <= $nymdc ) then
cat $extdata_files | sed 's|\(qfed2.emis_.*\).006.|\1.061.|g' > ExtData.rc
else
cat $extdata_files > ExtData.rc
endif
endif
if( $EXTDATA2G_TRUE == 1 ) then
$GEOSBIN/construct_extdata_yaml_list.py GEOS_ChemGridComp.rc
touch ExtData.rc
endif
# Move GOCART to use RRTMGP Bands
# -------------------------------
# UNCOMMENT THE LINES BELOW IF RUNNING RRTMGP
#
#set instance_files = `/bin/ls -1 *_instance*.rc`
#foreach instance ($instance_files)
# /bin/mv $instance $instance.tmp
# cat $instance.tmp | sed -e '/RRTMG/ s#RRTMG#RRTMGP#' > $instance
# /bin/rm $instance.tmp
#end
# Link Boundary Conditions for Appropriate Date
# ---------------------------------------------
setenv YEAR $yearc
./linkbcs
if (! -e tile.bin) then
$GEOSBIN/binarytile.x tile.data tile.bin
@MOM5 $GEOSBIN/binarytile.x tile_hist.data tile_hist.bin
endif
# If running in dual ocean mode, link sst and fraci data here
#set yy = `cat cap_restart | cut -c1-4`
#echo $yy
#ln -sf $SSTDIR/dataoceanfile_MERRA2_SST.${OGCM_IM}x${OGCM_JM}.${yy}.data sst.data
#ln -sf $SSTDIR/dataoceanfile_MERRA2_ICE.${OGCM_IM}x${OGCM_JM}.${yy}.data fraci.data
#######################################################################
# Split Saltwater Restart if detected
#######################################################################
if ( (-e $SCRDIR/openwater_internal_rst) && (-e $SCRDIR/seaicethermo_internal_rst)) then
echo "Saltwater internal state is already split, good to go!"
else
if ( ( -e $SCRDIR/saltwater_internal_rst ) || ( -e $EXPDIR/saltwater_internal_rst) ) then
echo "Found Saltwater internal state. Splitting..."
# If saltwater_internal_rst is in EXPDIR move to SCRDIR
# -----------------------------------------------------
if ( -e $EXPDIR/saltwater_internal_rst ) /bin/mv $EXPDIR/saltwater_internal_rst $SCRDIR
# The splitter script requires an OutData directory
# -------------------------------------------------
if (! -d OutData ) mkdir -p OutData
# Run the script
# --------------
@SINGULARITY_BUILD $RUN_CMD 1 $SINGULARITY_RUN $GEOSBIN/SaltIntSplitter tile.data $SCRDIR/saltwater_internal_rst
@NATIVE_BUILD $RUN_CMD 1 $GEOSBIN/SaltIntSplitter tile.data $SCRDIR/saltwater_internal_rst
# Move restarts
# -------------
/bin/mv OutData/openwater_internal_rst OutData/seaicethermo_internal_rst .
# Remove OutData
# --------------
/bin/rmdir OutData
# Make decorated copies for restarts tarball
# ------------------------------------------
cp openwater_internal_rst $EXPID.openwater_internal_rst.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}
cp seaicethermo_internal_rst $EXPID.seaicethermo_internal_rst.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}
# Inject decorated copies into restarts tarball
# ---------------------------------------------
tar rf $EXPDIR/restarts/restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}
# Remove the decorated restarts
# -----------------------------
/bin/rm $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}
# Remove the saltwater internal restart
# -------------------------------------
/bin/rm $SCRDIR/saltwater_internal_rst
else
echo "Neither saltwater_internal_rst, nor openwater_internal_rst and seaicethermo_internal_rst were found. Abort!"
exit 6
endif
endif
# Test Openwater Restart for Number of tiles correctness
# ------------------------------------------------------
if ( -x $GEOSBIN/rs_numtiles.x ) then
set N_OPENW_TILES_EXPECTED = `grep '^\s*0' tile.data | wc -l`
@SINGULARITY_BUILD set N_OPENW_TILES_FOUND = `$RUN_CMD 1 $SINGULARITY_RUN $GEOSBIN/rs_numtiles.x openwater_internal_rst | grep Total | awk '{print $NF}'`
@NATIVE_BUILD set N_OPENW_TILES_FOUND = `$RUN_CMD 1 $GEOSBIN/rs_numtiles.x openwater_internal_rst | grep Total | awk '{print $NF}'`
if ( $N_OPENW_TILES_EXPECTED != $N_OPENW_TILES_FOUND ) then
echo "Error! Found $N_OPENW_TILES_FOUND tiles in openwater. Expect to find $N_OPENW_TILES_EXPECTED tiles."
echo "Your restarts are probably for a different ocean."
exit 7
endif
endif
# Check for MERRA2OX Consistency
# ------------------------------
# The MERRA2OX pchem file is only valid until 201706, so this is a first
# attempt at a check to make sure you aren't using it and are past the date
# Check for MERRA2OX by looking at AGCM.rc
set PCHEM_CLIM_YEARS = `awk '/pchem_clim_years/ {print $2}' AGCM.rc`
# If it is 39, we are using MERRA2OX
if ( $PCHEM_CLIM_YEARS == 39 ) then
# Grab the date from cap_restart
set YEARMON = `cat cap_restart | cut -c1-6`
# Set a magic date
set MERRA2OX_END_DATE = "201706"
# String comparison seems to work here...
if ( $YEARMON > $MERRA2OX_END_DATE ) then
echo "You seem to be using MERRA2OX pchem species file, but your simulation date [${YEARMON}] is after 201706. This file is only valid until this time."
exit 2
endif
endif
##################################################################
######
###### Perform Forecast
######
##################################################################
# Environment variables for MPI, etc
# ----------------------------------
@SETENVS
@MPT_SHEPHERD
# Run bundleParser.py
#---------------------
python bundleParser.py
# If REPLAY, link necessary forcing files
# ---------------------------------------
set REPLAY_MODE = `grep '^\s*REPLAY_MODE:' AGCM.rc | cut -d: -f2`
if( $REPLAY_MODE == 'Exact' | $REPLAY_MODE == 'Regular' ) then
set ANA_EXPID = `grep '^\s*REPLAY_ANA_EXPID:' AGCM.rc | cut -d: -f2`
set ANA_LOCATION = `grep '^\s*REPLAY_ANA_LOCATION:' AGCM.rc | cut -d: -f2`
set REPLAY_FILE = `grep '^\s*REPLAY_FILE:' AGCM.rc | cut -d: -f2`
set REPLAY_FILE09 = `grep '^\s*REPLAY_FILE09:' AGCM.rc | cut -d: -f2`
set REPLAY_FILE_TYPE = `echo $REPLAY_FILE | cut -d"/" -f1 | grep -v %`
set REPLAY_FILE09_TYPE = `echo $REPLAY_FILE09 | cut -d"/" -f1 | grep -v %`
# Disable GAAS and Link REPLAY files
# ---------------------------------------------
/bin/mv -f GEOS_ChemGridComp.rc GEOS_ChemGridComp.rc.tmp
cat GEOS_ChemGridComp.rc.tmp | sed "s?ENABLE_GAAS:.*?ENABLE_GAAS: .FALSE.?g" > GEOS_ChemGridComp.rc
/bin/ln -sf ${ANA_LOCATION}/${REPLAY_FILE_TYPE} .
/bin/ln -sf ${ANA_LOCATION}/${REPLAY_FILE09_TYPE} .
endif
# Establish safe default number of OpenMP threads
# -----------------------------------------------
setenv OMP_NUM_THREADS 1
# Run GEOSgcm.x
# -------------
if( $USE_SHMEM == 1 ) $GEOSBIN/RmShmKeys_sshmpi.csh >& /dev/null
if( $USE_IOSERVER == 1 ) then
set IOSERVER_OPTIONS = "--npes_model $MODEL_NPES --nodes_output_server $NUM_OSERVER_NODES"
set IOSERVER_EXTRA = "--oserver_type multigroup --npes_backend_pernode $NUM_BACKEND_PES"
else
set IOSERVER_OPTIONS = ""
set IOSERVER_EXTRA = ""
endif
@SINGULARITY_BUILD @OCEAN_PRELOAD $RUN_CMD $TOTAL_PES $SINGULARITY_RUN $GEOSEXE $IOSERVER_OPTIONS $IOSERVER_EXTRA --logging_config 'logging.yaml'
@NATIVE_BUILD @OCEAN_PRELOAD $RUN_CMD $TOTAL_PES $GEOSEXE $IOSERVER_OPTIONS $IOSERVER_EXTRA --logging_config 'logging.yaml'
if( $USE_SHMEM == 1 ) $GEOSBIN/RmShmKeys_sshmpi.csh >& /dev/null
if( -e EGRESS ) then
set rc = 0
else
set rc = -1
endif
echo GEOSgcm Run Status: $rc
#######################################################################
# Move HISTORY Files to Holding Directory
#######################################################################
foreach collection ( $collections )
/bin/mv `/bin/ls -1 *.${collection}.*` $FCSTDIR
end
#######################################################################
# Create STATS
#######################################################################
endif # End STATS_ONLY Test
set nymd = $date0
set yyyymm = `echo $nymd | cut -b1-6`
@ TMPVAL = &FLOOP - 1
set FDAYS = `printf "%02d" $TMPVAL`
set statsdir = $EXPDIR/forecasts/${FCST_LABL}.stats.$yyyymm.f${FDAYS}day
mkdir -p $statsdir
cd $statsdir
set year0 = `echo $nymd | cut -b1-4`
set month0 = `echo $nymd | cut -b5-6`
set fcst_files = `/bin/ls -1 $FCSTDIR/${FCST_ID}.geosgcm_fcst*nc4`
set ana_files = ''
@ n = 1
while ($n <= &FLOOP)
set year = `echo $nymd | cut -b1-4`
set month = `echo $nymd | cut -b5-6`
# G5REPLAY Verification
# ---------------------
if( $CYCLED == .TRUE. ) then
set next = `/bin/ls -1 $EXPDIR/holding/geosgcm_prog/${year}*/$EXPID.geosgcm_prog.${nymd}*nc4`
else
set next = `/bin/ls -1 ${ANA_LOCATION}/asm/Y$year/M$month/${ANA_EXPID}.inst3_3d_asm_Np.${nymd}*nc4`
endif
set ana_files = `echo ${ana_files} $next`
set date = `$GEOSUTIL/post/tick $nymd 0 86400`
set nymd = $date[1]
@ n = $n + 1
end
$RUN_CMD 1 $GEOSUTIL/bin/stats.x -fcst $fcst_files \
-ana $ana_files \
-cli $SHARE/gmao_ops/verification/stats/MERRA-2.inst3_3d_asm_Np.198501_201412.clim_00z.576x361.data.nc4 \
$SHARE/gmao_ops/verification/stats/MERRA-2.inst3_3d_asm_Np.198501_201412.clim_06z.576x361.data.nc4 \
$SHARE/gmao_ops/verification/stats/MERRA-2.inst3_3d_asm_Np.198501_201412.clim_12z.576x361.data.nc4 \
$SHARE/gmao_ops/verification/stats/MERRA-2.inst3_3d_asm_Np.198501_201412.clim_18z.576x361.data.nc4 \
-tag $EXPID -nfreq 060000 -rc $GEOSUTIL/post/stats.rc -fhour &FHRS
#######################################################################
# Update Forecast Counter
#######################################################################
#/bin/rm -r $SCRDIR
@ NFCST = $NFCST + 1
set date = `$GEOSUTIL/post/tick $date0 $time0 86400`
end