Transcript
Page 1: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

1

GuideforInstallingCALMET/CALPUFF/CALWRF/CALPOSTbyTimChui 23Aug2018withinitialcontributionsfromMattFung 2016andminoradditionsbyRolandStull 11Sep2018 forgfortranversion6.3.0Dept.ofEarth,Ocean&AtmosphericSciencesUniv.ofBritishColumbia,Vancouver,BCV6T1Z4,CanadaForoperatingsystems:Linux,Unix,MacOSPrerequisites:

• CheckthatyouhavetheGNUcompilersinstalledonyoursystem,specificallygfortrano which gfortran

§ CheckswhetherornotgfortranisinyourPATH;ifnot,youneedtoaddthecompilerbinarydirectorytoyourPATH:

• export PATH=/path/to/compiler/bin:$PATH • Usuallyin/usr/local/binor/opt/local/bin

§ Ifgfortranisnotonyoursystem,you’llneedtoinstallit;bestwaywouldbetouseapackagemanager

o gfortran--version§ Checkscompilerversion§ Shouldbeversion5+(i.e.5.4.0,6.1.0,6.3.0,etc.)

• CheckwhetheryouhavenetCDFinstalledonyoursystem;neededforCALWRF

o which ncdump § CheckswhetherornotthenetCDFutilityncdumpisinyourPATH;if

not,youneedtoaddthenetCDFbinarydirectorytoyourPATH:• export PATH=/path/to/netcdf/bin:$PATH • Ifyouinstalledthroughapackagemanager,shouldbein

/opt/local/binNamely,thepathis/opt/local/bin/ncdump

§ IfnetCDFisnotinstalledonyoursystem,you’llneedtoinstallit;bestwaywouldbetouseapackagemanager,ORbuildnetcdf-3.6.3yourself

o ncdump -V(mayshowversionjustbyrunningncdump)§ ChecksnetCDFversion§ EitherVersion3or4work,butyouhavetokeepknowwhichversion

you’reusing(willapplylaterwheninstallingCALWRF) (Ihavencdumpversion4.3.3.1atthetimeofthiswriting.)

Page 2: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

2

SourceFiles

• CALMET_v5.8.5.zipo ContainssourcecodeforCALMETv5.8.5(USEPAapproved)

• CALMET.zipo ContainssourcecodeforCALMETv5.8.4;alsocontainsDEMOdirectoryneeded

fortutorialrunofCALMETv5.8.5

• CALPUFF_v5.8.5.zipo ContainssourcecodeforCALPUFFv5.8.5(USEPAapproved)

• CALPUFF.zipo ContainssourcecodeforCALPUFFv5.8.4;alsocontainsDEMOdirectoryneeded

fortutorialrunofCALPUFFv5.8.5

• CALWRF_v2.0.2_L131108.zipo ContainssourcecodeforCALWRFv2.0.2o RequiresnetCDFforinstallationo ***UserneedstoprovideownWRFmeteorologyoutputfilesinnetCDFformat[

netCDF(wrfout)]filestotestinstallation***

• CALPOST_v6.221.zipo ContainssourcecodeforCALPOSTv6.221

CALMET

• Assumeyou’reworkinginthehomedirectory:createdirectorytoholdallCAL-relatedfiles,andchangedirectorytoCAL

o mkdir CAL o cd CAL

• Transferordownloadall.zipfilestoCAL;candosoinFinderwindow(ifonMac),orby

copying:o cp /path/to/CALPUFF.zip . (includethelastspaceandperiod) o cp /path/to/CALMET.zip . (includethelastspaceandperiod) o etc.

• UntartheCALMETzipfiles,eitherbydouble-clickingintheFinderwindow,orusinga

command-lineutility(tar,unzip,gzip,dependingonOS)o tar -xvzf CALMET.zip o tar -xvzf CALMET_v5.8.5.zip

Page 3: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

3

• ChangedirectoryintosourcecodedirectoryofCALMETv5.8.5

o cd CALMET_v5.8.5/CODE

