-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_cable-pop.act9test.sh
1931 lines (1842 loc) · 78.1 KB
/
run_cable-pop.act9test.sh
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
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Explor / Pearcey / Aurora
# https://slurm.schedmd.com/sbatch.html
#SBATCH --ignore-pbs
# Name - 8 letters and digits
#SBATCH --job-name=bios9
#SBATCH --output=%x-%j.out
#SBATCH --error=%x-%j.out
# -N nodes / -n tasks (mpiexec, srun, ...)
# -c cpus_per_task (OpenMP, make -j, ...)
#SBATCH --nodes=1
#SBATCH --ntasks=4
#SBATCH --ntasks-per-node=4
# Check memory on *nix with /usr/bin/time -v ./prog
# time (day-hh:mm:ss) / memory (optional, units K,M,G,T)
#SBATCH --time=01:00:00
#SBATCH --mem=4G
#SBATCH --mail-type=FAIL,STAGE_OUT,TIME_LIMIT,INVALID_DEPEND,END
# section cuntz@explor
#SBATCH --account=oqx29
# Explor partitions (sinfo):
# https://explor.univ-lorraine.fr/new_queue/
# debug, std, gpu
#SBATCH --partition=std
# old hf partitions are cne[01-16]
# #SBATCH --constraint=HF
#SBATCH --exclude=cnf[01-08],cnh[01-02],cni[01-24],cnj[01-64],cnk[01-08]
#SBATCH [email protected]
# # section nieradzik@aurora
# #SBATCH --qos=test -t 15:00
# #SBATCH [email protected]
# Gadi
# https://opus.nci.org.au/display/Help/How+to+submit+a+job
#PBS -N mc_01
#PBS -P x45
# express / normal / copyq (2x24, cascadelake)
#PBS -q normal
# Typical for global or Aust continent at 0.25, 192 GB memory and 48 cpus,
# maybe 12 hours walltime
# Typical for small runs, fewer cpus than pixels
#PBS -l walltime=02:00:00
#PBS -l mem=48GB
#PBS -l ncpus=4
# #PBS -l jobfs=1GB
#PBS -l storage=gdata/x45
#PBS -l software=netCDF:MPI:Intel:GNU
#PBS -r y
#PBS -l wd
#PBS -j oe
#PBS -S /bin/bash
#PBS -M [email protected]
#PBS -m ae
# cuntz@explor, cuntz@mc16, cuntz@mcinra, moc801@gadi cuntz@gadi
# kna016@pearcey knauer@pearcey, jk8585@gadi knauer@gadi
# bri220@pearcey, pcb599@gadi briggs@gadi
# yc3714@gadi villalobos@gadi
# nieradzik@aurora
# inh599@gadi harman@gadi
system=inh599@gadi
# MPI run or single processor run
# nproc should fit with job tasks
dompi=1 # 0: normal run: ./cable
# 1: MPI run: mpiexec -n ${nproc} ./cable_mpi
nproc=4 # Number of cores for MPI runs
# must be same as above: SBATCH -n nproc or PBS -l ncpus=nproc
# --------------------------------------------------------------------
#
# Full Cable run with biomass spinup, POP, land-use change, etc.
#
# This script uses CRU-JRA forcing.
#
# Global meteo and land-use change data can be used with a mask giving land points.
# In step 0, the land mask can be extracted for a single point, an area
# or a number of random points can be chosen.
# Alternatively, single site met, LUH2, forcing and mask can be extracted from the global data sets.
#
# The run sequence is as follows:
# 1. Create a climate restart file using Cable's default vegetation distribution.
# 2. First phase of spinup with static land use, fixed atmospheric CO2 and
# N deposition from 1700, and 30 years of repeated meteorology.
# Zero initial biomass stocks, POP and climate.
# 3. Bring biomass stocks into equilibrium, restricting labile P and mineral N pools.
# Repeat a and b several times.
# a) Start from restart files.
# b) Use dump files for the biophysics. Quasi-equilibrium of soil and litter pools
# using an analytic steady-state solution.
# 4. Same as 3 but without any restriction on labile P and mineral N pools.
# Repeat a and b several times.
# 5. Second phase of spinup with dynamic land use, atmospheric CO2 and N deposition.
# a) Dynamic land use from 1580 to 1699, using still fixed atmospheric CO2 and
# N deposition from 1700, and 30 years of repeated meteorology.
# b) Run from 1700 to 1899 with dynmic land use, varying atmospheric CO2 and N deposition,
# but still with 30 years of repeated meteorology.
# 6. Final historical run, everything dynamic from 1900 to 2017.
# 7. Future run, everything dynamic (not all met types).
#
# Written, Matthias Cuntz, Aug 2019, following the run scripts and namelists provided by Vanessa Haverd
# Modified, Jurgen Knauer, 2020 - gm_explicit, coordination, acclimation
# - bios, plume, future runs
# Matthias Cuntz, Mar 2021 - functions into run_cable-pop_lib.sh
#
# --------------------------------------------------------------------
#ASKJK - changes in comparison to gm_acclim_coord
# 1. Removed switch Test_parallel=1 -> used [[ dompi -eq 1 ]]
# 2. ScriptsPath="${workpath}/scripts"
# but
# namelistpath="$(dirname ${workpath})/namelists"
# with
# workpath="/home/599/jk8585/CABLE_run/gm_acclim_coord/global_runs"
# cablehome="/home/599/jk8585/CABLE_code"
# -> changed to similar of ScriptsPath="$(dirname ${workpath})/scripts"
# 3. Need plume.nml, bios.nml, gm_LUT_*.nc
# 4. output%grid = "mask" (in gm_acclim_coord) or "land" (default before) [PB:Always has to be "mask"]
# 5. What should be for Run in bios.nml after 1. Climate restart?
# 6. Why is YearEnd different for plume (1849) compared to cru (1699) in 5a. First dynamic land use?
# 7. Do we need chunking in 5a, 5b, 6, and 7? [PB: unnecessary at this point, but possibly for 0.05degs]
# 8. Do we need cropping output to latlon region at the end: is this not in step 0 with ${doextractsite} -eq 1? [PB: Not needed for # BIOS
#
#ASKJK - changes in comparison to gm_acclim_coord
# --------------------------------------------------------------------
# Sequence switches
#
imeteo=0 # 0: Use global meteo, land use and mask
# 1: Use local mask, but global meteo and land use (doextractsite=1)
# 2: Use local meteo, land use and mask (doextractsite=2)
# Step 0
purge_restart=0 # 1/0: Do/Do not delete all restart files (completely new run, e.g. if settings changed)
doextractsite=0 # 0: Do not extract local meteo, land use nor mask
# 1: Do extract only mask at specific site/region (imeteo=1)
# 2: Do extract meteo, land use and mask at specific site/region (imeteo=2)
# Does not work with randompoints /= 0 but with latlon
experiment=acttestmpinewmet
randompoints=0 # <0: use -1*randompoints from file ${LandMaskFilePath}/${experiment}_points.csv if existing
# 0: use latlon
# >0: generate and use randompoints random grid points from GlobalLandMaskFile
# lat,lon or latmin,latmax,lonmin,lonmax # must have . in numbers otherwise indexes taken
latlon=42.536875,-72.172602
# latlon=-34.5,-33.5,149.5,156.5
# latlon=42.5,43.5,109.5,110.5
# latlon=-44.0,-10.0,110.0,155.0 # Australia
# Step 1
doclimate=1 # 1/0: Do/Do not create climate restart file
# Step 2
dofromzero=1 # 1/0: Do/Do not first spinup phase from zero biomass stocks
# Step 3
doequi1=0 # 1/0: Do/Do not bring biomass stocks into quasi-equilibrium with restricted P and N pools
nequi1=0 # number of times to repeat steps in doequi1
# Step 4
doequi2=0 # 1/0: Do/Do not bring biomass stocks into quasi-equilibrium with unrestricted P and N pools
nequi2=4 # number of times to repeat steps in doequi2
# Step 5a
doiniluc=0 # 1/0: Do/Do not spinup with dynamic land use (5a)
# Step 5b
doinidyn=0 # 1/0: Do/Do not full dynamic spinup from 1700 to 1899 (5b)
# Step 6
dofinal=0 # 1/0: Do/Do not final run from 1900 to 2017
# Step 7
dofuture=0 # 1/0: Do/Do not future runs (plume only)
# --------------------------------------------------------------------
# Other switches
#
# MetType
mettype='bios' # 'cru', 'plume', 'bios'
degrees=0.25 # bios only: resolution of met and LUC (0.05 or 0.25)
metmodel='hadgem2' # 'hadgem2', 'ipsl' (only used if mettype='plume')
RCP='hist' # 'hist', '2.6', '4.5', '6.0', '8.5' (no future runs if RCP='hist')
# Cable
explicit_gm=0 # 1/0: explicit (finite) or implicit mesophyll conductance
use_LUTgm=1 # 1/0: Do/Do not use lookup table for parameter conversion accounting for gm (only used if explicit_gm=1)
Rubisco_params="Bernacchi_2002" # "Bernacchi_2002" or "Walker_2013"
coordinate_photosyn=1 # 1/0: Do/Do not coordinate photosynthesis
coord=F # T/F: version of photosyn. optimisation (optimised(F) or forced (T))
acclimate_photosyn=1 # 1/0: Do/Do not acclimate photosynthesis
call_pop=1 # 1/0: Do/Do not use POP population dynamics model, coupled to CASA
doc13o2=0 # 1/0: Do/Do not calculate 13C
c13o2_simple_disc=0 # 1/0: simple or full 13C leaf discrimination
# --------------------------------------------------------------------
# Setup
#
set -e
trap cleanup 1 2 3 6
pid=$$
isdir="${PWD}"
prog=$0
pprog=$(basename ${prog})
pdir=$(dirname ${prog})
tmp=${TMPDIR:-"/tmp"}
system=$(echo ${system} | tr A-Z a-z)
sys=${system#*@}
user=${system%@*}
#
# Special things on specific computer system such as loading modules
#
export mpiexecdir=
if [[ "${sys}" == "explor" ]] ; then
# prog is slurm_script
pdir=${isdir}
# # INTELMPI - load mpi module first, otherwise intel module will not prepend LD_LIBRARY_PATH
# module load intelmpi/2018.5.274
# module load intel/2018.5
# unset I_MPI_PMI_LIBRARY
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/local/lib:${HOME}/local/netcdf-fortran-4.4.4-ifort2018.0/lib
# export mpiexecdir=/soft/env/soft/all/intel/2018.3/compilers_and_libraries_2018.5.274/linux/mpi/intel64/bin
# INTEL / OpenMPI - load mpi module first, otherwise intel module will not pre-pend LD_LIBRARY_PATH
module load openmpi/3.0.0/intel18
module load intel/2018.5
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/oqx29/shared/local.save/lib:/home/oqx29/shared/local.save/netcdf-fortran-4.4.4-ifort2018.0/lib
export mpiexecdir=/opt/soft/hf/openmpi-3.0.0-intel18/bin
# # GNU / OpenMPI
# module load gcc/6.3.0
# module load openmpi/3.0.1/gcc/6.3.0
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/local/lib:${HOME}/local/netcdf-fortran-4.4.4-gfortran63/lib
# export mpiexecdir=/opt/soft/hf/openmpi/3.0.1/gcc/6.3.0/bin
if [[ ${doextractsite} -ge 1 ]] ; then module load python/intel/2019/3 ; fi
elif [[ "${sys}" == "mc16" ]] ; then
# export mpiexecdir=/usr/local/openmpi-4.1.1-gfortran/bin
export mpiexecdir=/usr/local/openmpi-4.1.1-ifort/bin
elif [[ "${sys}" == "mcinra" ]] ; then
export mpiexecdir=/usr/local/openmpi-3.1.4-gfortran/bin
# export mpiexecdir=/usr/local/openmpi-3.1.5-ifort/bin
elif [[ "${sys}" == "pearcey" ]] ; then
# prog is slurm_script
pdir=${isdir}
module del intel-cc intel-fc
module add intel-cc/16.0.1.150 intel-fc/16.0.1.150
module unload intel-mpi/5.0.1.035
module add netcdf/4.3.3.1 openmpi/1.8.8
elif [[ "${sys}" == "gadi" ]] ; then
pdir=${isdir}
. /etc/bashrc
module purge
# module load intel-compiler/2019.5.281
# module load intel-mpi/2019.5.281
# module load netcdf/4.6.3
# module load intel-compiler/2021.5.0
# module load intel-mpi/2021.5.1
# module load netcdf/4.8.0
# # module load hdf5/1.10.5
module load intel-compiler-llvm/2023.0.0
module load intel-mpi/2021.8.0
module load netcdf/4.9.2
if [[ ${doextractsite} -ge 1 ]] ; then
module load python3/3.7.4
export PYTHONPATH=${PYTHONPATH}:/g/data/x45/python/lib/python3.7/site-packages
fi
if [[ ${randompoints} -eq 0 ]] ; then module load nco/4.9.2 ; fi # needed for cropping outputs
export mpiexecdir=/apps/intel-mpi/2019.5.281/intel64/bin
elif [[ "${sys}" == "aurora" ]] ; then
pdir=${isdir}
module purge
module load intel/2020a
module load netCDF-Fortran/4.5.2
if [[ ${doextractsite} -ge 1 ]] ; then
module load GCCcore/10.3.0 Python/3.9.5
export PYTHONPATH=${PYTHONPATH} #CLN not copied!#:/g/data/x45/python/lib/python3.7/site-packages
echo 'Extraction not possible at the moment. Set Py-Path!'
exit -666
fi
export mpiexecdir=""
fi
if [[ ! -z ${mpiexecdir} ]] ; then export mpiexecdir="${mpiexecdir}/" ; fi
#
# Directories of things
#
# Naming of experiments for gm_acclim_coord experiments of Jurgen
if [[ ("${system}" == "jk8585@gadi") || ("${system}" == "knauer@gadi") ]] ; then
experiment=test_${mettype}
if [[ "${mettype}" == "plume" ]] ; then
# (TEST_)(exp|imp)_(no)coord(T|F)(_PSacclim)_(B2002|W2013)
if [[ ${explicit_gm} -eq 1 ]] ; then
if [[ ${coordinate_photosyn} -eq 1 ]] ; then
if [[ ${acclimate_photosyn} -eq 1 ]] ; then
experiment=exp_coord${coord}_PSacclim
else
experiment=exp_coord${coord}
fi
else
if [[ ${acclimate_photosyn} -eq 1 ]] ; then
experiment=exp_nocoord_PSacclim
else
experiment=exp_nocoord
fi
fi
else
if [[ ${coordinate_photosyn} -eq 1 ]] ; then
if [[ ${acclimate_photosyn} -eq 1 ]] ; then
experiment=imp_coord${coord}_PSacclim
else
experiment=imp_coord${coord}
fi
else
if [[ ${acclimate_photosyn} -eq 1 ]] ; then
experiment=imp_nocoord_PSacclim
else
experiment=imp_nocoord
fi
fi
fi
if [[ "${Rubisco_params}" == "Bernacchi_2002" ]] ; then
experiment=${experiment}_B2002
elif [[ "${Rubisco_params}" == "Walker_2013" ]] ; then
experiment=${experiment}_W2013
else
echo "unknown option for 'Rubisco_params', exiting..."
exit 1
fi
if [[ ${dompi} -ne 0 ]] ; then
experiment=TEST_${experiment}
fi
fi
fi
#
# Relative directories must be relative to the directory of this script,
# not relative to the directory from which this script is launched (if different)
# nor relative to the run path.
#
if [[ "${system}" == "cuntz@explor" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
cablebase="/home/oqx29/zzy20/prog/cable"
sitepath="${cablebase}/runs/bios9/${experiment}"
cablehome="${cablebase}/branches/NESP2pt9_BLAZE"
cabledata="/home/oqx29/shared/cable"
metdata="/home/oqx29/shared/met_forcing"
workpath=${cablehome}
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="${cabledata}/CABLE-AUX"
# BLAZE directory
BlazeDataPath="${cabledata}/Data_BLAZE"
# Global MET, MASK, LUH
if [[ "${mettype}" == "cru" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global MET
# GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
GlobalLandMaskFile="${cabledata}/ipbes/masks/glob_ipsl_1x1.nc"
# GlobalMetPath="${cabledata}/CRUJRA2022/daily_1deg"
GlobalMetPath="${metdata}/CRUJRA2022/daily_1deg"
# Global LUC
GlobalTransitionFilePath="${cabledata}/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${mettype}" == "plume" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global MET
# GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalLandMaskFile="${cabledata}/ipbes/masks/gridinfo_CSIRO_1x1.nc"
GlobalMetPath="${cabledata}/ipbes/${metmodel}/1deg"
# only in plume.nml
CO2Path="${cabledata}/ipbes/co2"
NdepPath="${cabledata}/ipbes/ndep"
# Global LUC
GlobalTransitionFilePath="${cabledata}/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${mettype}" == "bios" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_CRU05x05_4tiles.nc" # note that SurfaceFile does not need subsetting
# Global MET
GlobalLandMaskFile="${cabledata}/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="${cabledata}/BIOS3_forcing/acttest9/met/" # last slash is needed
ParamPath="${cabledata}/BIOS3_forcing/acttest9/params/" # only in bios.nml
# Global LUC
GlobalTransitionFilePath="${cabledata}/LUH2/v3h/${degrees}deg_aust/EXTRACT"
fi
elif [[ "${system}" == "cuntz@mc16" || "${system}" == "cuntz@mcinra" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
cablebase="/Users/cuntz/prog/vanessa/cable"
sitepath="${cablebase}/runs/single_sites/${experiment}"
cablehome="${cablebase}/branches/NESP2pt9_BLAZE"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
# exe="${cablehome}/branches/NESP2pt9_BLAZE/offline/cable-mpi-gfortran"
exe="${cablehome}/offline/cable-mpi-ifort"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="${cablebase}/CABLE-AUX"
# Global Mask, CRU, LUC
GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
GlobalMetPath=
GlobalTransitionFilePath=
elif [[ "${system}" == "moc801@gadi" || "${system}" == "cuntz@gadi" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
# sitepath="/home/801/moc801/prog/cable/runs/single_sites/${experiment}"
sitepath="/scratch/x45/moc801/cable/c13"
cablehome="/home/801/moc801/prog/cable/branches/NESP2pt9_BLAZE"
workpath=${cablehome}
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/g/data/x45/CABLE-AUX"
# BLAZE directory
BlazeDataPath="/g/data/x45/Data_BLAZE"
# Global MET, MASK, LUH
if [[ "${mettype}" == "cru" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global MET
# GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${mettype}" == "plume" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global MET
# GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
# only in plume.nml
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${mettype}" == "bios" ]] ; then
# Global MASK
SurfaceFile="${aux}/offline/gridinfo_CSIRO_CRU05x05_4tiles.nc" # note that SurfaceFile does not need subsetting
# Global MET
GlobalLandMaskFile="/g/data/x45/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="/g/data/x45/BIOS3_forcing/acttest9/met/" # last slash is needed
ParamPath="/g/data/x45/BIOS3_forcing/acttest9/params/" # only in bios.nml
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/v3h/${degrees}deg_aust/EXTRACT"
fi
elif [[ "${system}" == "kna016@pearcey" || "${system}" == "knauer@pearcey" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
sitepath="/OSM/CBR/OA_GLOBALCABLE/work/Juergen/CABLE_run/parallel_runs/${experiment}"
cablehome="/OSM/CBR/OA_GLOBALCABLE/work/Juergen/CABLE_code/NESP2pt9_BLAZE"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/OSM/CBR/OA_GLOBALCABLE/work/Vanessa/CABLE-AUX"
# Global Mask
GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global CRU
GlobalMetPath="/OSM/CBR/OA_GLOBALCABLE/work/CRU-JRA55/crujra/daily_1deg"
# Global LUC
GlobalTransitionFilePath="/OSM/CBR/OA_GLOBALCABLE/work/LUH2/v3/1deg"
elif [[ "${system}" == "jk8585@gadi" || "${system}" == "knauer@gadi" ]] ; then
# Run directory: runpath="${sitepath}/run"
sitepath="/g/data/x45/jk8585/global_runs/gm_acclim_coord/${experiment}"
cablecode="/home/599/jk8585/CABLE_code/gm_acclim_coord"
cablehome="/home/599/jk8585/CABLE_run/gm_acclim_coord"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablecode}/offline/cable-mpi"
else
exe="${cablecode}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/g/data/x45/CABLE-AUX"
# Global Mask
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global Met
if [[ "${mettype}" == "cru" ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
elif [[ "${mettype}" == "plume" ]] ; then
# GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
# only in plume.nml
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
elif [[ "${mettype}" == "bios" ]] ; then
GlobalLandMaskFile="/g/data/x45/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="/g/data/x45/BIOS3_forcing/acttest9/met/" # last slash is needed
ParamPath="/g/data/x45/BIOS3_forcing/acttest9/params/" # only in bios.nml
GlobalTransitionFilePath="/g/data/x45/LUH2/v3h/${degrees}deg_aust/EXTRACT"
fi
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${system}" == "yc3714@gadi" || "${system}" == "villalobos@gadi" ]] ; then
# Run directory: runpath="${sitepath}/run"
sitepath="/g/data/x45/BIOS3_output/${experiment}" # Results
workpath="/home/563/yc3714/CSIRO/CABLE_run/BIOS3_blaze" # run directory
cablehome="/home/563/yc3714/CSIRO/CABLE_code/9011/NESP2pt9_BLAZE" # model home
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/g/data/x45/CABLE-AUX"
# Global Mask
SurfaceFile="${aux}/offline/gridinfo_CSIRO_CRU05x05_4tiles.nc" # note that SurfaceFile does not need subsetting
# Global Met
if [[ "${mettype}" == "cru" ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
elif [[ "${mettype}" == "plume" ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
# only in plume.nml
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
elif [[ "${mettype}" == "bios" ]] ; then
GlobalLandMaskFile="/g/data/x45/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="/g/data/x45/BIOS3_forcing/acttest9/met/" # last slash is needed
ParamPath="/g/data/x45/BIOS3_forcing/acttest9/params/" # only in bios.nml
GlobalTransitionFilePath="/g/data/x45/LUH2/v3h/${degrees}deg_aust/EXTRACT"
fi
# Global LUC
# GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${system}" == "inh599@gadi" || "${system}" == "harman@gadi" ]] ; then
# Run directory: runpath="${sitepath}/run"
#sitepath="/g/data/x45/BIOS3_output/${experiment}" # Results
sitepath="/scratch/x45/inh599/BIOStests/${experiment}" # Results
workpath="/home/599/inh599/JAC/CABLE/BLAZEruns" # run directory
cablehome="/home/599/inh599/JAC/CABLE/BLAZE_9184" # model home
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/g/data/x45/CABLE-AUX"
BlazeDataPath="/g/data/x45/Data_BLAZE"
# Global Mask
SurfaceFile="${aux}/offline/gridinfo_CSIRO_CRU05x05_4tiles.nc" # note that SurfaceFile does not need subsetting
# Global Met
if [[ "${mettype}" == "cru" ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
elif [[ "${mettype}" == "plume" ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
# only in plume.nml
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
elif [[ "${mettype}" == "bios" ]] ; then
GlobalLandMaskFile="/g/data/x45/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="/g/data/x45/BIOS3_forcing/acttest9/met/" # last slash is needed - updated 29/3/2024
ParamPath="/g/data/x45/BIOS3_forcing/acttest9/params/" # only in bios.nml
GlobalTransitionFilePath="/g/data/x45/LUH2/v3h/${degrees}deg_aust/EXTRACT"
fi
# Global LUC
# GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
elif [[ "${system}" == "bri220@pearcey" || "${system}" == "briggs@pearcey" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
sitepath="/OSM/CBR/OA_GLOBALCABLE/work/Peter/CABLE_run/parallel_runs/${experiment}"
cablehome="/OSM/CBR/OA_GLOBALCABLE/work/Peter/CABLE_code"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/NESP2pt9_BLAZE/offline/cable-mpi"
else
exe="${cablehome}/NESP2pt9_BLAZE/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/OSM/CBR/OA_GLOBALCABLE/work/Vanessa/CABLE-AUX"
# Global Mask
GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
# Global CRU
GlobalMetPath="/OSM/CBR/OA_GLOBALCABLE/work/CRU-JRA55/crujra/daily_1deg"
# Global LUC
GlobalTransitionFilePath="/OSM/CBR/OA_GLOBALCABLE/work/LUH2/v3/1deg"
elif [[ "${system}" == "pcb599@gadi" || "${system}" == "briggs@gadi" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
sitepath="/g/data/x45/BIOS3_output/${experiment}"
workpath="/home/599/pcb599/CABLE_run/BIOS3/run"
cablehome="/home/599/pcb599/CABLE_code/NESP2pt9_BLAZE"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/g/data/x45/CABLE-AUX"
# Global Mask
GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
# Global Met
if [[ "${mettype}" == 'plume' ]] ; then
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
elif [[ "${mettype}" == 'bios' ]] ; then
GlobalLandMaskFile="/g/data/x45/BIOS3_forcing/acttest9/acttest9" # no file extension
GlobalMetPath="/g/data/x45/BIOS3_forcing/acttest9/met/" # last slash is needed
ParamPath="/g/data/x45/BIOS3_forcing/acttest9/params/"
GlobalTransitionFilePath="/g/data/x45/LUH2/v3h/${degrees}deg_aust/EXTRACT"
elif [[ "${mettype}" == 'cru' ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
fi
elif [[ "${system}" == "nieradzik@aurora" ]] ; then
# Run directory: runpath="${sitepath}/run_xxx"
sitepath="/home/x_larni/STOREDIR/RUNDIR/CABLE/${experiment}"
workpath="/home/x_larni/SRC/CABLE/NESP2pt9_BLAZE"
cablehome="/home/x_larni/SRC/CABLE/NESP2pt9_BLAZE"
# Cable executable
if [[ ${dompi} -eq 1 ]] ; then
exe="${cablehome}/offline/cable-mpi"
else
exe="${cablehome}/offline/cable"
fi
# CABLE-AUX directory (uses offline/gridinfo_CSIRO_1x1.nc and offline/modis_phenology_csiro.txt)
aux="/home/x_larni/STOREDIR/DATA/CABLE-AUX"
# Global Mask
GlobalLandMaskFile="${aux}/offline/gridinfo_CSIRO_1x1.nc"
SurfaceFile="${aux}/offline/gridinfo_CSIRO_1x1.nc" # note that SurfaceFile does not need subsetting
# Global LUC
GlobalTransitionFilePath="/g/data/x45/LUH2/GCB_2019/1deg/EXTRACT"
# Global Met
if [[ "${mettype}" == 'plume' ]] ; then
GlobalMetPath="/g/data/x45/ipbes/${metmodel}/1deg"
CO2Path="/g/data/x45/ipbes/co2"
NdepPath="/g/data/x45/ipbes/ndep"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalLandMaskFile="/g/data/x45/ipbes/masks/gridinfo_CSIRO_1x1.nc"
elif [[ "${mettype}" == 'bios' ]] ; then
GlobalLandMaskFile="/home/x_larni/STOREDIR/DATA/CABLE_INPUT/acttest9/acttest9" # no file extension
GlobalMetPath="/home/x_larni/STOREDIR/DATA/CABLE_INPUT/acttest9/met/" # last slash is needed
ParamPath="/home/x_larni/STOREDIR/DATA/CABLE_INPUT/acttest9/params/"
GlobalTransitionFilePath="/home/x_larni/STOREDIR/DATA/CABLE_INPUT/LUH2/v3h/${degrees}deg_aust/EXTRACT"
elif [[ "${mettype}" == 'cru' ]] ; then
GlobalLandMaskFile="/g/data/x45/ipbes/masks/glob_ipsl_1x1.nc"
GlobalMetPath="/g/data/x45/CRUJRA2020/daily_1deg"
fi
else
echo "System not known."
exit 1
fi
# Run directory
#runpath="${sitepath}/run_20210618"
runpath="${sitepath}/run"
# Cable parameters
if [[ "${mettype}" == 'bios' ]] ; then
namelistpath="${workpath}/namelists_bios"
filename_veg="${workpath}/params_bios/def_veg_params.txt"
filename_soil="${workpath}/params_bios/def_soil_params.txt"
casafile_cnpbiome="${workpath}/params_bios/pftlookup.csv"
else
namelistpath="${workpath}/namelists"
filename_veg="${workpath}/params/def_veg_params.txt"
filename_soil="${workpath}/params/def_soil_params.txt"
casafile_cnpbiome="${workpath}/params/pftlookup.csv"
fi
# Other scripts
ScriptsPath="${cablehome}/scripts"
# Mask
LandMaskFile="${sitepath}/mask/${experiment}_landmask.nc"
# Met
if [[ "${mettype}" == 'bios' ]] ; then
MetPath="${sitepath}/met/bios_${degrees}deg"
ClimateFile="${sitepath}/mask/bios_climate_rst.nc"
if [[ "${sys}" == "gadi" ]]; then
if [[ (${doclimate} -eq 0) && (! -f ${ClimateFile}) ]] ; then
ClimateFile="/g/data/x45/BIOS3_output/bio_climate_acttest9/bios_climate_rst.nc"
fi
fi
else
MetPath="${sitepath}/met/cru_jra_1deg"
ClimateFile="${sitepath}/mask/cru_climate_rst.nc"
if [[ "${sys}" == "gadi" ]]; then
if [[ (${doclimate} -eq 0) && (! -f ${ClimateFile}) ]] ; then
ClimateFile="/g/data/x45/ipbes/cable_climate/ipsl_climate_rst_glob_1deg.nc"
fi
fi
fi
# LUC
TransitionFilePath="${sitepath}/LUH2/v3/1deg"
# gm lookup tables
gm_lut_bernacchi_2002="${cablehome}/params/gm_LUT_351x3601x7_1pt8245_Bernacchi2002.nc"
gm_lut_walker_2013="${cablehome}/params/gm_LUT_351x3601x7_1pt8245_Walker2013.nc"
# 13C
filename_d13c_atm="${cablehome}/params/graven_et_al_gmd_2017-table_s1-delta_13c-1700-2025.txt"
# --------------------------------------------------------------------
# Start Script
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# Helper functions, most functions are in plumber_cable-pop_lib.sh
#
source ${pdir}/run_cable-pop_lib.sh
# usage of script
function usage()
{
printf "${pprog} [-h]\n"
printf "Runs Cable on a single grid cell with spinup, POP, land-use change, etc.\n"
printf "Behaviour of the script is controlled by switches at the top of the script (ca. line 101ff).\n"
printf "\n"
printf "Options\n"
printf " -h Prints this help screen.\n"
}
# cleanup at end or at trap
function cleanup()
{
\rm -f ${tmp}/*.${pid}*
exit 1
}
# returns argument to extract lat and lon with ncks
function nckslatlon()
{
vars=$(ncvarlist ${1})
if [[ -z $(isin latitude ${vars}) ]] ; then ilat="lat" ; else ilat="latitude" ; fi
if [[ -z $(isin longitude ${vars}) ]] ; then ilon="lon" ; else ilon="longitude" ; fi
if [[ -z $(echo ${2} | cut -f 3 -d ",") || -z $(echo ${2} | cut -f 4 -d ",") ]] ; then
iilat=$(echo ${2} | cut -f 1 -d ",")
iilon=$(echo ${2} | cut -f 2 -d ",")
echo "-d ${ilat},${iilat} -d ${ilon},${iilon}"
else
iilat1=$(echo ${2} | cut -f 1 -d ",")
iilat2=$(echo ${2} | cut -f 2 -d ",")
iilon1=$(echo ${2} | cut -f 3 -d ",")
iilon2=$(echo ${2} | cut -f 4 -d ",")
echo "-d ${ilat},${iilat1},${iilat2} -d ${ilon},${iilon1},${iilon2}"
fi
}
# --------------------------------------------------------------------------------------------------
# Preparation
#
# Get options
while getopts "h" option ; do
case ${option} in
h) usage; exit;;
*) printf "Error ${pprog}: unimplemented option.\n\n" 1>&2; usage 1>&2; exit 1;;
esac
done
shift $((${OPTIND} - 1))
#
# get directories
mkdir -p ${sitepath}/mask
pdir=$(abspath ${pdir})
cd ${pdir}
adir=$(abspath ${aux})
exe=$(absfile ${exe})
mkdir -p ${runpath}
rdir=$(abspath ${runpath})
ndir=$(abspath ${namelistpath})
sdir=$(abspath ${ScriptsPath})
#
# prepare run directory
cd ${rdir}
mkdir -p logs
mkdir -p outputs
mkdir -p restart
ln -sf ${adir}
# ln -sf ${exe}
cp ${exe} ./
iexe=$(basename ${exe})
cd ${pdir}
#
# set stacksize to unlimited if permitted, otherwise to 15 bit if possible
set +e
ulimit -s unlimited 2> /dev/null || ulimit -s 32768
set -e
# --------------------------------------------------------------------
# Info
#
t1=$(date +%s)
printf "Started at %s\n" "$(date)"
printf "\nSetup\n"
printf " Serial / Parallel\n"
printf " dompi=${dompi}\n"
printf " nproc=${nproc}\n"
printf "\n"
printf " Sequence\n"
printf " imeteo=${imeteo}\n"
printf " doextractsite=${doextractsite}\n"
printf " experiment=${experiment}\n"
printf " randompoints=${randompoints}\n"
printf " latlon=${latlon}\n"
printf " doclimate=${doclimate}\n"
printf " dofromzero=${dofromzero}\n"
printf " doequi1=${doequi1}\n"
printf " nequi1=${nequi1}\n"
printf " doequi2=${doequi2}\n"
printf " nequi2=${nequi2}\n"
printf " doiniluc=${doiniluc}\n"
printf " doinidyn=${doinidyn}\n"
printf " dofinal=${dofinal}\n"
printf " dofuture=${dofuture}\n"
printf "\n"
printf " Options\n"
printf " mettype=${mettype}\n"
printf " metmodel=${metmodel}\n"
printf " RCP=${RCP}\n"
printf " explicit_gm=${explicit_gm}\n"
printf " use_LUTgm=${use_LUTgm}\n"
printf " Rubisco_params=${Rubisco_params}\n"
printf " coordinate_photosyn=${coordinate_photosyn}\n"
printf " coord=${coord}\n"
printf " acclimate_photosyn=${acclimate_photosyn}\n"
printf " call_pop=${call_pop}\n"
printf " doc13o2=${doc13o2}\n"
printf " c13o2_simple_disc=${c13o2_simple_disc}\n"
printf "\n"
printf " Directories\n"
printf " sitepath=${sitepath}\n"
printf " cablehome=${cablehome}\n"
printf " exe=${exe}\n"
printf " aux=${aux}\n"
printf " GlobalLandMaskFile=${GlobalLandMaskFile}\n"
printf " SurfaceFile=${SurfaceFile}\n"
printf " GlobalMetPath=${GlobalMetPath}\n"
printf " GlobalTransitionFilePath=${GlobalTransitionFilePath}\n"
printf " runpath=${runpath}\n"
printf " namelistpath=${namelistpath}\n"
printf " filename_veg=${filename_veg}\n"
printf " filename_soil=${filename_soil}\n"
printf " casafile_cnpbiome=${casafile_cnpbiome}\n"
printf " LandMaskFile=${LandMaskFile}\n"
printf " MetPath=${MetPath}\n"
printf " ClimateFile=${ClimateFile}\n"
printf " TransitionFilePath=${TransitionFilePath}\n"
printf " gm_lut_bernacchi_2002=${gm_lut_bernacchi_2002}\n"
printf " gm_lut_walker_2013=${gm_lut_walker_2013}\n"
printf " filename_d13c_atm=${filename_d13c_atm}\n"
printf "\n"
# --------------------------------------------------------------------
# Prep input
#
# 0. Extract meteo, land use and mask for one specific site from global files
if [[ ${doextractsite} -ge 2 ]] ; then
set +e
xnco=$(which ncks 2> /dev/null)
set -e
if [[ -z ${xnco} ]] ; then module load nco ; fi
fi
if [[ ${doextractsite} -eq 1 ]] ; then
echo "0. Set local mask"
cd ${pdir}
# mask
LandMaskFilePath=$(dirname ${LandMaskFile})
mkdir -p ${LandMaskFilePath}
LandMaskFile=$(absfile ${LandMaskFile})
# echo $(basename ${LandMaskFile})
# generate random points if ${randompoints} > 0
if [[ ${randompoints} -ne 0 ]] ; then
dogeneraterandom=1
rpoints=${randompoints}
if [[ ${randompoints} -lt 0 ]] ; then
if [[ -f ${LandMaskFilePath}/${experiment}_points.csv ]] ; then dogeneraterandom = 0 ; fi
rpoints=$(( ${randompoints} * -1 ))
fi
# generate random points
cat > ${tmp}/sedtmp.${pid} << EOF
basepath = "${sitepath}"
gridinfo_file = "${GlobalLandMaskFile}"
outname = "${LandMaskFilePath}/${experiment}_points.csv"
EOF
applysed ${tmp}/sedtmp.${pid} ${sdir}/generate_latlonlist.py ${LandMaskFilePath}/generate_latlonlist.py
python3 ${LandMaskFilePath}/generate_latlonlist.py ${rpoints}
# set mask to generated random points
cat > ${tmp}/sedtmp.${pid} << EOF
path = "${LandMaskFilePath}"
maskfname = "${LandMaskFile}"
latlonfile = "${LandMaskFilePath}/${experiment}_points.csv"
gridinfo_file = "${GlobalLandMaskFile}"
EOF
if [[ "${mettype}" == "bios" ]] ; then
echo "res = 0.25" >> ${tmp}/sedtmp.${pid}
fi
applysed ${tmp}/sedtmp.${pid} ${sdir}/create_landmask.py ${LandMaskFilePath}/create_landmask.py
sed -i -e "s|from lnutils.*|sys.path.insert(1,'${sdir}'); from lnutils import latlon2ixjy|" ${LandMaskFilePath}/create_landmask.py
python3 ${LandMaskFilePath}/create_landmask.py
else
# # cdo -s -f nc4 -z zip sellonlatbox,-72.5,-72.0,42.5,43.0 ${GlobalLandMaskFile} ${LandMaskFile}
# ncks -O $(nckslatlon ${GlobalLandMaskFile} ${latlon}) ${GlobalLandMaskFile} ${LandMaskFile}
cat > ${tmp}/sedtmp.${pid} << EOF
path = "${LandMaskFilePath}"
maskfname = "${LandMaskFile}"
gridinfo_file = "${GlobalLandMaskFile}"
EOF
if [[ "${mettype}" == "bios" ]] ; then
echo "res = 0.25" >> ${tmp}/sedtmp.${pid}
fi
applysed ${tmp}/sedtmp.${pid} ${sdir}/create_landmask.py ${LandMaskFilePath}/create_landmask.py
sed -i -e "s|from lnutils.*|sys.path.insert(1,'${sdir}'); from lnutils import latlon2ixjy|" ${LandMaskFilePath}/create_landmask.py
python3 ${LandMaskFilePath}/create_landmask.py ${latlon}
fi
elif [[ ${doextractsite} -eq 2 ]] ; then
echo "0. Extract local meteo and mask"
cd ${pdir}
# meteorology
met_list="pre pres dlwrf dswrf spfh tmax tmin ugrd vgrd ndep"
mkdir -p ${MetPath}
MetPath=$(abspath ${MetPath})
for mm in ${met_list} ; do
echo ${GlobalMetPath}/${mm}
mkdir -p ${MetPath}/${mm}
for nc in ${GlobalMetPath}/${mm}/*.nc ; do
ff=$(basename ${nc})
echo " ${ff}"
# cdo -s -f nc4 -z zip sellonlatbox,-72.5,-72.0,42.5,43.0 ${nc} ${MetPath}/${mm}/${ff}
ncks -O $(nckslatlon ${nc} ${latlon}) ${nc} ${MetPath}/${mm}/${ff}
done
done
echo ${GlobalMetPath}/co2/*.csv
mkdir -p ${MetPath}/co2
cp ${GlobalMetPath}/co2/*.csv ${MetPath}/co2/
# land use
mkdir -p ${TransitionFilePath}
TransitionFilePath=$(abspath ${TransitionFilePath})
echo ${GlobalTransitionFilePath}
for nc in ${GlobalTransitionFilePath}/*.nc ; do
ff=$(basename ${nc})
echo " ${ff}"
# cdo -s -f nc4 -z zip sellonlatbox,-72.5,-72.0,42.5,43.0 ${nc} ${TransitionFilePath}/${ff}
ncks -O $(nckslatlon ${nc} ${latlon}) ${nc} ${TransitionFilePath}/${ff}
done
# mask
LandMaskFilePath=$(dirname ${LandMaskFile})
mkdir -p ${LandMaskFilePath}
LandMaskFile=$(absfile ${LandMaskFile})
echo $(basename ${LandMaskFile})
# cdo -s -f nc4 -z zip sellonlatbox,-72.5,-72.0,42.5,43.0 ${GlobalLandMaskFile} ${LandMaskFile}
ncks -O $(nckslatlon ${GlobalLandMaskFile} ${latlon}) ${GlobalLandMaskFile} ${LandMaskFile}
fi
# --------------------------------------------------------------------
# Prepare sequence
#
# Choose meteo, land use and mask directories and files
if [[ ${imeteo} -eq 0 ]] ; then
MetPath=$(abspath ${GlobalMetPath})
TransitionFilePath=$(abspath ${GlobalTransitionFilePath})
LandMaskFile=$(absfile ${GlobalLandMaskFile})
elif [[ ${imeteo} -eq 1 ]] ; then
MetPath=$(abspath ${GlobalMetPath})
TransitionFilePath=$(abspath ${GlobalTransitionFilePath})