Changeset 1062 for palm/trunk/SCRIPTS
- Timestamp:
- Nov 21, 2012 3:57:18 PM (12 years ago)
- Location:
- palm/trunk/SCRIPTS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/nc2vdf
r1046 r1062 15 15 check_muk=false 16 16 check_hlrn=false 17 check_workstation=false 17 18 sys="unknown" 18 19 … … 40 41 check_hlrn=true 41 42 fi 43 # if [ $(expr "$HOSTNAME" : "") -eq 1 ] ### insert $HOSTNAME of your workstation here if you are not running vapor on one of the systems above 44 # then 45 # check_workstation=true 46 # fi 47 42 48 43 49 … … 55 61 module load ncl 56 62 fi 63 64 if [ $check_workstation == "true" ] 65 then 66 sys="workstation" 67 fi 57 68 58 69 if [ $sys == "unknown" ] 59 70 then 60 echo "+++ unknown system. Exiting..."61 exit 071 echo "+++ unknown system." 72 #exit 0 62 73 else 63 74 echo "*** nc2vdf will execute at $sys" -
palm/trunk/SCRIPTS/nc2vdf.ncl
r1047 r1062 18 18 ; Current revisions: 19 19 ; ----------------- 20 ; full batch mode support, loading configuration from an external file 21 ; fallback to interactive mode if no configuration present 22 ; batch mode does not support loading more than one variable per file if there 23 ; is more than one file specified (but there is a workaround) 24 ; you cannot add time steps to a variable from an additional file in batch mode 20 25 ; 21 26 ; Former revisions: … … 40 45 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" 41 46 42 outputfile = "default.vdf" 47 alt_varnames = False 48 man = True 49 path = "" 43 50 44 51 if(isfilepresent(inputfile)) then 45 52 print("*** Loading " + inputfile) 46 53 loadscript(inputfile) 54 man = False 47 55 else 48 print("+++ Input file does not exist. Exiting...") 49 exit 56 print("+++ Input file does not exist.") 57 man_resp = systemfunc("read -p 'Enter manual mode? (y/n) ' RESP; echo $RESP") 58 if (man_resp .eq. "y") then 59 man = True 60 else 61 print("+++ Exiting...") 62 exit 63 end if 50 64 end if 51 65 … … 53 67 begin 54 68 69 if (.not. man) then 55 70 ; print loaded data from input file 56 71 print("*** loading " + dimsizes(files) + ":") … … 60 75 61 76 print("*** will create dataset " + outputfile) 62 63 64 workpath = systemfunc("echo $PWD") + "/" 65 path = "" 66 67 68 ; hannes stuff below ;-) 69 77 end if 78 79 ;****************************************************** 80 ;give path to the directory where NetCDF files are stored: 81 print("*** Checking hostname...") 82 sys = "unknown" 83 query = systemfunc("echo $HOSTNAME") 84 check_muk = isStrSubset(query,"muk.uni-hannover.de") 85 check_hice = isStrSubset(query,"hicegate2") 86 check_bice = isStrSubset(query,"bicegate2") 87 check_huv = isStrSubset(query,"huv") 88 check_buv = isStrSubset(query,"buv") 89 check_WS = isStrSubset(query,"kookaburra") ;*** insert name of your workstation here 90 91 92 93 if ( check_muk .eq. True ) then 94 print("*** nc2vdf will execute at IMUK") 95 sys = "IMUK" 96 else 97 if ( check_hice .eq. True .or. check_bice .eq. True ) then 98 print("*** nc2vdf will execute on hicegate2/bicegate2") 99 sys = "HLRN" 100 else 101 if ( check_huv .eq. True .or. check_buv .eq. True ) then 102 print("*** nc2vdf will execute on UV") 103 sys = "HLRN" 104 else 105 if ( check_WS .eq. True) then 106 print("*** nc2vdf will execute on a workstation PC/Mac") 107 sys = "workstation" 108 path = "/Applications/VAPOR.app/Contents/MacOS/" ;*** costomize path for WS 109 end if 110 end if 111 end if 112 end if 113 if ( sys .eq. "unknown" ) then 114 print("+++ unknown system. Exiting...") 115 exit 116 end if 117 118 119 workpath = systemfunc("echo $PWD") + "/" 120 121 122 ;****************************************************** 123 ;****************************************************** 124 if man then 125 ;specify name of output file: 126 outputfile = "building.vdf" ;<<<<------------- !!! 127 end if 128 ;****************************************************** 70 129 ;****************************************************** 71 130 … … 86 145 87 146 88 ;print("You may need to run 'vapor-setup.sh' in order to set all enviroment variables.") 89 ;/muksoft/packages/vapor/2.1.0/bin/vapor-setup.sh 90 91 92 ;**** Get names of variables wanted to appear in the VDF file, then get their dimensions with min/max x,y,z 93 print(" ") 94 print("Choose the *.nc files containing 3D data by typing their indices (seperated by ','). Start with the first files of the timeseries.") 95 print(" ") 96 files_avail = systemfunc("cd "+workpath+"; ls *.nc") 97 print(" "+files_avail) 98 99 100 files_in_ary = toint(str_split(systemfunc("read file; echo $file"), ",")) 101 nofiles = dimsizes(files_in_ary) 102 file_in = new(nofiles,string) 103 104 do i=0,nofiles-1 105 file_in(i) = files_avail(files_in_ary(i)) 106 end do 107 147 148 if man then 149 ;**** Get names of variables wanted to appear in the VDF file, then get their dimensions with min/max x,y,z 150 print(" ") 151 print("Choose the *.nc files containing 3D data by typing their indices (seperated by ','). Start with the first files of the timeseries.") 152 print(" ") 153 files_avail = systemfunc("cd "+workpath+"; ls *.nc") 154 print(" "+files_avail) 155 156 157 files_in_ary = toint(str_split(systemfunc("read file; echo $file"), ",")) 158 nofiles = dimsizes(files_in_ary) 159 file_in = new(nofiles,string) 160 161 do i=0,nofiles-1 162 file_in(i) = files_avail(files_in_ary(i)) 163 end do 164 else 165 file_in = files 166 nofiles = dimsizes(file_in) 167 end if 108 168 109 169 … … 113 173 if (nofiles .ge. 2) then 114 174 nvars = 1 175 if man then 115 176 varString = new((/nofiles,nvars/),string) 177 end if; man 116 178 dimNames = new((/nofiles,nvars,4/),string) 117 179 end if … … 119 181 120 182 do i=0,nofiles-1 183 print("Loading file...") 121 184 f = addfile(workpath+file_in(i),"r") 122 185 123 186 varNames = getfilevarnames(f) 124 print("Loading file...")125 187 126 188 189 if man then 127 190 print(" ") 128 191 print("The following variables were found in "+file_in(i)+":") … … 136 199 137 200 nvars = dimsizes(vars) 138 201 end if; man 202 139 203 if (nofiles .eq. 1) then 204 if man then 140 205 varString = new((/nofiles,nvars/),string) 206 end if; man 141 207 dimNames = new((/nofiles,nvars,4/),string) 142 208 end if … … 145 211 146 212 do n=0,nvars-1 147 213 if man then 148 214 varString(i,n) = varNames(vars(n)) 215 end if; man 216 217 if alt_varnames then 218 varString(i,n) = varNames(vars(i,n)) 219 end if 149 220 150 221 if (vars3d .ne. "") then 151 vars3d = vars3d + ":" + var Names(vars(n))222 vars3d = vars3d + ":" + varString(i,n) 152 223 else 153 vars3d = var Names(vars(n))224 vars3d = varString(i,n) 154 225 end if 155 226 … … 164 235 z = f->$dimNames(i,n,1)$ 165 236 y = f->$dimNames(i,n,2)$ 166 x = f->$dimNames(i,n,3)$237 x = f->$dimNames(i,n,3)$ 167 238 168 239 if (z_min .ge. min(z)) then … … 197 268 end do 198 269 199 print(varString) 200 270 ;print(varString) 271 272 if man then 201 273 delete(files_avail) 202 203 204 print(" ") 205 periodic = systemfunc("read -p 'Periodic lateral boundaries? (y/n) ' RESP; echo $RESP") 206 if (periodic .eq. "y") then 274 end if 275 276 if man then 277 print(" ") 278 periodic_resp = systemfunc("read -p 'Periodic lateral boundaries? (y/n) ' RESP; echo $RESP") 279 if (periodic_resp .eq. "y") then 280 periodic = True 281 else 282 periodic = False 283 end if 284 end if 285 286 if (periodic) then 207 287 px = 1 208 288 py = 1 … … 214 294 print(" ") 215 295 216 grid = systemfunc("read -p 'Is grid stretching used? (y/n) YES will cut of heights above dz_stretch_level? ' RESP; echo $RESP") 217 if (grid .eq. "y") then 218 stretch_level = stringtointeger(systemfunc("read -p 'Please type height of dz_stretch_level (in meters) ' RESP; echo $RESP")) 219 z_max = stretch_level ;**** limit z_max 296 if man then 297 grid_resp = systemfunc("read -p 'Is grid stretching used? (y/n) YES will cut of heights above dz_stretch_level? ' RESP; echo $RESP") 298 if (grid_resp .eq. "y") then 299 grid_stretch = True 300 else 301 grid_stretch = False 302 end if 303 end if 304 305 if (grid_stretch) then 306 if man then 307 stretch_level = stringtointeger(systemfunc("read -p 'Please type height of dz_stretch_level (in meters) ' RESP; echo $RESP")) 308 end if; man 309 z_max = stretch_level ;**** limit z_max 220 310 end if 221 311 … … 238 328 end if 239 329 330 if man then 240 331 print(" ") 241 332 … … 250 341 t_end = stringtointeger(systemfunc("read -p 'Type index of last time step: ' ts; echo $ts")) 251 342 end if 252 253 print(" ") 254 askreflevel = systemfunc("read -p 'Specify a maximum refinement level? (y/n) No will set the default value. ' RESP; echo $RESP") 255 if (askreflevel .eq. "y") then 256 reflevel = systemfunc("read -p 'Please type maximum refinement level ' RESP; echo $RESP") 257 reflevel_str = "-level "+ reflevel 343 end if 344 345 if (.not. man) then 346 if (.not. spec_ts) then 347 t_start = 0 348 t_end = dimsizes(time)-1 349 end if 350 end if 351 352 if man then 353 print(" ") 354 askreflevel = systemfunc("read -p 'Specify a maximum refinement level? (y/n) No will set the default value. ' RESP; echo $RESP") 355 if (askreflevel .eq. "y") then 356 reflevel = systemfunc("read -p 'Please type maximum refinement level ' RESP; echo $RESP") 357 reflevel_str = "-level "+ reflevel 358 else 359 reflevel_str = "" 360 end if 361 print(" ") 258 362 else 259 reflevel_str = "" 260 end if 261 print(" ") 262 363 if spec_reflevel then 364 reflevel_str = "-level "+ reflevel 365 else 366 reflevel_str = "" 367 end if 368 end if 369 370 263 371 264 372 ;******************************************************************************* … … 313 421 314 422 ;******************************************************************************* 315 423 if man then 316 424 ;**** Read more files and add them to VDF/VDC 317 425 addmore = "y" … … 448 556 addmore = systemfunc("read -p 'Add additional *.nc files? (y/n) ' RESP; echo $RESP") 449 557 end do 450 558 end if; man 451 559 ;******************************************************************************* 452 560 print("Done.")
Note: See TracChangeset
for help on using the changeset viewer.