• Openupcalutils.forinaneditor.IpreferBBEditonthemacdesktop.Butifyoupreferaneditorintheterminalwindow,try

o vi calutils.for

• Inlines2712tolines2715,adda!tothebeginningofthoselinestocommentthemout.

• Uncommentlines2721to2724byremovingthec ***atthebeginningofthoselines(makingsurethatthefirstcharactersofthelinesareseveralspacesfromtheleftmostcolumnofthecode)

• Refertovidocumentation(orwhatevereditoryou’reusing)ifyou’reunsureofhow

tomakeedits

• Aftermakingandsavingyourchanges,thecodeshouldlooklikethefollowing:

• ThesechangesareneededbecauseCALMETassumesuserscompilewithIntelifort,whichcontainsthefunctionNARGS()todeterminehowmanycommandlineargumentsareusedwhencallingcalmet.exe;becauseweareusinggfortran,the

Page 4: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

4

functiontouseisinsteadIARGC()

• Afteryou’vemadeyourchanges,saveandquityoureditor(:wqifeditinginvi).

• Inyourterminalwindow,typethefollowingsothatthegfortrancompilerwon'tgiveaFATALerrorduetoamissing"m"flag:export PATH=/usr/bin:$PATH

• compilethecodebycreatingtheobjectcalmet.exeo gfortran -o calmet.exe calmet.for o Ifyoudiditcorrectly,youshouldseeawholebunchofwarnings(fine),butno

errors(notfine)• Assumingthatthe.exewassuccessfullybuilt,runit:

o ./calmet.exe o Shouldseethefollowingerror:

“Atline24501offilecalmet.for(unit=15)Fortranruntimeerror:Cannotopenfile'calmet.inp':Nosuchfileordirectory”

• CopyovertheDEMOfilefromCALMET.zipintothedirectoryCALMET_v5.8.5(atthe

samelevelasCODE):o cd ..(shouldnowbeinCALMET_v5.8.5)o cp –r ../CALMET/DEMO . (includethelastspaceandperiod) o cd DEMO

• LinkintheexecutablethatyoubuiltinCODEintoDEMO(youshouldnowbeinDEMO):

o ln -s ../CODE/calmet.exe . (includethelastspaceandperiod)

• CMET.INPistheinput(control)file,anditspecifiesseveral.DATfilestoruncalmet.exe;theversionyouhaveinDEMOisalreadyreadytogo,andrequiresnoediting

• Youmayseecmet.datandcmet.lstinthedirectory;getridofthemtoensurethatyouproduceyourownversionsafterrunningCALMET:

o rm cmet.dat(outputfromprevioustestrun)o rm cmet.lst(logfilefromprevioustestrun)

• Runcalmet.exewiththeinputfile:o ./calmet.exe CMET.INP

• Ifalliswell,youshouldseecmet.datandcmet.lst,andcalmet.exewasinstalled

successfully.cmet.lstisviewableinatexteditor,andIencourageyoutoexamineit.cmet.datisnotviewable,butitistheinputforCALPUFF.

Page 5: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

5

CALPUFF

• Gobacktothebaseinstallationdirectoryo cd ~/CAL

• UntartheCALPUFF-relatedzipfilesbydouble-clickingonthefileinthefinderwindow.

Orifyouareinaterminalwindow,dothefollowing.o tar -xvzf CALPUFF.zip o tar -xvzf CALPUFF_v5.8.5.zip o cd CALPUFF_v5.8.5/CODE

• Inyourfavoriteeditor,Commentoutlines2723to2726,anduncomment2732to

2735,incalutils.for,identicaltowhatyoudidforCALMET.Saveyourresult.Onceyou’redone,thecodeshouldlooklikethefollowing:

• Intheterminalwindow,typeexport PATH=/usr/bin:$PATH

• Compilecalpuff.exeo gfortran -o calpuff.exe calpuff.for

Page 6: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

6

• Onceagain,youshouldseewarnings,butnoerrors.Ifyouruncalpuff:

./calpuff.exe,youshouldseethefollowingerror:

