【轮子DIY】一个比较通用的fortran90程序make系统 - 悲催的科学匠人 - 冷水's blog
【轮子DIY】一个比较通用的fortran90程序make系统
冷水
posted @ 2013年4月17日 14:55
in fortran
, 3240 阅读
一个项目中的副产品,目的是为fotran90项目构造简单的make系统
目录结构是主目录下必须包含bin,src和make目录。make目录下是一些makefile,而src就是源代码了。由于fortran的module特殊性,如果有module,src必须包含一个mod目录。如果包含fortran77代码,我也专门开辟一个f77目录包含这些文件,当然叶可以采用其它办法。此外,如果包含混编的c代码,我放入anisc目录。其它代码那找类别分别创建src的子目录即可。一个例子如下
poject +---bin +---make +---src +---mod +---f77 +---anisc +---main
make目录中关键的文件有
- make.inc,定义所有编译参数
- make_mod,专用于编译module
- make_f77,专用于编译fortran77代码
- make_clib,专用于编译c文件
- make_sub,用于编译其它src下子目录中fortran90代码
- Makefile,主make文件
make.inc
# CMODE # options: # gnu, # pgi, # intel COMPILER=gnu # path PROJECT_HOME=.. SRCDIR=$(PROJECT_HOME)/src OBJDIR=$(PROJECT_HOME)/obj_$(COMPILER)/$(CMODE) MODDIR=$(PROJECT_HOME)/mod BINDIR=$(PROJECT_HOME)/bin # PGI fortran and C ifeq ($(COMPILER),pgi) FC=mpif90 LINK=mpif90 CC=pgcc ifeq ($(CMODE),debug) FFLAGS0 = -module $(OBJDIR) -g -r8 -Kieee -C else CMODE = release FFLAGS0 = -module $(OBJDIR) -O2 -r8 -Kieee endif ARCH = ar ARCHFLAG = cr endif # Intel fortran and C ifeq ($(COMPILER),intel) FC=mpif90 LINK=mpif90 CC=icc ifeq ($(CMODE),debug) FFLAGS0 = -module $(OBJDIR) -g -r8 -check all else CMODE = release FFLAGS0 = -module $(OBJDIR) -O2 -r8 endif ARCH = ar ARCHFLAG = cr endif # GNU fortran and C ifeq ($(COMPILER),gnu) FC=mpif90 LINK=mpif90 CC=gcc ifeq ($(CMODE),debug) FFLAGS0 = -J$(OBJDIR) -fdefault-real-8 -frecord-marker=4 -g -fcheck=all -fbacktrace else CMODE = release FFLAGS0 = -J$(OBJDIR) -O2 -fdefault-real-8 -frecord-marker=4 endif ARCH = ar ARCHFLAG = cr endif FFLAGS = $(FFLAGS0) # LIB dir 这里加入必要的库和路径 LIBDIR= #-L$(BLASDIR) -L$(LAPACKDIR) LIBS = # # output exe file, 你可以修改run为其它名称 EXE=$(BINDIR)/run_$(COMPILER)_$(CMODE)
make_f77
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.f) MYTMP= $(patsubst %.f,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.f $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ) submit:
make_clib
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.c) MYTMP= $(patsubst %.c,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.c $(CC) -c $< -o $@ clean: rm -f $(MYOBJ) submit:
make_sub
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.f90) MYTMP= $(patsubst %.f90,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)/%,$(OBJDIR)/$(DEST)/%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/$(DEST)/%.o: $(SRCDIR)/$(SUB)/%.f90 $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ) submit:
make_mod
include make.inc SUB=mod # 这里必须按照一定顺序填写module源代码文件 MYSRC = $(SRCDIR)/$(SUB)/mod1.f90 \ $(SRCDIR)/$(SUB)/mod2.f90 \ $(SRCDIR)/$(SUB)/mod3.f90 MYTMP= $(patsubst %.f90,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.f90 $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ)
Makefile
include make.inc TMPLIB = $(OBJDIR)/../libmytmp_$(CMODE).a all: objs main main: $(TMPLIB) $(LINK) $(TMPLIB) $(LIBDIR) $(LIBS) $(FFLAGS) -o $(EXE) #编译所有obj文件并构造库,在make_mod后列出所有src子目录的编译命令 make -f make_sub "SUB=子目录名称" objs: make -f make_mod make -f make_sub "SUB=main" make -f make_f77 "SUB=f77" make -f make_clib "SUB=anis_c" $(ARCH) $(ARCHFLAG) $(OBJDIR)/../libmytmp_$(CMODE).a $(OBJDIR)/*.o #删除所有obj文件、mod文件和库,在make_mod后列出所有src子目录的编译命令 make -f make_sub "SUB=子目录名称" clean 来清理给定类别的obj文件 #这里只是举例说明可以指定clean一部分文件,在某些场合下可以采用这个方法进行较为精确的clean控制 cleanall: make -f make_mod clean make -f make_sub "SUB=main" clean make -f make_f77 "SUB=f77" clean make -f make_clib "SUB=anis_c" clean rm -f $(OBJDIR)/../libmytmp_$(CMODE).a rm -f $(OBJDIR)/*.mod #粗暴的删除所有编译生成的文件, clean: rm -f $(OBJDIR)/../libmytmp_$(CMODE).a rm -f $(OBJDIR)/*.mod rm -f $(OBJDIR)/*.o #创建obj文件目录 dir: mkdir ../obj_$(COMPILER) mkdir ../obj_$(COMPILER)/debug mkdir ../obj_$(COMPILER)/release
具体使用时,只需要为module手工填写文件名,其它非module的代码一律自动寻找。第一次编译,需要先 make dir创建目录,而后再make。默认编译优化版本,使用make CMODE=debug会编译调试版本。
2022年8月25日 15:21
Student Portal - Western Governors University. Access the WGU student portal here. Students can find instructions for initial log in to the learning portal for the university. This will give you access to the WGU Student Portal, wgu student portal which you will need to access in order to complete the financial aid process and/or make your first tuition 2021.Student Portal - Western Governors University. Access the WGU student portal here. Students can find instructions for initial log in to the learning portal for the university. This will give you access to the WGU Student Portal.
2023年10月31日 23:03
I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google
2023年12月06日 19:38
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.World Facts For Children… […]here are some links to sites that we link to because we think they are worth visiting[…]…
2023年12月06日 20:23
Greetings, I think your blog could be having internet browser compatibility issues. When I look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, great website!|
2023年12月06日 20:44
I think this is one of the most vital info for me. And i’m glad studying your article. However should observation on few general things, The web site style is perfect, the articles is in reality excellent : D. Just right activity, cheers| This is a topic which is near to my heart… Take care! Exactly where are your contact details though?|
2023年12月06日 20:53
was wondering if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?|
2023年12月06日 21:01
I in addition to my buddies happened to be digesting the excellent points located on your web site and then all of the sudden I had an awful feeling I never expressed respect to the site owner for them. All the men were absolutely thrilled to read through them and have now in truth been having fun with them. Thank you for actually being indeed kind and then for obtaining this kind of excellent useful guides most people are really desperate to know about. My honest regret for not expressing appreciation to earlier.
2023年12月06日 21:03
Hello, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam responses? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me crazy so any assistance is very much appreciated.|
2023年12月06日 21:55
Hey! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Terrific blog and amazing design.| You reported this exceptionally well! fda kratom
2023年12月06日 22:02
I absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for. Does one offer guest writers to write content for yourself? I wouldn’t mind creating a post or elaborating on many of the subjects you write concerning here. Again, awesome web log!|
2023年12月06日 22:10
Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|
2023年12月06日 22:16
I in addition to my buddies happened to be digesting the excellent points located on your web site and then all of the sudden I had an awful feeling I never expressed respect to the site owner for them. All the men were absolutely thrilled to read through them and have now in truth been having fun with them. Thank you for actually being indeed kind and then for obtaining this kind of excellent useful guides most people are really desperate to know about. My honest regret for not expressing appreciation to earlier.
2023年12月06日 22:17
was wondering if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?|
2023年12月06日 22:44
Just wish to say your article is as amazing. The clarity in your post is just nice and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.|
2023年12月06日 23:20
Strong blog. I acquired several nice info. I?ve been keeping a watch on this technology for a few time. It?utes attention-grabbing the method it retains totally different, however many of the primary components remain a similar. have you observed a lot change since Search engines created their own latest purchase in the field?
2023年12月06日 23:31
It’s the best time to make a few plans for the longer term and it is time to be happy. I have learn this post and if I may just I wish to counsel you few attention-grabbing issues or advice. Maybe you can write next articles relating to this article. I wish to read even more things approximately it!|
2023年12月06日 23:43
Good – I should definitely pronounce, impressed with your web site. I had no trouble navigating through all the tabs as well as related info ended up being truly easy to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Excellent task.
2023年12月06日 23:51
Nice post. I discover something tougher on various blogs everyday. Most commonly it is stimulating to see content off their writers and practice a little there. I’d would prefer to use some using the content on my own weblog whether you do not mind. Natually I’ll supply you with a link with your web blog. Thanks for sharing.
2023年12月07日 00:01
Nice post. I discover something tougher on various blogs everyday. Most commonly it is stimulating to see content off their writers and practice a little there. I’d would prefer to use some using the content on my own weblog whether you do not mind. Natually I’ll supply you with a link with your web blog. Thanks for sharing.
2023年12月07日 00:01
Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Cheers| Hi. i think that you should add captcha to your blog.
2023年12月07日 00:03
Nice post. I discover something tougher on various blogs everyday. Most commonly it is stimulating to see content off their writers and practice a little there. I’d would prefer to use some using the content on my own weblog whether you do not mind. Natually I’ll supply you with a link with your web blog. Thanks for sharing.
2023年12月07日 00:06
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.World Facts For Children… […]here are some links to sites that we link to because we think they are worth visiting[…]…
2023年12月07日 00:25
I think this is one of the most vital info for me. And i’m glad studying your article. However should observation on few general things, The web site style is perfect, the articles is in reality excellent : D. Just right activity, cheers| This is a topic which is near to my heart… Take care! Exactly where are your contact details though?|
2023年12月07日 00:28
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.World Facts For Children… […]here are some links to sites that we link to because we think they are worth visiting[…]…
2023年12月07日 00:41
An impressive share, I just given this onto a colleague who had previously been performing a small analysis on this. And hubby in fact bought me breakfast simply because I found it for him.. smile. So permit me to reword that: Thnx for the treat! But yeah Thnkx for spending any time go over this, I find myself strongly regarding this and really like reading much more about this topic. If you can, as you grow expertise, does one mind updating your blog post with increased details? It can be extremely helpful for me. Massive thumb up with this blog post!
2023年12月07日 01:04
Greetings, I think your blog could be having internet browser compatibility issues. When I look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, great website!|
2023年12月07日 01:18
Hello, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam responses? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me crazy so any assistance is very much appreciated.|
2023年12月07日 01:26
was wondering if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?|
2023年12月07日 01:33
Hey! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Terrific blog and amazing design.| You reported this exceptionally well! fda kratom
2023年12月07日 01:47
I in addition to my buddies happened to be digesting the excellent points located on your web site and then all of the sudden I had an awful feeling I never expressed respect to the site owner for them. All the men were absolutely thrilled to read through them and have now in truth been having fun with them. Thank you for actually being indeed kind and then for obtaining this kind of excellent useful guides most people are really desperate to know about. My honest regret for not expressing appreciation to earlier.
2023年12月07日 01:49
Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|
2023年12月07日 02:05
I’m impressed, I must say. Actually rarely do you encounter a blog that’s both educative and entertaining, and let me tell you, you’ve got hit the nail to the head. Your notion is outstanding; the issue is an issue that not enough people are speaking intelligently about. I am very happy that we found this at my look for something about it.
2023年12月07日 02:11
I’m impressed, I must say. Actually rarely do you encounter a blog that’s both educative and entertaining, and let me tell you, you’ve got hit the nail to the head. Your notion is outstanding; the issue is an issue that not enough people are speaking intelligently about. I am very happy that we found this at my look for something about it.
2023年12月07日 02:16
was wondering if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?|
2023年12月07日 02:32
I’m impressed, I must say. Actually rarely do you encounter a blog that’s both educative and entertaining, and let me tell you, you’ve got hit the nail to the head. Your notion is outstanding; the issue is an issue that not enough people are speaking intelligently about. I am very happy that we found this at my look for something about it.
2023年12月07日 02:33
Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website? My website is in the very same area of interest as yours and my users would certainly benefit from some of the information you provide here. Please let me know if this alright with you. Thanks a lot!|
2023年12月07日 02:35
Just wish to say your article is as amazing. The clarity in your post is just nice and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.|
2023年12月07日 02:49
Good – I should definitely pronounce, impressed with your web site. I had no trouble navigating through all the tabs as well as related info ended up being truly easy to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Excellent task.
2023年12月07日 03:00
you’re actually a just right webmaster. The web site loading pace is incredible. It seems that you are doing any unique trick. Moreover, The contents are masterpiece. you have done a wonderful job on this matter! you’re in point of fact a excellent webmaster. The web site loading velocity is amazing. It sort of feels that you’re doing any unique trick. Also, The contents are masterpiece. you’ve done a wonderful job on this matter!
2023年12月07日 03:00
I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web savvy so I’m not 100 certain. Any tips or advice would be greatly appreciated. Many thanks|
2024年1月19日 18:45
It doesn't make sense to spend that much pennies on using that when you can just have it also. I couldn't refer this a 'Leptitox killer'. You might have to be aware of all the fulfilling stuff you can do with this
2024年1月19日 20:18
I would like to thank you for the efforts you have made in writing this article
2024年1月19日 20:50
Excellent article. Very interesting to read. I really love to read such a nice article. Thanks!
2024年1月19日 21:35
It’s hard to find knowledgeable people on this topic however you sound like you know what you’re talking about! Thanks
2024年1月19日 22:24
I think that thanks for the valuabe information and insights you have so provided here
2024年1月19日 23:01
We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work.
2024年1月19日 23:34
It is a great website.. The Design looks very good.. Keep working like that!
2024年1月19日 23:54
That is the reason consentrate on you will need to unique placement of feet some time before authoring. Will likely be doable to help far more suitable writing in this fashion
2024年1月20日 00:29
"Wonderful website. Plenty of helpful info here. I’m sending it to several buddies ans additionally sharing in delicious.
And obviously, thank you in your sweat!"
2024年1月20日 01:17
I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information
2024年1月20日 01:48
I couldn’t have really asked for a more rewarding blog. You’re there to give excellent suggestions, going directly to the point for simple understanding of your target audience. You’re surely a terrific expert in this subject. Thank you for remaining there human beings like me.
2024年1月20日 02:26
I think this is one of the most significant information for me. And i'm glad reading your article.
2024年1月20日 18:45
Good day, your writing style is great and i love it,
2024年1月20日 20:32
Pleasant blog and totally exceptiona
2024年1月20日 21:01
"Hi there everyone, it’s my first pay a quick visit at this web site, and article is
genuinely fruitful in favor of me, keep up posting these content."
2024年1月21日 21:25
Pleasant blog and totally exceptiona
2024年1月23日 21:09
This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info:
2024年1月24日 00:25
Great post, you have pointed out some fantastic points , I likewise think this s a very wonderful website.
2024年1月25日 16:05
카지노 바카라사이트 우리카지노 카지노는 바카라, 블랙잭, 룰렛 및 슬롯 등 다양한 게임을 즐기실 수 있는 공간입니다. 게임에서 승리하면 큰 환호와 함께 많은 당첨금을 받을 수 있고, 패배하면 아쉬움과 실망을 느끼게 됩니다.
2024年1月25日 16:09
하노이 꼭 가봐야 할 베스트 업소 추천 안내 및 예약, 하노이 밤문화 에 대해서 정리해 드립니다. 하노이 가라오케, 하노이 마사지, 하노이 풍선바, 하노이 밤문화를 제대로 즐기시기 바랍니다. 하노이 밤문화 베스트 업소 요약 베스트 업소 추천 및 정리.
2024年1月26日 18:56
Pleasant article.Think so new type of elements have incorporated into your article. Sitting tight for your next article
2024年1月26日 19:11
Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription..
2024年1月26日 19:26
There are many dissertation internet sites on-line after you uncover unsurprisingly identified in your website page. ✅
2024年1月28日 15:18
No.1 먹튀검증 사이트, 먹튀사이트, 검증사이트, 토토사이트, 안전사이트, 메이저사이트, 안전놀이터 정보를 제공하고 있습니다. 먹튀해방으로 여러분들의 자산을 지켜 드리겠습니다. 먹튀검증 전문 커뮤니티 먹튀클린만 믿으세요!!
2024年1月28日 15:22
베트남 남성전용 커뮤니티❣️ 베트남 하이에나 에서 베트남 밤문화를 추천하여 드립니다. 베트남 가라오케, 베트남 VIP마사지, 베트남 이발관, 베트남 황제투어 남자라면 꼭 한번은 경험 해 봐야할 화끈한 밤문화로 모시겠습니다.
2024年4月23日 16:14
블록체인개발 코인지갑개발 IT컨설팅 메스브레인팀이 항상 당신을 도울 준비가 되어 있습니다. 우리는 마음으로 가치를 창조한다는 철학을 바탕으로 일하며, 들인 노력과 시간에 부흥하는 가치만을 받습니다. 고객이 만족하지 않으면 기꺼이 환불해 드립니다.
https://xn--539awa204jj6kpxc0yl.kr/
2024年6月02日 19:09
The tech-original mission is to help you better understand technology, and make better decisions in the fields of IT, Tech, and Crypto.
https://www.tech-original.com/
2024年6月06日 23:41
The tech-original mission is to help you better understand technology, and make better decisions in the fields of IT, Tech, and Crypto.
https://www.tech-original.com/