1 | #!/bin/bash |
---|
2 | # Partition to run on: |
---|
3 | #MSUB -q rome |
---|
4 | # project to run on |
---|
5 | #MSUB -A gen10391 |
---|
6 | # disks to use |
---|
7 | #MSUB -m scratch,work,store |
---|
8 | # Job name |
---|
9 | #MSUB -r run_PEM |
---|
10 | # Job standard output: |
---|
11 | #MSUB -o run_PEM.%I |
---|
12 | # Job standard error: |
---|
13 | #MSUB -e run_PEM.%I |
---|
14 | # number of OpenMP threads c |
---|
15 | #MSUB -c 1 |
---|
16 | # number of MPI tasks n |
---|
17 | #MSUB -n 1 |
---|
18 | # number of nodes to use N |
---|
19 | #MSUB -N 1 |
---|
20 | # max job run time T (in seconds) |
---|
21 | #MSUB -T 860 |
---|
22 | #MSUB -Q test |
---|
23 | # request exclusive use of the node (128 cores) |
---|
24 | ##MSUB -x |
---|
25 | |
---|
26 | # A few parameters that might need be changed depending on your setup: |
---|
27 | # Path to the arch.env to source: |
---|
28 | source ../trunk/LMDZ.COMMON/arch.env |
---|
29 | |
---|
30 | #------------------ Modify here the name of PEM exe -------------------- |
---|
31 | ## fill in the name of executable for PEM: |
---|
32 | exePEM=pem_29_phymars_seq.e |
---|
33 | |
---|
34 | #------------------ Modify here the name of GCM exe -------------------- |
---|
35 | ## fill in the name of executable for GCM: |
---|
36 | exeGCM=testphys1d_29_phymars_para.e |
---|
37 | |
---|
38 | #-------------- Modify here the name of reshape XIOS exe --------------- |
---|
39 | ## fill in the name of executable for reshape XIOS: |
---|
40 | exeReshape=reshape_XIOS_output_64x48x29_phymars_seq.e |
---|
41 | |
---|
42 | #---------------- Modify here the number of PEM calls ------------------ |
---|
43 | ## set the number of PEM calls: |
---|
44 | nPEM=1000 |
---|
45 | |
---|
46 | #---------------- Modify here the number of GCM calls ------------------ |
---|
47 | ## set the number of GCM calls between each PEM call: |
---|
48 | nGCM=2 |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | #--------- Check if files/directories exist to be able to run ---------- |
---|
53 | echo Starting script to call PEM with GCM! |
---|
54 | if [ ! -d "profiles" ]; then |
---|
55 | mkdir profiles |
---|
56 | else |
---|
57 | rm profiles/* |
---|
58 | fi |
---|
59 | if [ ! -d "diagfis" ]; then |
---|
60 | mkdir diagfis |
---|
61 | else |
---|
62 | rm diagfis/* |
---|
63 | fi |
---|
64 | if [ ! -d "startfis" ]; then |
---|
65 | mkdir startfis |
---|
66 | else |
---|
67 | rm startfis/* |
---|
68 | fi |
---|
69 | if [ ! -r "context_lmdz_physics.xml" ]; then |
---|
70 | echo File context_lmdz_physics.xml does not exist! |
---|
71 | exit 0 |
---|
72 | fi |
---|
73 | if [ ! -r "field_def_physics_mars.xml" ]; then |
---|
74 | echo File field_def_physics_mars.xml does not exist! |
---|
75 | exit 0 |
---|
76 | fi |
---|
77 | if [ ! -r "file_def_physics_mars.xml" ]; then |
---|
78 | echo File file_def_physics_mars.xml does not exist! |
---|
79 | exit 0 |
---|
80 | fi |
---|
81 | if [ ! -r "iodef.xml" ]; then |
---|
82 | echo File iodef.xml does not exist! |
---|
83 | exit 0 |
---|
84 | fi |
---|
85 | if [ ! -r "run_PEM.def" ]; then |
---|
86 | echo File diagfi_PEM.def does not exist! |
---|
87 | exit 0 |
---|
88 | fi |
---|
89 | if [ ! -r "run_GCM.def" ]; then |
---|
90 | echo File diagfi_GCM.def does not exist! |
---|
91 | exit 0 |
---|
92 | fi |
---|
93 | if [ ! -r "run_PEM.def" ]; then |
---|
94 | echo File diagfi_PEM.def does not exist! |
---|
95 | exit 0 |
---|
96 | fi |
---|
97 | if [ ! -r "run_GCM.def" ]; then |
---|
98 | echo File diagfi_GCM.def does not exist! |
---|
99 | exit 0 |
---|
100 | fi |
---|
101 | |
---|
102 | #---------------------------- Initialization --------------------------- |
---|
103 | iPEM=1 |
---|
104 | ((iGCM = ($iPEM - 1)*$nGCM + 1)) |
---|
105 | cp startfi.nc startfis/ |
---|
106 | cp startfi_PEM.nc startfis/ |
---|
107 | for file in profile_*; do |
---|
108 | cp $file profiles/${file}_0 |
---|
109 | done |
---|
110 | |
---|
111 | #---------------------- Main loop to call PEM/GCM ---------------------- |
---|
112 | while [ $iPEM -le $nPEM ]; do |
---|
113 | #--- Loop to run GCM year by year |
---|
114 | cp run_GCM.def run.def |
---|
115 | cp diagfi_GCM.def diagfi.def |
---|
116 | for ((i = 1; i <= $nGCM; i++)); do |
---|
117 | echo Run GCM $iGCM: call $i out of $nGCM... |
---|
118 | ./$exeGCM > lrun${iGCM} 2>&1 |
---|
119 | mv diagfi.nc diagfis/diagfi${iGCM}.nc |
---|
120 | cp Xdiurnalave.nc diagfis/Xdiurnalave${iGCM}.nc |
---|
121 | mv Xdiurnalave.nc data2reshape${i}.nc |
---|
122 | cp restartfi.nc startfis/startfi${iGCM}.nc |
---|
123 | mv restartfi.nc startfi.nc |
---|
124 | for file in profile_out_*; do |
---|
125 | cp $file profiles/${file/_out/}_${iGCM} |
---|
126 | mv $file ${file/_out/} |
---|
127 | done |
---|
128 | ((iGCM++)) |
---|
129 | echo Done! |
---|
130 | done |
---|
131 | #--- Reshaping GCM data with XIOS |
---|
132 | echo Reshaping GCM data with XIOS... |
---|
133 | for i in $(ls datareshaped*); do |
---|
134 | rm $i |
---|
135 | done |
---|
136 | ./$exeReshape |
---|
137 | for file in datareshaped*; do |
---|
138 | mv $file ${file/reshaped/_GCM_Y} |
---|
139 | done |
---|
140 | echo Done! |
---|
141 | #--- Running PEM |
---|
142 | echo Run PEM $iPEM... |
---|
143 | cp run_PEM.def run.def |
---|
144 | cp diagfi_PEM.def diagfi.def |
---|
145 | mv startfi.nc startfi_evol.nc |
---|
146 | ./$exePEM > mrun${iPEM} 2>&1 |
---|
147 | mv diagfi.nc diagfis/diagfi_PEM${iPEM}.nc |
---|
148 | cp restartfi_evol.nc startfis/startfi_postPEM${iPEM}.nc |
---|
149 | mv restartfi_evol.nc startfi.nc |
---|
150 | cp restartfi_PEM.nc startfis/startfi_PEM${iPEM}.nc |
---|
151 | mv restartfi_PEM.nc startfi_PEM.nc |
---|
152 | for file in profile_out_*; do |
---|
153 | cp $file profiles/${file/_out/}PEM_${iPEM} |
---|
154 | mv $file ${file/_out/} |
---|
155 | done |
---|
156 | mv info_run_PEM.txt info_run_PEM${iPEM}.txt |
---|
157 | ((iPEM++)) |
---|
158 | echo Done! |
---|
159 | done |
---|
160 | |
---|
161 | #---------------------- Preparation for relaunch ---------------------- |
---|
162 | echo Reinitializing starting files... |
---|
163 | cp startfis/startfi.nc . |
---|
164 | for file in profiles/*_0; do |
---|
165 | cp $file ${file/_0/} |
---|
166 | done |
---|
167 | |
---|
168 | echo Script finished. |
---|