“Atline40386offilecalpuff.for(unit=1)Fortranruntimeerror:Cannotopenfile'calpuff.inp':Nosuchfileordirectory”

• Likebefore,copyintheDEMOdirectoryfromCALPUFF.zipatthesamelevelasCODE,changedirectorysothatyou’reinDEMO,thenlinkinyournewexecutable:

o cd .. (whichshouldputyoubackindirectoryCALPUFF_v5.8.5) o cp -r ../CALPUFF/DEMO . (includethelastspaceandperiod) o cd DEMO o ln -s ../CODE/calpuff.exe . (includethelastspaceandperiod)

• TheinputfileisCPUF.INP,theoutputlogfileisCPUF.LST,andtheoutputfileswillbe

CPUF.CON,CPUF.DRY,CPUF.VIS,CPUF.WET.Getridofanyoutputfilesthatmighthavealreadybeenprovided,becauseyouwanttoseeifyoucanrunCALUFFtocreateyourownoutputfiles.Soremovethesefiles,eitherdirectlyusingtheMacFinder,orinyourterminalwindow:

o rm CPUF.LST o rm CPUF.CON o rm CPUF.DRY o rm CPUF.VIS o rm CPUF.WET

• Theonly.DATfilethatCALPUFFneedstoruniscmet.dat,whichwouldhavebeen

producedfromCALMET(thecmet.datinDEMOwaspre-made,andisnotidenticaltothecmet.datyouproducedwhentestingcalmet.exe).

• RunCALPUFF:

o ./calpuff.exe CPUF.INP

• YoushouldseethenewlogfileCPUF.LST,andthenewoutputfilesCPUF.CON,CPUF.DRY,CPUF.VIS,CPUF.WET.Ifalliswell,calpuff.exehasbeensuccessfullyinstalled.OnlyCPUF.LSTisviewableinatexteditor.

CALWRF

• TheproceduretoinstallCALWRFisverydifferentfrominstallingCALMETandCALWRF,andrequiresnetCDF

Page 7: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

7

• Toviewfilesaboveyourhomedirectory,typecd ~/.. lsandusesimilarmethodstonavigatetoplacestoseewhereyourncdumpis.

• SettheenvironmentvariablestopointtoyournetCDFlibrariesandincludefileso Ifyourncdumpisin/path/to/netcdf/bin,thenyourlibrariesarelikelyin

/path/to/netcdf/lib(shouldseelibnetcdff.aand/orlibnetcdf.a),andyourincludefilesarein/path/to/netcdf/include(shouldseenetcdf.inc)

o Toanswerthequestionabove,onemethodistousetheMacfinderandsearchonncdumptofindwhichdirectoryitisin.

• Asan***example***,iftherootdirectoryofyournetCDFbuildisin/opt/local,then

youshouldsetthefollowingvariables:o export NETLIB=/opt/local/lib o export NETINC=/opt/local/inc o export NETINC=/opt/local/include

• Gobacktothebaseinstallationdirectory

o cd ~/CAL

• UnzipCALWRFintheMacFinderbydoubleclickingonit,oruntaritintheterminalwindow:

o tar -xvzf CALWRF_v2.0.2_L131108.zip

• Intheterminalwindow,changeyourworkingdirectoryo cd CALWRF_v2.0.2_L131108/code

• Compilecalwrf.exedependingonyourversionofnetCDF(oneline):

o ifyouhavenetCDF-3:gfortran -L$NETLIB -lnetcdf -I$NETINC -o calwrf.exe calwrf.f

o ifyouhavenetCDF-4:gfortran -L$NETLIB -lnetcdff -I$NETINC -o calwrf.exe calwrf.f

• Theabovecommandsmeantousegfortran,withnetcdflibrariesplacedin$NETLIB(grabbingtheappropriatefilelibnetcdf.a[netcdf-3;-lnetcdf]orlibnetcdff.a[netcdf-4;-lnetcdff]),aswellastheheaderfilesincludedin$NETINC,andbuildtheobjectfilecalwrf.exe

• Ifalliswell,youshouldseenoerror,andtheexecutablecalwrf.exeshouldbeproduced.

