1 ! standalone moisture model test
2 ! inpout from file moisture_input.txt with each line of the form
8 use module_fr_sfire_phys, only: advance_moisture, init_fuel_cats, moisture_classes
9 use module_fr_sfire_util, only: fire_print_msg , crash
12 character(len=128)::infile,outfile,prtfile
13 integer, parameter::nfmc=5 ! change if needed
15 integer, parameter:: ims=1,ime=1,jms=1,jme=1
16 integer::its=ims,ite=ime,jts=jms,jte=jme
17 real, dimension(ims:ime,1:nfmc,jms:jme)::fmc_gc,fmc_equi,fmc_lag
18 real, dimension(ims:ime,jms:jme)::t2,q2,psfc,t2_old,q2_old,psfc_old, &
19 rainc,rainnc,rain_old,rh_fire
21 integer::fmoist_init=2 ! initialize at equilibrium
23 integer::istep,i,k,nsteps=999999
24 real::t,p,q,rain,hours,fmc(nfmc),hours_old
25 character(len=100)::fmt(8)
29 infile='moisture_input.txt'
30 outfile='moisture_output.txt'
31 prtfile='moisture_print.txt'
33 fire_print_msg = 2 ! change to 2 to get more debugging prints
35 call init_fuel_cats(.true.)
37 open(1,file=trim(infile),form='formatted',status='old',err=91)
38 open(7,file=trim(prtfile),form='formatted',status='unknown',err=93)
39 open(8,file=trim(outfile),form='formatted',status='unknown',err=92)
42 if(moisture_classes>5)call crash('at most 5 moisture classes allowed')
44 write(i,1)'Step','Time', 'T','P','Q','RAIN','RH',('EQUI',k,'TLAG',k,'FMC',k,k=1,moisture_classes)
45 write(i,2)' ','hours','K','Pa','kg/kg','mm','1',('kg/kg','hours','kg/kg',k=1,moisture_classes)
47 1 format(a4,a8, a6, a9, a8 ,a8, a6, 5(a5,i1,a8,i1,a5,i1))
48 2 format(a4,a8, a6, a9, a8 ,a8, a6, 5(a6,a9,a6))
49 fmt(6)='(i4,f8.2,f6.1,f9.1,f8.5,f8.1,f6.3,5(f6.3,f9.1,f6.3))'
53 fire_print_msg = 0 ! change to 2 to get more debugging prints
58 read(1,*,end=9,err=94)hours,t,p,q,rain
63 moisture_dt=0. ! required on initialization
66 moisture_dt=3600*(hours - hours_old) !
77 call advance_moisture( &
78 initialize, & ! initialize timestepping. true on the first call at time 0, then false
79 ims,ime, jms,jme, & ! memory dimensions
80 its,ite, jts,jte, & ! tile dimensions
81 nfmc, & ! dimension of moisture fields
82 moisture_dt, & ! timestep = time step time elapsed from the last call
83 rainc, rainnc, & ! accumulated rain
84 t2, q2, psfc, & ! temperature (K), vapor contents (kg/kg), pressure (Pa) at the surface
85 rain_old, & ! previous value of accumulated rain
86 t2_old, q2_old, psfc_old, & ! previous values of the atmospheric state at surface
87 rh_fire, & ! relative humidity
88 fmc_gc, & ! fuel moisture by class, updated
89 fmc_equi, & ! fuel moisture equilibrium by class, for diagnostics only
90 fmc_lag & ! fuel moisture timelag by class, for diagnostics only
95 write(i,fmt(i))istep,hours,t,p,q,rain,rh_fire(its,jts),(fmc_equi(its,k,jts),fmc_lag(its,k,jts),fmc_gc(its,k,jts), &
101 write(6,*)'Maximum number of steps reached before reading whole input file ',trim(infile)
104 write(6,*)'Completed ',istep-1,' steps'
105 write(6,*)'Input from flat text file ',trim(infile)
106 write(6,*)'Output with headers is in ',trim(prtfile)
107 write(6,*)'Output as a flat text is in ',trim(outfile)
114 91 print *,'Cannot open ',trim(infile)
116 92 print *,'Cannot open ',trim(outfile)
118 93 print *,'Cannot open ',trim(prtfile)
120 94 print *,'Error reading record ',istep,' in file ',trim(infile)
126 end program moisture_main