[Wrf-users] WRF with g95: success with some tweaks

Arnold Moene arnold.moene at wur.nl
Thu Mar 10 01:56:49 MST 2005


Dear all,

I've managed to compile and run WRF with the GNU Fortran 95 compiler 
This is no news, according to the 'success page' of g95: 
http://g95.sourceforge.net/g95_status.html. However, since I haven't 
found an overview of the tweaks needed to do this, I'd like to share 
them with you.
BTW: do not underestimate the importance of the fact that WRF (and the 
upcoming version of WRFSI) work with g95. Since the GNU compiler (of 
which g95 will be part by the end of the year, if I'm well-informed) is 
the most portable compiler on the planet, WRF will be the most portable 
atmospheric model!

For those that would like to compile WRF with the GNU Fortran 95 
compiler, here are the tweaks that are needed. Many of those tweaks have 
to do with strings (more generally 'lines') extending beyond column 132. 
For the rest the code is nearly g95 (= 'standard' ?) compliant. I will 
try to convince the lead developer of g95 to add an option to allow code 
lines to be of unrestricted (or just large) length.

Up to now I only tested the RSL option, and I've only run with one 
domain. My next check will be to run with 2 domains.

My compiler version was:
gcc version 4.0.0 20050129 (experimental) (g95!) Mar  8 2005

Another things to note is that you need to have a netcdf lib that was 
compiled with g95 as well:
setenv FC g95
setenv F90 g95
setenv CFLAGS "-Df2cFortran"
./configure
make


Here it comes (code following < is old code, code following > is new 
code, my comments are preceeded by a #)


# Of course we have to tell that it needs the correct compiler. With
# these tweaks to configure.defaults, g95 will come up as an option when
# you run ./configure
diff -r WRFV2/arch/configure.defaults WRFV2.new/arch/configure.defaults
3466c3466
< #ARCH    PC Linux i486 i586 i686, PGI compiler  (single threaded, 
supports nesting using RSL without MPI)
---
 > #ARCH    PC Linux i486 i586 i686, G95 compiler  (single threaded, 
supports nesting using RSL without MPI)
3472,3473c3472,3473
< FC              =       pgf90
< LD              =       pgf90
---
 > FC              =       g95
 > LD              =       g95
3475,3477c3475,3477
< SFC             =       pgf90
< FCOPTIM		=	-fast
< FCDEBUG		=	#-g
---
 > SFC             =       g95
 > FCOPTIM		=	-O2
 > FCDEBUG		=	-g
3479c3479
< FCBASEOPTS      =       -w -byteswapio -Mfree -tp p6 $(FCDEBUG)
---
 > FCBASEOPTS      =       -ffree-form $(FCDEBUG)
3536c3536
< 	( cd ../external/RSL/RSL ; make CC="$(CC)" CFLAGS='-DSTUBS' 
FC="$(FC)" FFLAGS='-byteswapio' MAX_DOMAINS=$(MAX_DOMAINS) 
MAX_PROC=$(MAX_PROC) LEARN_BCAST=-DLEARN_BCAST stub )
---
 > 	( cd ../external/RSL/RSL ; make CC="$(CC)" CFLAGS='-DSTUBS 
-DF2CSTYLE' FC="$(FC)" FFLAGS='' MAX_DOMAINS=$(MAX_DOMAINS) 
MAX_PROC=$(MAX_PROC) LEARN_BCAST=-DLEARN_BCAST linux )

# Apparently, 'byte' is not a standard type
diff -r WRFV2/external/RSL/RSL/vicopy.F WRFV2.new/external/RSL/RSL/vicopy.F
20c20
<       byte a(*), b(*)
---
 >       integer*1 a(*), b(*)
38c38
<       byte a(*)
---
 >       integer*1 a(*)

# Those macros result in much too long lines. So what I did is that
# I copied the resuling code from modul_tules.f, and spread it over 4
# lines. The only thing is that the line numbers in the error messages
# are incorrect now. Sorry.

