@@ -433,7 +433,7 @@ This was commented hdu stuff
433
433
/*
434
434
tirific.dc1
435
435
436
- Program: TIRIFIC (Version 2.3.7 )
436
+ Program: TIRIFIC (Version 2.3.8 )
437
437
438
438
Purpose: Fit a tilted-ring model to a datacube
439
439
@@ -1049,6 +1049,9 @@ typedef struct startinf
1049
1049
/** @brief Indicator if this is the first run or a consecutive one */
1050
1050
int firstrun;
1051
1051
1052
+ /** @brief Indicator of the restartid */
1053
+ int restartid;
1054
+
1052
1055
/** @brief time stamp for file */
1053
1056
time_t timestamp;
1054
1057
@@ -6338,7 +6341,7 @@ int main(int argc, char *argv[])
6338
6341
6339
6342
printf("\n");
6340
6343
printf("####################\n");
6341
- printf("# TIRIFIC v. 2.3.7 #\n");
6344
+ printf("# TiRiFiC v. 2.3.8 #\n");
6342
6345
printf("####################\n");
6343
6346
printf("\n");
6344
6347
@@ -6843,8 +6846,8 @@ static startinf *create_startinf(void)
6843
6846
/* First set all pointers to 0 and initialise some pointers */
6844
6847
startinfv -> arel = NULL;
6845
6848
startinfv -> restartname = NULL;
6849
+ startinfv -> restartid = 0;
6846
6850
startinfv -> firstrun = 1;
6847
- startinfv -> restartname = NULL;
6848
6851
/* if (!(startinfv -> restartname = getfcharray(200, NULL))) */
6849
6852
/* goto error; */
6850
6853
if (!((startinfv -> filestat) = (struct stat *) malloc(sizeof(struct stat)))) {
@@ -6904,7 +6907,9 @@ static startinf *get_startinf(int argc, char **argv)
6904
6907
char *buffer = NULL;
6905
6908
int nread, nreturned;
6906
6909
char *returnedc;
6907
- int *prompt;
6910
+ int *prompt, *restartid;
6911
+ int restartdef = 0;
6912
+ int defrestartdef = 0;
6908
6913
int promptdef = 0;
6909
6914
int keypres;
6910
6915
char **varystr = NULL;
@@ -6948,10 +6953,19 @@ static startinf *get_startinf(int argc, char **argv)
6948
6953
if (!(startinfv -> arel = simparse_scn_arel_insert(NULL, "Command line", buffer, NULL)))
6949
6954
goto error;
6950
6955
6956
+ /* An input of restartid != 0 on the command line is an error */
6957
+ if (simparse_scn_arel_readval_int(startinfv -> arel, "RESTARTID", "ID of restart process [0]", 1, &restartdef, 1, 1, 0, 0, &keypres, &nread, &nreturned, &restartid))
6958
+ goto error;
6959
+
6960
+ if (*restartid) {
6961
+ fprintf(stderr, "Error: cannot define RESTARTID=%i, other than RESTARTID=0 on command line.\n(Would lead to an endless loop.)\n", *restartid);
6962
+ goto error;
6963
+ }
6964
+
6951
6965
/* Read out the file name */
6952
6966
if (simparse_scn_arel_readval_string(startinfv -> arel, "DEFFILE", "Provide default file name (default: no file).", 0, NULL, 0, -1, 0, 0, &keypres, &nread, &nreturned, &returnedc))
6953
6967
goto error;
6954
-
6968
+
6955
6969
if ((returnedc[0]))
6956
6970
printf("Using default file with name: %s\n", returnedc);
6957
6971
@@ -7002,7 +7016,10 @@ static startinf *get_startinf(int argc, char **argv)
7002
7016
freeparsed(varystr);
7003
7017
varystr = NULL;
7004
7018
7005
-
7019
+ if (simparse_scn_arel_readval_int(startinfv -> arel, "RESTARTID", "ID of restart process [0]", 1, &restartdef, 1, 1, 0, 0, &keypres, &nread, &nreturned, &restartid))
7020
+ goto error;
7021
+ startinfv -> restartid = *restartid;
7022
+
7006
7023
/* The startfile */
7007
7024
/* sprintf(mes, "Give restartfile name."); */
7008
7025
/* for (i = 0; i < 200; ++i) */
@@ -7016,13 +7033,14 @@ static startinf *get_startinf(int argc, char **argv)
7016
7033
7017
7034
free(buffer);
7018
7035
7019
- return startinfv;
7036
+ return startinfv;
7020
7037
7021
7038
error:
7022
7039
if ((startinfv)) {
7023
7040
/* Stop the logfile io, also put ndisks = 1, is irrelevant */
7024
7041
destroy_startinf(startinfv);
7025
7042
}
7043
+
7026
7044
if ((buffer))
7027
7045
free(buffer);
7028
7046
if ((startinfv -> arel))
@@ -7093,9 +7111,11 @@ static int loop_restart(startinf *startinfv)
7093
7111
/* char mes[81]; */
7094
7112
/* int def, nel, i; */
7095
7113
char **varystr = NULL;
7114
+ int *restartid;
7115
+ int restartdef = 0;
7096
7116
int keypres, nread, nreturned;
7097
7117
simparse_scn_keyvalli **keyvallifile;
7098
-
7118
+
7099
7119
/* If the function is called, this should be done */
7100
7120
startinfv -> firstrun = 0;
7101
7121
@@ -7104,38 +7124,57 @@ static int loop_restart(startinf *startinfv)
7104
7124
7105
7125
/* Check if file information can be acquired and fill stuff */
7106
7126
if (stat(startinfv -> restartname, startinfv -> filestat)) {
7127
+
7128
+ /* Notice that tirific will not wait until the restartfile is created */
7107
7129
return 0;
7108
7130
}
7109
7131
else {
7110
- fflush(NULL);
7111
- printf("Waiting for file %s to change.\n", startinfv -> restartname);
7112
-
7132
+ fflush(NULL);
7133
+ printf("Waiting for file %s to change", startinfv -> restartname);
7134
+ if (startinfv -> restartid) {
7135
+ if ((keyvallifile = simparse_scn_keyvallilist_gfrfi(startinfv -> arel[2] -> orifilename))) {
7136
+ printf(" and RESTARTID= %i to change in %s.\n", startinfv -> restartid, startinfv -> arel[2] -> orifilename);
7137
+ }
7138
+ }
7139
+ else {
7140
+ printf(".\n");
7141
+ }
7113
7142
7114
7143
/* Run a loop until the timestamps are the same or the file becomes unreadable */
7115
7144
while (startinfv -> timestamp >= startinfv -> filestat -> st_mtime) {
7116
7145
if (stat(startinfv -> restartname, startinfv -> filestat)) {
7117
7146
break;
7118
7147
}
7119
7148
}
7149
+ printf("File %s has changed.", startinfv -> restartname);
7120
7150
7121
7151
/* Now refresh the input name and read it in again (not sure if this works or if the .def file has to be reread into some buffer before */
7122
7152
/* Changed this here */
7123
7153
cancel_tir(startinfv -> arel, "RESTARTNAME=", 1);
7154
+
7155
+ /* Just make sure that the file is re-read */
7124
7156
7125
- /* Just make sure that the file is re-read */
7126
- if (startinfv -> arel && startinfv -> arel[1] && startinfv -> arel[2]) {
7127
- if ((keyvallifile = simparse_scn_keyvallilist_gfrfi(startinfv -> arel[2] -> orifilename))) {
7128
- simparse_scn_keyvallilist_dest(startinfv -> arel[2] -> keyvallifile);
7129
- startinfv -> arel[2] -> keyvallifile = keyvallifile;
7130
- }
7131
- else {
7132
- simparse_scn_arel_timestamp_early(startinfv -> arel[2]);
7133
- }
7134
- }
7135
-
7157
+ /* This may add an extra layer of security of sync */
7158
+ do {
7159
+ if (startinfv -> arel && startinfv -> arel[1] && startinfv -> arel[2]) {
7160
+ if ((keyvallifile = simparse_scn_keyvallilist_gfrfi(startinfv -> arel[2] -> orifilename))) {
7161
+ simparse_scn_keyvallilist_dest(startinfv -> arel[2] -> keyvallifile);
7162
+ startinfv -> arel[2] -> keyvallifile = keyvallifile;
7163
+ }
7164
+ else {
7165
+ simparse_scn_arel_timestamp_early(startinfv -> arel[2]);
7166
+ }
7167
+ }
7168
+ if (simparse_scn_arel_readval_int(startinfv -> arel, "RESTARTID=", "ID of restart process [0]", 1, &startinfv -> restartid, 1, 1, 0, 0, &keypres, &nread, &nreturned, &restartid))
7169
+ /* if (simparse_scn_arel_readval_int(startinfv -> arel, "RESTARTID=", "ID of restart process [0]", 1, &restartdef, 1, 1, 0, 0, &keypres, &nread, &nreturned, &restartid))*/
7170
+ goto error;
7171
+ } while ((*restartid == startinfv -> restartid) && (startinfv -> restartid != 0));
7172
+
7173
+ startinfv -> restartid = *restartid;
7174
+
7136
7175
if ((startinfv -> restartname)) {
7137
- free(startinfv -> restartname);
7138
- startinfv -> restartname = NULL;
7176
+ free(startinfv -> restartname);
7177
+ startinfv -> restartname = NULL;
7139
7178
}
7140
7179
7141
7180
/* sprintf(mes, "Give restartfile name."); */
@@ -7437,11 +7476,11 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7437
7476
7438
7477
if (!startinfv -> firstrun)
7439
7478
return loginfv;
7440
-
7479
+
7441
7480
/* Try to allocate */
7442
7481
if (!(log = create_loginf()))
7443
7482
goto error;
7444
-
7483
+
7445
7484
#ifdef OPENMPTIR
7446
7485
/* The very first thing to do is to ask for the number of cores */
7447
7486
log -> ncores = 1;
@@ -7460,7 +7499,7 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7460
7499
#else
7461
7500
log -> ncores = 1;
7462
7501
#endif
7463
-
7502
+
7464
7503
/* First thing to do is the logfile and the text logfile */
7465
7504
7466
7505
/* The logfile */
@@ -7479,7 +7518,7 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7479
7518
7480
7519
/* This puts an \0 to the end of the text */
7481
7520
/* termsinglestr(log -> logname); */
7482
-
7521
+
7483
7522
/* The text logfile */
7484
7523
if (simparse_scn_arel_readval_string(startinfv -> arel, "TEXTLOG", "Provide text logfile name (default: no file).", 0, "", 0, -1, 0, 0, &keypres, &nread, &nreturned, &(log -> textlog)))
7485
7524
goto error;
@@ -7513,11 +7552,10 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7513
7552
/* termsinglestr(log -> progresslog); */
7514
7553
/* Kamphuis addition end */
7515
7554
7516
-
7517
7555
/* The result name */
7518
7556
if (simparse_scn_arel_readval_string(startinfv -> arel, "TABLE", "Give output table name (default: no file).", 0, "", 0, -1, 0, 0, &keypres, &nread, &nreturned, &(log -> table)))
7519
7557
goto error;
7520
-
7558
+
7521
7559
/* for (i = 0; i < 200; ++i) */
7522
7560
/* log -> table[i] = ' '; */
7523
7561
/* log -> table[200] = '\0'; */
@@ -7537,7 +7575,6 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7537
7575
log -> distance = 10;
7538
7576
def = 2;
7539
7577
7540
-
7541
7578
sprintf(mes,"Distance in Mpc [10]");
7542
7579
nel = 1;
7543
7580
userdble_tir(startinfv -> arel, &log -> distance, &nel, &def, "DISTANCE=", mes);
@@ -7549,7 +7586,7 @@ static loginf *get_loginf(startinf *startinfv, loginf *loginfv)
7549
7586
}
7550
7587
7551
7588
return log;
7552
-
7589
+
7553
7590
error:
7554
7591
if ((log)) {
7555
7592
/* Stop the logfile io, also put ndisks = 1, is irrelevant */
@@ -15597,6 +15634,13 @@ static int putgenresults(startinf *startinfv, loginf *log, hdrinf *hdr, ringparm
15597
15634
anyout_tir(&dev, mes);
15598
15635
15599
15636
/* New Kamphuis */
15637
+ if (startinfv -> restartid) {
15638
+ length = strlen(mes);
15639
+ sprintf(mes+length,
15640
+ " R:%i ", /* current restart-id */
15641
+ startinfv -> restartid /* size */
15642
+ );
15643
+ }
15600
15644
progressout(startinfv, mes);
15601
15645
15602
15646
/* error source ? */
@@ -17671,7 +17715,9 @@ static int progressout(startinf *startinfv, char *message)
17671
17715
fprintf(stream,"%s",message);
17672
17716
fprintf(stream, "\n");
17673
17717
/* and close again otherwise the file stays unreadable */
17674
- fclose(stream);
17718
+ fflush(stream);
17719
+ fclose(stream);
17720
+ fflush(NULL);
17675
17721
}
17676
17722
17677
17723
if ((progname))
0 commit comments