source: palm/trunk/SCRIPTS/palm_find_lowest_available_log_point_index @ 3994

Last change on this file since 3994 was 3027, checked in by knoop, 7 years ago

Added awesome lowest available log_piont index finder script

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#!/usr/bin/env bash
2#------------------------------------------------------------------------------#
3# This file is part of the PALM model system.
4#
5# PALM is free software: you can redistribute it and/or modify it under the terms
6# of the GNU General Public License as published by the Free Software Foundation,
7# either version 3 of the License, or (at your option) any later version.
8#
9# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# PALM. If not, see <http://www.gnu.org/licenses/>.
15#
16# Copyright 2018-2018  Leibniz Universitaet Hannover
17#------------------------------------------------------------------------------#
18#
19# Current revisions:
20# ------------------
21#
22#
23# Former revisions:
24# -----------------
25# $Id: palm_find_lowest_available_log_point_index 3027 2018-05-22 15:23:58Z suehring $
26# Initial revision
27#
28#------------------------------------------------------------------------------#
29# palm_find_lowest_available_log_point_index does what its name indicates
30#------------------------------------------------------------------------------#
31SOURCE="${BASH_SOURCE[0]}"
32while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
33  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
34  SOURCE="$(readlink "$SOURCE")"
35  # if $SOURCE was a relative symlink, we need to resolve it
36  # relative to the path where the symlink file was located
37  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
38done
39SCRIPT_LOCATION="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
40
41working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../")
42trunk_dir=$(readlink -f "${SCRIPT_LOCATION}/../")
43
44contains() {
45    [[ ${1} =~ (^|[[:space:]])${2}($|[[:space:]]) ]] && return 0 || return 1
46}
47
48all_found_log_point=$(grep -P "CALL +cpu_log\( +log_point\(" ${trunk_dir}/SOURCE/* \
49      | grep -oP "(?<!\d)\d+(?!\d)" | sort -n | uniq \
50      | grep -oP "(?<!\d)\d+(?!\d)")
51
52log_point_size=$(grep -oP "TYPE\(logpoint\), DIMENSION\(\d+\) ::  log_point =" \
53      ${trunk_dir}/SOURCE/cpulog_mod.f90 \
54      | grep -oP "(?<!\d)\d+(?!\d)")
55
56for n in $(seq 1 ${log_point_size}) ; do
57   if ! contains "$all_found_log_point" "$n"; then
58     echo "log_point($n)   is the lowest available log_point   index."
59     break
60   fi
61   if [[ ${n} -ge ${log_point_size} ]]; then
62      echo "ERROR: array log_point (size: ${log_point_size}) is full. " \
63           "Please increase its size in file \"cpulog_mod.f90\"."
64   fi
65done
66
67
68all_found_log_point_s=$(grep -P "CALL +cpu_log\( +log_point_s\(" ${trunk_dir}/SOURCE/* \
69      | grep -oP "(?<!\d)\d+(?!\d)" | sort -n | uniq \
70      | grep -oP "(?<!\d)\d+(?!\d)")
71
72log_point_s_size=$(grep -oP "TYPE\(logpoint\), DIMENSION\(\d+\) ::  log_point_s =" \
73      ${trunk_dir}/SOURCE/cpulog_mod.f90 \
74      | grep -oP "(?<!\d)\d+(?!\d)")
75
76for n in $(seq 1 ${log_point_s_size}) ; do
77   if ! contains "$all_found_log_point_s" "$n"; then
78     echo "log_point_s($n) is the lowest available log_point_s index."
79     break
80   fi
81   if [[ ${n} -ge ${log_point_s_size} ]]; then
82      echo "ERROR: array log_point_s (size: ${log_point_s_size}) is full. " \
83           "Please increase its size in file \"cpulog_mod.f90\"."
84   fi
85done
Note: See TracBrowser for help on using the repository browser.