• Next,youmightneedtoeditthefilenamesofthewrfoutputfiles(whichyouwilluseasinputtoCALWRF)toremove"/"fromthefilenames,sotheMacdoesn'taccidentallythinkyouaretryingtogotoasubdirectory.

Page 8: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

8

o Forexample,forourcourse,weprovided5outputfilesfromaWRFrun,whichareinadirectorycalledwrf_mini-outputFiles

o InsidetheCALWRF_v2.0.2_L131108directory,createanewdirectorycalledwrf_out,andcopythe5wrffilesintoit.Theneditthemusingyourfavoritetexteditortoreplacethe"/"with"_":

• ThecorrespondinginputfileisCALWRF_v2.0.2_L131108/calwrf.inp,whichwas

providedintheoriginalfilesthatyoudownloaded.Ithasaverynicesetofcommentsshowinghowotherfileinputsmightlook.Pleaseviewtheirsampleinatexteditor.SoyoumustedittheirsampleinputfileinatexteditortomatchwhatevernetCDF/wrfoutfileyouwishtoconvert.

o Hereishowitlooks,afterIeditedittousethe5wrffilesshownabove:

Page 9: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

9

• Copythecalwrf.exefilethatyouproducedintothemainCALWRF...directory(i.e.,thedirectorythatalreadyhasthecalwrf.inpfileandthewrf_outsubdirectory)

• Runcalwrf:./calwrf.exeIfsuccessful,itwillsay"CALWRF succeeded"onyourterminalwindow.

• Theoutputofcalwrf.exewillproducelogfilecalwrf.lst,aswellasa2Dfile(10sofMBbasedonour4wrffilesabove)containingsurface/diagnosticfields,anda3Dfile(100sofMB)foruseasinputinCALMET.

CALPOST

• Gobacktothebaseinstallationdirectoryo cd ~/CAL

• UnzipCALPOSTbydoubleclickingonitintheMacFinder.Or,inatermainwindow,

UntarCALPOST:o tar -xvzf CALPOST_v6.221.zip

andthenchangedirectoriesintoit: o cd CALPOST/v6.221

• Usingyourfavoriteeditor,Editline18078inCALPOST.FORsothattheformatstring

‘(i)’hasaspecifiedwidth‘(i121)’,becauseo Unspecifiedwidthsarenotsupportedingfortrano Chosethenumber121forthewidthbecausethevariableawork2is120

characterslongatmax(line17997iswhereawork2isdeclared).

• Shouldlooklikethefollowingafteryouredit:•

• Commentoutline2597incalutils.for;shouldlooklikethefollowingafteryouredit:

Page 10: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

10

• Commentoutline2713incalutils.for,anduncommentlines2735to2738;shouldlooklikethefollowingafteryouredit:

Page 11: Guide for Installing CALMET/CALPUFF/CALWRF/CALPOST · o Contains source code for CALMET v5.8.5 ... • Next, you might need to edit the file names of the wrf output files (which you

UBCATSC595D-AtmosphericDispersionModeling

11

• Exportthepath:Intheterminalwindow,typeexport PATH=/usr/bin:$PATH

• Compilecalpost.exeo gfortran –o calpost.exe CALPOST.FOR

• Youshouldseewarnings,butnoerrors.Ifyouruntheexecutable

./calpost.exeyoushouldgetthefollowingerror:“Atline708offileCALPOST.FOR(unit=4)Fortranruntimeerror:Cannotopenfile'calpuff.con':Nosuchfileordirectory”

• Gobacktothepreviousdirectory,andruncalpost.exeusingthecontrolfileCalpost.inp,operatingonthegriddedfileCALPUFF.CON(whatyouwouldproduceifyouranCALPUFF)

o cd .. o cp v6.221/calpost.exe . o ./calpost.exe Calpost.inp

• CALPOSTshouldproducealogfilecalpost.lst,whichcontainsthegriddeddatafrom

CALPUFF.CONinareadableformat.Youhavenowfinishedinstallingcalpost.exe.==endofguide==


Top Related