(RESOLVED) BASH scripts for automation

All topics related to compiling WRF, including environment set-up, and library installation
Post Reply
Whatheway
Posts: 15
Joined: Thu Oct 29, 2020 9:47 am

(RESOLVED) BASH scripts for automation

Post by Whatheway » Fri Mar 12, 2021 12:22 am

Good evening everyone,

I am following a tutorial online for setting up the WPS/WRF and I would like to automate the process some in a script.
I am trying to write a IF/ELSE statement that will look at the UTC time on my desktop and round down to the nearest run.

This is what I have come up with but I can't see to get it to run.

Any help would be great!

#!/bin/bash

UTC_TIME= if [`date +%H -u` -ge 0] && [`date +%H -u` -lt 5]
then UTC_TIME=0
elif [`date +%H -u` -ge 6] && [`date +%H -u` -lt 11]
then UTC_TIME=6
elif [`date +%H -u` -ge 12] && [`date +%H -u` -lt 17]
then UTC_TIME=12
else [`date +%H -u` -ge 18] && [`date +%H -u` -lt 23]
UTC_TIME=18
fi

echo $UTC_TIME

kwerner
Posts: 2287
Joined: Wed Feb 14, 2018 9:21 pm

Re: BASH scripts for automation

Post by kwerner » Mon Mar 15, 2021 5:12 pm

Hi,
Unfortunately the wrf support team does not have the resources to support scripting that isn't part of the WRF code, but hopefully someone in the community will be able to provide some tips!
NCAR/MMM

Whatheway
Posts: 15
Joined: Thu Oct 29, 2020 9:47 am

Re: BASH scripts for automation

Post by Whatheway » Mon Mar 15, 2021 10:38 pm

RESOLVED:

hour=`date +%H -u`

if [[ $hour -ge 00 && $hour -le 05 ]]; then
STARTHOUR=00
fi

if [[ $hour -ge 06 && $hour -le 11 ]]; then
STARTHOUR=06
fi

if [[ $hour -ge 12 && $hour -le 17 ]]; then
STARTHOUR=12
fi

if [[ $hour -ge 18 && $hour -le 23 ]]; then
STARTHOUR=18
fi

kwerner
Posts: 2287
Joined: Wed Feb 14, 2018 9:21 pm

Re: BASH scripts for automation

Post by kwerner » Thu Mar 18, 2021 7:13 pm

Thank you for updating this - hopefully it will help out someone else in the future!
NCAR/MMM

Post Reply

Return to “WRF Compiling/Installation”