Victor Ruehle

From Docswiki
Jump to navigation Jump to search

Here is a collection of wiki pages I find usefule or am working on:

General

Crystal structure prediction

GMIN

OPTIM

Dirty hacks

Detect name clashes for COMMON blocks

THIS CHECK IS NOT SUIFFICIENT! A note at the beginning, for any new stuff: Do NOT use common blocks, use modules instead!!

One ugly cause which can lead to problems when combinind 2 fortran programs are name clashes in common blocks. I wrote a simple quick and dirty script to detect whether two programs have identically named common blocks. There is no guarantee whether this catches everything, but worth a quick try

The first script findcommons.sh parses all named common blocks in a list of file

 #!/bin/bash
 tmpfile=$(mktemp)
 for filter in $@; do
   find . -name "$filter" -exec sed -ne 's/^\s*[Cc][Oo][Mm][Mm][Oo][Nn]\s*\/\s*\([^\/]*\)\s*\/.*$/\1/p' {} \; >> $tmpfile 
 done
 sort --ignore-case --unique -u ${tmpfile}

To use it

 cd /source/of/proc/one
 findcommons.sh *.f *.f90 *.F *.F90 *.src > commons.txt
 cd /source/of/proc/two
 source/to/proc/one>findcommons.sh *.f *.f90 *.F *.F90 *.src > commons.txt
 # now check whether there are mulsiple occurencies
 cat /source/of/proc/one/commons.txt /source/of/proc/two/commons.txt | sort --ignore-case | uniq -c --ignore-case | sed -e '/^\s*1/d'