diff -r WRFV2/frame/module_tiles.F WRFV2.new/frame/module_tiles.F
203,206c203,223
<      ERROR_TEST(ips,<,smx)
<      ERROR_TEST(ipe,>,emx)
<      ERROR_TEST(jps,<,smy)
<      ERROR_TEST(jpe,>,emy)
---
 >      IF( ips < smx)THEN
 >              WRITE(mess,'("set_tiles:",3A4)')'ips','<','smx'
 >              CALL wrf_error_fatal3 ( "module_tiles.b" , 203 , mess)
 >      ENDIF
 >      IF( ipe > emx)THEN
 >              WRITE(mess,'("set_tiles:",3A4)')'ipe','>','emx'
 >              CALL wrf_error_fatal3 ( "module_tiles.b" , 204 , mess)
 >      ENDIF
 >      IF( jps < smy)THEN
 >              WRITE(mess,'("set_tiles:",3A4)')'jps','<','smy'
 >              CALL wrf_error_fatal3 ( "module_tiles.b" , 205 , mess)
 >      ENDIF
 >      IF( jpe > emy)THEN
 >              WRITE(mess,'("set_tiles:",3A4)')'jpe','>','emy'
 >              CALL wrf_error_fatal3 ( "module_tiles.b" , 206 , mess)
 >      ENDIF
 >
 > !     ERROR_TEST(ips,<,smx)
 > !     ERROR_TEST(ipe,>,emx)
 > !     ERROR_TEST(jps,<,smy)
 > !     ERROR_TEST(jpe,>,emy)

