forked from metno/NORTRIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNORTRIP_inputparams_subroutines.f90
1028 lines (920 loc) · 54.2 KB
/
NORTRIP_inputparams_subroutines.f90
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!NORTRIP_inputparams_subroutines.f90
!----------------------------------------------------------------------
subroutine read_NORTRIP_parameters
use NORTRIP_definitions
implicit none
character(256) temp_path
character(256) temp_file
character(256) temp_name
character(256) temp_str,temp_str1,temp_str2,temp_str3
character(256) read_str(2)
integer unit_in,unit_logfile_temp
integer index_val,index_temp
logical exists
real include_track_temp,f_track_temp(10)
!Functions
character(256) match_string_char
real read_string_val
real match_string_val
unit_in=unit_read_NORTRIP_parameters
unit_logfile_temp=unit_logfile !use -1 not to write anything, 0 to go to screen
!Open pathname file for reading
temp_name=trim(path_inputparam)//trim(filename_inputparam)//'_params.txt'
inquire(file=temp_name,exist=exists)
if (.not.exists) then
write(unit_logfile_temp,*)'ERROR: '//trim(temp_name)//' does not exist.'
return
endif
open(unit_in,file=temp_name,access='sequential',status='old',readonly)
!Open log file
!write(*,*) 'LOG NAME:',trim(filename_log)
if (unit_logfile.gt.0) then
open(unit_logfile,file=filename_log,status='old',position='append')
endif
write(unit_logfile_temp,'(A)') '================================================================'
write(unit_logfile_temp,'(A)') 'Reading model parameters (read_NORTRIP_parameters)'
write(unit_logfile_temp,'(A)') '================================================================'
!Read wear parameters
do s=1,num_wear
temp_str=''
temp_str1=''
if (s.eq.road_index) then
temp_str1='Road wear'
elseif (s.eq.tyre_index) then
temp_str1='Tyre wear'
elseif (s.eq.brake_index) then
temp_str1='Brake wear'
endif
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
!write(unit_logfile,*) trim(temp_str)
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !Skip line
call read_line_val3(unit_in,unit_logfile,W_0(s,st,he),W_0(s,wi,he),W_0(s,su,he))
call read_line_val3(unit_in,unit_logfile,W_0(s,st,li),W_0(s,wi,li),W_0(s,su,li))
read(unit_in,*,ERR=10) temp_str !Skip line
call read_line_val5(unit_in,unit_logfile,a_wear(s,1),a_wear(s,2),a_wear(s,3),a_wear(s,4),a_wear(s,5))
enddo
!Snow depth wear threshold
rewind(unit_in)
temp_str=''
temp_str1='Snow depth wear threshold'
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
!write(unit_logfile,*) trim(temp_str)
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !Skip line
call read_line_val1(unit_in,unit_logfile,s_roadwear_thresh)
!Pavement type scaling factor
rewind(unit_in)
temp_str=''
temp_str1='Pavement type scaling factor'
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
call read_line_int1(unit_in,unit_logfile,num_pave)
read(unit_in,*,ERR=10) temp_str !Skip line
do s=1,num_pave
read(unit_in,'(a)',end=10) temp_str
index_val=index(temp_str,achar(9))
temp_str1=temp_str(1:index_val-1)
read(temp_str1,*) index_temp
temp_str=temp_str(index_val+1:)
index_val=index(temp_str,achar(9))
temp_str2=temp_str(1:index_val-1)
temp_str3=temp_str(index_val+1:)
read(temp_str3,*) h_pave(s)
write(unit_logfile,'(I2,A38,A3,e10.2)') index_temp,trim(temp_str2),' = ',h_pave(s)
enddo
!Driving cycle scaling factor
rewind(unit_in)
temp_str=''
temp_str1='Driving cycle scaling factor'
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
call read_line_int1(unit_in,unit_logfile,num_dc)
read(unit_in,*,ERR=10) temp_str !Skip line
do s=1,num_dc
read(unit_in,'(a)',end=10) temp_str
index_val=index(temp_str,achar(9))
temp_str1=temp_str(1:index_val-1)
read(temp_str1,*) index_temp
temp_str=temp_str(index_val+1:)
index_val=index(temp_str,achar(9))
temp_str2=temp_str(1:index_val-1)
temp_str3=temp_str(index_val+1:)
read(temp_str3,*) h_drivingcycle(s)
write(unit_logfile,'(I2,A38,A3,e10.2)') index_temp,trim(temp_str2),' = ',h_drivingcycle(s)
enddo
!Suspension scaling factors
rewind(unit_in)
temp_str=''
temp_str1='Suspension scaling factors'
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
do s=1,num_source
call read_line_val4(unit_in,unit_logfile,h_0_sus(s,pm_all),h_0_sus(s,pm_200),h_0_sus(s,pm_10),h_0_sus(s,pm_25))
enddo
call read_line_val4(unit_in,unit_logfile,h_0_q_road(pm_all),h_0_q_road(pm_200),h_0_q_road(pm_10),h_0_q_road(pm_25))
!Road suspension
temp_str=''
temp_str1='Road suspension'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,f_0_suspension(1,1,st,he),f_0_suspension(1,1,wi,he),f_0_suspension(1,1,su,he))
call read_line_val3(unit_in,unit_logfile,f_0_suspension(1,1,st,li),f_0_suspension(1,1,wi,li),f_0_suspension(1,1,su,li))
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val5(unit_in,unit_logfile,a_sus(1),a_sus(2),a_sus(3),a_sus(4),a_sus(5))
do s=1,num_source
do x=1,num_size
do t=1,num_tyre
do v=1,num_veh
f_0_suspension(s,x,t,v)=f_0_suspension(1,1,t,v)*h_0_sus(s,x)
enddo
enddo
enddo
enddo
!Abrasion factor
temp_str=''
temp_str1='Abrasion factor'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,f_0_abrasion(st,he),f_0_abrasion(wi,he),f_0_abrasion(su,he))
call read_line_val3(unit_in,unit_logfile,f_0_abrasion(st,li),f_0_abrasion(wi,li),f_0_abrasion(su,li))
call read_line_val1(unit_in,unit_logfile,V_ref_abrasion)
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val4(unit_in,unit_logfile,h_0_abrasion(pm_all),h_0_abrasion(pm_200),h_0_abrasion(pm_10),h_0_abrasion(pm_25))
!Crushing factor
temp_str=''
temp_str1='Crushing factor'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,f_0_crushing(st,he),f_0_crushing(wi,he),f_0_crushing(su,he))
call read_line_val3(unit_in,unit_logfile,f_0_crushing(st,li),f_0_crushing(wi,li),f_0_crushing(su,li))
call read_line_val1(unit_in,unit_logfile,V_ref_crushing)
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val4(unit_in,unit_logfile,h_0_crushing(pm_all),h_0_crushing(pm_200),h_0_crushing(pm_10),h_0_crushing(pm_25))
!Sources participating in abrasion and crushing
temp_str=''
temp_str1='Sources participating in abrasion and crushing'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
do s=1,num_source
call read_line_val2(unit_in,unit_logfile,p_0_abrasion(s),p_0_crushing(s))
enddo
!Direct emission factor
temp_str=''
temp_str1='Direct emission factor'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
do s=1,num_wear
call read_line_val1(unit_in,unit_logfile,f_0_dir(s))
enddo
call read_line_val1(unit_in,unit_logfile,f_0_dir(crushing_index))
call read_line_val1(unit_in,unit_logfile,f_0_dir(abrasion_index))
call read_line_val1(unit_in,unit_logfile,f_0_dir(exhaust_index))
!Fractional size distribution emissions
temp_str=''
temp_str1='Fractional size distribution'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
do s=1,num_source
call read_line_val4(unit_in,unit_logfile,f_PM(s,pm_all,1),f_PM(s,pm_200,1),f_PM(s,pm_10,1),f_PM(s,pm_25,1))
do t=1,num_tyre
f_PM(s,:,t)=f_PM(s,:,1)
enddo
enddo
s=crushing_index
call read_line_val4(unit_in,unit_logfile,f_PM(s,pm_all,1),f_PM(s,pm_200,1),f_PM(s,pm_10,1),f_PM(s,pm_25,1))
s=abrasion_index
call read_line_val4(unit_in,unit_logfile,f_PM(s,pm_all,1),f_PM(s,pm_200,1),f_PM(s,pm_10,1),f_PM(s,pm_25,1))
do t=1,num_tyre
f_PM(abrasion_index,:,t)=f_PM(abrasion_index,:,1)
f_PM(crushing_index,:,t)=f_PM(crushing_index,:,1)
enddo
!Create the binned size distribution
f_PM_bin=f_PM
do x=1,num_size
if (x.eq.num_size) then
f_PM_bin(1:num_source,x,1:num_tyre)=f_PM(1:num_source,x,1:num_tyre)
f_PM_bin(crushing_index,x,1:num_tyre)=f_PM(crushing_index,x,1:num_tyre)
f_PM_bin(abrasion_index,x,1:num_tyre)=f_PM(abrasion_index,x,1:num_tyre)
else
f_PM_bin(1:num_source,x,1:num_tyre)=f_PM(1:num_source,x,1:num_tyre)-f_PM(1:num_source,x+1,1:num_tyre)
f_PM_bin(crushing_index,x,1:num_tyre)=f_PM(crushing_index,x,1:num_tyre)-f_PM(crushing_index,x+1,1:num_tyre)
f_PM_bin(abrasion_index,x,1:num_tyre)=f_PM(abrasion_index,x,1:num_tyre)-f_PM(abrasion_index,x+1,1:num_tyre)
endif
enddo
call read_line_val1(unit_in,unit_logfile,V_ref_pm_fraction)
call read_line_val1(unit_in,unit_logfile,c_pm_fraction)
!Wind blown dust emission factors
temp_str=''
temp_str1='Wind blown dust emission factors'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val1(unit_in,unit_logfile,tau_wind)
call read_line_val1(unit_in,unit_logfile,FF_thresh)
!Activity factors
temp_str=''
temp_str1='Activity efficiency factors'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
i=ploughing_eff_index
call read_line_val4(unit_in,unit_logfile,h_eff(i,1,pm_all),h_eff(i,1,pm_200),h_eff(i,1,pm_10),h_eff(i,1,pm_25))
i=cleaning_eff_index
call read_line_val4(unit_in,unit_logfile,h_eff(i,1,pm_all),h_eff(i,1,pm_200),h_eff(i,1,pm_10),h_eff(i,1,pm_25))
i=drainage_eff_index
call read_line_val4(unit_in,unit_logfile,h_eff(i,1,pm_all),h_eff(i,1,pm_200),h_eff(i,1,pm_10),h_eff(i,1,pm_25))
i=spraying_eff_index
call read_line_val4(unit_in,unit_logfile,h_eff(i,1,pm_all),h_eff(i,1,pm_200),h_eff(i,1,pm_10),h_eff(i,1,pm_25))
do x=1,num_size
i=ploughing_eff_index
h_eff(i,dust_index,x)=h_eff(i,1,x)
i=cleaning_eff_index
h_eff(i,dust_index,x)=h_eff(i,1,x)
i=drainage_eff_index
h_eff(i,dust_index,x)=h_eff(i,1,x)
i=spraying_eff_index
h_eff(i,dust_index,x)=h_eff(i,1,x)
enddo
!Salt efficiency factors
read(unit_in,*,ERR=10) temp_str !skip line
i=ploughing_eff_index
call read_line_val2(unit_in,unit_logfile,h_eff(i,salt_index(1),pm_all),h_eff(i,salt_index(2),pm_all))
i=cleaning_eff_index
call read_line_val2(unit_in,unit_logfile,h_eff(i,salt_index(1),pm_all),h_eff(i,salt_index(2),pm_all))
i=drainage_eff_index
call read_line_val2(unit_in,unit_logfile,h_eff(i,salt_index(1),pm_all),h_eff(i,salt_index(2),pm_all))
i=spraying_eff_index
call read_line_val2(unit_in,unit_logfile,h_eff(i,salt_index(1),pm_all),h_eff(i,salt_index(2),pm_all))
do x=1,num_size
i=ploughing_eff_index
h_eff(i,salt_index,x)=h_eff(i,salt_index,pm_all)
i=cleaning_eff_index
h_eff(i,salt_index,x)=h_eff(i,salt_index,pm_all)
i=drainage_eff_index
h_eff(i,salt_index,x)=h_eff(i,salt_index,pm_all)
i=spraying_eff_index
h_eff(i,salt_index,x)=h_eff(i,salt_index,pm_all)
enddo
!Deposition velocity
temp_str=''
temp_str1='Deposition velocity'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,w_dep(pm_200),w_dep(pm_10),w_dep(pm_25))
!Concentration conversion limit values
temp_str=''
temp_str1='Concentration conversion limit values'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val1(unit_in,unit_logfile,conc_min)
call read_line_val1(unit_in,unit_logfile,emis_min)
!Spray and splash factors
temp_str=''
temp_str1='Spray and splash factors'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,R_0_spray(he,water_index),R_0_spray(he,snow_index),R_0_spray(he,ice_index))
call read_line_val3(unit_in,unit_logfile,R_0_spray(li,water_index),R_0_spray(li,snow_index),R_0_spray(li,ice_index))
call read_line_val3(unit_in,unit_logfile,V_ref_spray(water_index),V_ref_spray(snow_index),V_ref_spray(ice_index))
call read_line_val3(unit_in,unit_logfile,g_road_sprayable_min(water_index),g_road_sprayable_min(snow_index),g_road_sprayable_min(ice_index))
call read_line_val3(unit_in,unit_logfile,a_spray(water_index),a_spray(snow_index),a_spray(ice_index))
call read_line_val3(unit_in,unit_logfile,V_thresh_spray(water_index),V_thresh_spray(snow_index),V_thresh_spray(ice_index))
!Drainage parameters
temp_str=''
temp_str1='Drainage parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val2(unit_in,unit_logfile,g_road_drainable_min,g_road_drainable_thresh)
call read_line_val1(unit_in,unit_logfile,snow_dust_drainage_retainment_limit)
call read_line_val1(unit_in,unit_logfile,tau_road_drainage)
!Ploughing parameters
temp_str=''
temp_str1='Ploughing parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip line
call read_line_val3(unit_in,unit_logfile,h_ploughing_moisture(water_index),h_ploughing_moisture(snow_index),h_ploughing_moisture(ice_index))
call read_line_val3(unit_in,unit_logfile,ploughing_thresh(water_index),ploughing_thresh(snow_index),ploughing_thresh(ice_index))
!temp_str=''
!temp_str1='Ploughing minimum parameters'
!rewind(unit_in)
!do while (index(temp_str,trim(temp_str1)).eq.0)
! read(unit_in,'(a)',ERR=10) temp_str
!end do
!write(unit_logfile,'(A)') '----------------------------------------------------------------'
!write(unit_logfile,'(A)') trim(temp_str)
!write(unit_logfile,'(A)') '----------------------------------------------------------------'
!call read_line_val3(unit_in,unit_logfile,ploughing_min_thresh(water_index),ploughing_min_thresh(snow_index),ploughing_min_thresh(ice_index))
!Energy balance parameters
temp_str=''
temp_str1='Energy balance parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip
call read_line_val1(unit_in,unit_logfile,g_road_evaporation_thresh)
!call read_line_val1(unit_in,unit_logfile,z0)
call read_line_val1or3(unit_in,unit_logfile,z0m_in,z0t_in,z0q_in)
!write(*,*) z0m_in,z0t_in,z0q_in
!stop
z0=z0m_in/1000. !Convert from mm to m
if (z0t_in.eq.0) then
z0t=z0/10. !Default
else
z0t=z0t_in/1000.
endif
if (z0q_in.eq.0) then
z0q=z0/10. !Default
else
z0q=z0q_in/1000.
endif
call read_line_val1(unit_in,unit_logfile,albedo_snow)
call read_line_val1(unit_in,unit_logfile,dzs)
call read_line_val1(unit_in,unit_logfile,sub_surf_average_time)
read(unit_in,*,ERR=10) temp_str !skip
call read_line_val3(unit_in,unit_logfile,sub_surf_param(1),sub_surf_param(2),sub_surf_param(3))
read(unit_in,*,ERR=10) temp_str !skip
call read_line_val2(unit_in,unit_logfile,a_traffic(he),a_traffic(li))
call read_line_val2(unit_in,unit_logfile,H_veh(he),H_veh(li))
!Retention parameters
temp_str=''
temp_str1='Retention parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip
call read_line_val3(unit_in,unit_logfile,g_retention_thresh(road_index),g_retention_thresh(brake_index),g_retention_thresh(salt_index(2)))
call read_line_val3(unit_in,unit_logfile,g_retention_min(road_index),g_retention_min(brake_index),g_retention_min(salt_index(2)))
!Surface texture scaling parameters
temp_str=''
temp_str1='Surface texture parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip
do i=1,5
call read_line_val1(unit_in,unit_logfile,texture_scaling(i))
enddo
!Rescale these parameters
g_road_drainable_min=g_road_drainable_min*texture_scaling(1)
f_0_suspension=f_0_suspension*texture_scaling(2)
R_0_spray=R_0_spray*texture_scaling(3)
h_eff(drainage_eff_index,dust_index,:)=h_eff(drainage_eff_index,dust_index,:)*texture_scaling(4)
h_eff(spraying_eff_index,dust_index,:)=h_eff(spraying_eff_index,dust_index,:)*texture_scaling(5)
!Road track parameters
temp_str=''
temp_str1='Road track parameters'
rewind(unit_in)
do while (index(temp_str,trim(temp_str1)).eq.0)
read(unit_in,'(a)',ERR=10) temp_str
end do
write(unit_logfile,'(A)') '----------------------------------------------------------------'
write(unit_logfile,'(A)') trim(temp_str)
write(unit_logfile,'(A)') '----------------------------------------------------------------'
read(unit_in,*,ERR=10) temp_str !skip
num_track=0
do i=1,num_track_max
!Must be in this order (alltrack_type,outtrack_type,intrack_type,shoulder_type,kerb_type)
call read_line_val4(unit_in,unit_logfile,include_track_temp,f_track_temp(1),f_track_temp(2),f_track_temp(3))
if (include_track_temp.gt.0) then
num_track=num_track+1
f_track(num_track)=f_track_temp(1)
veh_track(num_track)=f_track_temp(2)
mig_track(num_track)=f_track_temp(3)
track_type(num_track)=i
endif
enddo
close(unit_in,status='keep')
return
10 close(unit_in,status='keep')
end subroutine read_NORTRIP_parameters
!----------------------------------------------------------------------
!----------------------------------------------------------------------
subroutine read_NORTRIP_flags
use NORTRIP_definitions
implicit none
character(256) temp_name
integer unit_in,unit_logfile_temp
logical exists
integer read_zip_file_temp,use_single_road_loop_temp
!Functions
integer match_string_int
real match_string_val
unit_in=unit_read_NORTRIP_flags
unit_logfile_temp=unit_logfile !use -1 not to write anything, 0 to go to screen
!Open pathname file for reading
temp_name=trim(path_inputparam)//trim(filename_inputparam)//'_flags.txt'
inquire(file=temp_name,exist=exists)
if (.not.exists) then
write(unit_logfile_temp,*)'ERROR: '//trim(temp_name)//' does not exist. Using default flags'
return
endif
open(unit_in,file=temp_name,access='sequential',status='old',readonly)
!Open log file
!if (unit_logfile.gt.0) then
! open(unit_logfile,file=filename_log,status='old',position='append')
!endif
write(unit_logfile_temp,'(A)') '================================================================'
write(unit_logfile_temp,'(A)') 'Reading model flags (read_NORTRIP_flags)'
write(unit_logfile_temp,'(A)') '================================================================'
!WEAR
wear_flag(road_index)=match_string_int('road_wear_flag',unit_in,unit_logfile_temp,0)
wear_flag(tyre_index)=match_string_int('tyre_wear_flag',unit_in,unit_logfile_temp,0)
wear_flag(brake_index)=match_string_int('brake_wear_flag',unit_in,unit_logfile_temp,0)
exhaust_flag=match_string_int('exhaust_flag',unit_in,unit_logfile_temp,0)
road_suspension_flag=match_string_int('road_suspension_flag',unit_in,unit_logfile_temp,0)
dust_deposition_flag=match_string_int('dust_deposition_flag',unit_in,unit_logfile_temp,0)
abrasion_flag=match_string_int('abrasion_flag',unit_in,unit_logfile_temp,0)
crushing_flag=match_string_int('crushing_flag',unit_in,unit_logfile_temp,0)
dust_drainage_flag=match_string_int('dust_drainage_flag',unit_in,unit_logfile_temp,0)
dust_spray_flag=match_string_int('dust_spray_flag',unit_in,unit_logfile_temp,0)
dust_ploughing_flag=match_string_int('dust_ploughing_flag',unit_in,unit_logfile_temp,0)
wind_suspension_flag=match_string_int('wind_suspension_flag',unit_in,unit_logfile_temp,0)
!MOISTURE
retention_flag=match_string_int('retention_flag',unit_in,unit_logfile_temp,0)
use_obs_retention_flag=match_string_int('use_obs_retention_flag',unit_in,unit_logfile_temp,0)
water_spray_flag=match_string_int('water_spray_flag',unit_in,unit_logfile_temp,0)
drainage_type_flag=match_string_int('drainage_type_flag',unit_in,unit_logfile_temp,0)
surface_humidity_flag=match_string_int('surface_humidity_flag',unit_in,unit_logfile_temp,0)
use_salt_humidity_flag=match_string_int('use_salt_humidity_flag',unit_in,unit_logfile_temp,0)
retain_water_by_snow_flag=match_string_val('retain_water_by_snow_flag',unit_in,unit_logfile_temp,retain_water_by_snow_flag)
!ENERGY BALANCE
evaporation_flag=match_string_int('evaporation_flag',unit_in,unit_logfile_temp,0)
canyon_shadow_flag=match_string_int('canyon_shadow_flag',unit_in,unit_logfile_temp,0)
canyon_long_rad_flag=match_string_int('canyon_long_rad_flag',unit_in,unit_logfile_temp,0)
use_subsurface_flag=match_string_int('use_subsurface_flag',unit_in,unit_logfile_temp,0)
use_traffic_turb_flag=match_string_int('use_traffic_turb_flag',unit_in,unit_logfile_temp,0)
use_melt_freeze_energy_flag=match_string_int('use_melt_freeze_energy_flag',unit_in,unit_logfile_temp,0)
use_stability_flag=match_string_int('use_stability_flag',unit_in,unit_logfile_temp,use_stability_flag)
use_energy_correction_flag=match_string_int('use_energy_correction_flag',unit_in,unit_logfile_temp,0)
!ACTIVITY
use_salting_data_flag(1)=match_string_val('use_salting_data_1_flag',unit_in,unit_logfile_temp,0.0)
use_salting_data_flag(2)=match_string_val('use_salting_data_2_flag',unit_in,unit_logfile_temp,0.0)
use_sanding_data_flag=match_string_val('use_sanding_data_flag',unit_in,unit_logfile_temp,0)
use_ploughing_data_flag=match_string_int('use_ploughing_data_flag',unit_in,unit_logfile_temp,0)
use_cleaning_data_flag=match_string_int('use_cleaning_data_flag',unit_in,unit_logfile_temp,0)
use_wetting_data_flag=match_string_int('use_wetting_data_flag',unit_in,unit_logfile_temp,0)
auto_salting_flag=match_string_int('auto_salting_flag',unit_in,unit_logfile_temp,0)
auto_binding_flag=match_string_int('auto_binding_flag',unit_in,unit_logfile_temp,0)
auto_sanding_flag=match_string_int('auto_sanding_flag',unit_in,unit_logfile_temp,0)
auto_ploughing_flag=match_string_int('auto_ploughing_flag',unit_in,unit_logfile_temp,0)
auto_cleaning_flag=match_string_int('auto_cleaning_flag',unit_in,unit_logfile_temp,0)
salt_type(2)=match_string_int('binding_salt_flag',unit_in,unit_logfile_temp,2)
activity_in_tunnels_flag=match_string_int('activity_in_tunnels_flag',unit_in,unit_logfile_temp,0)
salt_after_ploughing_flag=match_string_int('salt_after_ploughing_flag',unit_in,unit_logfile_temp,0)
!OUTPUT
plot_type_flag=match_string_int('plot_type_flag',unit_in,unit_logfile_temp,0)
save_type_flag=match_string_int('save_type_flag',unit_in,unit_logfile_temp,0)
save_init_data_as_netcdf_flag=match_string_int('save_init_data_as_netcdf_flag',unit_in,unit_logfile_temp,0)
save_road_summary_data_as_netcdf_flag=match_string_int('save_road_summary_data_as_netcdf_flag',unit_in,unit_logfile_temp,0)
!DISPERSION
use_ospm_flag=match_string_int('use_ospm_flag',unit_in,unit_logfile_temp,0)
!FORECAST
forecast_hour=match_string_int('forecast_hour',unit_in,unit_logfile_temp,0)
forecast_type=match_string_int('forecast_type',unit_in,unit_logfile_temp,1)
!ZIP INPUT FILES. Set to 3 to read all inputs as zip
read_zip_file_temp=match_string_int('read_data_in_zip_format',unit_in,unit_logfile_temp,0)
if (read_zip_file_temp.ge.1) read_timeseriesdata_in_zip_format=.true.
if (read_zip_file_temp.ge.2) read_metadata_in_zip_format=.true.
if (read_zip_file_temp.ge.3) read_initialdata_in_zip_format=.true.
!Define if the routine uses the single road option for large datasets
use_single_road_loop_temp=match_string_int('use_single_road_loop_flag',unit_in,unit_logfile_temp,0)
use_single_road_loop_flag=.false.
if (use_single_road_loop_temp.eq.1) use_single_road_loop_flag=.true.
!Operating system. Only used for deleting files that have been unzipped. 1 is windows, 2 is linux
operating_system=match_string_int('operating_system',unit_in,unit_logfile_temp,operating_system)
!Additional override parameters
override_long_rad_in_offset=match_string_val('override_long_rad_in_offset',unit_in,unit_logfile_temp,nodata_orig)
override_RH_offset=match_string_val('override_RH_offset',unit_in,unit_logfile_temp,nodata_orig)
override_T_a_offset=match_string_val('override_T_2m_offset',unit_in,unit_logfile_temp,nodata_orig)
override_wind_speed_correction=match_string_val('override_wind_speed_correction',unit_in,unit_logfile_temp,nodata_orig)
override_albedo_road_offset=match_string_val('override_albedo_road_offset',unit_in,unit_logfile_temp,nodata_orig)
!if (unit_logfile.gt.0) then
! close(unit_logfile,status='keep')
!endif
10 close(unit_in,status='keep')
end subroutine read_NORTRIP_flags
!----------------------------------------------------------------------
!----------------------------------------------------------------------
subroutine read_NORTRIP_activities
use NORTRIP_definitions
implicit none
character(256) temp_name
integer unit_in,unit_logfile_temp
logical exists
logical :: activity_data_already_allocated=.false.
!Functions
integer match_string_int
real match_string_val
unit_in=unit_read_NORTRIP_activities
unit_logfile_temp=unit_logfile !use -1 not to write anything, 0 to go to screen
!Open pathname file for reading
temp_name=trim(path_inputparam)//trim(filename_inputparam)//'_activities.txt'
inquire(file=temp_name,exist=exists)
if (.not.exists) then
write(unit_logfile_temp,*)'ERROR: '//trim(temp_name)//' does not exist. Using default flags'
return
endif
open(unit_in,file=temp_name,access='sequential',status='old',readonly)
!Open log file
!if (unit_logfile.gt.0) then
! open(unit_logfile,file=filename_log,status='old',position='append')
!endif
write(unit_logfile_temp,'(A)') '================================================================'
write(unit_logfile_temp,'(A)') 'Reading model auto activity parameters (read_NORTRIP_activities)'
write(unit_logfile_temp,'(A)') '================================================================'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
write(unit_logfile_temp,'(A)') 'Salting (salt1+salt2)'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
salting_hour_ref(1)=match_string_val('salting_hour(1)',unit_in,unit_logfile_temp,0.0)
salting_hour_ref(2)=match_string_val('salting_hour(2)',unit_in,unit_logfile_temp,0.0)
delay_salting_day_ref=match_string_val('delay_salting_day',unit_in,unit_logfile_temp,0.0)
check_salting_day_ref=match_string_val('check_salting_day',unit_in,unit_logfile_temp,0.0)
min_temp_salt_ref=match_string_val('min_temp_salt',unit_in,unit_logfile_temp,0.0)
max_temp_salt_ref=match_string_val('max_temp_salt',unit_in,unit_logfile_temp,0.0)
precip_rule_salt_ref=match_string_val('precip_rule_salt',unit_in,unit_logfile_temp,0.0)
RH_rule_salt_ref=match_string_val('RH_rule_salt',unit_in,unit_logfile_temp,0.0)
g_salting_rule_ref=match_string_val('g_salting_rule',unit_in,unit_logfile_temp,0.0)
salt_mass_ref=match_string_val('salt_mass',unit_in,unit_logfile_temp,0.0)
salt_dilution_ref=match_string_val('salt_dilution',unit_in,unit_logfile_temp,0.0)
salt_type_distribution_ref=match_string_val('salt_type_distribution',unit_in,unit_logfile_temp,1.0)
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
write(unit_logfile_temp,'(A)') 'Sanding'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
sanding_hour_ref(1)=match_string_val('sanding_hour(1)',unit_in,unit_logfile_temp,0.0)
sanding_hour_ref(2)=match_string_val('sanding_hour(2)',unit_in,unit_logfile_temp,0.0)
delay_sanding_day_ref=match_string_val('delay_sanding_day',unit_in,unit_logfile_temp,0.0)
check_sanding_day_ref=match_string_val('check_sanding_day',unit_in,unit_logfile_temp,0.0)
min_temp_sand_ref=match_string_val('min_temp_sand',unit_in,unit_logfile_temp,0.0)
max_temp_sand_ref=match_string_val('max_temp_sand',unit_in,unit_logfile_temp,0.0)
precip_rule_sand_ref=match_string_val('precip_rule_sand',unit_in,unit_logfile_temp,0.0)
RH_rule_sand_ref=match_string_val('RH_rule_sand',unit_in,unit_logfile_temp,0.0)
g_sanding_rule_ref=match_string_val('g_sanding_rule',unit_in,unit_logfile_temp,0.0)
sand_mass_ref=match_string_val('sand_mass',unit_in,unit_logfile_temp,0.0)
sand_dilution_ref=match_string_val('sand_dilution',unit_in,unit_logfile_temp,0.0)
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
write(unit_logfile_temp,'(A)') 'Snow ploughing'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
delay_ploughing_hour_ref=match_string_val('delay_ploughing_hour',unit_in,unit_logfile_temp,0.0)
ploughing_thresh_2_ref=match_string_val('ploughing_thresh',unit_in,unit_logfile_temp,0.0)
if (ploughing_thresh_2_ref.gt.0) then
ploughing_thresh(snow_index)=ploughing_thresh_2_ref
ploughing_thresh(ice_index)=ploughing_thresh_2_ref
endif
ploughing_min_thresh_2_ref=match_string_val('ploughing_min_thresh',unit_in,unit_logfile_temp,ploughing_min_thresh_2_ref)
if (ploughing_min_thresh_2_ref.gt.0) then
ploughing_min_thresh(snow_index)=ploughing_min_thresh_2_ref
ploughing_min_thresh(ice_index)=ploughing_min_thresh_2_ref
ploughing_min_thresh(water_index)=ploughing_min_thresh_2_ref
endif
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
write(unit_logfile_temp,'(A)') 'Cleaning'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
cleaning_hour_ref(1)=match_string_val('cleaning_hour(1)',unit_in,unit_logfile_temp,cleaning_hour_ref(1))
cleaning_hour_ref(2)=match_string_val('cleaning_hour(2)',unit_in,unit_logfile_temp,cleaning_hour_ref(2))
delay_cleaning_hour_ref=match_string_val('delay_cleaning_hour',unit_in,unit_logfile_temp,0.0)
delay_cleaning_day_ref=match_string_val('delay_cleaning_day',unit_in,unit_logfile_temp,0.0)
!If no day value is read then use the hour value. Otherwise the rest is in days
if (delay_cleaning_day_ref.eq.0.0) delay_cleaning_day_ref=delay_cleaning_hour_ref/24.
min_temp_cleaning_ref=match_string_val('min_temp_cleaning',unit_in,unit_logfile_temp,0.0)
clean_with_salting_ref=match_string_int('clean_with_salting',unit_in,unit_logfile_temp,0)
start_month_cleaning_ref=match_string_val('start_month_cleaning',unit_in,unit_logfile_temp,0.0)
end_month_cleaning_ref=match_string_val('end_month_cleaning',unit_in,unit_logfile_temp,0.0)
wetting_with_cleaning_ref=match_string_val('wetting_with_cleaning',unit_in,unit_logfile_temp,0.0)
efficiency_of_cleaning_ref=match_string_val('efficiency_of_cleaning',unit_in,unit_logfile_temp,0.0)
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
write(unit_logfile_temp,'(A)') 'Binding (salt2)'
write(unit_logfile_temp,'(A)') '----------------------------------------------------------------'
binding_hour_ref(1)=match_string_val('binding_hour(1)',unit_in,unit_logfile_temp,0.0)
binding_hour_ref(2)=match_string_val('binding_hour(2)',unit_in,unit_logfile_temp,0.0)
delay_binding_day_ref=match_string_val('delay_binding_day',unit_in,unit_logfile_temp,0.0)
check_binding_day_ref=match_string_val('check_binding_day',unit_in,unit_logfile_temp,0.0)
min_temp_binding_ref=match_string_val('min_temp_binding',unit_in,unit_logfile_temp,0.0)
max_temp_binding_ref=match_string_val('max_temp_binding',unit_in,unit_logfile_temp,0.0)
precip_rule_binding_ref=match_string_val('precip_rule_binding',unit_in,unit_logfile_temp,0.0)
RH_rule_binding_ref=match_string_val('RH_rule_binding',unit_in,unit_logfile_temp,0.0)
g_binding_rule_ref=match_string_val('g_binding_rule',unit_in,unit_logfile_temp,0.0)
binding_mass_ref=match_string_val('binding_mass',unit_in,unit_logfile_temp,0.0)
binding_dilution_ref=match_string_val('binding_dilution',unit_in,unit_logfile_temp,0.0)
start_month_binding_ref=match_string_val('start_month_binding',unit_in,unit_logfile_temp,0.0)
end_month_binding_ref=match_string_val('end_month_binding',unit_in,unit_logfile_temp,0.0)
!if (unit_logfile.gt.0) then
! close(unit_logfile,status='keep')
!endif
10 close(unit_in,status='keep')
!Allocate the auto_activity parameters for all roads if they have not already been allocated in the transfer routine (coupling to multiroad code)
!Set the flag if these have not been allocated. Onlt necessary fo rthe first case since they are either allocated for all or none in the multiroad code
if (.not.allocated(salting_hour)) then
allocate (salting_hour(2,0:n_roads))
activity_data_already_allocated=.false.
else
activity_data_already_allocated=.true.
endif
if (.not.allocated(delay_salting_day)) allocate (delay_salting_day(0:n_roads))
if (.not.allocated(check_salting_day)) allocate (check_salting_day(0:n_roads))
if (.not.allocated(min_temp_salt)) allocate (min_temp_salt(0:n_roads))
if (.not.allocated(max_temp_salt)) allocate (max_temp_salt(0:n_roads))
if (.not.allocated(precip_rule_salt)) allocate (precip_rule_salt(0:n_roads))
if (.not.allocated(RH_rule_salt)) allocate (RH_rule_salt(0:n_roads))
if (.not.allocated(g_salting_rule)) allocate (g_salting_rule(0:n_roads))
if (.not.allocated(salt_mass)) allocate (salt_mass(0:n_roads))
if (.not.allocated(salt_dilution)) allocate (salt_dilution(0:n_roads))
if (.not.allocated(salt_type_distribution)) allocate (salt_type_distribution(0:n_roads))
if (.not.allocated(sanding_hour)) allocate (sanding_hour(2,0:n_roads))
if (.not.allocated(delay_sanding_day)) allocate (delay_sanding_day(0:n_roads))
if (.not.allocated(check_sanding_day)) allocate (check_sanding_day(0:n_roads))
if (.not.allocated(min_temp_sand)) allocate (min_temp_sand(0:n_roads))
if (.not.allocated(max_temp_sand)) allocate (max_temp_sand(0:n_roads))
if (.not.allocated(precip_rule_sand)) allocate (precip_rule_sand(0:n_roads))
if (.not.allocated(RH_rule_sand)) allocate (RH_rule_sand(0:n_roads))
if (.not.allocated(g_sanding_rule)) allocate (g_sanding_rule(0:n_roads))
if (.not.allocated(sand_mass)) allocate (sand_mass(0:n_roads))
if (.not.allocated(sand_dilution)) allocate (sand_dilution(0:n_roads))
if (.not.allocated(delay_ploughing_hour)) allocate (delay_ploughing_hour(0:n_roads))
if (.not.allocated(ploughing_thresh_2)) allocate (ploughing_thresh_2(0:n_roads))
if (.not.allocated(cleaning_hour)) allocate (cleaning_hour(2,0:n_roads))
if (.not.allocated(delay_cleaning_day)) allocate (delay_cleaning_day(0:n_roads))
if (.not.allocated(min_temp_cleaning)) allocate (min_temp_cleaning(0:n_roads))
if (.not.allocated(clean_with_salting)) allocate (clean_with_salting(0:n_roads))
if (.not.allocated(start_month_cleaning)) allocate (start_month_cleaning(0:n_roads))
if (.not.allocated(end_month_cleaning)) allocate (end_month_cleaning(0:n_roads))
if (.not.allocated(wetting_with_cleaning)) allocate (wetting_with_cleaning(0:n_roads))
if (.not.allocated(efficiency_of_cleaning)) allocate (efficiency_of_cleaning(0:n_roads))
if (.not.allocated(binding_hour)) allocate (binding_hour(2,0:n_roads))
if (.not.allocated(delay_binding_day)) allocate (delay_binding_day(0:n_roads))
if (.not.allocated(check_binding_day)) allocate (check_binding_day(0:n_roads))
if (.not.allocated(min_temp_binding)) allocate (min_temp_binding(0:n_roads))
if (.not.allocated(max_temp_binding)) allocate (max_temp_binding(0:n_roads))
if (.not.allocated(precip_rule_binding)) allocate (precip_rule_binding(0:n_roads))
if (.not.allocated(RH_rule_binding)) allocate (RH_rule_binding(0:n_roads))
if (.not.allocated(g_binding_rule)) allocate (g_binding_rule(0:n_roads))
if (.not.allocated(binding_mass)) allocate (binding_mass(0:n_roads))
if (.not.allocated(binding_dilution)) allocate (binding_dilution(0:n_roads))
if (.not.allocated(start_month_binding)) allocate (start_month_binding(0:n_roads))
if (.not.allocated(end_month_binding)) allocate (end_month_binding(0:n_roads))
!If these were not previously allocated and given values then fill them all with no data
if (.not.activity_data_already_allocated) then
salting_hour=nodata_activity
delay_salting_day=nodata_activity
check_salting_day=nodata_activity
min_temp_salt=nodata_activity
max_temp_salt=nodata_activity
precip_rule_salt=nodata_activity
RH_rule_salt=nodata_activity
g_salting_rule=nodata_activity
salt_mass=nodata_activity
salt_dilution=nodata_activity
salt_type_distribution=nodata_activity
sanding_hour=nodata_activity
delay_sanding_day=nodata_activity
check_sanding_day=nodata_activity
min_temp_sand=nodata_activity
max_temp_sand=nodata_activity
precip_rule_sand=nodata_activity
RH_rule_sand=nodata_activity
g_sanding_rule=nodata_activity
sand_mass=nodata_activity
sand_dilution=nodata_activity
delay_ploughing_hour=nodata_activity
ploughing_thresh_2=nodata_activity
cleaning_hour=nodata_activity
delay_cleaning_day=nodata_activity
min_temp_cleaning=nodata_activity
clean_with_salting=nodata_activity
start_month_cleaning=nodata_activity
end_month_cleaning=nodata_activity
wetting_with_cleaning=nodata_activity
efficiency_of_cleaning=nodata_activity
binding_hour=nodata_activity
delay_binding_day=nodata_activity
check_binding_day=nodata_activity
min_temp_binding=nodata_activity
max_temp_binding=nodata_activity
precip_rule_binding=nodata_activity
RH_rule_binding=nodata_activity
g_binding_rule=nodata_activity
binding_mass=nodata_activity
binding_dilution=nodata_activity
start_month_binding=nodata_activity
end_month_binding=nodata_activity
endif
!Transfer the ref values to the read-in multiple road values if the multiple road values are 'nodata_activity'
!Only checks the first road value for no data.
if (salting_hour(1,1).eq.nodata_activity) salting_hour(1,:)=salting_hour_ref(1)
if (salting_hour(2,1).eq.nodata_activity) salting_hour(2,:)=salting_hour_ref(2)
if (delay_salting_day(1).eq.nodata_activity) delay_salting_day(:)=delay_salting_day_ref
if (check_salting_day(1).eq.nodata_activity) check_salting_day(:)=check_salting_day_ref
if (min_temp_salt(1).eq.nodata_activity) min_temp_salt(:)=min_temp_salt_ref
if (max_temp_salt(1).eq.nodata_activity) max_temp_salt(:)=max_temp_salt_ref
if (precip_rule_salt(1).eq.nodata_activity) precip_rule_salt(:)=precip_rule_salt_ref
if (RH_rule_salt(1).eq.nodata_activity) RH_rule_salt(:)=RH_rule_salt_ref
if (g_salting_rule(1).eq.nodata_activity) g_salting_rule(:)=g_salting_rule_ref
if (salt_mass(1).eq.nodata_activity) salt_mass(:)=salt_mass_ref
if (salt_dilution(1).eq.nodata_activity) salt_dilution(:)=salt_dilution_ref
if (salt_type_distribution(1).eq.nodata_activity) salt_type_distribution(:)=salt_type_distribution_ref
if (sanding_hour(1,1).eq.nodata_activity) sanding_hour(1,:)=sanding_hour_ref(1)
if (sanding_hour(2,1).eq.nodata_activity) sanding_hour(2,:)=sanding_hour_ref(2)
if (delay_sanding_day(1).eq.nodata_activity) delay_sanding_day(:)=delay_sanding_day_ref
if (check_sanding_day(1).eq.nodata_activity) check_sanding_day(:)=check_sanding_day_ref
if (min_temp_sand(1).eq.nodata_activity) min_temp_sand(:)=min_temp_sand_ref
if (max_temp_sand(1).eq.nodata_activity) max_temp_sand(:)=max_temp_sand_ref
if (precip_rule_sand(1).eq.nodata_activity) precip_rule_sand(:)=precip_rule_sand_ref
if (RH_rule_sand(1).eq.nodata_activity) RH_rule_sand(:)=RH_rule_sand_ref
if (g_sanding_rule(1).eq.nodata_activity) g_sanding_rule(:)=g_sanding_rule_ref
if (sand_mass(1).eq.nodata_activity) sand_mass(:)=sand_mass_ref
if (sand_dilution(1).eq.nodata_activity) sand_dilution(:)=sand_dilution_ref
if (delay_ploughing_hour(1).eq.nodata_activity) delay_ploughing_hour(:)=delay_ploughing_hour_ref
if (ploughing_thresh_2(1).eq.nodata_activity) ploughing_thresh_2(:)=ploughing_thresh_2_ref
if (cleaning_hour(1,1).eq.nodata_activity) cleaning_hour(1,:)=cleaning_hour_ref(1)
if (cleaning_hour(2,1).eq.nodata_activity) cleaning_hour(2,:)=cleaning_hour_ref(2)
if (delay_cleaning_day(1).eq.nodata_activity) delay_cleaning_day(:)=delay_cleaning_day_ref
if (min_temp_cleaning(1).eq.nodata_activity) min_temp_cleaning(:)=min_temp_cleaning_ref
if (clean_with_salting(1).eq.nodata_activity) clean_with_salting(:)=clean_with_salting_ref
if (start_month_cleaning(1).eq.nodata_activity) start_month_cleaning(:)=start_month_cleaning_ref
if (end_month_cleaning(1).eq.nodata_activity) end_month_cleaning(:)=end_month_cleaning_ref
if (wetting_with_cleaning(1).eq.nodata_activity) wetting_with_cleaning(:)=wetting_with_cleaning_ref
if (efficiency_of_cleaning(1).eq.nodata_activity) efficiency_of_cleaning(:)=efficiency_of_cleaning_ref
if (binding_hour(1,1).eq.nodata_activity) binding_hour(1,:)=binding_hour_ref(1)
if (binding_hour(2,1).eq.nodata_activity) binding_hour(2,:)=binding_hour_ref(2)
if (delay_binding_day(1).eq.nodata_activity) delay_binding_day(:)=delay_binding_day_ref
if (check_binding_day(1).eq.nodata_activity) check_binding_day(:)=check_binding_day_ref
if (min_temp_binding(1).eq.nodata_activity) min_temp_binding(:)=min_temp_binding_ref
if (max_temp_binding(1).eq.nodata_activity) max_temp_binding(:)=max_temp_binding_ref
if (precip_rule_binding(1).eq.nodata_activity) precip_rule_binding(:)=precip_rule_binding_ref
if (RH_rule_binding(1).eq.nodata_activity) RH_rule_binding(:)=RH_rule_binding_ref
if (g_binding_rule(1).eq.nodata_activity) g_binding_rule(:)=g_binding_rule_ref
if (binding_mass(1).eq.nodata_activity) binding_mass(:)=binding_mass_ref
if (binding_dilution(1).eq.nodata_activity) binding_dilution(:)=binding_dilution_ref
if (start_month_binding(1).eq.nodata_activity) start_month_binding(:)=start_month_binding_ref
if (end_month_binding(1).eq.nodata_activity) end_month_binding(:)=end_month_binding_ref
end subroutine read_NORTRIP_activities
!----------------------------------------------------------------------
!----------------------------------------------------------------------
subroutine read_NORTRIP_runway_info
use NORTRIP_definitions
implicit none
character(256) filename
!Local
character(256) :: temp_str
logical :: exists
integer :: n_info
integer :: unit_in=40
integer :: n !!counter
write(unit_logfile,'(A)') '================================================================'
write(unit_logfile,'(A)') 'Reading runway information (read_NORTRIP_runway_info)'
write(unit_logfile,'(A)') '================================================================'
!Read in the meteo obs metadata file
!Test existence of the filename. If does not exist then use default. TODO: Read from parameter file?
filename=trim(path_inputparam)//"runway_info.csv"
inquire(file=trim(filename),exist=exists)
if (.not.exists) then
write(unit_logfile,'(A,A)') ' WARNING: Runway info file does not exist ', trim(filename)
return
endif
if (exists) then
write(unit_logfile,'(2A)') ' Opening runway information file: ',trim(filename)
open(unit_in,file=filename,access='sequential',status='old',readonly)
end if
!Find out how long the file is, reading a dummy variable
!Including the header so start at -1
n_info = -1
do while(.not.eof(unit_in))
n_info = n_info + 1
read(unit_in,*,ERR=5)
end do
5 write(unit_logfile,*) 'Number of data rows in runway info file= ',n_info
if (n_info .gt. 0) then
if (.not.allocated(runway_char_info_data)) allocate(runway_char_info_data(n_char_columns,n_info))
if (.not.allocated(runway_real_info_data)) allocate(runway_real_info_data(n_real_columns,n_info))