forked from elizakempton/Exo_Transmit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getNTau.c
70 lines (52 loc) · 1.92 KB
/
getNTau.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* This file is part of Exo_Transmit.
Exo_Transmit is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Exo_Transmit is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Exo_Transmit. If not, see <http://www.gnu.org/licenses/>.
*/
/*-------------------------- getNTau.c ---------------------------
Author: Patrick Slough ([email protected])
------------------------------------------------------------------ */
/* Determines how many layers of the T-P profile lie above the
pressure of the cloud layer specified in userInput.in
------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vars.h"
void getNTau(vars *variables, char *filename){
if(variables->THRESHOLD != 0){
char dum[7];
int NTau = 0;
int i = 0;
double pressure[variables->NTAU];
int index[variables->NTAU];
double threshold = variables->THRESHOLD;
printf("Cloud layer at %lf pa\n", threshold);
FILE *file = fopen(filename, "r");
if(file){
fscanf(file, "%s %s %s", dum, dum, dum);
while(fscanf(file, "%d %lf %*lf", &index[i], &pressure[i]) != EOF){
if(pressure[i] < threshold)
NTau++;
i++;
}
NTau++;
}
else{
printf("Error reading File\n");
exit(1);
}
fclose(file);
variables->NTAU = NTau;
}
else
printf("No Cloud layer will be calculated\n");
}
/* -------- end ----------------- GetNTau ------------------------ */