# Line was too long, split over two lines
diff -r WRFV2/main/ndown_em.F WRFV2.new/main/ndown_em.F
474c474,475
<             CALL wrf_error_fatal( 'real: error opening 
wrf_real_input_em for reading: ' // TRIM (si_inpname) )
---
 >             CALL wrf_error_fatal( 'real: error opening 
wrf_real_input_em for reading: ' //&
 >             TRIM (si_inpname) )

# Line was too long, split over two lines
diff -r WRFV2/main/real_em.F WRFV2.new/main/real_em.F
241c241,242
<         CALL wrf_error_fatal( 'error opening ' // TRIM(si_inpname) // 
' for input; bad date in namelist or file not in directory' )
---
 >         CALL wrf_error_fatal( 'error opening ' // TRIM(si_inpname) //&
 >         ' for input; bad date in namelist or file not in directory' )
309c310,311
<       CALL wrf_error_fatal( 'Ending date in namelist ' // 
end_date_char // ' prior to beginning date ' // start_date_char )
---
 >       CALL wrf_error_fatal( 'Ending date in namelist ' // &
 >       end_date_char // ' prior to beginning date ' // start_date_char )

# Line was too long, split over two lines
diff -r WRFV2/phys/module_cu_kfeta.F WRFV2.new/phys/module_cu_kfeta.F
2134c2134,2135
<               CALL wrf_error_fatal ( 'KAIN-FRITSCH, THIS COMBINATION 
OF IMOIST, IEXICE, IICE NOT ALLOWED' )
---
 >               CALL wrf_error_fatal (&
 >               'KAIN-FRITSCH, THIS COMBINATION OF IMOIST, IEXICE, IICE 
NOT ALLOWED' )

# Line was too long, split over two lines
diff -r WRFV2/phys/module_mp_etanew.F WRFV2.new/phys/module_mp_etanew.F
2141c2141,2142
<         CALL wrf_error_fatal ( 'module_mp_etanew: etanewinit: Can not 
find unused fortran unit to read in lookup table.' )
---
 >         CALL wrf_error_fatal ( &
 >         'module_mp_etanew: etanewinit: Can not find unused fortran 
unit to read in lookup table.' )

# Line was too long, split over two lines
diff -r WRFV2/phys/module_mp_lin.F WRFV2.new/phys/module_mp_lin.F
130c130,131
<       CALL wrf_error_fatal ( 'module_mp_lin: Improper use of Lin et al 
scheme; no ice phase. Please chose another one.')
---
 >       CALL wrf_error_fatal (&
 >       'module_mp_lin: Improper use of Lin et al scheme; no ice phase. 
Please chose another one.')

# This is not a standard format specification + line split over two lines
diff -r WRFV2/phys/module_ra_gfdleta.F WRFV2.new/phys/module_ra_gfdleta.F
8716c8716
<  697	format(11(f5.3,x))
---
 >  697	format(11(f5.3,1x))
9459c9459,9460
<         CALL wrf_error_fatal ( 'module_ra_gfdleta: co2o3: Can not find 
unused fortran unit to read in lookup table.' )
---
 >         CALL wrf_error_fatal (&
 >         'module_ra_gfdleta: co2o3: Can not find unused fortran unit 
to read in lookup table.' )
9463c9464,9465
<         CALL wrf_error_fatal ( 'module_ra_gfdleta: co2o3: Can not find 
unused fortran unit to read in lookup table.' )
---
 >         CALL wrf_error_fatal (&
 >         'module_ra_gfdleta: co2o3: Can not find unused fortran unit 
to read in lookup table.' )
9467c9469,9470
<         CALL wrf_error_fatal ( 'module_ra_gfdleta: co2o3: Can not find 
unused fortran unit to read in lookup table.' )
---
 >         CALL wrf_error_fatal (&
 >         'module_ra_gfdleta: co2o3: Can not find unused fortran unit 
to read in lookup table.' )

# Line was too long, split over two lines
diff -r WRFV2/phys/module_ra_rrtm.F WRFV2.new/phys/module_ra_rrtm.F
6558c6558,6559
<         CALL wrf_error_fatal ( 'module_ra_rrtm: rrtm_lookuptable: Can 
not find unused fortran unit to read in lookup table.' )
---
 >         CALL wrf_error_fatal (&
 >         'module_ra_rrtm: rrtm_lookuptable: Can not find unused 
fortran unit to read in lookup table.' )

# Line was too long, split over two lines
diff -r WRFV2/phys/module_sf_noahlsm.F WRFV2.new/phys/module_sf_noahlsm.F
617c617,618
<       CALL wrf_error_fatal( "module_sf_noahlsm.F: lsminit: out of 
range value of ISLTYP. Is this field in the input?" )
---
 >       CALL wrf_error_fatal(&
 >       "module_sf_noahlsm.F: lsminit: out of range value of ISLTYP. Is 
this field in the input?" )

# Line was too long, split over two lines
diff -r WRFV2/share/module_soil_pre.F WRFV2.new/share/module_soil_pre.F
556c556,557
<                   CALL wrf_error_fatal ( 'TOPOSOIL values have large 
positive values > 10,000 m , unrealistic.' )
---
 >                   CALL wrf_error_fatal &
 >                   ( 'TOPOSOIL values have large positive values > 
10,000 m , unrealistic.' )
564c565,566
< print *,'no soil temperature elevation adjustment, diff of soil height 
and terrain = ',ter(i,j) - toposoil(i,j)
---
 > print *,'no soil temperature elevation adjustment, diff of soil 
height and terrain = ',&
 >                           ter(i,j) - toposoil(i,j)
566c568,569
<                   CALL wrf_error_fatal ( 'TOPOSOIL difference with 
terrain elevation differs by more than 3000 m, unrealistic' )
---
 >                   CALL wrf_error_fatal ( &
 >                   'TOPOSOIL difference with terrain elevation differs 
by more than 3000 m, unrealistic' )

-- 
------------------------------------------------------------------------
Arnold F. Moene                          NEW tel: +31 (0)317 482604
Meteorology and Air Quality Group            fax: +31 (0)317 482811
Wageningen University                   e-mail: Arnold.Moene at wur.nl
Duivendaal 2                             url: http://www.met.wau.nl
6701 AP  Wageningen
The Netherlands
------------------------------------------------------------------------
Openoffice.org - Freedom at work
Firefox        - The browser you can trust (www.mozilla.org)
------------------------------------------------------------------------


More information about the Wrf-users mailing list