Changeset 1062 for palm/trunk/SCRIPTS


Ignore:
Timestamp:
Nov 21, 2012 3:57:18 PM (12 years ago)
Author:
maronga
Message:

updates in nc2vdf

Location:
palm/trunk/SCRIPTS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/nc2vdf

    r1046 r1062  
    1515    check_muk=false
    1616    check_hlrn=false
     17    check_workstation=false
    1718    sys="unknown"
    1819
     
    4041       check_hlrn=true
    4142    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
    4248
    4349
     
    5561       module load ncl
    5662    fi
     63   
     64    if [ $check_workstation == "true" ]
     65    then
     66       sys="workstation"
     67    fi
    5768
    5869    if [ $sys == "unknown" ]
    5970    then
    60        echo "+++ unknown system. Exiting..."
    61        exit 0
     71       echo "+++ unknown system."
     72       #exit 0
    6273    else
    6374       echo "*** nc2vdf will execute at $sys"
  • palm/trunk/SCRIPTS/nc2vdf.ncl

    r1047 r1062  
    1818; Current revisions:
    1919; -----------------
     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
    2025;
    2126; Former revisions:
     
    4045load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
    4146
    42 outputfile = "default.vdf"
     47alt_varnames = False
     48man = True
     49path = ""
    4350
    4451if(isfilepresent(inputfile)) then
    4552   print("*** Loading " + inputfile)
    4653   loadscript(inputfile)
     54   man = False
    4755else
    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
    5064end if
    5165
     
    5367begin
    5468
     69if (.not. man) then
    5570;   print loaded data from input file
    5671    print("*** loading " + dimsizes(files) + ":")
     
    6075
    6176    print("*** will create dataset " + outputfile)
    62 
    63 
    64     workpath = systemfunc("echo $PWD") + "/"
    65     path     = ""
    66 
    67 
    68 ; hannes stuff below ;-)
    69 
     77end 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   
     119workpath = systemfunc("echo $PWD") + "/"
     120
     121
     122;******************************************************
     123;******************************************************
     124if man then
     125;specify name of output file:
     126outputfile      = "building.vdf" ;<<<<------------- !!!
     127end if
     128;******************************************************
    70129;******************************************************
    71130
     
    86145
    87146
    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
     148if 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
     164else
     165    file_in = files
     166    nofiles = dimsizes(file_in)
     167end if
    108168
    109169
     
    113173if (nofiles .ge. 2) then
    114174nvars   = 1
     175if man then
    115176varString  = new((/nofiles,nvars/),string)
     177end if; man
    116178dimNames   = new((/nofiles,nvars,4/),string)
    117179end if
     
    119181
    120182do i=0,nofiles-1
     183    print("Loading file...")
    121184    f             = addfile(workpath+file_in(i),"r")
    122185
    123186    varNames      = getfilevarnames(f)
    124     print("Loading file...")
    125187   
    126    
     188   
     189    if man then
    127190    print(" ")
    128191    print("The following variables were found in "+file_in(i)+":")
     
    136199
    137200    nvars = dimsizes(vars)
    138 
     201    end if; man
     202   
    139203    if (nofiles .eq. 1) then
     204    if man then
    140205    varString  = new((/nofiles,nvars/),string)
     206    end if; man
    141207    dimNames   = new((/nofiles,nvars,4/),string)
    142208    end if
     
    145211
    146212    do n=0,nvars-1
    147 
     213       if man then
    148214       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
    149220       
    150221       if (vars3d .ne. "") then
    151        vars3d       = vars3d + ":" + varNames(vars(n))
     222       vars3d       = vars3d + ":" + varString(i,n)
    152223       else
    153        vars3d       = varNames(vars(n))
     224       vars3d       = varString(i,n)
    154225       end if
    155226
     
    164235       z        = f->$dimNames(i,n,1)$
    165236       y        = f->$dimNames(i,n,2)$
    166        x        = f->$dimNames(i,n,3)$
     237       x            = f->$dimNames(i,n,3)$
    167238
    168239       if (z_min .ge. min(z)) then
     
    197268end do
    198269
    199 print(varString)
    200 
     270;print(varString)
     271
     272if man then
    201273delete(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
     274end if
     275
     276if 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
     284end if
     285
     286if (periodic) then
    207287   px           = 1
    208288   py           = 1
     
    214294print(" ")
    215295
    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
     296if 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
     303end if
     304
     305if (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
    220310end if
    221311
     
    238328end if
    239329
     330if man then
    240331print(" ")
    241332
     
    250341   t_end        = stringtointeger(systemfunc("read -p 'Type index of last time step: ' ts; echo $ts"))
    251342end 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
     343end if
     344
     345if (.not. man) then
     346    if (.not. spec_ts) then
     347           t_start      = 0
     348           t_end        = dimsizes(time)-1
     349    end if
     350end if
     351
     352if 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(" ")
    258362else
    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
     368end if
     369
     370       
    263371
    264372;*******************************************************************************
     
    313421
    314422;*******************************************************************************
    315 
     423if man then
    316424;**** Read more files and add them to VDF/VDC
    317425addmore = "y"
     
    448556   addmore       = systemfunc("read -p 'Add additional *.nc files? (y/n) ' RESP; echo $RESP")
    449557end do
    450 
     558end if; man
    451559;*******************************************************************************
    452560print("Done.")
Note: See TracChangeset for help on using the changeset viewer.